@planning-inspectorate/dynamic-forms 3.3.3 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.azure/pipelines/azure-pipelines-pr.yml +4 -0
- package/.azure/pipelines/release.yml +4 -0
- package/.gitattributes +2 -0
- package/README.md +20 -9
- package/package.json +13 -5
- package/src/components/address/question.js +1 -10
- package/src/components/boolean/question.js +1 -1
- package/src/components/checkbox/question.js +2 -6
- package/src/components/date/question.js +1 -8
- package/src/components/date-period/question.js +1 -8
- package/src/components/email/question.js +4 -4
- package/src/components/manage-list/question.test.js +4 -19
- package/src/components/multi-field-input/question.js +3 -3
- package/src/components/multi-field-input/question.test.js +1 -1
- package/src/components/number-entry/question.js +1 -5
- package/src/components/radio/question.js +1 -1
- package/src/components/select/question.js +1 -1
- package/src/components/single-line-input/question.js +0 -8
- package/src/components/text-entry/question.js +4 -4
- package/src/components/text-entry-redact/index.njk +15 -11
- package/src/components/text-entry-redact/question.js +6 -16
- package/src/components/unit-option-entry/question.js +4 -11
- package/src/components/utils/component-types.js +18 -0
- package/src/index.js +72 -25
- package/src/middleware/redirect-to-unanswered-question.test.js +1 -1
- package/src/questions/options-question.js +5 -12
- package/src/questions/question-types.d.ts +3 -3
- package/src/questions/question.js +6 -6
- package/src/questions/questions.js +1 -1
- package/test/check-your-answers.test.js +3 -8
- package/test/conditional-journey.test.js +431 -0
- package/test/questions.test.js +15 -28
- package/test/snapshots/secret-wish.html +15 -11
- package/test/utils/question-test-utils.js +52 -4
- package/test/utils/test-server.js +1 -0
- package/test/utils/utils.js +16 -1
- package/tsconfig.json +9 -1
- package/types/commitlint.config.d.ts +7 -0
- package/types/commitlint.config.d.ts.map +1 -0
- package/types/eslint.config.d.ts +95 -0
- package/types/eslint.config.d.ts.map +1 -0
- package/types/src/components/address/question.d.ts +31 -0
- package/types/src/components/address/question.d.ts.map +1 -0
- package/types/src/components/address/question.test.d.ts +2 -0
- package/types/src/components/address/question.test.d.ts.map +1 -0
- package/types/src/components/boolean/question.d.ts +47 -0
- package/types/src/components/boolean/question.d.ts.map +1 -0
- package/types/src/components/boolean/question.test.d.ts +2 -0
- package/types/src/components/boolean/question.test.d.ts.map +1 -0
- package/types/src/components/checkbox/question.d.ts +49 -0
- package/types/src/components/checkbox/question.d.ts.map +1 -0
- package/types/src/components/checkbox/question.test.d.ts +2 -0
- package/types/src/components/checkbox/question.test.d.ts.map +1 -0
- package/types/src/components/date/question.d.ts +22 -0
- package/types/src/components/date/question.d.ts.map +1 -0
- package/types/src/components/date/question.test.d.ts +2 -0
- package/types/src/components/date/question.test.d.ts.map +1 -0
- package/types/src/components/date-period/question.d.ts +29 -0
- package/types/src/components/date-period/question.d.ts.map +1 -0
- package/types/src/components/date-period/question.test.d.ts +2 -0
- package/types/src/components/date-period/question.test.d.ts.map +1 -0
- package/types/src/components/date-time/question.d.ts +24 -0
- package/types/src/components/date-time/question.d.ts.map +1 -0
- package/types/src/components/date-time/question.test.d.ts +2 -0
- package/types/src/components/date-time/question.test.d.ts.map +1 -0
- package/types/src/components/email/question.d.ts +30 -0
- package/types/src/components/email/question.d.ts.map +1 -0
- package/types/src/components/email/question.test.d.ts +2 -0
- package/types/src/components/email/question.test.d.ts.map +1 -0
- package/types/src/components/identifier/question.d.ts +15 -0
- package/types/src/components/identifier/question.d.ts.map +1 -0
- package/types/src/components/identifier/question.test.d.ts +2 -0
- package/types/src/components/identifier/question.test.d.ts.map +1 -0
- package/types/src/components/manage-list/manage-list-section.d.ts +16 -0
- package/types/src/components/manage-list/manage-list-section.d.ts.map +1 -0
- package/types/src/components/manage-list/manage-list-section.test.d.ts +2 -0
- package/types/src/components/manage-list/manage-list-section.test.d.ts.map +1 -0
- package/types/src/components/manage-list/question.d.ts +41 -0
- package/types/src/components/manage-list/question.d.ts.map +1 -0
- package/types/src/components/manage-list/question.test.d.ts +2 -0
- package/types/src/components/manage-list/question.test.d.ts.map +1 -0
- package/types/src/components/manage-list/utils.d.ts +18 -0
- package/types/src/components/manage-list/utils.d.ts.map +1 -0
- package/types/src/components/manage-list/utils.test.d.ts +2 -0
- package/types/src/components/manage-list/utils.test.d.ts.map +1 -0
- package/types/src/components/multi-field-input/question.d.ts +106 -0
- package/types/src/components/multi-field-input/question.d.ts.map +1 -0
- package/types/src/components/multi-field-input/question.test.d.ts +2 -0
- package/types/src/components/multi-field-input/question.test.d.ts.map +1 -0
- package/types/src/components/number-entry/question.d.ts +37 -0
- package/types/src/components/number-entry/question.d.ts.map +1 -0
- package/types/src/components/radio/question.d.ts +53 -0
- package/types/src/components/radio/question.d.ts.map +1 -0
- package/types/src/components/radio/question.test.d.ts +2 -0
- package/types/src/components/radio/question.test.d.ts.map +1 -0
- package/types/src/components/select/question.d.ts +51 -0
- package/types/src/components/select/question.d.ts.map +1 -0
- package/types/src/components/select/question.test.d.ts +2 -0
- package/types/src/components/select/question.test.d.ts.map +1 -0
- package/types/src/components/single-line-input/question.d.ts +18 -0
- package/types/src/components/single-line-input/question.d.ts.map +1 -0
- package/types/src/components/single-line-input/question.test.d.ts +2 -0
- package/types/src/components/single-line-input/question.test.d.ts.map +1 -0
- package/types/src/components/text-entry/question.d.ts +34 -0
- package/types/src/components/text-entry/question.d.ts.map +1 -0
- package/types/src/components/text-entry/question.test.d.ts +2 -0
- package/types/src/components/text-entry/question.test.d.ts.map +1 -0
- package/types/src/components/text-entry-redact/question.d.ts +42 -0
- package/types/src/components/text-entry-redact/question.d.ts.map +1 -0
- package/types/src/components/text-entry-redact/question.test.d.ts +2 -0
- package/types/src/components/text-entry-redact/question.test.d.ts.map +1 -0
- package/types/src/components/unit-option-entry/question.d.ts +83 -0
- package/types/src/components/unit-option-entry/question.d.ts.map +1 -0
- package/types/src/components/unit-option-entry/question.test.d.ts +2 -0
- package/types/src/components/unit-option-entry/question.test.d.ts.map +1 -0
- package/types/src/components/utils/component-types.d.ts +19 -0
- package/types/src/components/utils/component-types.d.ts.map +1 -0
- package/types/src/components/utils/persisted-number-answer.d.ts +2 -0
- package/types/src/components/utils/persisted-number-answer.d.ts.map +1 -0
- package/types/src/components/utils/question-has-answer.d.ts +17 -0
- package/types/src/components/utils/question-has-answer.d.ts.map +1 -0
- package/types/src/components/utils/question-has-answer.test.d.ts +2 -0
- package/types/src/components/utils/question-has-answer.test.d.ts.map +1 -0
- package/types/src/components/utils/question-utils.d.ts +15 -0
- package/types/src/components/utils/question-utils.d.ts.map +1 -0
- package/types/src/components/utils/question-utils.test.d.ts +2 -0
- package/types/src/components/utils/question-utils.test.d.ts.map +1 -0
- package/types/src/controller.d.ts +78 -0
- package/types/src/controller.d.ts.map +1 -0
- package/types/src/controller.test.d.ts +2 -0
- package/types/src/controller.test.d.ts.map +1 -0
- package/types/src/index.d.ts +54 -0
- package/types/src/index.d.ts.map +1 -0
- package/types/src/journey/journey-response.d.ts +32 -0
- package/types/src/journey/journey-response.d.ts.map +1 -0
- package/types/src/journey/journey-response.test.d.ts +2 -0
- package/types/src/journey/journey-response.test.d.ts.map +1 -0
- package/types/src/journey/journey.d.ts +144 -0
- package/types/src/journey/journey.d.ts.map +1 -0
- package/types/src/journey/journey.test.d.ts +2 -0
- package/types/src/journey/journey.test.d.ts.map +1 -0
- package/types/src/lib/address-utils.d.ts +6 -0
- package/types/src/lib/address-utils.d.ts.map +1 -0
- package/types/src/lib/address-utils.test.d.ts +2 -0
- package/types/src/lib/address-utils.test.d.ts.map +1 -0
- package/types/src/lib/address.d.ts +43 -0
- package/types/src/lib/address.d.ts.map +1 -0
- package/types/src/lib/address.test.d.ts +2 -0
- package/types/src/lib/address.test.d.ts.map +1 -0
- package/types/src/lib/date-utils.d.ts +60 -0
- package/types/src/lib/date-utils.d.ts.map +1 -0
- package/types/src/lib/date-utils.test.d.ts +2 -0
- package/types/src/lib/date-utils.test.d.ts.map +1 -0
- package/types/src/lib/session-answer-store.d.ts +84 -0
- package/types/src/lib/session-answer-store.d.ts.map +1 -0
- package/types/src/lib/session-answer-store.test.d.ts +2 -0
- package/types/src/lib/session-answer-store.test.d.ts.map +1 -0
- package/types/src/lib/utils.d.ts +19 -0
- package/types/src/lib/utils.d.ts.map +1 -0
- package/types/src/lib/utils.test.d.ts +2 -0
- package/types/src/lib/utils.test.d.ts.map +1 -0
- package/types/src/lib/uuid.d.ts +7 -0
- package/types/src/lib/uuid.d.ts.map +1 -0
- package/types/src/lib/uuid.test.d.ts +2 -0
- package/types/src/lib/uuid.test.d.ts.map +1 -0
- package/types/src/middleware/build-get-journey.d.ts +6 -0
- package/types/src/middleware/build-get-journey.d.ts.map +1 -0
- package/types/src/middleware/redirect-to-unanswered-question.d.ts +12 -0
- package/types/src/middleware/redirect-to-unanswered-question.d.ts.map +1 -0
- package/types/src/middleware/redirect-to-unanswered-question.test.d.ts +2 -0
- package/types/src/middleware/redirect-to-unanswered-question.test.d.ts.map +1 -0
- package/types/src/questions/create-questions.d.ts +21 -0
- package/types/src/questions/create-questions.d.ts.map +1 -0
- package/types/src/questions/options-question.d.ts +74 -0
- package/types/src/questions/options-question.d.ts.map +1 -0
- package/types/src/questions/options-question.test.d.ts +2 -0
- package/types/src/questions/options-question.test.d.ts.map +1 -0
- package/types/src/questions/question.d.ts +274 -0
- package/types/src/questions/question.d.ts.map +1 -0
- package/types/src/questions/question.test.d.ts +2 -0
- package/types/src/questions/question.test.d.ts.map +1 -0
- package/types/src/questions/questions.d.ts +3 -0
- package/types/src/questions/questions.d.ts.map +1 -0
- package/types/src/section.d.ts +107 -0
- package/types/src/section.d.ts.map +1 -0
- package/types/src/section.test.d.ts +2 -0
- package/types/src/section.test.d.ts.map +1 -0
- package/types/src/validator/address-validator.d.ts +41 -0
- package/types/src/validator/address-validator.d.ts.map +1 -0
- package/types/src/validator/address-validator.test.d.ts +2 -0
- package/types/src/validator/address-validator.test.d.ts.map +1 -0
- package/types/src/validator/base-validator.d.ts +11 -0
- package/types/src/validator/base-validator.d.ts.map +1 -0
- package/types/src/validator/base-validator.test.d.ts +2 -0
- package/types/src/validator/base-validator.test.d.ts.map +1 -0
- package/types/src/validator/conditional-required-validator.d.ts +24 -0
- package/types/src/validator/conditional-required-validator.d.ts.map +1 -0
- package/types/src/validator/conditional-required-validator.test.d.ts +2 -0
- package/types/src/validator/conditional-required-validator.test.d.ts.map +1 -0
- package/types/src/validator/confirmation-checkbox-validator.d.ts +27 -0
- package/types/src/validator/confirmation-checkbox-validator.d.ts.map +1 -0
- package/types/src/validator/confirmation-checkbox-validator.test.d.ts +2 -0
- package/types/src/validator/confirmation-checkbox-validator.test.d.ts.map +1 -0
- package/types/src/validator/coordinates-validator.d.ts +22 -0
- package/types/src/validator/coordinates-validator.d.ts.map +1 -0
- package/types/src/validator/coordinates-validator.test.d.ts +2 -0
- package/types/src/validator/coordinates-validator.test.d.ts.map +1 -0
- package/types/src/validator/date-period-validator.d.ts +63 -0
- package/types/src/validator/date-period-validator.d.ts.map +1 -0
- package/types/src/validator/date-period-validator.test.d.ts +2 -0
- package/types/src/validator/date-period-validator.test.d.ts.map +1 -0
- package/types/src/validator/date-time-validator.d.ts +26 -0
- package/types/src/validator/date-time-validator.d.ts.map +1 -0
- package/types/src/validator/date-time-validator.test.d.ts +2 -0
- package/types/src/validator/date-time-validator.test.d.ts.map +1 -0
- package/types/src/validator/date-validator.d.ts +48 -0
- package/types/src/validator/date-validator.d.ts.map +1 -0
- package/types/src/validator/date-validator.test.d.ts +2 -0
- package/types/src/validator/date-validator.test.d.ts.map +1 -0
- package/types/src/validator/document-upload-validator.d.ts +10 -0
- package/types/src/validator/document-upload-validator.d.ts.map +1 -0
- package/types/src/validator/document-upload-validator.test.d.ts +2 -0
- package/types/src/validator/document-upload-validator.test.d.ts.map +1 -0
- package/types/src/validator/email-validator.d.ts +73 -0
- package/types/src/validator/email-validator.d.ts.map +1 -0
- package/types/src/validator/email-validator.test.d.ts +2 -0
- package/types/src/validator/email-validator.test.d.ts.map +1 -0
- package/types/src/validator/multi-field-input-validator.d.ts +70 -0
- package/types/src/validator/multi-field-input-validator.d.ts.map +1 -0
- package/types/src/validator/multi-field-input-validator.test.d.ts +2 -0
- package/types/src/validator/multi-field-input-validator.test.d.ts.map +1 -0
- package/types/src/validator/numeric-validator.d.ts +49 -0
- package/types/src/validator/numeric-validator.d.ts.map +1 -0
- package/types/src/validator/numeric-validator.test.d.ts +2 -0
- package/types/src/validator/numeric-validator.test.d.ts.map +1 -0
- package/types/src/validator/required-validator.d.ts +22 -0
- package/types/src/validator/required-validator.d.ts.map +1 -0
- package/types/src/validator/required-validator.test.d.ts +2 -0
- package/types/src/validator/required-validator.test.d.ts.map +1 -0
- package/types/src/validator/same-answer-validator.d.ts +18 -0
- package/types/src/validator/same-answer-validator.d.ts.map +1 -0
- package/types/src/validator/same-answer-validator.test.d.ts +2 -0
- package/types/src/validator/same-answer-validator.test.d.ts.map +1 -0
- package/types/src/validator/string-validator.d.ts +58 -0
- package/types/src/validator/string-validator.d.ts.map +1 -0
- package/types/src/validator/string-validator.test.d.ts +2 -0
- package/types/src/validator/string-validator.test.d.ts.map +1 -0
- package/types/src/validator/unit-option-entry-validator.d.ts +40 -0
- package/types/src/validator/unit-option-entry-validator.d.ts.map +1 -0
- package/types/src/validator/unit-option-entry-validator.test.d.ts +2 -0
- package/types/src/validator/unit-option-entry-validator.test.d.ts.map +1 -0
- package/types/src/validator/valid-option-validator.d.ts +22 -0
- package/types/src/validator/valid-option-validator.d.ts.map +1 -0
- package/types/src/validator/valid-option-validator.test.d.ts +2 -0
- package/types/src/validator/valid-option-validator.test.d.ts.map +1 -0
- package/types/src/validator/validation-error-handler.d.ts +20 -0
- package/types/src/validator/validation-error-handler.d.ts.map +1 -0
- package/types/src/validator/validation-error-handler.test.d.ts +2 -0
- package/types/src/validator/validation-error-handler.test.d.ts.map +1 -0
- package/types/src/validator/validator.d.ts +5 -0
- package/types/src/validator/validator.d.ts.map +1 -0
- package/types/src/validator/validator.test.d.ts +2 -0
- package/types/src/validator/validator.test.d.ts.map +1 -0
- package/types/test/mock/journey.d.ts +3 -0
- package/types/test/mock/journey.d.ts.map +1 -0
- package/types/test/mock/uuid.d.ts +7 -0
- package/types/test/mock/uuid.d.ts.map +1 -0
- package/types/test/utils/nunjucks.d.ts +2 -0
- package/types/test/utils/nunjucks.d.ts.map +1 -0
- package/types/test/utils/utils.d.ts +32 -0
- package/types/test/utils/utils.d.ts.map +1 -0
- package/src/lib/address.d.ts +0 -7
package/test/questions.test.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { describe, it } from 'node:test';
|
|
2
2
|
import assert from 'assert';
|
|
3
3
|
import { manageListQuestions, questionsInOrder } from './questions.js';
|
|
4
|
-
import path from 'path';
|
|
5
4
|
import { COMPONENT_TYPES } from '../src/index.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
5
|
+
import { assertSnapshot } from './utils/utils.js';
|
|
6
|
+
import {
|
|
7
|
+
createAppWithQuestions,
|
|
8
|
+
mockAnswerBody,
|
|
9
|
+
renderQuestionCheck,
|
|
10
|
+
postAnswer
|
|
11
|
+
} from '#test/utils/question-test-utils.js';
|
|
9
12
|
|
|
10
13
|
describe('question pages', () => {
|
|
11
14
|
it('should have a test for each question type', () => {
|
|
@@ -31,18 +34,11 @@ describe('question pages', () => {
|
|
|
31
34
|
* @param {import('#src/questions/question.js')} q
|
|
32
35
|
* @returns {Promise<void>}
|
|
33
36
|
*/
|
|
34
|
-
async function
|
|
35
|
-
mockRandomUUID(ctx);
|
|
37
|
+
async function renderQuestionAndSnapshot(ctx, url, snapshotName, q) {
|
|
36
38
|
const testServer = await createAppWithQuestions(ctx);
|
|
39
|
+
const text = await renderQuestionCheck(ctx, testServer, url, q.question);
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
redirect: 'manual'
|
|
40
|
-
});
|
|
41
|
-
assert.strictEqual(response.status, 200);
|
|
42
|
-
const text = await response.text();
|
|
43
|
-
// be sure to escape parentheses in the question text for the regex
|
|
44
|
-
assert.match(text, new RegExp(escapeForRegExp(q.question), 'i'));
|
|
45
|
-
assert.match(text, /<form action="" method="post"/i);
|
|
41
|
+
// Check options if present
|
|
46
42
|
if (q.options) {
|
|
47
43
|
for (const option of q.options) {
|
|
48
44
|
if (q.type === COMPONENT_TYPES.SELECT) {
|
|
@@ -56,9 +52,8 @@ describe('question pages', () => {
|
|
|
56
52
|
}
|
|
57
53
|
}
|
|
58
54
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
55
|
+
|
|
56
|
+
assertSnapshot(ctx, text, snapshotName + '.html');
|
|
62
57
|
}
|
|
63
58
|
|
|
64
59
|
/**
|
|
@@ -70,22 +65,14 @@ describe('question pages', () => {
|
|
|
70
65
|
async function postQuestionCheck(ctx, url, q) {
|
|
71
66
|
const testServer = await createAppWithQuestions(ctx);
|
|
72
67
|
const payload = mockAnswerBody(q);
|
|
73
|
-
|
|
74
|
-
if (![302, 303].includes(response.status)) {
|
|
75
|
-
const text = await response.text();
|
|
76
|
-
console.log(`Response for ${q.url}:\n`, text);
|
|
77
|
-
}
|
|
78
|
-
// Should redirect (302 or 303)
|
|
79
|
-
assert.ok([302, 303].includes(response.status), `Expected redirect, got ${response.status}`);
|
|
80
|
-
// Should redirect to the next question (if there is one)
|
|
81
|
-
return response.headers.get('location');
|
|
68
|
+
return postAnswer(testServer, url, payload);
|
|
82
69
|
}
|
|
83
70
|
|
|
84
71
|
for (let i = 0; i < questionsInOrder.length; i++) {
|
|
85
72
|
const q = questionsInOrder[i];
|
|
86
73
|
|
|
87
74
|
it(`should render question: ${q.url}`, async (ctx) => {
|
|
88
|
-
await
|
|
75
|
+
await renderQuestionAndSnapshot(ctx, '/questions/' + q.url, q.url, q);
|
|
89
76
|
});
|
|
90
77
|
|
|
91
78
|
it(`should POST valid data for question: ${q.url} and redirect to next`, async (ctx) => {
|
|
@@ -105,7 +92,7 @@ describe('question pages', () => {
|
|
|
105
92
|
for (let i = 0; i < questions.length; i++) {
|
|
106
93
|
const q = questions[i];
|
|
107
94
|
it(`should render question: ${q.url}`, async (ctx) => {
|
|
108
|
-
await
|
|
95
|
+
await renderQuestionAndSnapshot(ctx, '/' + qUrl(q), manageListQuestion.url + '_' + q.url, q);
|
|
109
96
|
});
|
|
110
97
|
|
|
111
98
|
it(`should POST valid data for question: ${q.url} and redirect to next`, async (ctx) => {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
</button>
|
|
44
44
|
|
|
45
45
|
<button type="button" class="govuk-button govuk-button--secondary" data-module="govuk-button" id="redact-undo-all">
|
|
46
|
-
|
|
46
|
+
Remove all redactions
|
|
47
47
|
</button>
|
|
48
48
|
</div>
|
|
49
49
|
|
|
@@ -107,16 +107,20 @@
|
|
|
107
107
|
showError('No changes to undo');
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
redactUndoAll.addEventListener('click', () => {
|
|
111
|
+
const unredated = unredactedText.dataset.original;
|
|
112
|
+
if (history.length === 0 && textArea.value === unredated) {
|
|
113
|
+
showError('No changes to undo');
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
hideError();
|
|
117
|
+
textArea.value = unredated || '';
|
|
118
|
+
history.length = 0;
|
|
119
|
+
|
|
120
|
+
for (const rejectLink of rejectLinks) {
|
|
121
|
+
rejectLink.text = 'Accept';
|
|
122
|
+
}
|
|
123
|
+
});
|
|
120
124
|
for (const rejectLink of rejectLinks) {
|
|
121
125
|
rejectLink.addEventListener('click', () => {
|
|
122
126
|
const index = parseInt(rejectLink.getAttribute('data-redact').replace('suggestion-reject-', ''));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import assert from 'assert';
|
|
1
2
|
import { getQuestions } from '#test/questions.js';
|
|
2
3
|
import { COMPONENT_TYPES } from '#src/index.js';
|
|
3
4
|
import { createApp } from '#test/utils/app.js';
|
|
@@ -9,16 +10,28 @@ import validate from '#src/validator/validator.js';
|
|
|
9
10
|
import { validationErrorHandler } from '#src/validator/validation-error-handler.js';
|
|
10
11
|
import { TestServer } from '#test/utils/test-server.js';
|
|
11
12
|
import { BOOLEAN_OPTIONS } from '#src/components/boolean/question.js';
|
|
13
|
+
import { escapeForRegExp } from '#test/utils/utils.js';
|
|
14
|
+
import { mockRandomUUID } from '#test/mock/uuid.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Object} CreateAppOptions
|
|
18
|
+
* @property {string} journeyId - The journey ID for session storage
|
|
19
|
+
* @property {(questions: Object, response: import('#src/journey/journey-response.js').JourneyResponse) => import('#src/journey/journey.js').Journey} createJourneyFn - Function to create the journey
|
|
20
|
+
* @property {Object} questions - The questions object
|
|
21
|
+
*/
|
|
12
22
|
|
|
13
23
|
/**
|
|
14
24
|
* @param {import('node:test').TestContext} ctx
|
|
25
|
+
* @param {CreateAppOptions} [options]
|
|
15
26
|
* @returns {Promise<TestServer>}
|
|
16
27
|
*/
|
|
17
|
-
export async function createAppWithQuestions(ctx) {
|
|
28
|
+
export async function createAppWithQuestions(ctx, options) {
|
|
18
29
|
const app = createApp();
|
|
19
|
-
const questions = getQuestions();
|
|
20
|
-
const
|
|
21
|
-
const
|
|
30
|
+
const questions = options?.questions ?? getQuestions();
|
|
31
|
+
const journeyId = options?.journeyId ?? JOURNEY_ID;
|
|
32
|
+
const createJourneyFn = options?.createJourneyFn ?? createJourney;
|
|
33
|
+
const getJourney = buildGetJourney((req, journeyResponse) => createJourneyFn(questions, journeyResponse));
|
|
34
|
+
const getJourneyResponse = buildGetJourneyResponseFromSession(journeyId);
|
|
22
35
|
|
|
23
36
|
// app.use((req, res, next) => {
|
|
24
37
|
// console.log(req.method, req.url, req.session);
|
|
@@ -198,3 +211,38 @@ export function mockAnswer(q) {
|
|
|
198
211
|
return 'test';
|
|
199
212
|
}
|
|
200
213
|
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Helper to render a question and check it's displayed correctly
|
|
217
|
+
* @param {import('node:test').TestContext} ctx
|
|
218
|
+
* @param {import('./test-server.js').TestServer} testServer
|
|
219
|
+
* @param {string} url
|
|
220
|
+
* @param {string} questionText
|
|
221
|
+
* @returns {Promise<string>}
|
|
222
|
+
*/
|
|
223
|
+
export async function renderQuestionCheck(ctx, testServer, url, questionText) {
|
|
224
|
+
mockRandomUUID(ctx);
|
|
225
|
+
const response = await testServer.get(url, { redirect: 'manual' });
|
|
226
|
+
assert.strictEqual(response.status, 200, `Expected 200 for ${url}, got ${response.status}`);
|
|
227
|
+
const text = await response.text();
|
|
228
|
+
assert.match(text, new RegExp(escapeForRegExp(questionText), 'i'));
|
|
229
|
+
assert.match(text, /<form action="" method="post"/i);
|
|
230
|
+
return text;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Helper to POST an answer and check the redirect
|
|
235
|
+
* @param {import('./test-server.js').TestServer} testServer
|
|
236
|
+
* @param {string} url
|
|
237
|
+
* @param {Record<string, unknown>} payload
|
|
238
|
+
* @returns {Promise<string|null>}
|
|
239
|
+
*/
|
|
240
|
+
export async function postAnswer(testServer, url, payload) {
|
|
241
|
+
const response = await testServer.post(url, payload, { redirect: 'manual' });
|
|
242
|
+
if (![302, 303].includes(response.status)) {
|
|
243
|
+
const text = await response.text();
|
|
244
|
+
console.log(`Response for ${url}:\n`, text);
|
|
245
|
+
}
|
|
246
|
+
assert.ok([302, 303].includes(response.status), `Expected redirect, got ${response.status}`);
|
|
247
|
+
return response.headers.get('location');
|
|
248
|
+
}
|
|
@@ -152,6 +152,7 @@ export class TestServer {
|
|
|
152
152
|
return response;
|
|
153
153
|
} catch (error) {
|
|
154
154
|
if (error instanceof Error && error.name === 'AbortError') {
|
|
155
|
+
// eslint-disable-next-line preserve-caught-error
|
|
155
156
|
throw new Error(`Request to ${path} timed out after ${this.#timeoutMs}ms`);
|
|
156
157
|
}
|
|
157
158
|
throw error;
|
package/test/utils/utils.js
CHANGED
|
@@ -2,13 +2,28 @@ import path from 'path';
|
|
|
2
2
|
import { mock } from 'node:test';
|
|
3
3
|
|
|
4
4
|
export function testDir() {
|
|
5
|
-
return path.join(
|
|
5
|
+
return path.join(import.meta.dirname, '..');
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export function snapshotsDir() {
|
|
9
9
|
return path.join(testDir(), 'snapshots');
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* @param {import('node:test').TestContext} ctx
|
|
14
|
+
* @param {string} content
|
|
15
|
+
* @param {string} name
|
|
16
|
+
*/
|
|
17
|
+
export function assertSnapshot(ctx, content, name) {
|
|
18
|
+
ctx.assert.fileSnapshot(
|
|
19
|
+
content.replaceAll('\r\n', '\n'), // OS agnostic line endings
|
|
20
|
+
path.join(snapshotsDir(), name),
|
|
21
|
+
{
|
|
22
|
+
serializers: [(v) => v]
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
12
27
|
/**
|
|
13
28
|
* @returns {import('pino').BaseLogger}
|
|
14
29
|
*/
|
package/tsconfig.json
CHANGED
|
@@ -7,10 +7,15 @@
|
|
|
7
7
|
"allowSyntheticDefaultImports": true,
|
|
8
8
|
"baseUrl": ".",
|
|
9
9
|
"checkJs": false,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"declarationMap": true,
|
|
12
|
+
"emitDeclarationOnly": true,
|
|
10
13
|
"erasableSyntaxOnly": true,
|
|
11
14
|
"esModuleInterop": true,
|
|
12
15
|
"module": "NodeNext",
|
|
13
16
|
"moduleResolution": "nodenext",
|
|
17
|
+
"outDir": "types",
|
|
18
|
+
"rootDir": ".",
|
|
14
19
|
"strict": true,
|
|
15
20
|
"target": "esnext",
|
|
16
21
|
"skipLibCheck": true,
|
|
@@ -18,7 +23,10 @@
|
|
|
18
23
|
"#question-types": ["./src/questions/question-types.d.ts"],
|
|
19
24
|
"#src/*": ["./src/*"],
|
|
20
25
|
"#test/*": ["./test/*"],
|
|
21
|
-
"#question": ["./src/questions/question.js"]
|
|
26
|
+
"#question": ["./src/questions/question.js"],
|
|
27
|
+
"#journey": ["./src/journey/journey.js"],
|
|
28
|
+
"#journey-response": ["./src/journey/journey-response.js"],
|
|
29
|
+
"#section": ["./src/section.js"]
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
32
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commitlint.config.d.ts","sourceRoot":"","sources":["../commitlint.config.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
declare const _default: ({
|
|
2
|
+
readonly rules: Readonly<import("eslint").Linter.RulesRecord>;
|
|
3
|
+
} | {
|
|
4
|
+
ignores: string[];
|
|
5
|
+
languageOptions: {
|
|
6
|
+
ecmaVersion: number;
|
|
7
|
+
sourceType: string;
|
|
8
|
+
globals: {
|
|
9
|
+
__dirname: false;
|
|
10
|
+
__filename: false;
|
|
11
|
+
AbortController: false;
|
|
12
|
+
AbortSignal: false;
|
|
13
|
+
AsyncDisposableStack: false;
|
|
14
|
+
atob: false;
|
|
15
|
+
Blob: false;
|
|
16
|
+
BroadcastChannel: false;
|
|
17
|
+
btoa: false;
|
|
18
|
+
Buffer: false;
|
|
19
|
+
ByteLengthQueuingStrategy: false;
|
|
20
|
+
clearImmediate: false;
|
|
21
|
+
clearInterval: false;
|
|
22
|
+
clearTimeout: false;
|
|
23
|
+
CloseEvent: false;
|
|
24
|
+
CompressionStream: false;
|
|
25
|
+
console: false;
|
|
26
|
+
CountQueuingStrategy: false;
|
|
27
|
+
crypto: false;
|
|
28
|
+
Crypto: false;
|
|
29
|
+
CryptoKey: false;
|
|
30
|
+
CustomEvent: false;
|
|
31
|
+
DecompressionStream: false;
|
|
32
|
+
DisposableStack: false;
|
|
33
|
+
DOMException: false;
|
|
34
|
+
ErrorEvent: false;
|
|
35
|
+
Event: false;
|
|
36
|
+
EventTarget: false;
|
|
37
|
+
exports: true;
|
|
38
|
+
fetch: false;
|
|
39
|
+
File: false;
|
|
40
|
+
FormData: false;
|
|
41
|
+
global: false;
|
|
42
|
+
Headers: false;
|
|
43
|
+
localStorage: false;
|
|
44
|
+
MessageChannel: false;
|
|
45
|
+
MessageEvent: false;
|
|
46
|
+
MessagePort: false;
|
|
47
|
+
module: false;
|
|
48
|
+
navigator: false;
|
|
49
|
+
Navigator: false;
|
|
50
|
+
performance: false;
|
|
51
|
+
Performance: false;
|
|
52
|
+
PerformanceEntry: false;
|
|
53
|
+
PerformanceMark: false;
|
|
54
|
+
PerformanceMeasure: false;
|
|
55
|
+
PerformanceObserver: false;
|
|
56
|
+
PerformanceObserverEntryList: false;
|
|
57
|
+
PerformanceResourceTiming: false;
|
|
58
|
+
process: false;
|
|
59
|
+
queueMicrotask: false;
|
|
60
|
+
ReadableByteStreamController: false;
|
|
61
|
+
ReadableStream: false;
|
|
62
|
+
ReadableStreamBYOBReader: false;
|
|
63
|
+
ReadableStreamBYOBRequest: false;
|
|
64
|
+
ReadableStreamDefaultController: false;
|
|
65
|
+
ReadableStreamDefaultReader: false;
|
|
66
|
+
Request: false;
|
|
67
|
+
require: false;
|
|
68
|
+
Response: false;
|
|
69
|
+
sessionStorage: false;
|
|
70
|
+
setImmediate: false;
|
|
71
|
+
setInterval: false;
|
|
72
|
+
setTimeout: false;
|
|
73
|
+
Storage: false;
|
|
74
|
+
structuredClone: false;
|
|
75
|
+
SubtleCrypto: false;
|
|
76
|
+
SuppressedError: false;
|
|
77
|
+
TextDecoder: false;
|
|
78
|
+
TextDecoderStream: false;
|
|
79
|
+
TextEncoder: false;
|
|
80
|
+
TextEncoderStream: false;
|
|
81
|
+
TransformStream: false;
|
|
82
|
+
TransformStreamDefaultController: false;
|
|
83
|
+
URL: false;
|
|
84
|
+
URLPattern: false;
|
|
85
|
+
URLSearchParams: false;
|
|
86
|
+
WebAssembly: false;
|
|
87
|
+
WebSocket: false;
|
|
88
|
+
WritableStream: false;
|
|
89
|
+
WritableStreamDefaultController: false;
|
|
90
|
+
WritableStreamDefaultWriter: false;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
})[];
|
|
94
|
+
export default _default;
|
|
95
|
+
//# sourceMappingURL=eslint.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint.config.d.ts","sourceRoot":"","sources":["../eslint.config.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export default class AddressQuestion extends Question {
|
|
2
|
+
/**
|
|
3
|
+
* @param {import('#question-types').QuestionParameters} params
|
|
4
|
+
*/
|
|
5
|
+
constructor(params: import("#question-types").QuestionParameters);
|
|
6
|
+
requiredFields: {
|
|
7
|
+
[key: string]: boolean;
|
|
8
|
+
} | undefined;
|
|
9
|
+
addressLabels: {
|
|
10
|
+
addressLine1: string;
|
|
11
|
+
addressLine2: string;
|
|
12
|
+
townCity: string;
|
|
13
|
+
county: string;
|
|
14
|
+
postcode: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* @param {Record<string, any>} answers
|
|
18
|
+
* @returns {*|string}
|
|
19
|
+
*/
|
|
20
|
+
answerForViewModel(answers: Record<string, any>): any | string;
|
|
21
|
+
/**
|
|
22
|
+
* @param {Object<string, any>} answer
|
|
23
|
+
* @returns The formatted address to be presented in the UI
|
|
24
|
+
*/
|
|
25
|
+
format(answer: {
|
|
26
|
+
[x: string]: any;
|
|
27
|
+
}): string;
|
|
28
|
+
formatLabelFromRequiredFields(fieldName: any): "" | " (optional)";
|
|
29
|
+
}
|
|
30
|
+
import { Question } from '#question';
|
|
31
|
+
//# sourceMappingURL=question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../../../src/components/address/question.js"],"names":[],"mappings":"AAOA;IACC;;OAEG;IACH,oBAFW,OAAO,iBAAiB,EAAE,kBAAkB,EAqBtD;IAXE;;kBAA8C;IAIhD;;;;;;MAMC;IAGF;;;OAGG;IACH,4BAHW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACjB,GAAC,GAAC,MAAM,CAqBpB;IAqCD;;;OAGG;IACH;;eAUC;IAuBD,kEAMC;CACD;yBAxIwB,WAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.test.d.ts","sourceRoot":"","sources":["../../../../src/components/address/question.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const BOOLEAN_OPTIONS: Readonly<{
|
|
2
|
+
YES: "yes";
|
|
3
|
+
NO: "no";
|
|
4
|
+
}>;
|
|
5
|
+
export function yesNoToBoolean(value: string | any): boolean;
|
|
6
|
+
export function booleanToYesNoValue(value: any): "yes" | "no";
|
|
7
|
+
export function booleanToYesNoOrNull(value: boolean | null): string | null;
|
|
8
|
+
export default class BooleanQuestion extends RadioQuestion {
|
|
9
|
+
/**
|
|
10
|
+
* @param {Object} params
|
|
11
|
+
* @param {string} params.title
|
|
12
|
+
* @param {string} params.question
|
|
13
|
+
* @param {string} params.fieldName
|
|
14
|
+
* @param {string} [params.url]
|
|
15
|
+
* @param {string} [params.hint]
|
|
16
|
+
* @param {string} [params.pageTitle]
|
|
17
|
+
* @param {string} [params.description]
|
|
18
|
+
* @param {string} [params.html]
|
|
19
|
+
* @param {string} [params.interfaceType]
|
|
20
|
+
* @param {Array.<import('../../questions/options-question.js').Option>} [params.options]
|
|
21
|
+
* @param {Array.<import('#base-validator').BaseValidator>} [params.validators]
|
|
22
|
+
* @param {boolean} [params.editable]
|
|
23
|
+
*/
|
|
24
|
+
constructor({ title, question, fieldName, url, hint, pageTitle, description, html, validators, interfaceType, options, editable }: {
|
|
25
|
+
title: string;
|
|
26
|
+
question: string;
|
|
27
|
+
fieldName: string;
|
|
28
|
+
url?: string | undefined;
|
|
29
|
+
hint?: string | undefined;
|
|
30
|
+
pageTitle?: string | undefined;
|
|
31
|
+
description?: string | undefined;
|
|
32
|
+
html?: string | undefined;
|
|
33
|
+
interfaceType?: string | undefined;
|
|
34
|
+
options?: import("../../questions/options-question.js").Option[] | undefined;
|
|
35
|
+
validators?: any[] | undefined;
|
|
36
|
+
editable?: boolean | undefined;
|
|
37
|
+
});
|
|
38
|
+
interfaceType: string;
|
|
39
|
+
/**
|
|
40
|
+
* Get the data to save from the request, returns an object of answers
|
|
41
|
+
* @param {import('express').Request} req
|
|
42
|
+
* @param {JourneyResponse} journeyResponse - current journey response, modified with the new answers
|
|
43
|
+
* @returns {Promise.<Object>}
|
|
44
|
+
*/ getDataToSave(req: any, journeyResponse: JourneyResponse): Promise<Object>;
|
|
45
|
+
}
|
|
46
|
+
import RadioQuestion from '../radio/question.js';
|
|
47
|
+
//# sourceMappingURL=question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../../../src/components/boolean/question.js"],"names":[],"mappings":"AAEA;;;GAGG;AAMI,sCAHI,MAAM,GAAC,GAAC,GACN,OAAO,CAOnB;AAEM,8DAEN;AAMM,4CAHI,OAAO,GAAC,IAAI,GACV,MAAM,GAAC,IAAI,CAOvB;AAED;IACC;;;;;;;;;;;;;;OAcG;IACH,mIAbG;QAAuB,KAAK,EAApB,MAAM;QACS,QAAQ,EAAvB,MAAM;QACS,SAAS,EAAxB,MAAM;QACU,GAAG;QACH,IAAI;QACJ,SAAS;QACT,WAAW;QACX,IAAI;QACJ,aAAa;QACyC,OAAO;QACpB,UAAU;QAClD,QAAQ;KAAC,EAiDpC;IADA,sBAAkC;IAGnC;;;;;OAKG,CACH,yCAHW,eAAe,GACb,OAAO,CAAE,MAAM,CAAC,CAe5B;CACD;0BAtHyB,sBAAsB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.test.d.ts","sourceRoot":"","sources":["../../../../src/components/boolean/question.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef ConditionalAnswerObject
|
|
3
|
+
* @type {object}
|
|
4
|
+
* @property {string} value the checkbox answer
|
|
5
|
+
* @property {string} conditional the conditional text input
|
|
6
|
+
*/
|
|
7
|
+
export default class CheckboxQuestion extends OptionsQuestion {
|
|
8
|
+
/**
|
|
9
|
+
* @param {Object} params
|
|
10
|
+
* @param {string} params.title
|
|
11
|
+
* @param {string} params.question
|
|
12
|
+
* @param {string} params.fieldName
|
|
13
|
+
* @param {string} [params.url]
|
|
14
|
+
* @param {string} [params.pageTitle]
|
|
15
|
+
* @param {string} [params.description]
|
|
16
|
+
* @param {Array.<import('../../questions/options-question.js').Option>} params.options
|
|
17
|
+
* @param {Array.<import('#base-validator').BaseValidator>} [params.validators]
|
|
18
|
+
*/
|
|
19
|
+
constructor({ title, question, fieldName, url, pageTitle, description, options, validators }: {
|
|
20
|
+
title: string;
|
|
21
|
+
question: string;
|
|
22
|
+
fieldName: string;
|
|
23
|
+
url?: string | undefined;
|
|
24
|
+
pageTitle?: string | undefined;
|
|
25
|
+
description?: string | undefined;
|
|
26
|
+
options: Array<import("../../questions/options-question.js").Option>;
|
|
27
|
+
validators?: any[] | undefined;
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* returns the formatted answers values to be used to build task list elements
|
|
31
|
+
* @param {string | ConditionalAnswerObject } answer will be a single value string, a comma-separated string representing multiple values (one of which may be a conditional) or a single ConditionalAnswerObject
|
|
32
|
+
* @param {import('#journey').Journey} journey
|
|
33
|
+
* @param {String} sectionSegment
|
|
34
|
+
* @returns {Array.<Object>}
|
|
35
|
+
*/
|
|
36
|
+
formatAnswerForSummary(sectionSegment: string, journey: import("#journey").Journey, answer: string | ConditionalAnswerObject): Array<Object>;
|
|
37
|
+
}
|
|
38
|
+
export type ConditionalAnswerObject = {
|
|
39
|
+
/**
|
|
40
|
+
* the checkbox answer
|
|
41
|
+
*/
|
|
42
|
+
value: string;
|
|
43
|
+
/**
|
|
44
|
+
* the conditional text input
|
|
45
|
+
*/
|
|
46
|
+
conditional: string;
|
|
47
|
+
};
|
|
48
|
+
import OptionsQuestion from '../../questions/options-question.js';
|
|
49
|
+
//# sourceMappingURL=question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../../../src/components/checkbox/question.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH;IACC;;;;;;;;;;OAUG;IACH,8FATG;QAAuB,KAAK,EAApB,MAAM;QACS,QAAQ,EAAvB,MAAM;QACS,SAAS,EAAxB,MAAM;QACU,GAAG;QACH,SAAS;QACT,WAAW;QAC0C,OAAO,EAA5E,KAAK,CAAE,OAAO,qCAAqC,EAAE,MAAM,CAAC;QACH,UAAU;KAAC,EAgB9E;IAED;;;;;;OAMG;IACH,wDAJW,OAAO,UAAU,EAAE,OAAO,UAD1B,MAAM,GAAG,uBAAuB,GAG9B,KAAK,CAAE,MAAM,CAAC,CAuC1B;CACD;;;;;WA7Ea,MAAM;;;;iBACN,MAAM;;4BATQ,qCAAqC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.test.d.ts","sourceRoot":"","sources":["../../../../src/components/checkbox/question.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class
|
|
3
|
+
*/
|
|
4
|
+
export default class DateQuestion extends Question {
|
|
5
|
+
/**
|
|
6
|
+
* @param {import('#question-types').QuestionParameters} params
|
|
7
|
+
* @param {string} [params.dateFormat]
|
|
8
|
+
*/
|
|
9
|
+
constructor({ dateFormat, ...params }: import("#question-types").QuestionParameters);
|
|
10
|
+
dateFormat: any;
|
|
11
|
+
/**
|
|
12
|
+
* Get the data to save from the request, returns an object of answers
|
|
13
|
+
* @param {import('express').Request} req
|
|
14
|
+
* @param {import('#journey-response').JourneyResponse} journeyResponse - current journey response, modified with the new answers
|
|
15
|
+
* @returns {Promise.<Object>}
|
|
16
|
+
*/ getDataToSave(req: any, journeyResponse: import("#journey-response").JourneyResponse): Promise<Object>;
|
|
17
|
+
answerForViewModel(answers: any, isPayload: any): {
|
|
18
|
+
[x: string]: any;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
import { Question } from '../../questions/question.js';
|
|
22
|
+
//# sourceMappingURL=question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../../../src/components/date/question.js"],"names":[],"mappings":"AAKA;;GAEG;AACH;IACC;;;OAGG;IACH,uCAHW,OAAO,iBAAiB,EAAE,kBAAkB,EAStD;IADA,gBAA4B;IAG7B;;;;;OAKG,CACH,yCAHW,OAAO,mBAAmB,EAAE,eAAe,GACzC,OAAO,CAAE,MAAM,CAAC,CAY5B;IAED;;MAwBC;CAoBD;yBAlFwB,6BAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.test.d.ts","sourceRoot":"","sources":["../../../../src/components/date/question.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a date period, two dates which make up a period or range
|
|
3
|
+
* @class
|
|
4
|
+
*/
|
|
5
|
+
export default class DatePeriodQuestion extends Question {
|
|
6
|
+
/**
|
|
7
|
+
* @param {import('#question-types').QuestionParameters} params
|
|
8
|
+
* @param {string} [params.dateFormat]
|
|
9
|
+
* @param {{start: string, end: string}} [params.labels]
|
|
10
|
+
* @param {{hour: number, minute: number, second: number}} [params.startTime]
|
|
11
|
+
* @param {{hour: number, minute: number, second: number}} [params.endTime]
|
|
12
|
+
*/
|
|
13
|
+
constructor({ dateFormat, labels, startTime, endTime, ...params }: import("#question-types").QuestionParameters);
|
|
14
|
+
dateFormat: any;
|
|
15
|
+
labels: any;
|
|
16
|
+
startTime: any;
|
|
17
|
+
endTime: any;
|
|
18
|
+
/**
|
|
19
|
+
* Get the data to save from the request, returns an object of answers
|
|
20
|
+
* @param {import('express').Request} req
|
|
21
|
+
* @param {import('#journey-response').JourneyResponse} journeyResponse - current journey response, modified with the new answers
|
|
22
|
+
* @returns {Promise.<Object>}
|
|
23
|
+
*/ getDataToSave(req: any, journeyResponse: import("#journey-response").JourneyResponse): Promise<Object>;
|
|
24
|
+
answerForViewModel(answers: any, isPayload: any): {
|
|
25
|
+
[x: string]: any;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
import { Question } from '#question';
|
|
29
|
+
//# sourceMappingURL=question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../../../src/components/date-period/question.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH;IACC;;;;;;OAMG;IACH,mEANW,OAAO,iBAAiB,EAAE,kBAAkB,EAetD;IAJA,gBAA4B;IAC5B,YAAsD;IACtD,eAA+D;IAC/D,aAA2D;IAG5D;;;;;OAKG,CACH,yCAHW,OAAO,mBAAmB,EAAE,eAAe,GACzC,OAAO,CAAE,MAAM,CAAC,CAgC5B;IAED;;MAuCC;CAuCD;yBAjJwB,WAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.test.d.ts","sourceRoot":"","sources":["../../../../src/components/date-period/question.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export default class DateTimeQuestion extends Question {
|
|
2
|
+
static AM: string;
|
|
3
|
+
static PM: string;
|
|
4
|
+
/**
|
|
5
|
+
* @param {import('@planning-inspectorate/dynamic-forms/src/questions/question-types.js').QuestionParameters} params
|
|
6
|
+
* @param {string} [params.dateFormat]
|
|
7
|
+
* @param {string} [params.timeFormat]
|
|
8
|
+
*/
|
|
9
|
+
constructor({ dateFormat, timeFormat, ...params }: any);
|
|
10
|
+
dateFormat: any;
|
|
11
|
+
timeFormat: any;
|
|
12
|
+
/**
|
|
13
|
+
* Get the data to save from the request, returns an object of answers
|
|
14
|
+
* @param {import('express').Request} req
|
|
15
|
+
* @param {JourneyResponse} journeyResponse - current journey response, modified with the new answers
|
|
16
|
+
* @returns {Promise.<Object>}
|
|
17
|
+
*/ getDataToSave(req: any, journeyResponse: JourneyResponse): Promise<Object>;
|
|
18
|
+
answerForViewModel(answers: any, isPayload: any): {
|
|
19
|
+
[x: string]: any;
|
|
20
|
+
};
|
|
21
|
+
#private;
|
|
22
|
+
}
|
|
23
|
+
import { Question } from '../../questions/question.js';
|
|
24
|
+
//# sourceMappingURL=question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"question.d.ts","sourceRoot":"","sources":["../../../../src/components/date-time/question.js"],"names":[],"mappings":"AAMA;IACC,kBAAiB;IACjB,kBAAiB;IAEjB;;;;OAIG;IACH,wDAOC;IAFA,gBAA4B;IAC5B,gBAA4B;IAG7B;;;;;OAKG,CACH,yCAHW,eAAe,GACb,OAAO,CAAE,MAAM,CAAC,CAqB5B;IAED;;MAqCC;;CAoCD;yBA5HwB,6BAA6B"}
|