|
1 | 1 | import { StatusCodes } from 'http-status-codes' |
2 | 2 |
|
| 3 | +import { buildDefinition } from '~/src/__stubs__/form-definition.js' |
3 | 4 | import { createServer } from '~/src/createServer.js' |
4 | 5 | import * as forms from '~/src/lib/forms.js' |
5 | 6 | import { |
@@ -470,8 +471,8 @@ describe('Form inspect routes', () => { |
470 | 471 | }) |
471 | 472 |
|
472 | 473 | describe('GET /admin/form-inspect/{id}/versions/{versionId} (diff)', () => { |
473 | | - const definitionA = { name: 'My form', pages: [] } |
474 | | - const definitionB = { name: 'My form updated', pages: [] } |
| 474 | + const definitionA = buildDefinition({ name: 'My form' }) |
| 475 | + const definitionB = buildDefinition({ name: 'My form updated' }) |
475 | 476 |
|
476 | 477 | test('renders diff detail page for 1..4 format', async () => { |
477 | 478 | jest |
@@ -524,30 +525,37 @@ describe('Form inspect routes', () => { |
524 | 525 | }) |
525 | 526 |
|
526 | 527 | test('objectHash exercises id, path and name branches', async () => { |
527 | | - const defA = { |
528 | | - name: 'My form', |
529 | | - pages: [ |
530 | | - { |
531 | | - path: '/page-1', |
532 | | - components: [{ name: 'firstName', type: 'TextField' }] |
533 | | - } |
534 | | - ], |
535 | | - conditions: [{ id: 'cond-1', name: 'Is adult' }], |
536 | | - lists: [{ name: 'countries', title: 'Countries', items: [] }], |
537 | | - sections: [] |
538 | | - } |
539 | | - const defB = { |
540 | | - name: 'My form', |
541 | | - pages: [ |
542 | | - { |
543 | | - path: '/page-1', |
544 | | - components: [{ name: 'lastName', type: 'TextField' }] |
545 | | - } |
546 | | - ], |
547 | | - conditions: [{ id: 'cond-2', name: 'Is minor' }], |
548 | | - lists: [{ name: 'regions', title: 'Regions', items: [] }], |
549 | | - sections: [] |
550 | | - } |
| 528 | + // Cast to FormDefinition — these are intentionally minimal fixtures |
| 529 | + // designed to exercise specific objectHash branches (id, path, name), |
| 530 | + // not fully valid definitions. |
| 531 | + const defA = /** @type {import('@defra/forms-model').FormDefinition} */ ( |
| 532 | + /** @type {unknown} */ ({ |
| 533 | + name: 'My form', |
| 534 | + pages: [ |
| 535 | + { |
| 536 | + path: '/page-1', |
| 537 | + components: [{ name: 'firstName', type: 'TextField' }] |
| 538 | + } |
| 539 | + ], |
| 540 | + conditions: [{ id: 'cond-1', name: 'Is adult' }], |
| 541 | + lists: [{ name: 'countries', title: 'Countries', items: [] }], |
| 542 | + sections: [] |
| 543 | + }) |
| 544 | + ) |
| 545 | + const defB = /** @type {import('@defra/forms-model').FormDefinition} */ ( |
| 546 | + /** @type {unknown} */ ({ |
| 547 | + name: 'My form', |
| 548 | + pages: [ |
| 549 | + { |
| 550 | + path: '/page-1', |
| 551 | + components: [{ name: 'lastName', type: 'TextField' }] |
| 552 | + } |
| 553 | + ], |
| 554 | + conditions: [{ id: 'cond-2', name: 'Is minor' }], |
| 555 | + lists: [{ name: 'regions', title: 'Regions', items: [] }], |
| 556 | + sections: [] |
| 557 | + }) |
| 558 | + ) |
551 | 559 |
|
552 | 560 | jest |
553 | 561 | .mocked(forms.getFormDefinitionVersion) |
|
0 commit comments