Skip to content

Commit c2f8b1d

Browse files
committed
test(rest): type the opt-out gate pin's route and row reads
Claude-Session: https://claude.ai/code/session_01SYEJqDL3NXxrJRBVqaMu9T Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9ee5f69 commit c2f8b1d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎packages/rest/src/import-control-opt-out-gate.test.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,14 @@ async function boot() {
141141
(rest as any).resolveExecCtx = async () => caller;
142142
rest.registerRoutes();
143143
const routes = rest.getRoutes();
144-
const find = (method: string, path: string) => routes.find((r: any) => r.method === method && r.path === path);
144+
const find = (method: string, path: string): any => {
145+
const route = routes.find((r: any) => r.method === method && r.path === path);
146+
if (!route) throw new Error(`route ${method} ${path} is not registered`);
147+
return route;
148+
};
145149
const sync = find('POST', '/api/v1/data/:object/import');
146150
const jobs = find('POST', '/api/v1/data/:object/import/jobs');
147151
const progress = find('GET', '/api/v1/data/import/jobs/:jobId');
148-
expect(sync && jobs && progress).toBeTruthy();
149152
return {
150153
engine,
151154
as(next: Record<string, unknown>) { caller = next; },
@@ -255,9 +258,9 @@ describe('[#24348] the import doors honour a control opt-out only for the system
255258
ctx.as(SYSTEM);
256259
const deal = await ctx.door(kind, 'oo_deal', { format: 'json', rows: DEAL_ROWS, runAutomations: false });
257260
expect(kind === 'sync' ? deal.res._json : deal.job).toMatchObject({ created: 1 });
258-
const stored = await ctx.engine.findOne('oo_deal', { where: { id: 'd1' } });
261+
const stored: any = await ctx.engine.findOne('oo_deal', { where: { id: 'd1' } });
259262
expect(stored).toMatchObject({ name: 'Acme renewal' });
260-
expect(stored.approval_status ?? null).toBeNull();
263+
expect(stored?.approval_status ?? null).toBeNull();
261264

262265
const frozen = await ctx.door(kind, 'oo_case', { format: 'json', rows: CASE_ROWS, ...CASE_UPDATE, runAutomations: false });
263266
expect(kind === 'sync' ? frozen.res._json : frozen.job).toMatchObject({ updated: 1 });

0 commit comments

Comments
 (0)