test: pin file_list BigInt normalization against the ctx-engine seam (#3869 rider)

file_list now routes through sqlQueryForEngine(ctx.engine); the pin keeps
the identical BigInt-normalization invariant but mocks the new seam
instead of the retired module-global db connection.
This commit is contained in:
test
2026-08-12 14:38:36 -07:00
committed by Sina Matian
parent a4422f96ef
commit 3e4bc112d8
+13 -15
View File
@@ -217,23 +217,21 @@ describe('collectFiles (production import)', () => {
mime_type: null, size_bytes: null, content_hash: 'h2',
created_at: '2026-04-27' },
];
const fakeSql: any = (..._: unknown[]) => Promise.resolve(fakeRows);
const spy = spyOn(db, 'getConnection').mockReturnValue(fakeSql);
// file_list now routes through the connected OperationContext engine
// (sqlQueryForEngine) instead of the module-global db connection; pin the
// same BigInt invariant against the new seam.
const fakeEngine: any = { executeRaw: async () => fakeRows };
try {
const op = operationsByName['file_list'];
const ctx: any = { engine: null, config: {}, logger: { info() {}, warn() {}, error() {} }, dryRun: false, remote: true };
const result = await op.handler(ctx, {}) as Array<Record<string, unknown>>;
const op = operationsByName['file_list'];
const ctx: any = { engine: fakeEngine, config: {}, logger: { info() {}, warn() {}, error() {} }, dryRun: false, remote: true };
const result = await op.handler(ctx, {}) as Array<Record<string, unknown>>;
expect(result.length).toBe(2);
expect(typeof result[0].size_bytes).toBe('number');
expect(result[0].size_bytes).toBe(4096);
expect(result[1].size_bytes).toBeNull();
// The exact failure mode openclaw reported.
expect(() => JSON.stringify(result)).not.toThrow();
} finally {
spy.mockRestore();
}
expect(result.length).toBe(2);
expect(typeof result[0].size_bytes).toBe('number');
expect(result[0].size_bytes).toBe(4096);
expect(result[1].size_bytes).toBeNull();
// The exact failure mode openclaw reported.
expect(() => JSON.stringify(result)).not.toThrow();
});
test('collectFiles skips node_modules', () => {