Skip to content

Commit 87506ab

Browse files
committed
test(web): strengthen the weaker contract assertions (#965)
PR review noted that a few cases asserted only `url` while the surrounding ones pinned method, params and body — weaker than the file's own standard, and the whole point of this suite is that it is the only place wire drift is caught. Tightened proofApi.startRun (now asserts POST + the body verbatim, with a non-empty body so a dropped field would show), prdApi.getVersions and the four proofApi GET-by-id cases (method + params), and settingsApi.verifyKey (method, plus a second case covering the supplied-value branch that had only its value:null default covered). Also collapsed the stray double blank line at the blockersApi insertion point.
1 parent 334975d commit 87506ab

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

web-ui/src/__tests__/lib/api.contract.test.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ describe('api.ts request contract', () => {
209209
});
210210
});
211211

212-
213212
describe('blockersApi', () => {
214213
it('getAll → GET /api/v2/blockers with workspace_path only', async () => {
215214
await blockersApi.getAll('/ws');
@@ -312,7 +311,10 @@ describe('api.ts request contract', () => {
312311

313312
it('getVersions → GET /api/v2/prd/:id/versions', async () => {
314313
await prdApi.getVersions('p-1', '/ws');
314+
expect(captured.method).toBe('get');
315315
expect(captured.url).toBe('/api/v2/prd/p-1/versions');
316+
expect(captured.params).toEqual({ workspace_path: '/ws' });
317+
expect(captured.body).toBeUndefined();
316318
});
317319

318320
it('createVersion → POST with snake_case change_summary', async () => {
@@ -456,12 +458,16 @@ describe('api.ts request contract', () => {
456458

457459
it('getRequirement → GET /api/v2/proof/requirements/:id', async () => {
458460
await proofApi.getRequirement('/ws', 'REQ-1');
461+
expect(captured.method).toBe('get');
459462
expect(captured.url).toBe('/api/v2/proof/requirements/REQ-1');
463+
expect(captured.params).toEqual({ workspace_path: '/ws' });
460464
});
461465

462466
it('getEvidence → GET /api/v2/proof/requirements/:id/evidence', async () => {
463467
await proofApi.getEvidence('/ws', 'REQ-1');
468+
expect(captured.method).toBe('get');
464469
expect(captured.url).toBe('/api/v2/proof/requirements/REQ-1/evidence');
470+
expect(captured.params).toEqual({ workspace_path: '/ws' });
465471
});
466472

467473
it('capture → POST /api/v2/proof/requirements with the body verbatim', async () => {
@@ -478,14 +484,19 @@ describe('api.ts request contract', () => {
478484
expect(captured.body).toEqual({ reason: 'r' });
479485
});
480486

481-
it('startRun → POST /api/v2/proof/run', async () => {
482-
await proofApi.startRun('/ws', { gates: [] } as never);
487+
it('startRun → POST /api/v2/proof/run with the body verbatim', async () => {
488+
await proofApi.startRun('/ws', { gates: ['unit'], strictness: 'strict' } as never);
489+
expect(captured.method).toBe('post');
483490
expect(captured.url).toBe('/api/v2/proof/run');
491+
expect(captured.body).toEqual({ gates: ['unit'], strictness: 'strict' });
492+
expect(captured.params).toEqual({ workspace_path: '/ws' });
484493
});
485494

486495
it('getRun → GET /api/v2/proof/runs/:id', async () => {
487496
await proofApi.getRun('/ws', 'r-1');
497+
expect(captured.method).toBe('get');
488498
expect(captured.url).toBe('/api/v2/proof/runs/r-1');
499+
expect(captured.params).toEqual({ workspace_path: '/ws' });
489500
});
490501

491502
it('listRuns → GET /api/v2/proof/runs with a default limit of 5', async () => {
@@ -495,7 +506,9 @@ describe('api.ts request contract', () => {
495506

496507
it('getRunDetail → GET /api/v2/proof/runs/:id/evidence', async () => {
497508
await proofApi.getRunDetail('/ws', 'r-1');
509+
expect(captured.method).toBe('get');
498510
expect(captured.url).toBe('/api/v2/proof/runs/r-1/evidence');
511+
expect(captured.params).toEqual({ workspace_path: '/ws' });
499512
});
500513
});
501514

@@ -628,9 +641,15 @@ describe('api.ts request contract', () => {
628641

629642
it('verifyKey sends value:null when omitted', async () => {
630643
await settingsApi.verifyKey('anthropic' as never);
644+
expect(captured.method).toBe('post');
631645
expect(captured.url).toBe('/api/v2/settings/verify-key');
632646
expect(captured.body).toEqual({ provider: 'anthropic', value: null });
633647
});
648+
649+
it('verifyKey forwards a supplied value', async () => {
650+
await settingsApi.verifyKey('anthropic' as never, 'sk-live');
651+
expect(captured.body).toEqual({ provider: 'anthropic', value: 'sk-live' });
652+
});
634653
});
635654

636655
describe('proofConfigApi', () => {

0 commit comments

Comments
 (0)