Skip to content

Commit 90728d7

Browse files
committed
test(objectql): pin the engine→driver-options preserveAudit wire (#3493)
Follow-up hardening for #3497. Each layer of the historical-import audit preservation is tested (audit hook + readonly whitelist through the real engine in plugin.integration.test.ts; the driver's updated_at stamp in sql-driver-timestamp-format.test.ts; the runner wiring in import-runner-historical.test.ts) — but nothing asserted that the ENGINE threads `context.preserveAudit` into the DRIVER options, the wire that makes the driver's stamp reachable from a real write. Add that assertion via the shared `buildDriverOptions` observable (same pattern as the tenantId forwarding tests), plus its opt-in negative. Test-only; releases nothing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B5rdfBKjkbcoEif4KUV6xE
1 parent c65ab6c commit 90728d7

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

packages/objectql/src/engine.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,23 @@ describe('ObjectQL Engine', () => {
572572
await engine.count('task', {}, { context: { tenantId: 't-cnt' } as any });
573573
expect((mockDriver.count as any).mock.calls.at(-1)?.[2]).toMatchObject({ tenantId: 't-cnt' });
574574
});
575+
576+
// #3493 — a historical import sets `preserveAudit` on the write context;
577+
// `buildDriverOptions` must thread it into the DRIVER options so the SQL
578+
// driver keeps a supplied `updated_at` instead of force-stamping now. It
579+
// is the SAME shared builder on read and write, so `find` is the cheap
580+
// observable of the wire (as with `tenantId` above); the driver's actual
581+
// honoring of the option lives in @objectstack/driver-sql, and the audit
582+
// hook + readonly whitelist in plugin.integration.test.ts.
583+
it('threads preserveAudit from the context into the driver options (#3493)', async () => {
584+
await engine.find('task', { filters: [] }, { context: { preserveAudit: true } as any });
585+
expect(lastFindOpts()).toMatchObject({ preserveAudit: true });
586+
});
587+
588+
it('does NOT set preserveAudit when the context omits it (opt-in)', async () => {
589+
await engine.find('task', { filters: [] }, { context: { tenantId: 't' } as any });
590+
expect(lastFindOpts()?.preserveAudit).toBeUndefined();
591+
});
575592
});
576593

577594
describe('tenancy.enabled:false objects are platform-global (#3249, ADR-0066)', () => {

0 commit comments

Comments
 (0)