Skip to content

Commit 190cea2

Browse files
committed
test(objectql): type the registry-first pins' query options instead of erasing them
The two direct engine reads in the new tenant-scan pins passed their options through `as any`, which the query-options erasure ratchet counts in test code too. They now share one typed EngineQueryOptions constant, and the spy's recorded options are read without a cast. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ErfyP2Rx7XWHJA27QjyUi
1 parent dfb2af2 commit 190cea2

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎packages/objectql/src/lifecycle/lifecycle-service.organization-registry.test.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
*/
2828

2929
import { describe, it, expect, vi } from 'vitest';
30+
import type { EngineQueryOptions } from '@objectstack/spec/data';
3031
import { ObjectQL } from '../engine.js';
3132
import { LifecycleService } from './lifecycle-service.js';
3233
import { parseLifecycleDuration } from './duration.js';
@@ -43,6 +44,9 @@ const TELEMETRY_OBJ = {
4344

4445
const ORG_OBJECT = { name: 'sys_organization', fields: { name: { type: 'text' } } } as any;
4546

47+
/** A system-context read of one row, spelled as a typed query. */
48+
const ORG_PROBE: EngineQueryOptions = { limit: 1, context: { isSystem: true } };
49+
4650
const isoCutoff = (literal: string) => new Date(FIXED_NOW - parseLifecycleDuration(literal)).toISOString();
4751

4852
/** The regulated tenant keeps its rows three times longer than the global window. */
@@ -120,7 +124,7 @@ async function lifecycleEngine(opts: {
120124
driverReads,
121125
driverDeletes,
122126
/** The `where` of every candidate read the reaper issued through the engine. */
123-
reapReads: () => callsOn('sys_job_run').map(({ call }) => (call[1] as any)?.where),
127+
reapReads: () => callsOn('sys_job_run').map(({ call }) => call[1]?.where),
124128
/** How many times the tenant scan asked the engine for `sys_organization`. */
125129
orgReads: () => callsOn('sys_organization').length,
126130
/** What the engine rejected the tenant scan's read with. */
@@ -174,7 +178,7 @@ describe('LifecycleService.sweep — the tenant scan asks the registry first (#2
174178
const box = await lifecycleEngine({ registerOrganization: false });
175179

176180
const refusal = await box.engine
177-
.find('sys_organization', { limit: 1, context: { isSystem: true } } as any)
181+
.find('sys_organization', ORG_PROBE)
178182
.then(() => undefined, (error: unknown) => error as Error & { code?: unknown; status?: unknown; object?: unknown });
179183

180184
expect(refusal?.code).toBe('OBJECT_NOT_FOUND');
@@ -255,7 +259,7 @@ describe('LifecycleService.sweep — the tenant scan asks the registry first (#2
255259
box.engine.registerHook(
256260
'beforeFind',
257261
async () => {
258-
await box.engine.find('sys_org_unit', { limit: 1, context: { isSystem: true } } as any);
262+
await box.engine.find('sys_org_unit', ORG_PROBE);
259263
},
260264
{ object: 'sys_organization' },
261265
);

0 commit comments

Comments
 (0)