Skip to content

Commit 5f27d15

Browse files
Copilothotlong
andcommitted
fix: add count() method to mock context and fix enterprise-erp test
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent b89bbf7 commit 5f27d15

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • packages/foundation/core/test/__mocks__/@objectstack

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,15 @@ export class ObjectQL {
241241
return hookContext.result;
242242
});
243243
return opCtx.result;
244+
},
245+
count: async (filter?: any) => {
246+
const driver = this.drivers.get(this.defaultDriver || this.drivers.keys().next().value);
247+
if (driver?.count) {
248+
return driver.count(name, filter);
249+
}
250+
// Fallback: use find and count
251+
const results = driver?.find ? await driver.find(name, filter) : [];
252+
return Array.isArray(results) ? results.length : 0;
244253
}
245254
})
246255
};

0 commit comments

Comments
 (0)