Skip to content

Commit be605e6

Browse files
committed
test(rest): type the engine reads in the public-form required pins
The row-count and read-back calls pass typed query and read options instead of erasing them with `as any`, so the query-options-erasure ratchet holds. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BVm1pAXVXQ3PjC42j1kPFf
1 parent d4e5162 commit be605e6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎packages/rest/src/public-form-required.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { RestServer } from './rest-server';
3737

3838
const OBJECT = 'pf_required_lead_24131';
3939
const SLUG = 'pf-required-24131';
40-
const SYS = { context: { isSystem: true } } as const;
40+
const SYS = { context: { isSystem: true } };
4141

4242
/** `name` and `company` are object-required; `email` / `tags` / the conditional ones are not. */
4343
const LEAD = {
@@ -117,7 +117,7 @@ interface Answer { status: number; body: any }
117117
describe('[#24131] POST /forms/:slug/submit enforces the form\'s own `required`', () => {
118118
let engine: ObjectQL;
119119
let post: (body: Record<string, unknown>) => Promise<Answer>;
120-
const rowCount = async (): Promise<number> => (await engine.find(OBJECT, {}, SYS as any)).length;
120+
const rowCount = async (): Promise<number> => (await engine.find(OBJECT, {}, SYS)).length;
121121

122122
beforeAll(async () => {
123123
const driver = new SqlDriver({ client: 'better-sqlite3', connection: { filename: ':memory:' }, useNullAsDefault: true } as any);
@@ -194,7 +194,7 @@ describe('[#24131] POST /forms/:slug/submit enforces the form\'s own `required`'
194194
const answer = await post(COMPLETE);
195195
expect(answer.status, JSON.stringify(answer.body)).toBe(201);
196196
expect(typeof answer.body.id).toBe('string');
197-
const stored = await engine.findOne(OBJECT, { where: { id: answer.body.id } } as any, SYS as any);
197+
const stored = await engine.findOne(OBJECT, { where: { id: answer.body.id } }, SYS);
198198
expect(stored).toMatchObject({ name: 'Ada', company: 'Analytical Engines', email: 'ada@example.test', tags: ['lead'] });
199199
expect(await rowCount()).toBe(before + 1);
200200
}, 60_000);
@@ -229,7 +229,7 @@ describe('[#24131] POST /forms/:slug/submit enforces the form\'s own `required`'
229229
it('BOUNDARY — a hidden entry, a conditionally visible entry and an entry in a conditional section are not judged by the door', async () => {
230230
const answer = await post(COMPLETE);
231231
expect(answer.status, JSON.stringify(answer.body)).toBe(201);
232-
const stored = await engine.findOne(OBJECT, { where: { id: answer.body.id } } as any, SYS as any);
232+
const stored = await engine.findOne(OBJECT, { where: { id: answer.body.id } }, SYS);
233233
expect(stored?.reason ?? null).toBeNull();
234234
expect(stored?.referrer ?? null).toBeNull();
235235
expect(stored?.region ?? null).toBeNull();

0 commit comments

Comments
 (0)