From 3d91f8c02510f233ecfa1ac4e7c63f96aa4cacb3 Mon Sep 17 00:00:00 2001 From: Jeremi Joslin Date: Tue, 1 Dec 2026 15:50:47 +0000 Subject: [PATCH] test(client): validate task response fixtures against OpenAPI [skip ci] Signed-off-by: Jeremi Joslin --- clients/typescript/package-lock.json | 78 +++++++ clients/typescript/package.json | 2 + clients/typescript/tests/acceptance.test.ts | 7 +- .../tasks/proposal-application-refused.json | 17 +- .../fixtures/tasks/proposal-applied.json | 15 +- .../fixtures/tasks/proposal-approved.json | 15 +- .../fixtures/tasks/proposal-cancelled.json | 15 +- .../tasks/proposal-draft-attached.json | 19 +- .../tasks/proposal-draft-no-input.json | 15 +- .../tasks/proposal-draft-optional.json | 17 +- .../tests/fixtures/tasks/proposal-draft.json | 17 +- .../fixtures/tasks/proposal-list-last.json | 15 +- .../tests/fixtures/tasks/proposal-list.json | 36 ++-- .../tasks/proposal-package-changed.json | 17 +- .../fixtures/tasks/proposal-rejected.json | 15 +- .../fixtures/tasks/proposal-sent-back.json | 19 +- .../tasks/proposal-submitted-stale.json | 17 +- .../fixtures/tasks/proposal-submitted.json | 17 +- .../typescript/tests/tasks-proposals.test.ts | 200 ++++++++++-------- .../tests/tasks-response-contracts.test.ts | 57 +++++ .../typescript/tests/tasks-screens.test.ts | 2 +- 21 files changed, 389 insertions(+), 223 deletions(-) create mode 100644 clients/typescript/tests/tasks-response-contracts.test.ts diff --git a/clients/typescript/package-lock.json b/clients/typescript/package-lock.json index d06ec8261f..ef1c1ef3dc 100644 --- a/clients/typescript/package-lock.json +++ b/clients/typescript/package-lock.json @@ -16,6 +16,8 @@ }, "devDependencies": { "@types/node": "24.10.1", + "ajv": "8.20.0", + "ajv-formats": "3.0.1", "playwright-core": "1.63.0", "typescript": "5.9.3" }, @@ -33,6 +35,72 @@ "undici-types": "~7.16.0" } }, + "node_modules/ajv": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ajv-formats": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-uri": { + "version": "3.1.9", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz", + "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true, + "license": "MIT" + }, "node_modules/playwright-core": { "version": "1.63.0", "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.63.0.tgz", @@ -46,6 +114,16 @@ "node": ">=20" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/typescript": { "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", diff --git a/clients/typescript/package.json b/clients/typescript/package.json index 0e4bfaf9a4..7873cee2e8 100644 --- a/clients/typescript/package.json +++ b/clients/typescript/package.json @@ -58,6 +58,8 @@ }, "devDependencies": { "@types/node": "24.10.1", + "ajv": "8.20.0", + "ajv-formats": "3.0.1", "playwright-core": "1.63.0", "typescript": "5.9.3" }, diff --git a/clients/typescript/tests/acceptance.test.ts b/clients/typescript/tests/acceptance.test.ts index 15ff24fecf..06d99ecc35 100644 --- a/clients/typescript/tests/acceptance.test.ts +++ b/clients/typescript/tests/acceptance.test.ts @@ -66,6 +66,7 @@ for (const { answer, reason, requestInput, options, extra } of [ test('service Proposal start and attach keep the existing HTTP exchange', async () => { const draft = JSON.parse(readFileSync(new URL('./fixtures/tasks/proposal-draft-optional.json', import.meta.url), 'utf8')) const attached = JSON.parse(readFileSync(new URL('./fixtures/tasks/proposal-draft-attached.json', import.meta.url), 'utf8')) + const proposalPath = `/v1/proposals/${draft.id}` const requests: Array<{ method: string; path: string; query: string; headers: Headers; body: RequestInit['body'] }> = [] let view = draft const client = facility({ baseUrl, fetch: async (url, init) => { @@ -80,9 +81,9 @@ test('service Proposal start and attach keep the existing HTTP exchange', async await client.facility.proposals.attach(proposal, 'supporting-document', file) assert.deepEqual(requests.map(({ method, path }) => [method, path]), [ ['POST', '/v1/actions/correct-address/proposals'], - ['GET', '/v1/proposals/prop-1'], - ['PATCH', '/v1/proposals/prop-1/attachments/supporting-document'], - ['GET', '/v1/proposals/prop-1'], + ['GET', proposalPath], + ['PATCH', `${proposalPath}/attachments/supporting-document`], + ['GET', proposalPath], ]) assert.ok(requests.every(({ query }) => query === '?accessProfile=facility-correction-author')) assert.deepEqual(JSON.parse(String(requests[0]?.body)), { input: { city: 'Springfield' } }) diff --git a/clients/typescript/tests/fixtures/tasks/proposal-application-refused.json b/clients/typescript/tests/fixtures/tasks/proposal-application-refused.json index 17144f6082..5816536572 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-application-refused.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-application-refused.json @@ -1,8 +1,9 @@ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "submitted", + "status": "awaiting-party", "turn": "party", "submissionVersion": 1, "revision": 5, @@ -26,7 +27,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "download", - "path": "/v1/proposals/prop-1/attachments/supporting-document?submissionVersion=1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/attachments/supporting-document?submissionVersion=1", "availability": { "observedRevision": 3, "available": true @@ -47,7 +48,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 5, "available": true @@ -57,7 +58,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -70,7 +71,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -83,7 +84,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -96,7 +97,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -107,7 +108,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, diff --git a/clients/typescript/tests/fixtures/tasks/proposal-applied.json b/clients/typescript/tests/fixtures/tasks/proposal-applied.json index 1ff8480d5b..f3d56fc39a 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-applied.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-applied.json @@ -1,8 +1,9 @@ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "applied", + "status": "applied", "turn": "nobody", "submissionVersion": 1, "revision": 8, @@ -18,7 +19,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 8, "available": true @@ -28,7 +29,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -41,7 +42,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -54,7 +55,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -67,7 +68,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -80,7 +81,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, diff --git a/clients/typescript/tests/fixtures/tasks/proposal-approved.json b/clients/typescript/tests/fixtures/tasks/proposal-approved.json index 170129207c..fd4d4cec3c 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-approved.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-approved.json @@ -1,8 +1,9 @@ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "submitted", + "status": "approved", "turn": "nobody", "submissionVersion": 1, "revision": 7, @@ -18,7 +19,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 7, "available": true @@ -28,7 +29,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-7\"", "availability": { "observedRevision": 7, @@ -41,7 +42,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-7\"", "availability": { "observedRevision": 7, @@ -54,7 +55,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-7\"", "availability": { "observedRevision": 7, @@ -65,7 +66,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-7\"", "availability": { "observedRevision": 7, @@ -76,7 +77,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-7\"", "availability": { "observedRevision": 7, diff --git a/clients/typescript/tests/fixtures/tasks/proposal-cancelled.json b/clients/typescript/tests/fixtures/tasks/proposal-cancelled.json index 0accfce7a1..02f586174c 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-cancelled.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-cancelled.json @@ -1,8 +1,9 @@ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "cancelled", + "status": "cancelled", "turn": "nobody", "submissionVersion": 1, "revision": 8, @@ -18,7 +19,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 8, "available": true @@ -28,7 +29,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -41,7 +42,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -54,7 +55,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -67,7 +68,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -80,7 +81,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, diff --git a/clients/typescript/tests/fixtures/tasks/proposal-draft-attached.json b/clients/typescript/tests/fixtures/tasks/proposal-draft-attached.json index 3065015f7a..08e9f7deba 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-draft-attached.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-draft-attached.json @@ -1,8 +1,9 @@ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "draft", + "status": "draft", "turn": "party", "submissionVersion": 1, "revision": 4, @@ -26,7 +27,7 @@ "accessProfile": "facility-correction-author", "method": "PATCH", "operation": "upload", - "path": "/v1/proposals/prop-1/attachments/supporting-document", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/attachments/supporting-document", "ifMatch": "\"etag-4\"", "availability": { "observedRevision": 4, @@ -37,7 +38,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "download", - "path": "/v1/proposals/prop-1/attachments/supporting-document?submissionVersion=1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/attachments/supporting-document?submissionVersion=1", "availability": { "observedRevision": 3, "available": true @@ -58,7 +59,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 4, "available": true @@ -68,7 +69,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-4\"", "availability": { "observedRevision": 4, @@ -79,7 +80,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-4\"", "availability": { "observedRevision": 4, @@ -90,7 +91,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-4\"", "availability": { "observedRevision": 4, @@ -103,7 +104,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-4\"", "availability": { "observedRevision": 4, @@ -114,7 +115,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-4\"", "availability": { "observedRevision": 4, diff --git a/clients/typescript/tests/fixtures/tasks/proposal-draft-no-input.json b/clients/typescript/tests/fixtures/tasks/proposal-draft-no-input.json index 62bd3792c4..3370e4e287 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-draft-no-input.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-draft-no-input.json @@ -1,8 +1,9 @@ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "draft", + "status": "draft", "turn": "party", "submissionVersion": 1, "revision": 3, @@ -14,7 +15,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 3, "available": true @@ -24,7 +25,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -35,7 +36,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -46,7 +47,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -59,7 +60,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -70,7 +71,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, diff --git a/clients/typescript/tests/fixtures/tasks/proposal-draft-optional.json b/clients/typescript/tests/fixtures/tasks/proposal-draft-optional.json index 206eaef223..97c2ec3842 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-draft-optional.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-draft-optional.json @@ -1,8 +1,9 @@ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "draft", + "status": "draft", "turn": "party", "submissionVersion": 1, "revision": 3, @@ -26,7 +27,7 @@ "accessProfile": "facility-correction-author", "method": "PATCH", "operation": "upload", - "path": "/v1/proposals/prop-1/attachments/supporting-document", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/attachments/supporting-document", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -41,7 +42,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 3, "available": true @@ -51,7 +52,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -62,7 +63,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -73,7 +74,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -86,7 +87,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -97,7 +98,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, diff --git a/clients/typescript/tests/fixtures/tasks/proposal-draft.json b/clients/typescript/tests/fixtures/tasks/proposal-draft.json index d466cf445e..98f6900574 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-draft.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-draft.json @@ -1,8 +1,9 @@ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "draft", + "status": "draft", "turn": "party", "submissionVersion": 1, "revision": 3, @@ -26,7 +27,7 @@ "accessProfile": "facility-correction-author", "method": "PATCH", "operation": "upload", - "path": "/v1/proposals/prop-1/attachments/supporting-document", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/attachments/supporting-document", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -41,7 +42,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 3, "available": true @@ -51,7 +52,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -62,7 +63,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -73,7 +74,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -86,7 +87,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -97,7 +98,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, diff --git a/clients/typescript/tests/fixtures/tasks/proposal-list-last.json b/clients/typescript/tests/fixtures/tasks/proposal-list-last.json index 94f2fbc5ee..d538b64ff6 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-list-last.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-list-last.json @@ -1,10 +1,11 @@ { "items": [ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "applied", + "status": "applied", "turn": "nobody", "submissionVersion": 1, "revision": 8, @@ -20,7 +21,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 8, "available": true @@ -30,7 +31,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -43,7 +44,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -56,7 +57,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -69,7 +70,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -82,7 +83,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, diff --git a/clients/typescript/tests/fixtures/tasks/proposal-list.json b/clients/typescript/tests/fixtures/tasks/proposal-list.json index 1bc6037836..2133533668 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-list.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-list.json @@ -1,10 +1,11 @@ { "items": [ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "draft", + "status": "draft", "turn": "party", "submissionVersion": 1, "revision": 3, @@ -28,7 +29,7 @@ "accessProfile": "facility-correction-author", "method": "PATCH", "operation": "upload", - "path": "/v1/proposals/prop-1/attachments/supporting-document", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/attachments/supporting-document", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -43,7 +44,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 3, "available": true @@ -53,7 +54,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -64,7 +65,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -75,7 +76,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -88,7 +89,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -99,7 +100,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-3\"", "availability": { "observedRevision": 3, @@ -109,10 +110,11 @@ } }, { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "submitted", + "status": "awaiting-party", "turn": "party", "submissionVersion": 1, "revision": 6, @@ -136,7 +138,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "download", - "path": "/v1/proposals/prop-1/attachments/supporting-document?submissionVersion=1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/attachments/supporting-document?submissionVersion=1", "availability": { "observedRevision": 3, "available": true @@ -157,7 +159,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 6, "available": true @@ -167,7 +169,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-6\"", "availability": { "observedRevision": 6, @@ -180,7 +182,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-6\"", "availability": { "observedRevision": 6, @@ -193,7 +195,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-6\"", "availability": { "observedRevision": 6, @@ -204,7 +206,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-6\"", "availability": { "observedRevision": 6, @@ -215,7 +217,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-6\"", "availability": { "observedRevision": 6, @@ -225,7 +227,7 @@ }, "decision": { "status": "changes-requested", - "decidedAt": "2026-11-27T11:00:00Z", + "decidedAt": "2026-11-27T11:00:00.000000Z", "publicReason": "Please add the licence number." } } diff --git a/clients/typescript/tests/fixtures/tasks/proposal-package-changed.json b/clients/typescript/tests/fixtures/tasks/proposal-package-changed.json index cf8017cc14..0abb019ea5 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-package-changed.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-package-changed.json @@ -1,8 +1,9 @@ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "submitted", + "status": "awaiting-party", "turn": "party", "submissionVersion": 1, "revision": 5, @@ -26,7 +27,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "download", - "path": "/v1/proposals/prop-1/attachments/supporting-document?submissionVersion=1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/attachments/supporting-document?submissionVersion=1", "availability": { "observedRevision": 3, "available": true @@ -47,7 +48,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 5, "available": true @@ -57,7 +58,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -70,7 +71,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -83,7 +84,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -96,7 +97,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -107,7 +108,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, diff --git a/clients/typescript/tests/fixtures/tasks/proposal-rejected.json b/clients/typescript/tests/fixtures/tasks/proposal-rejected.json index 58ecdf52a8..154993d965 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-rejected.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-rejected.json @@ -1,8 +1,9 @@ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "rejected", + "status": "rejected", "turn": "nobody", "submissionVersion": 1, "revision": 8, @@ -18,7 +19,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 8, "available": true @@ -28,7 +29,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -41,7 +42,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -54,7 +55,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -67,7 +68,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, @@ -80,7 +81,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-8\"", "availability": { "observedRevision": 8, diff --git a/clients/typescript/tests/fixtures/tasks/proposal-sent-back.json b/clients/typescript/tests/fixtures/tasks/proposal-sent-back.json index bb10c44546..b3b9531748 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-sent-back.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-sent-back.json @@ -1,8 +1,9 @@ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "submitted", + "status": "awaiting-party", "turn": "party", "submissionVersion": 1, "revision": 6, @@ -26,7 +27,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "download", - "path": "/v1/proposals/prop-1/attachments/supporting-document?submissionVersion=1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/attachments/supporting-document?submissionVersion=1", "availability": { "observedRevision": 3, "available": true @@ -47,7 +48,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 6, "available": true @@ -57,7 +58,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-6\"", "availability": { "observedRevision": 6, @@ -70,7 +71,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-6\"", "availability": { "observedRevision": 6, @@ -83,7 +84,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-6\"", "availability": { "observedRevision": 6, @@ -94,7 +95,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-6\"", "availability": { "observedRevision": 6, @@ -105,7 +106,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-6\"", "availability": { "observedRevision": 6, @@ -115,7 +116,7 @@ }, "decision": { "status": "changes-requested", - "decidedAt": "2026-11-27T11:00:00Z", + "decidedAt": "2026-11-27T11:00:00.000000Z", "publicReason": "Please add the licence number." } } diff --git a/clients/typescript/tests/fixtures/tasks/proposal-submitted-stale.json b/clients/typescript/tests/fixtures/tasks/proposal-submitted-stale.json index 40506cf847..66d876af91 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-submitted-stale.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-submitted-stale.json @@ -1,8 +1,9 @@ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "submitted", + "status": "in-review", "turn": "official", "submissionVersion": 1, "revision": 5, @@ -26,7 +27,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "download", - "path": "/v1/proposals/prop-1/attachments/supporting-document?submissionVersion=1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/attachments/supporting-document?submissionVersion=1", "availability": { "observedRevision": 3, "available": true @@ -47,7 +48,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 5, "available": true @@ -57,7 +58,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -70,7 +71,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -83,7 +84,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -96,7 +97,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -107,7 +108,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, diff --git a/clients/typescript/tests/fixtures/tasks/proposal-submitted.json b/clients/typescript/tests/fixtures/tasks/proposal-submitted.json index af87ffc63e..a7759b9b1a 100644 --- a/clients/typescript/tests/fixtures/tasks/proposal-submitted.json +++ b/clients/typescript/tests/fixtures/tasks/proposal-submitted.json @@ -1,8 +1,9 @@ { - "id": "prop-1", + "id": "9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "actionId": "correct-address", "actionRevision": "rev-a", "state": "submitted", + "status": "in-review", "turn": "official", "submissionVersion": 1, "revision": 5, @@ -26,7 +27,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "download", - "path": "/v1/proposals/prop-1/attachments/supporting-document?submissionVersion=1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/attachments/supporting-document?submissionVersion=1", "availability": { "observedRevision": 3, "available": true @@ -47,7 +48,7 @@ "accessProfile": "facility-correction-author", "method": "GET", "operation": "get", - "path": "/v1/proposals/prop-1", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44", "availability": { "observedRevision": 5, "available": true @@ -57,7 +58,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "edit", - "path": "/v1/proposals/prop-1/edit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/edit", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -70,7 +71,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "submit", - "path": "/v1/proposals/prop-1/submit", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/submit", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -83,7 +84,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "revise", - "path": "/v1/proposals/prop-1/revise", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/revise", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -94,7 +95,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "cancel", - "path": "/v1/proposals/prop-1/cancel", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/cancel", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, @@ -105,7 +106,7 @@ "accessProfile": "facility-correction-author", "method": "POST", "operation": "rebase", - "path": "/v1/proposals/prop-1/rebase", + "path": "/v1/proposals/9a7ce3fb-c931-4d60-8991-7f6d395f0c44/rebase", "ifMatch": "\"etag-5\"", "availability": { "observedRevision": 5, diff --git a/clients/typescript/tests/tasks-proposals.test.ts b/clients/typescript/tests/tasks-proposals.test.ts index 7c6452907f..01f412c4ce 100644 --- a/clients/typescript/tests/tasks-proposals.test.ts +++ b/clients/typescript/tests/tasks-proposals.test.ts @@ -41,7 +41,8 @@ function register(routes: Record, extra: { token?: boolean } = } const ok = (doc: unknown, status = 200) => Response.json(doc, { status }) -const P = '/v1/proposals/prop-1' +const proposalId = '9a7ce3fb-c931-4d60-8991-7f6d395f0c44' +const P = `/v1/proposals/${proposalId}` const calls = (seen: Seen[]) => seen.map(s => `${s.method} ${s.path.replace(P, '')}`) const keyOf = (s: Seen) => s.headers.get('idempotency-key') ?? '' @@ -71,8 +72,8 @@ async function refusal(promise: Promise, code: string, reason?: string) // 1 and 14: commands follow served links, only start/get/list use the options profile. test('get reads the proposal with the options profile and no mutation headers', async () => { const { seen, commands } = register({ [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')) }) - const proposal = await commands.get('prop-1') - assert.equal(proposal.id, 'prop-1') + const proposal = await commands.get(proposalId) + assert.equal(proposal.id, proposalId) assert.equal(seen[0]?.query.get('accessProfile'), accessProfile) assert.equal(seen[0]?.headers.has('if-match'), false) assert.equal(seen[0]?.headers.get('authorization'), 'Bearer fixture') @@ -120,7 +121,7 @@ test('list sends the filter and returns plain Proposals with a null cursor on th assert.equal(last.nextCursor, null) }) -// 4: status, row by row (rule: records/2026/2026-11-27-proposal-review-loop/status-rule.md). +// These helper-only inputs exercise the fallback for older responses without a served status. test('proposalStatus follows the derivation row by row', () => { const submitted = fixture('proposal-submitted') const rows: [string, ServedProposal, string][] = [ @@ -136,11 +137,15 @@ test('proposalStatus follows the derivation row by row', () => { ['nobody, no decision', { ...submitted, turn: 'nobody' }, 'processing'], ['nobody, application applying', { ...submitted, turn: 'nobody', applicationStatus: { mode: 'automatic', state: 'applying' } }, 'processing'], ] - for (const [name, served, status] of rows) assert.equal(proposalStatus(served), status, name) + for (const [name, served, status] of rows) { + const { status: _servedStatus, ...legacy } = served + assert.equal(proposalStatus(legacy), status, name) + } }) test('proposalStatus: the party turn wins over an approved decision', () => { - assert.equal(proposalStatus({ ...fixture('proposal-approved'), turn: 'party' }), 'awaiting-party') + const { status: _servedStatus, ...legacy } = fixture('proposal-approved') + assert.equal(proposalStatus({ ...legacy, turn: 'party' }), 'awaiting-party') }) test('proposalStatus uses a served status of the eight, and derives when the value is unknown', () => { @@ -154,7 +159,7 @@ test('proposalStatus uses a served status of the eight, and derives when the val // 3, 5, 6: the derived view. test('can is total, maps links, and gives a reason and a sentence when a command is not offered', async () => { const { commands } = register({ [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')) }) - const draft = await commands.get('prop-1') + const draft = await commands.get(proposalId) assert.deepEqual(Object.keys(draft.can).sort(), ['attach', 'cancel', 'edit', 'rebase', 'resubmit', 'submit']) for (const name of ['attach', 'cancel', 'edit', 'submit'] as const) { assert.equal(draft.can[name].available, true, name) @@ -170,11 +175,11 @@ test('can is total, maps links, and gives a reason and a sentence when a command test('can.resubmit follows the revise link and carries the served reason and recovery', async () => { const docs = { open: fixture('proposal-sent-back'), stale: fixture('proposal-submitted-stale') } const { commands } = register({ [`GET ${P}`]: (_s, n) => ok(n === 1 ? docs.open : docs.stale) }) - const open = await commands.get('prop-1') + const open = await commands.get(proposalId) assert.equal(open.can.resubmit.available, true) assert.equal(open.can.attach.available, false) assert.equal(open.can.attach.reason, 'not-offered') - const waiting = await commands.get('prop-1') + const waiting = await commands.get(proposalId) assert.deepEqual( { available: waiting.can.resubmit.available, reason: waiting.can.resubmit.reason, recovery: waiting.can.resubmit.recovery }, { available: false, reason: 'pending-review', recovery: 'refresh' }, @@ -185,12 +190,19 @@ test('can.resubmit follows the revise link and carries the served reason and rec test('sentBack is true only for a submitted proposal whose decision asks for changes', async () => { const docs = ['proposal-sent-back', 'proposal-submitted', 'proposal-approved'] const { commands } = register({ [`GET ${P}`]: (_s, n) => ok(fixture(docs[n - 1]!)) }) - assert.equal((await commands.get('prop-1')).sentBack, true) - assert.equal((await commands.get('prop-1')).sentBack, false) - assert.equal((await commands.get('prop-1')).sentBack, false) + const sentBack = await commands.get(proposalId) + assert.equal(sentBack.sentBack, true) + assert.equal(sentBack.status, 'awaiting-party') + assert.deepEqual(sentBack.decision, { + status: 'changes-requested', + decidedAt: '2026-11-27T11:00:00.000000Z', + publicReason: 'Please add the licence number.', + }) + assert.equal((await commands.get(proposalId)).sentBack, false) + assert.equal((await commands.get(proposalId)).sentBack, false) const draftWithDecision = { ...fixture('proposal-draft-optional'), decision: { status: 'changes-requested', decidedAt: '2026-11-27T11:00:00Z' } } const { commands: other } = register({ [`GET ${P}`]: () => ok(draftWithDecision) }) - assert.equal((await other.get('prop-1')).sentBack, false) + assert.equal((await other.get(proposalId)).sentBack, false) }) test('the attachments view maps value and verification status and carries what the slot accepts', async () => { @@ -206,7 +218,7 @@ test('the attachments view maps value and verification status and carries what t }, }) for (const [index, status] of expected.entries()) { - const view = (await commands.get('prop-1')).attachments['supporting-document']! + const view = (await commands.get(proposalId)).attachments['supporting-document']! assert.equal(view.status, status, `row ${index}`) assert.equal(view.required, true) assert.deepEqual(view.accepts, { contentTypes: ['application/pdf'], maximumBytes: 1048576 }) @@ -217,10 +229,10 @@ test('the attachments view maps value and verification status and carries what t test('a Proposal is plain data: it survives structuredClone and a JSON round trip', async () => { const { commands } = register({ [`GET ${P}`]: () => ok(fixture('proposal-draft-attached')) }) - const proposal = await commands.get('prop-1') + const proposal = await commands.get(proposalId) assert.deepEqual(structuredClone(proposal), proposal) assert.deepEqual(JSON.parse(JSON.stringify(proposal)), proposal) - const minimal = await register({ [`GET ${P}`]: () => ok(fixture('proposal-draft-no-input')) }).commands.get('prop-1') + const minimal = await register({ [`GET ${P}`]: () => ok(fixture('proposal-draft-no-input')) }).commands.get(proposalId) assert.deepEqual(JSON.parse(JSON.stringify(minimal)), minimal) assert.equal('input' in minimal, false) }) @@ -232,7 +244,7 @@ test('edit merges into the readable input, sends the link condition and a derive [`GET ${P}`]: () => ok(fixture('proposal-draft-attached')), [`POST ${P}/edit`]: () => ok(fixture('proposal-draft-attached')), }) - const p = (await register({ [`GET ${P}`]: () => ok(draft) }).commands.get('prop-1')) + const p = (await register({ [`GET ${P}`]: () => ok(draft) }).commands.get(proposalId)) const view = await scripted.commands.edit(p, { city: 'Shelbyville' }) assert.deepEqual(calls(scripted.seen), ['POST /edit', 'GET ']) const [edit] = scripted.seen @@ -245,7 +257,7 @@ test('edit merges into the readable input, sends the link condition and a derive }) test('the derived key repeats for the same command and differs for another body', async () => { - const p = await register({ [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')) }).commands.get('prop-1') + const p = await register({ [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')) }).commands.get(proposalId) const keys: string[] = [] for (const city of ['A', 'A', 'B']) { const { seen, commands } = register({ @@ -261,7 +273,7 @@ test('the derived key repeats for the same command and differs for another body' test('edit refuses before sending when the grant cannot read the input', async () => { const { seen, commands } = register({ [`GET ${P}`]: () => ok(fixture('proposal-draft-no-input')) }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) await refusal(commands.edit(p, { city: 'X' }), 'client.inputs-not-readable') assert.equal(seen.length, 1, 'only the get was sent') }) @@ -271,7 +283,7 @@ test('a missing link refuses with client.command-unavailable and not-offered, wi const doc = fixture('proposal-draft-optional') delete doc.links['submit'] const { seen, commands } = register({ [`GET ${P}`]: () => ok(doc) }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) seen.length = 0 const error = await refusal(commands.submit(p), 'client.command-unavailable', 'not-offered') assert.match(error.detail ?? '', /not offered/i) @@ -280,7 +292,7 @@ test('a missing link refuses with client.command-unavailable and not-offered, wi test('a command the state does not allow refuses with the served reason, without a request', async () => { const { seen, commands } = register({ [`GET ${P}`]: () => ok(fixture('proposal-submitted')) }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) seen.length = 0 await refusal(commands.submit(p), 'client.command-unavailable', 'stale-revision') await refusal(commands.edit(p, {}), 'client.command-unavailable', 'stale-revision') @@ -290,7 +302,7 @@ test('a command the state does not allow refuses with the served reason, without test('a link the register marks unavailable refuses with its reason and recovery', async () => { const { seen, commands } = register({ [`GET ${P}`]: () => ok(fixture('proposal-submitted-stale')) }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) seen.length = 0 const error = await refusal(commands.resubmit(p), 'client.command-unavailable', 'pending-review') assert.equal(error.problem?.['recovery'], 'refresh') @@ -301,7 +313,7 @@ test('a command link that carries a different operation than its name is refused const doc = fixture('proposal-draft-optional') doc.links['submit']!.operation = 'apply' const { seen, commands } = register({ [`GET ${P}`]: () => ok(doc) }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) seen.length = 0 await refusal(commands.submit(p), 'client.link-operation') assert.equal(seen.length, 0) @@ -310,7 +322,7 @@ test('a command link that carries a different operation than its name is refused // 9: attach. test('attach checks the slot, the type and the size before sending', async () => { const { seen, commands } = register({ [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')) }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) seen.length = 0 await refusal(commands.attach(p, 'nope', pdf()), 'client.unknown-slot') const type = await refusal(commands.attach(p, 'supporting-document', new Blob(['x'], { type: 'image/png' })), 'client.file-type') @@ -330,7 +342,7 @@ test('attach sends the bytes with the slot link condition, the file type and a d [`GET ${P}`]: () => ok(doc), [`PATCH ${P}/attachments/supporting-document`]: () => { doc = fixture('proposal-draft-attached'); return ok(doc) }, }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) const file = pdf(6) const view = await commands.attach(p, 'supporting-document', file) const patch = seen.find(s => s.method === 'PATCH')! @@ -348,7 +360,7 @@ test('attach infers PDF from an untyped filename and sends the resolved content [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')), [`PATCH ${P}/attachments/supporting-document`]: () => ok(fixture('proposal-draft-attached')), }) - const draft = await commands.get('prop-1') + const draft = await commands.get(proposalId) const file = new File(['bytes'], 'support.PDF') assert.equal(file.type, '') await commands.attach(draft, 'supporting-document', file) @@ -369,13 +381,13 @@ test('attach normalises JPEG aliases and refuses a PDF filename on a PNG-only sl }, }, { accessProfile }) slot.contentTypes = ['image/jpeg'] - const jpeg = await commands.get('prop-1') + const jpeg = await commands.get(proposalId) for (const alias of ['image/jpg', 'image/pjpeg']) { await commands.attach(jpeg, 'supporting-document', new File(['x'], 'photo.unknown', { type: alias })) } assert.deepEqual(contentTypes, ['image/jpeg', 'image/jpeg']) slot.contentTypes = ['image/png'] - const png = await commands.get('prop-1') + const png = await commands.get(proposalId) const error = await refusal(commands.attach(png, 'supporting-document', new File(['x'], 'support.pdf')), 'client.file-type') assert.match(error.detail!, /accepts image\/png/u) assert.equal(contentTypes.length, 2) @@ -388,7 +400,7 @@ test('the attach key follows the file bytes', async () => { [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')), [`PATCH ${P}/attachments/supporting-document`]: () => ok(fixture('proposal-draft-attached')), }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) await commands.attach(p, 'supporting-document', new Blob([new Uint8Array(4).fill(fill)], { type: 'application/pdf' })) keys.push(keyOf(seen.find(s => s.method === 'PATCH')!)) } @@ -403,7 +415,7 @@ test('submit and cancel send an empty body with their own link condition', async [`POST ${P}/submit`]: () => ok(fixture('proposal-submitted')), [`POST ${P}/cancel`]: () => ok(fixture('proposal-cancelled')), }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) await commands.submit(p) const submit = seen.find(s => s.path.endsWith('/submit'))! assert.equal(submit.headers.get('if-match'), '"etag-3"') @@ -412,7 +424,7 @@ test('submit and cancel send an empty body with their own link condition', async [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')), [`POST ${P}/cancel`]: () => ok(fixture('proposal-cancelled')), }) - const view = await other.cancel(await other.get('prop-1')) + const view = await other.cancel(await other.get(proposalId)) assert.equal(seenCancel.find(s => s.path.endsWith('/cancel'))?.headers.get('if-match'), '"etag-3"') assert.equal(view.status, 'draft', 'the view is the document read again, not the command answer') }) @@ -474,7 +486,7 @@ const changed = { city: 'Shelbyville' } test('resubmit reads the register, revises, attaches, edits only when needed, then submits', async () => { const server = resubmitServer({ ignoreRevisedInput: true }) - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) server.seen.length = 0 const view = await server.commands.resubmit(p, { changes: changed, files: { 'supporting-document': pdf() } }) assert.deepEqual(calls(server.seen), [ @@ -490,12 +502,12 @@ test('resubmit reads the register, revises, attaches, edits only when needed, th test('resubmit skips the edit when the revised document already holds the changes, and sends {} without changes', async () => { const withChanges = resubmitServer() - const p = await withChanges.commands.get('prop-1') + const p = await withChanges.commands.get(proposalId) withChanges.seen.length = 0 await withChanges.commands.resubmit(p, { changes: changed }) assert.deepEqual(calls(withChanges.seen).filter(c => !c.startsWith('GET')), ['POST /revise', 'POST /submit']) const plain = resubmitServer() - const q = await plain.commands.get('prop-1') + const q = await plain.commands.get(proposalId) plain.seen.length = 0 await plain.commands.resubmit(q) assert.deepEqual(JSON.parse(String(writesOf(plain.seen)[0]?.body)), {}) @@ -503,7 +515,7 @@ test('resubmit skips the edit when the revised document already holds the change test('resubmit removes an input that a change sets to undefined', async () => { const server = resubmitServer() - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) server.seen.length = 0 await server.commands.resubmit(p, { changes: { city: undefined } }) assert.deepEqual(JSON.parse(String(writesOf(server.seen)[0]?.body)), { input: { facilityId: 'f-1' } }) @@ -514,7 +526,7 @@ test('resubmit removes an input that a change sets to undefined', async () => { test('resubmit refuses a bad file before the first write', async () => { const server = resubmitServer() - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) server.seen.length = 0 await refusal(server.commands.resubmit(p, { files: { 'supporting-document': new Blob(['x'], { type: 'image/png' }) } }), 'client.file-type') await refusal(server.commands.resubmit(p, { files: { nope: pdf() } }), 'client.unknown-slot') @@ -523,22 +535,22 @@ test('resubmit refuses a bad file before the first write', async () => { test('resubmit is available only while the party is to act, and says so', async () => { const { seen, commands } = register({ [`GET ${P}`]: () => ok(fixture('proposal-submitted')) }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) assert.equal(p.served.links['revise']?.availability?.available, true, 'the register offers revise in review') assert.deepEqual([p.can.resubmit.available, p.can.resubmit.reason], [false, 'not-awaiting-party']) assert.ok(p.can.resubmit.message.length > 5) seen.length = 0 await refusal(commands.resubmit(p), 'client.command-unavailable', 'not-awaiting-party') assert.equal(writesOf(seen).length, 0) - const approved = await register({ [`GET ${P}`]: () => ok(fixture('proposal-approved')) }).commands.get('prop-1') + const approved = await register({ [`GET ${P}`]: () => ok(fixture('proposal-approved')) }).commands.get(proposalId) assert.equal(approved.can.resubmit.reason, 'not-awaiting-party') - const sentBack = await register({ [`GET ${P}`]: () => ok(fixture('proposal-sent-back')) }).commands.get('prop-1') + const sentBack = await register({ [`GET ${P}`]: () => ok(fixture('proposal-sent-back')) }).commands.get(proposalId) assert.equal(sentBack.can.resubmit.available, true) }) test('two concurrent resubmit calls with the same correction make one revise and one submit', async () => { const server = resubmitServer() - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) const [a, b] = await Promise.all([server.commands.resubmit(p, { changes: changed }), server.commands.resubmit(p, { changes: changed })]) assert.deepEqual([server.count.revise, server.count.submit], [1, 1]) assert.equal(a.status, 'in-review') @@ -547,7 +559,7 @@ test('two concurrent resubmit calls with the same correction make one revise and test('two different concurrent corrections: the second is refused, not reported as done', async () => { const server = resubmitServer() - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) const [a, b] = await Promise.allSettled([server.commands.resubmit(p, { changes: { city: 'A' } }), server.commands.resubmit(p, { changes: { city: 'B' } })]) assert.equal(a.status, 'fulfilled') assert.equal(b.status, 'rejected') @@ -557,7 +569,7 @@ test('two different concurrent corrections: the second is refused, not reported test('a copy older than a later round is refused', async () => { const server = resubmitServer() - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) server.setDoc({ ...fixture('proposal-submitted'), submissionVersion: 3 }) server.seen.length = 0 await staleCopy(server.commands.resubmit(p, { changes: changed })) @@ -566,7 +578,7 @@ test('a copy older than a later round is refused', async () => { test("another tab's different correction is refused, not overwritten", async () => { const server = resubmitServer() - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) server.setDoc({ ...nextVersion(fixture('proposal-draft-optional')), input: { facilityId: 'f-1', city: 'Other' } }) server.seen.length = 0 await staleCopy(server.commands.resubmit(p, { changes: changed })) @@ -575,7 +587,7 @@ test("another tab's different correction is refused, not overwritten", async () test('a refused stale resubmit does not make the register copy this instance\'s own', async () => { const server = resubmitServer() - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) const later = { ...nextVersion(fixture('proposal-submitted')), revision: 9, input: { facilityId: 'f-1', city: 'Other' } } for (const link of Object.values(later.links)) if (link.ifMatch) link.ifMatch = '"etag-9"' server.setDoc(later) @@ -587,7 +599,7 @@ test('a refused stale resubmit does not make the register copy this instance\'s test('without changes, a draft is resumed only when nothing else was edited and given files are held', async () => { const server = resubmitServer() - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) server.setDoc({ ...nextVersion(fixture('proposal-draft-optional')), input: { facilityId: 'f-1', city: 'Half-edited' } }) server.seen.length = 0 await staleCopy(server.commands.resubmit(p)) @@ -601,7 +613,7 @@ test('without changes, a draft is resumed only when nothing else was edited and test('a plain retry with the same file resumes after a revise landed and the attach failed', async () => { const server = resubmitServer({ failAttachOnce: true }) - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) const options = { files: { 'supporting-document': pdf() } } await assert.rejects(server.commands.resubmit(p, options), { status: 503 }) const view = await server.commands.resubmit(p, options) @@ -611,7 +623,7 @@ test('a plain retry with the same file resumes after a revise landed and the att test('a draft whose slot holds a third file is refused as another tab\'s upload', async () => { const server = resubmitServer() - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) const draft = { ...nextVersion(fixture('proposal-draft-attached')), input: { ...p.input } } draft.attachments!['supporting-document']!.value!.sha256 = 'c'.repeat(64) server.setDoc(draft) @@ -623,7 +635,7 @@ test('a draft whose slot holds a third file is refused as another tab\'s upload' test('resuming from a draft whose input cannot be read is refused', async () => { const server = resubmitServer() - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) const hidden = nextVersion(fixture('proposal-draft-optional')) delete hidden.input server.setDoc(hidden) @@ -634,7 +646,7 @@ test('resuming from a draft whose input cannot be read is refused', async () => test('a retry after a submit that landed but lost its answer returns the submitted document', async () => { const server = resubmitServer({ loseSubmitAnswerOnce: true }) - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) await assert.rejects(server.commands.resubmit(p, { changes: changed }), { status: 503 }) const view = await server.commands.resubmit(p, { changes: changed }) assert.equal(view.state, 'submitted') @@ -645,7 +657,7 @@ test('a retry after a submit that landed but lost its answer returns the submitt test('a retry after a failure between revise and submit matches the resolved type on the draft', async () => { const file = new File([pdf()], 'support.pdf') const server = resubmitServer({ failSubmitOnce: true, sha256: await hex(file) }) - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) const options = { changes: changed, files: { 'supporting-document': file } } await assert.rejects(server.commands.resubmit(p, options), { status: 503 }) const view = await server.commands.resubmit(p, options) @@ -656,7 +668,7 @@ test('a retry after a failure between revise and submit matches the resolved typ test('a fresh instance after a failure in the middle continues from the draft', async () => { const server = resubmitServer({ failAttachOnce: true }) - const p = await server.commands.get('prop-1') + const p = await server.commands.get(proposalId) const options = { changes: changed, files: { 'supporting-document': pdf() } } await assert.rejects(server.commands.resubmit(p, options), { status: 503 }) const reloaded = proposalCommands(server.client, { accessProfile }) @@ -679,7 +691,7 @@ test('two quick submits make one submit and one clean refusal, never a stale err return ok(doc) }, }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) events.length = 0 const [a, b] = await Promise.allSettled([commands.submit(p), commands.submit(p)]) assert.equal(a.status, 'fulfilled') @@ -696,7 +708,7 @@ test('a queued write uses the newest document this instance has seen, not the st [`GET ${P}`]: () => ok(served), [`POST ${P}/edit`]: () => { served = fixture('proposal-draft-attached'); return ok(served) }, }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) seen.length = 0 await Promise.all([commands.edit(p, { city: 'A' }), commands.edit(p, { city: 'B' })]) const edits = seen.filter(s => s.path.endsWith('/edit')) @@ -709,14 +721,14 @@ test('writes on different proposals do not wait for each other', async () => { const gate = new Promise(resolve => { release = resolve }) const second = fixture('proposal-draft-optional') second.id = 'prop-2' - for (const link of Object.values(second.links)) link.path = link.path.replace('prop-1', 'prop-2') + for (const link of Object.values(second.links)) link.path = link.path.replace(proposalId, 'prop-2') const { commands } = register({ [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')), 'GET /v1/proposals/prop-2': () => ok(second), [`POST ${P}/submit`]: async () => { await gate; return ok(fixture('proposal-submitted')) }, 'POST /v1/proposals/prop-2/submit': () => ok(fixture('proposal-submitted')), }) - const one = await commands.get('prop-1') + const one = await commands.get(proposalId) const two = await commands.get('prop-2') const slow = commands.submit(one) const fast = await commands.submit(two) @@ -741,7 +753,7 @@ test('download returns a Blob with the stored type when the register answers wit [`GET ${P}`]: () => ok(doc), [`GET ${P}/attachments/supporting-document`]: () => new Response(bytes, { headers: { 'Content-Type': 'application/pdf' } }), }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) const blob = await commands.download(p, 'supporting-document') assert.equal(blob.type, 'application/pdf') assert.deepEqual(new Uint8Array(await blob.arrayBuffer()), bytes) @@ -756,7 +768,7 @@ test('download returns a Blob when the register answers with octet-stream', asyn [`GET ${P}`]: () => ok(doc), [`GET ${P}/attachments/supporting-document`]: () => new Response(new Uint8Array([1, 2, 3]), { headers: { 'Content-Type': 'application/octet-stream' } }), }) - const blob = await commands.download(await commands.get('prop-1'), 'supporting-document') + const blob = await commands.download(await commands.get(proposalId), 'supporting-document') assert.equal(blob.type, 'application/octet-stream') assert.deepEqual(new Uint8Array(await blob.arrayBuffer()), new Uint8Array([1, 2, 3])) }) @@ -771,7 +783,7 @@ test('download keeps only a short list of safe served types', async () => { }, } const commands = proposalCommands(stub, { accessProfile }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) const seen: string[] = [] for (const served of ['application/pdf', 'image/png', 'image/jpeg', 'text/html', 'image/svg+xml']) { types.push(served) @@ -791,7 +803,7 @@ test('download caps the answer at the slot size and checks size and digest befor }, } const commands = proposalCommands(stub, { accessProfile }) - await commands.download(await commands.get('prop-1'), 'supporting-document') + await commands.download(await commands.get(proposalId), 'supporting-document') assert.equal(calls.at(-1)?.maxResponseBytes, 1048576) }) @@ -801,7 +813,7 @@ test('download throws too-large for a body over the slot size', async () => { [`GET ${P}`]: () => ok(doc), [`GET ${P}/attachments/supporting-document`]: () => new Response(new Uint8Array(1048577), { headers: { 'Content-Type': 'application/octet-stream' } }), }) - await assert.rejects(commands.download(await commands.get('prop-1'), 'supporting-document'), { reason: 'too-large' }) + await assert.rejects(commands.download(await commands.get(proposalId), 'supporting-document'), { reason: 'too-large' }) }) test('download throws client.content-digest when the bytes do not match the served digest or size', async () => { @@ -811,7 +823,7 @@ test('download throws client.content-digest when the bytes do not match the serv [`GET ${P}`]: () => ok(doc), [`GET ${P}/attachments/supporting-document`]: () => new Response(body, { headers: { 'Content-Type': 'application/octet-stream' } }), }) - await assert.rejects(commands.download(await commands.get('prop-1'), 'supporting-document'), + await assert.rejects(commands.download(await commands.get(proposalId), 'supporting-document'), (error: unknown) => error instanceof RegistryError && error.code === 'client.content-digest' && error.kind === 'unexpected' && error.reason === 'schema' && (onScreen(error), true)) } @@ -821,9 +833,9 @@ test('download refuses a link that names no submission version as an unexpected const doc = fixture('proposal-draft-attached') const slot = doc.attachments!['supporting-document']! delete slot.value - slot.links['download']!.path = '/v1/proposals/prop-1/attachments/supporting-document' + slot.links['download']!.path = `/v1/proposals/${proposalId}/attachments/supporting-document` const { seen, commands } = register({ [`GET ${P}`]: () => ok(doc) }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) seen.length = 0 const error = await refusal(commands.download(p, 'supporting-document'), 'client.link-operation') assert.equal(describeError(error), clientSentences['client.link-operation']) @@ -832,7 +844,7 @@ test('download refuses a link that names no submission version as an unexpected test('download refuses an unknown slot and a slot without a download link', async () => { const { seen, commands } = register({ [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')) }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) seen.length = 0 await refusal(commands.download(p, 'nope'), 'client.unknown-slot') await refusal(commands.download(p, 'supporting-document'), 'client.command-unavailable', 'not-offered') @@ -842,11 +854,11 @@ test('download refuses an unknown slot and a slot without a download link', asyn // signal and page mode. test('an aborted signal reaches the call', async () => { const { commands } = register({ [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')) }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) const controller = new AbortController() controller.abort() await assert.rejects(commands.submit(p, { signal: controller.signal }), { reason: 'aborted' }) - await assert.rejects(commands.get('prop-1', { signal: controller.signal }), { reason: 'aborted' }) + await assert.rejects(commands.get(proposalId, { signal: controller.signal }), { reason: 'aborted' }) }) test('page mode sends no bearer credential and cookies to the same origin only', async () => { @@ -854,7 +866,7 @@ test('page mode sends no bearer credential and cookies to the same origin only', [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')), [`POST ${P}/submit`]: () => ok(fixture('proposal-submitted')), }, { token: false }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) await commands.submit(p) for (const s of seen) { assert.equal(s.headers.has('authorization'), false) @@ -873,7 +885,7 @@ test('the helper accepts the facility and the minimal generated clients', async const minimal = new Minimal(new Transport({ baseUrl, token: () => 'fixture', fetch: async () => ok(fixture('proposal-draft-optional')) })) const commands = proposalCommands(minimal, { accessProfile: 'directory-editor' }) assert.equal(typeof acceptsGeneratedClients, 'function') - await assert.doesNotReject(commands.get('prop-1')) + await assert.doesNotReject(commands.get(proposalId)) }) test('onProgress goes unchanged to the byte transfer calls only', async () => { @@ -891,7 +903,7 @@ test('onProgress goes unchanged to the byte transfer calls only', async () => { } const commands = proposalCommands(stub, { accessProfile }) const onProgress = () => {} - await commands.resubmit(await commands.get('prop-1'), { files: { 'supporting-document': pdf() }, onProgress }) + await commands.resubmit(await commands.get(proposalId), { files: { 'supporting-document': pdf() }, onProgress }) const byOperation = Object.fromEntries(recorded.map(r => [r.operation, r.onProgress])) assert.equal(byOperation['proposals.attachments.supporting-document.patch'], onProgress) assert.equal(byOperation['proposals.revise'], undefined) @@ -899,11 +911,11 @@ test('onProgress goes unchanged to the byte transfer calls only', async () => { recorded.length = 0 const later = proposalCommands(stub, { accessProfile }) doc = await holding(new Uint8Array([1])) - await later.download(await later.get('prop-1'), 'supporting-document', { onProgress }) + await later.download(await later.get(proposalId), 'supporting-document', { onProgress }) assert.equal(recorded.find(r => r.operation.startsWith('proposals.attachments.') && r.operation.endsWith('.get'))?.onProgress, onProgress) doc = fixture('proposal-draft-optional') recorded.length = 0 - await later.attach(await later.get('prop-1'), 'supporting-document', pdf(), { onProgress }) + await later.attach(await later.get(proposalId), 'supporting-document', pdf(), { onProgress }) assert.equal(recorded.find(r => r.operation.endsWith('.patch'))?.onProgress, onProgress) }) @@ -916,7 +928,7 @@ test('start keeps its own key and reports a saved change when the read after it const error = await commands.start('correct-address', {}).then(() => assert.fail('expected an error'), (e: unknown) => e) assert.ok(error instanceof RegistryError) assert.equal(error.problem?.['code'], 'client.read-after-write') - assert.equal(error.problem?.['proposalId'], 'prop-1') + assert.equal(error.problem?.['proposalId'], proposalId) assert.equal(error.kind, 'unreachable') assert.equal(error.status, 503) assert.equal(error.outcomeUnknown, false) @@ -933,12 +945,12 @@ test('a command whose write landed but whose read fails reports it with the writ [`GET ${P}`]: () => ++reads === 1 ? ok(fixture('proposal-draft-optional')) : new Response(null, { status: 503 }), [`POST ${P}/submit`]: () => ok(fixture('proposal-submitted')), }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) const error = await commands.submit(p).then(() => assert.fail('expected an error'), (e: unknown) => e) assert.ok(error instanceof RegistryError) assert.equal(error.code, 'client.read-after-write') onScreen(error) - assert.equal(error.problem?.['proposalId'], 'prop-1') + assert.equal(error.problem?.['proposalId'], proposalId) assert.equal(error.idempotencyKey, keyOf(seen.find(s => s.method === 'POST')!)) assert.equal(error.outcomeUnknown, false) assert.match(error.detail ?? '', /saved/i) @@ -971,19 +983,19 @@ test('can.rebase is available only when the register offers it and the proposal recovery.links['submit']!.availability = { available: false, observedRevision: 3, reason: 'invalid-input', recovery: 'rebase' } const docs = ['proposal-package-changed', 'proposal-draft', 'proposal-sent-back', 'proposal-applied'] const { commands } = register({ [`GET ${P}`]: (_s, n) => ok(n <= 4 ? fixture(docs[n - 1]!) : recovery) }) - const changed = await commands.get('prop-1') + const changed = await commands.get(proposalId) assert.equal(changed.can.rebase.available, true) assert.match(changed.can.rebase.message, /form for this application has changed/i) assert.deepEqual(changed.can.resubmit, { available: false, reason: 'package-changed', recovery: 'rebase', message: changed.can.resubmit.message }) for (const name of ['proposal-draft', 'proposal-sent-back']) { - const view = await commands.get('prop-1') + const view = await commands.get(proposalId) assert.deepEqual([view.can.rebase.available, view.can.rebase.reason], [false, 'not-needed'], name) } - assert.equal((await commands.get('prop-1')).can.rebase.reason, 'already-applied') - assert.equal((await commands.get('prop-1')).can.rebase.available, true, 'a link that recovers by rebase is enough') + assert.equal((await commands.get(proposalId)).can.rebase.reason, 'already-applied') + assert.equal((await commands.get(proposalId)).can.rebase.available, true, 'a link that recovers by rebase is enough') const missing = fixture('proposal-package-changed') delete missing.links['rebase'] - const view = await register({ [`GET ${P}`]: () => ok(missing) }).commands.get('prop-1') + const view = await register({ [`GET ${P}`]: () => ok(missing) }).commands.get(proposalId) assert.equal(view.can.rebase.reason, 'not-offered') }) @@ -994,7 +1006,7 @@ test('a package-changed proposal can be rebased and then submitted', async () => [`POST ${P}/rebase`]: () => { doc = { ...fixture('proposal-draft-optional'), submissionVersion: 2, revision: 6 }; return ok(doc) }, [`POST ${P}/submit`]: () => { doc = fixture('proposal-submitted'); return ok(doc) }, }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) seen.length = 0 const draft = await commands.rebase(p, { city: 'Shelbyville' }) assert.deepEqual(calls(seen), ['POST /rebase', 'GET ']) @@ -1013,20 +1025,20 @@ test('rebase without changes sends the readable input unchanged', async () => { [`GET ${P}`]: () => ok(doc), [`POST ${P}/rebase`]: () => { doc = fixture('proposal-draft-optional'); return ok(doc) }, }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) await commands.rebase(p) assert.deepEqual(JSON.parse(String(seen.find(s => s.method === 'POST')?.body)), { input: { facilityId: 'f-1', city: 'Springfield' } }) }) test('rebase refuses with not-needed, and when the input cannot be read, without a write', async () => { const { seen, commands } = register({ [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')) }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) seen.length = 0 await refusal(commands.rebase(p), 'client.command-unavailable', 'not-needed') const hidden = fixture('proposal-package-changed') delete hidden.input const other = register({ [`GET ${P}`]: () => ok(hidden) }) - await refusal(other.commands.rebase(await other.commands.get('prop-1')), 'client.inputs-not-readable') + await refusal(other.commands.rebase(await other.commands.get(proposalId)), 'client.inputs-not-readable') assert.equal(writesOf(seen).length + writesOf(other.seen).length, 0) }) @@ -1039,7 +1051,7 @@ test('after a write whose read failed, the next write reads the proposal first a [`GET ${P}`]: () => ++reads === 2 ? new Response(null, { status: 503 }) : ok(doc), [`POST ${P}/edit`]: s => { doc = { ...fixture('proposal-draft-attached'), input: sent(s) }; return ok(doc) }, }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) await assert.rejects(commands.edit(p, { city: 'A' }), { code: 'client.read-after-write' }) seen.length = 0 await commands.edit(p, { facilityId: 'f-9' }) @@ -1059,9 +1071,9 @@ test('a list that learns a newer revision does not change the condition a comman 'GET /v1/proposals': () => ok({ items: [newer] }), [`POST ${P}/submit`]: () => ok(fixture('proposal-submitted')), }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) await commands.list() - await commands.get('prop-1') + await commands.get(proposalId) await commands.submit(p) assert.equal(seen.find(s => s.method === 'POST')?.headers.get('if-match'), '"etag-3"') }) @@ -1071,7 +1083,7 @@ test('submit follows the register: unavailable with attachment-required refuses const doc = fixture('proposal-draft') doc.links['submit']!.availability = { available: false, observedRevision: 3, reason: 'attachment-required', recovery: 'correct-input' } const { seen, commands } = register({ [`GET ${P}`]: () => ok(doc) }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) assert.deepEqual([p.can.submit.available, p.can.submit.reason, p.can.submit.recovery], [false, 'attachment-required', 'correct-input']) assert.equal(p.can.submit.message, 'A required document is missing. Add it before sending.') seen.length = 0 @@ -1084,7 +1096,7 @@ test('the helper does not compute a missing required slot: an available submit l [`GET ${P}`]: () => ok(fixture('proposal-draft')), [`POST ${P}/submit`]: () => ok(fixture('proposal-submitted')), }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) assert.equal(p.attachments['supporting-document']?.status, 'empty') assert.equal(p.attachments['supporting-document']?.required, true) assert.equal(p.can.submit.available, true) @@ -1099,7 +1111,7 @@ test('a manual Apply the register refused counts as needing a rebase, with its o [`GET ${P}`]: () => ok(doc), [`POST ${P}/rebase`]: () => { doc = { ...fixture('proposal-draft-optional'), submissionVersion: 2, revision: 6 }; return ok(doc) }, }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) assert.equal(p.can.rebase.available, true) assert.match(p.can.rebase.message, /could not be applied/i) assert.notEqual(p.can.rebase.message, availabilityMessages['rebase']) @@ -1183,7 +1195,7 @@ test('edit removes an input whose change is undefined', async () => { [`GET ${P}`]: () => ok(fixture('proposal-draft-optional')), [`POST ${P}/edit`]: () => ok(fixture('proposal-draft-attached')), }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) await commands.edit(p, { city: undefined, postalCode: '12345' }) assert.deepEqual(JSON.parse(String(seen.find(s => s.method === 'POST')?.body)), { input: { facilityId: 'f-1', postalCode: '12345' } }) }) @@ -1197,7 +1209,7 @@ test('a Proposal carries the served action revision, digest, handoff refusal, ap doc.application = { applicationId: 'app-1', effectDigest: digest, resultLinks: [{ recordId: 'r', recordType: 'facility', revision: 2 }], submissionVersion: 1 } doc.applicationStatus = { mode: 'manual', state: 'blocked', reason: 'package-changed', recovery: 'rebase' } const { commands } = register({ [`GET ${P}`]: () => ok(doc) }) - const p = await commands.get('prop-1') + const p = await commands.get(proposalId) assert.equal(p.actionRevision, 'rev-a') assert.equal(p.effectDigest, digest) assert.deepEqual(p.handoffRefusal, { code: 'review.refused' }) @@ -1205,7 +1217,7 @@ test('a Proposal carries the served action revision, digest, handoff refusal, ap assert.deepEqual(p.applicationStatus, doc.applicationStatus) assert.equal(p.blockedReason, 'package-changed') assert.deepEqual(JSON.parse(JSON.stringify(p)), p) - const plain = await register({ [`GET ${P}`]: () => ok(fixture('proposal-draft')) }).commands.get('prop-1') + const plain = await register({ [`GET ${P}`]: () => ok(fixture('proposal-draft')) }).commands.get(proposalId) for (const member of ['effectDigest', 'handoffRefusal', 'application', 'applicationStatus', 'blockedReason']) assert.equal(member in plain, false, member) }) @@ -1214,7 +1226,7 @@ test('the attachments view says whether a slot can be uploaded to and downloaded const { commands } = register({ [`GET ${P}`]: (_s, n) => ok(fixture(docs[n - 1]!)) }) const flags = [] for (const _ of docs) { - const view = (await commands.get('prop-1')).attachments['supporting-document']! + const view = (await commands.get(proposalId)).attachments['supporting-document']! flags.push([view.canUpload, view.canDownload]) } assert.deepEqual(flags, [[true, false], [true, true], [false, true]]) @@ -1223,5 +1235,5 @@ test('the attachments view says whether a slot can be uploaded to and downloaded test('proposalFromServed gives the same Proposal the commands do', async () => { const doc = fixture('proposal-sent-back') const { commands } = register({ [`GET ${P}`]: () => ok(doc) }) - assert.deepEqual(proposalFromServed(doc), await commands.get('prop-1')) + assert.deepEqual(proposalFromServed(doc), await commands.get(proposalId)) }) diff --git a/clients/typescript/tests/tasks-response-contracts.test.ts b/clients/typescript/tests/tasks-response-contracts.test.ts new file mode 100644 index 0000000000..41fee6f160 --- /dev/null +++ b/clients/typescript/tests/tasks-response-contracts.test.ts @@ -0,0 +1,57 @@ +import test from 'node:test' +import assert from 'node:assert/strict' +import { readdirSync, readFileSync } from 'node:fs' +import { Ajv2020 } from 'ajv/dist/2020.js' +import { default as formats } from 'ajv-formats' + +type Schema = Record +interface OpenApi { + components: { schemas: Record } + paths: Record + }>> +} + +const readJson = (relativePath: string): unknown => + JSON.parse(readFileSync(new URL(relativePath, import.meta.url), 'utf8')) +const breg = readJson('../../../products/breg/examples/required-attachment/openapi.json') as OpenApi +const documents = readJson('../../../products/documents/generated/registry-documents.openapi.json') as OpenApi + +function responseValidator(api: OpenApi, path: string, method = 'get', status = '200') { + // OpenAPI carries its local references in components and may annotate schemas with x- fields. + const ajv = new Ajv2020({ strictSchema: false }) + formats.default(ajv) + ajv.addFormat('uint32', { type: 'number', validate: value => value >= 0 && value <= 0xffff_ffff }) + ajv.addFormat('uint64', { type: 'number', validate: value => value >= 0 && value < 2 ** 64 }) + return ajv.compile({ + ...api.paths[path]![method]!.responses[status]!.content['application/json'].schema, + components: api.components, + }) +} + +const proposal = responseValidator(breg, '/v1/proposals/{proposal_id}') +const proposalPage = responseValidator(breg, '/v1/proposals') +const document = responseValidator(documents, '/v1/documents/{documentId}') +const documentResponses: Record> = { + 'document-ready.json': document, + 'document-pending.json': responseValidator(documents, '/v1/uploads/{uploadId}/content', 'put'), + 'document-policies.json': responseValidator(documents, '/v1/document-policies'), + 'document-reservation.json': responseValidator(documents, '/v1/documents', 'post', '201'), + 'document-grant.json': responseValidator(documents, '/v1/documents/{documentId}/grants', 'post', '201'), +} + +for (const name of readdirSync(new URL('./fixtures/tasks/', import.meta.url)).filter(name => name.endsWith('.json')).sort()) { + test(`task response fixture ${name} matches its generated OpenAPI schema`, () => { + const validate = name.startsWith('proposal-list') ? proposalPage : + name.startsWith('proposal-') ? proposal : documentResponses[name] + assert.ok(validate, `missing response schema for ${name}`) + const fixture = readJson(`./fixtures/tasks/${name}`) + assert.ok(validate(fixture), JSON.stringify(validate.errors)) + if (name.startsWith('proposal-')) { + const response = fixture as { status?: string; items?: { status?: string }[] } + for (const item of response.items ?? [response]) { + assert.equal(typeof item.status, 'string', 'current Proposal fixtures carry the served status') + } + } + }) +} diff --git a/clients/typescript/tests/tasks-screens.test.ts b/clients/typescript/tests/tasks-screens.test.ts index 021a67959e..e2ad198ad7 100644 --- a/clients/typescript/tests/tasks-screens.test.ts +++ b/clients/typescript/tests/tasks-screens.test.ts @@ -120,7 +120,7 @@ test('a replaced table reaches every can.* message, as the same table reaches de test('proposalCommands takes the table, so what it reads and what describeError shows agree', async () => { const doc = fixture('proposal-draft') const commands = proposalCommands({ call: async () => ({ data: doc }) }, { accessProfile: 'facility-correction-author', clientSentences: { available: 'Oui.' } }) - const p = await commands.get('prop-1') + const p = await commands.get(doc.id) assert.equal(p.can.submit.message, 'Oui.') const { items } = await proposalCommands({ call: async () => ({ data: { items: [doc] } }) }, { accessProfile: 'x', clientSentences: { available: 'Oui.' } }).list() assert.equal(items[0]!.can.submit.message, 'Oui.')