Skip to content

Commit 761e431

Browse files
Copilothotlong
andcommitted
Fix test failures - correct metadata registry mock to match runtime behavior
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent a0db351 commit 761e431

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

packages/foundation/core/src/app.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,14 @@ export class ObjectQL implements IObjectQL {
215215
}
216216

217217
getObject(name: string): ObjectConfig | undefined {
218-
const item = this.kernel.metadata.get<MetadataItem>('object', name);
219-
return item?.content as ObjectConfig | undefined;
218+
return this.kernel.metadata.get<ObjectConfig>('object', name);
220219
}
221220

222221
getConfigs(): Record<string, ObjectConfig> {
223222
const result: Record<string, ObjectConfig> = {};
224-
const items = this.kernel.metadata.list<MetadataItem>('object');
223+
const items = this.kernel.metadata.list<ObjectConfig>('object');
225224
for (const item of items) {
226-
const obj = item.content as ObjectConfig;
227-
result[obj.name] = obj;
225+
result[item.name] = item;
228226
}
229227
return result;
230228
}

packages/foundation/core/test/__mocks__/@objectstack/runtime.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ class MockMetadataRegistry {
2121

2222
get<T = any>(type: string, id: string): T | undefined {
2323
const typeMap = this.store.get(type);
24-
return typeMap?.get(id) as T | undefined;
24+
const item = typeMap?.get(id);
25+
return item?.content as T;
2526
}
2627

2728
list<T = any>(type: string): T[] {
2829
const typeMap = this.store.get(type);
2930
if (!typeMap) return [];
30-
return Array.from(typeMap.values()) as T[];
31+
return Array.from(typeMap.values()).map(item => item.content as T);
3132
}
3233

3334
unregister(type: string, id: string): boolean {

0 commit comments

Comments
 (0)