@ukhomeoffice/cop-react-form-renderer 4.66.1 → 4.68.1
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/dist/components/CheckYourAnswers/Answer.js +6 -16
- package/dist/components/CheckYourAnswers/Answer.test.js +104 -129
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +26 -64
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +428 -555
- package/dist/components/CheckYourAnswers/index.js +0 -3
- package/dist/components/CollectionPage/CollectionPage.js +13 -42
- package/dist/components/CollectionPage/CollectionPage.test.js +160 -206
- package/dist/components/CollectionPage/index.js +0 -3
- package/dist/components/FormComponent/Collection.js +35 -79
- package/dist/components/FormComponent/Collection.test.js +340 -391
- package/dist/components/FormComponent/Container.js +10 -31
- package/dist/components/FormComponent/Container.test.js +304 -357
- package/dist/components/FormComponent/FormComponent.js +17 -60
- package/dist/components/FormComponent/FormComponent.test.js +190 -228
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +0 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +0 -2
- package/dist/components/FormComponent/helpers/getComponentError.js +0 -6
- package/dist/components/FormComponent/helpers/getComponentError.test.js +0 -2
- package/dist/components/FormComponent/helpers/index.js +0 -4
- package/dist/components/FormComponent/index.js +0 -3
- package/dist/components/FormPage/FormPage.js +21 -53
- package/dist/components/FormPage/FormPage.test.js +122 -160
- package/dist/components/FormPage/index.js +0 -3
- package/dist/components/FormRenderer/FormRenderer.js +106 -296
- package/dist/components/FormRenderer/FormRenderer.test.js +820 -1058
- package/dist/components/FormRenderer/handlers/cyaAction.js +0 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +0 -2
- package/dist/components/FormRenderer/handlers/getPageId.test.js +1 -2
- package/dist/components/FormRenderer/handlers/handlers.test.js +1 -18
- package/dist/components/FormRenderer/handlers/index.js +0 -5
- package/dist/components/FormRenderer/handlers/navigate.js +0 -5
- package/dist/components/FormRenderer/handlers/submissionError.js +0 -2
- package/dist/components/FormRenderer/helpers/canActionProceed.js +0 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +0 -2
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +1 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +4 -12
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
- package/dist/components/FormRenderer/helpers/getCYA.js +0 -9
- package/dist/components/FormRenderer/helpers/getCYA.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getFormState.js +0 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getNextPageId.js +0 -25
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +1 -4
- package/dist/components/FormRenderer/helpers/getPage.js +0 -5
- package/dist/components/FormRenderer/helpers/getPage.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +0 -6
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +0 -10
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +4 -7
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +32 -41
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +122 -8
- package/dist/components/FormRenderer/helpers/index.js +1 -11
- package/dist/components/FormRenderer/index.js +0 -3
- package/dist/components/FormRenderer/onCYAAction.js +8 -30
- package/dist/components/FormRenderer/onCYAAction.test.js +54 -79
- package/dist/components/FormRenderer/onPageAction.js +123 -0
- package/dist/components/FormRenderer/onPageAction.test.js +632 -0
- package/dist/components/PageActions/ActionButton.js +2 -17
- package/dist/components/PageActions/ActionButton.test.js +58 -81
- package/dist/components/PageActions/PageActions.js +3 -10
- package/dist/components/PageActions/PageActions.test.js +95 -120
- package/dist/components/PageActions/index.js +0 -3
- package/dist/components/SummaryList/GroupAction.js +5 -26
- package/dist/components/SummaryList/GroupAction.test.js +14 -28
- package/dist/components/SummaryList/RowAction.js +5 -25
- package/dist/components/SummaryList/RowAction.test.js +14 -28
- package/dist/components/SummaryList/SummaryList.js +7 -31
- package/dist/components/SummaryList/SummaryList.test.js +69 -126
- package/dist/components/SummaryList/SummaryListHeadingRow.js +3 -8
- package/dist/components/SummaryList/SummaryListRow.js +4 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +2 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/index.js +0 -2
- package/dist/components/SummaryList/index.js +0 -3
- package/dist/components/TaskList/Task.js +9 -31
- package/dist/components/TaskList/Task.test.js +32 -59
- package/dist/components/TaskList/TaskList.js +32 -59
- package/dist/components/TaskList/TaskList.test.js +52 -90
- package/dist/components/TaskList/TaskState.js +2 -10
- package/dist/components/TaskList/TaskState.test.js +23 -41
- package/dist/components/TaskList/index.js +0 -3
- package/dist/components/index.js +0 -7
- package/dist/context/HooksContext/HooksContext.js +21 -39
- package/dist/context/HooksContext/HooksContext.test.js +18 -34
- package/dist/context/HooksContext/index.js +0 -5
- package/dist/context/ValidationContext/ValidationContext.js +26 -56
- package/dist/context/ValidationContext/ValidationContext.test.js +43 -64
- package/dist/context/ValidationContext/index.js +0 -5
- package/dist/context/index.js +0 -3
- package/dist/hooks/index.js +0 -9
- package/dist/hooks/useAxios.js +17 -36
- package/dist/hooks/useGetRequest.js +57 -93
- package/dist/hooks/useHooks.js +2 -4
- package/dist/hooks/useRefData.js +14 -41
- package/dist/hooks/useValidation.js +2 -4
- package/dist/index.js +0 -9
- package/dist/models/PageAction.js +4 -4
- package/dist/models/TaskStates.js +4 -4
- package/dist/models/index.js +1 -10
- package/dist/setupTests.js +0 -13
- package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +1 -19
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +4 -11
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +4 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +4 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +4 -8
- package/dist/utils/CheckYourAnswers/getCYARow.js +1 -10
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +8 -23
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +6 -21
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +2 -9
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +4 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +7 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +4 -32
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +4 -34
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +4 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +4 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +7 -25
- package/dist/utils/CheckYourAnswers/index.js +1 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +9 -12
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +41 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +4 -12
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +5 -6
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +1 -2
- package/dist/utils/CollectionPage/index.js +1 -5
- package/dist/utils/CollectionPage/mergeCollectionPages.js +5 -11
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +1 -2
- package/dist/utils/Component/addShowWhen.js +4 -10
- package/dist/utils/Component/addShowWhen.test.js +1 -2
- package/dist/utils/Component/applyToComponentTree.js +4 -18
- package/dist/utils/Component/applyToComponentTree.test.js +4 -8
- package/dist/utils/Component/cleanAttributes.js +1 -8
- package/dist/utils/Component/cleanAttributes.test.js +15 -16
- package/dist/utils/Component/elevateNestedComponents.js +0 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +0 -2
- package/dist/utils/Component/getComponent.js +7 -86
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +33 -51
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +8 -35
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +12 -29
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +6 -24
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +5 -22
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +156 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +8 -35
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +10 -34
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +12 -31
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +1 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +3 -7
- package/dist/utils/Component/getDefaultValue.js +4 -8
- package/dist/utils/Component/getDefaultValue.test.js +0 -3
- package/dist/utils/Component/index.js +0 -10
- package/dist/utils/Component/isEditable.js +1 -4
- package/dist/utils/Component/isEditable.test.js +1 -5
- package/dist/utils/Component/setupContainerComponentsPath.js +4 -9
- package/dist/utils/Component/setupContainerComponentsPath.test.js +0 -3
- package/dist/utils/Component/showComponent.js +1 -8
- package/dist/utils/Component/showComponent.test.js +1 -2
- package/dist/utils/Component/wrapInFormGroup.js +0 -7
- package/dist/utils/Condition/index.js +0 -5
- package/dist/utils/Condition/meetsAllConditions.js +0 -9
- package/dist/utils/Condition/meetsAllConditions.test.js +1 -2
- package/dist/utils/Condition/meetsCondition.js +9 -34
- package/dist/utils/Condition/meetsCondition.test.js +21 -14
- package/dist/utils/Condition/meetsOneCondition.js +1 -9
- package/dist/utils/Condition/meetsOneCondition.test.js +1 -2
- package/dist/utils/Condition/setupConditions.js +4 -13
- package/dist/utils/Condition/setupConditions.test.js +0 -2
- package/dist/utils/Container/getEditableComponents.js +0 -7
- package/dist/utils/Container/getEditableComponents.test.js +1 -12
- package/dist/utils/Container/index.js +0 -5
- package/dist/utils/Container/setupNesting.js +4 -12
- package/dist/utils/Container/setupNesting.test.js +4 -10
- package/dist/utils/Container/showContainer.js +9 -18
- package/dist/utils/Container/showContainer.test.js +1 -2
- package/dist/utils/Data/applyFormula.js +6 -29
- package/dist/utils/Data/applyFormula.test.js +1 -2
- package/dist/utils/Data/getAutocompleteSource.js +1 -5
- package/dist/utils/Data/getAutocompleteSource.test.js +1 -2
- package/dist/utils/Data/getDataPath.js +3 -17
- package/dist/utils/Data/getDataPath.test.js +0 -4
- package/dist/utils/Data/getOptions.js +4 -14
- package/dist/utils/Data/getOptions.test.js +1 -2
- package/dist/utils/Data/getSourceData.js +6 -21
- package/dist/utils/Data/getSourceData.test.js +4 -6
- package/dist/utils/Data/index.js +1 -11
- package/dist/utils/Data/refDataToOptions.js +5 -13
- package/dist/utils/Data/refDataToOptions.test.js +1 -2
- package/dist/utils/Data/setDataItem.js +0 -5
- package/dist/utils/Data/setDataItem.test.js +0 -2
- package/dist/utils/Data/setupFormData.js +6 -25
- package/dist/utils/Data/setupFormData.test.js +8 -11
- package/dist/utils/Data/setupRefDataUrlForComponent.js +4 -15
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +1 -3
- package/dist/utils/FormPage/applyConditionalProperties.js +4 -11
- package/dist/utils/FormPage/applyConditionalProperties.test.js +4 -6
- package/dist/utils/FormPage/getFormPage.js +4 -16
- package/dist/utils/FormPage/getFormPage.test.js +10 -9
- package/dist/utils/FormPage/getFormPages.js +4 -9
- package/dist/utils/FormPage/getFormPages.test.js +6 -7
- package/dist/utils/FormPage/getPageActions.js +6 -19
- package/dist/utils/FormPage/getPageActions.test.js +1 -3
- package/dist/utils/FormPage/getParagraphFromText.js +0 -3
- package/dist/utils/FormPage/getParagraphFromText.test.js +1 -3
- package/dist/utils/FormPage/index.js +0 -7
- package/dist/utils/FormPage/showFormPage.js +9 -18
- package/dist/utils/FormPage/showFormPage.test.js +0 -2
- package/dist/utils/FormPage/showFormPageCYA.js +0 -5
- package/dist/utils/FormPage/showFormPageCYA.test.js +0 -2
- package/dist/utils/FormPage/useComponent.js +7 -19
- package/dist/utils/FormPage/useComponent.test.js +4 -7
- package/dist/utils/Format/formatData.js +0 -5
- package/dist/utils/Format/formatData.test.js +1 -2
- package/dist/utils/Format/formatDataForComponent.js +1 -6
- package/dist/utils/Format/formatDataForComponent.test.js +28 -47
- package/dist/utils/Format/formatDataForForm.js +4 -9
- package/dist/utils/Format/formatDataForForm.test.js +14 -11
- package/dist/utils/Format/formatDataForPage.js +1 -5
- package/dist/utils/Format/formatDataForPage.test.js +15 -12
- package/dist/utils/Format/index.js +1 -6
- package/dist/utils/Hub/getFormHub.js +0 -8
- package/dist/utils/Hub/getFormHub.test.js +6 -8
- package/dist/utils/Hub/index.js +1 -3
- package/dist/utils/Meta/documents/getDocuments.js +1 -4
- package/dist/utils/Meta/documents/getDocuments.test.js +4 -10
- package/dist/utils/Meta/documents/index.js +1 -5
- package/dist/utils/Meta/documents/setDocumentsForField.js +4 -11
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +4 -16
- package/dist/utils/Meta/index.js +1 -4
- package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
- package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -2
- package/dist/utils/Operate/getFirstOf.js +2 -9
- package/dist/utils/Operate/getFirstOf.test.js +0 -2
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +6 -2
- package/dist/utils/Operate/index.js +0 -3
- package/dist/utils/Operate/persistValueInFormData.js +1 -8
- package/dist/utils/Operate/persistValueInFormData.test.js +0 -4
- package/dist/utils/Operate/runPageOperations.js +3 -19
- package/dist/utils/Operate/runPageOperations.test.js +4 -6
- package/dist/utils/Operate/setValueInFormData.js +2 -7
- package/dist/utils/Operate/setValueInFormData.test.js +0 -2
- package/dist/utils/Operate/shouldRun.js +1 -14
- package/dist/utils/Operate/shouldRun.test.js +5 -8
- package/dist/utils/Validate/additional/conditionallyRequired.js +0 -3
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +0 -2
- package/dist/utils/Validate/additional/index.js +1 -22
- package/dist/utils/Validate/additional/index.test.js +0 -6
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -8
- package/dist/utils/Validate/additional/mustBeAfter.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -8
- package/dist/utils/Validate/additional/mustBeBefore.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +5 -16
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +4 -8
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -12
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -13
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeLongerThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +0 -3
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeShorterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +0 -5
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +4 -5
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +0 -3
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +0 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +0 -6
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +4 -7
- package/dist/utils/Validate/additional/utils.js +10 -26
- package/dist/utils/Validate/index.js +1 -11
- package/dist/utils/Validate/validateCollection.js +4 -10
- package/dist/utils/Validate/validateCollection.test.js +4 -6
- package/dist/utils/Validate/validateComponent.js +2 -39
- package/dist/utils/Validate/validateComponent.test.js +4 -22
- package/dist/utils/Validate/validateContainer.js +4 -14
- package/dist/utils/Validate/validateContainer.test.js +4 -10
- package/dist/utils/Validate/validateDate.js +6 -38
- package/dist/utils/Validate/validateDate.test.js +0 -4
- package/dist/utils/Validate/validateEmail.js +1 -8
- package/dist/utils/Validate/validateEmail.test.js +5 -4
- package/dist/utils/Validate/validateMultifile.js +0 -7
- package/dist/utils/Validate/validateMultifile.test.js +5 -6
- package/dist/utils/Validate/validatePage.js +4 -16
- package/dist/utils/Validate/validatePage.test.js +30 -25
- package/dist/utils/Validate/validateRegex.js +0 -10
- package/dist/utils/Validate/validateRegex.test.js +5 -4
- package/dist/utils/Validate/validateRequired.js +0 -8
- package/dist/utils/Validate/validateRequired.test.js +5 -4
- package/dist/utils/Validate/validateTextArea.js +0 -8
- package/dist/utils/Validate/validateTextArea.test.js +0 -2
- package/dist/utils/Validate/validateTime.js +5 -22
- package/dist/utils/Validate/validateTime.test.js +0 -2
- package/dist/utils/index.js +4 -20
- package/package.json +2 -2
|
@@ -1,74 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
var _react = require("@testing-library/react");
|
|
6
|
-
|
|
7
5
|
var _axios = _interopRequireDefault(require("axios"));
|
|
8
|
-
|
|
9
6
|
var _axiosMockAdapter = _interopRequireDefault(require("axios-mock-adapter"));
|
|
10
|
-
|
|
11
7
|
var _react2 = _interopRequireDefault(require("react"));
|
|
12
|
-
|
|
13
8
|
var _reactDom = require("react-dom");
|
|
14
|
-
|
|
15
9
|
var _testUtils = require("react-dom/test-utils");
|
|
16
|
-
|
|
17
10
|
var _models = require("../../models");
|
|
18
|
-
|
|
19
11
|
var _CheckYourAnswers = require("../CheckYourAnswers/CheckYourAnswers");
|
|
20
|
-
|
|
21
12
|
var _TaskList = require("../TaskList/TaskList");
|
|
22
|
-
|
|
23
13
|
var _FormRenderer = _interopRequireWildcard(require("./FormRenderer"));
|
|
24
|
-
|
|
25
14
|
var _areYouACivilServant = _interopRequireDefault(require("../../json/areYouACivilServant.json"));
|
|
26
|
-
|
|
27
15
|
var _grade = _interopRequireDefault(require("../../json/grade.json"));
|
|
28
|
-
|
|
29
16
|
var _team = _interopRequireDefault(require("../../json/team.json"));
|
|
30
|
-
|
|
31
17
|
var _userProfileData = _interopRequireDefault(require("../../json/userProfile.data.json"));
|
|
32
|
-
|
|
33
18
|
var _userProfile = _interopRequireDefault(require("../../json/userProfile.json"));
|
|
34
|
-
|
|
35
19
|
var _taskList = _interopRequireDefault(require("../../json/taskList.json"));
|
|
36
|
-
|
|
37
20
|
var _firstForm = _interopRequireDefault(require("../../json/firstForm.json"));
|
|
38
|
-
|
|
39
21
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
40
|
-
|
|
41
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
42
|
-
|
|
43
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
44
|
-
|
|
24
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
45
25
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
46
|
-
|
|
47
26
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
48
|
-
|
|
49
27
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
50
|
-
|
|
51
28
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
52
|
-
|
|
53
29
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
54
|
-
|
|
55
30
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
56
|
-
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
60
|
-
|
|
31
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
32
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
61
33
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
62
|
-
|
|
63
34
|
describe('components', function () {
|
|
64
35
|
describe('FormRenderer', function () {
|
|
65
36
|
var mockAxios = new _axiosMockAdapter.default(_axios.default);
|
|
66
37
|
var container = null;
|
|
67
|
-
|
|
68
38
|
var refDataUrl = function refDataUrl(suffix) {
|
|
69
39
|
return "".concat(_userProfileData.default.urls.refData, "/").concat(suffix);
|
|
70
40
|
};
|
|
71
|
-
|
|
72
41
|
beforeEach(function () {
|
|
73
42
|
container = document.createElement('div');
|
|
74
43
|
document.body.appendChild(container);
|
|
@@ -82,1115 +51,908 @@ describe('components', function () {
|
|
|
82
51
|
container.remove();
|
|
83
52
|
container = null;
|
|
84
53
|
});
|
|
85
|
-
|
|
86
54
|
var checkForm = function checkForm(container) {
|
|
87
55
|
var form = container.childNodes[0];
|
|
88
56
|
expect(form.tagName).toEqual('DIV');
|
|
89
57
|
expect(form.classList).toContain(_FormRenderer.DEFAULT_CLASS);
|
|
90
58
|
return form;
|
|
91
59
|
};
|
|
92
|
-
|
|
93
60
|
var getChangeLink = function getChangeLink(summaryList) {
|
|
94
61
|
var _summaryList$childNod = _slicedToArray(summaryList.childNodes[0].childNodes[0].childNodes, 3),
|
|
95
|
-
|
|
96
|
-
|
|
62
|
+
actions = _summaryList$childNod[2];
|
|
97
63
|
return actions.childNodes[0];
|
|
98
64
|
};
|
|
99
|
-
|
|
100
65
|
var getContinueButton = function getContinueButton(page) {
|
|
101
66
|
return page.childNodes[page.childNodes.length - 1].childNodes[0].childNodes[0];
|
|
102
67
|
};
|
|
103
|
-
|
|
104
68
|
var getCancelButton = function getCancelButton(page) {
|
|
105
69
|
return page.childNodes[page.childNodes.length - 1].childNodes[1].childNodes[0];
|
|
106
70
|
};
|
|
107
|
-
|
|
108
|
-
it('should start on the hub page correctly and display the title', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
71
|
+
it('should start on the hub page correctly and display the title', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
109
72
|
var form, title, hub;
|
|
110
|
-
return
|
|
111
|
-
while (1) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
hub = form.childNodes[1];
|
|
140
|
-
expect(hub.tagName).toEqual('DIV');
|
|
141
|
-
expect(hub.classList).toContain(_CheckYourAnswers.DEFAULT_CLASS);
|
|
142
|
-
|
|
143
|
-
case 10:
|
|
144
|
-
case "end":
|
|
145
|
-
return _context2.stop();
|
|
146
|
-
}
|
|
73
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
74
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
75
|
+
case 0:
|
|
76
|
+
_context2.next = 2;
|
|
77
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
78
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
79
|
+
while (1) switch (_context.prev = _context.next) {
|
|
80
|
+
case 0:
|
|
81
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
82
|
+
data: _userProfileData.default
|
|
83
|
+
})), container);
|
|
84
|
+
case 1:
|
|
85
|
+
case "end":
|
|
86
|
+
return _context.stop();
|
|
87
|
+
}
|
|
88
|
+
}, _callee);
|
|
89
|
+
})));
|
|
90
|
+
case 2:
|
|
91
|
+
form = checkForm(container);
|
|
92
|
+
expect(form.childNodes.length).toEqual(2); // Title + Hub page (= CYA)
|
|
93
|
+
title = form.childNodes[0];
|
|
94
|
+
expect(title.tagName).toEqual('H1');
|
|
95
|
+
expect(title.textContent).toEqual(_userProfile.default.title);
|
|
96
|
+
hub = form.childNodes[1];
|
|
97
|
+
expect(hub.tagName).toEqual('DIV');
|
|
98
|
+
expect(hub.classList).toContain(_CheckYourAnswers.DEFAULT_CLASS);
|
|
99
|
+
case 10:
|
|
100
|
+
case "end":
|
|
101
|
+
return _context2.stop();
|
|
147
102
|
}
|
|
148
103
|
}, _callee2);
|
|
149
104
|
})));
|
|
150
|
-
it('should fire the onFormLoad method passed in the hooks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
105
|
+
it('should fire the onFormLoad method passed in the hooks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
151
106
|
var onFormLoadCalled, ON_FORM_LOAD, HOOKS;
|
|
152
|
-
return
|
|
153
|
-
while (1) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
})));
|
|
183
|
-
|
|
184
|
-
case 5:
|
|
185
|
-
expect(onFormLoadCalled).toBeTruthy();
|
|
186
|
-
|
|
187
|
-
case 6:
|
|
188
|
-
case "end":
|
|
189
|
-
return _context4.stop();
|
|
190
|
-
}
|
|
107
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
108
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
109
|
+
case 0:
|
|
110
|
+
onFormLoadCalled = false;
|
|
111
|
+
ON_FORM_LOAD = function ON_FORM_LOAD() {
|
|
112
|
+
onFormLoadCalled = true;
|
|
113
|
+
};
|
|
114
|
+
HOOKS = {
|
|
115
|
+
onFormLoad: ON_FORM_LOAD
|
|
116
|
+
};
|
|
117
|
+
_context4.next = 5;
|
|
118
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
119
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
120
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
121
|
+
case 0:
|
|
122
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
123
|
+
data: _userProfileData.default,
|
|
124
|
+
hooks: HOOKS
|
|
125
|
+
})), container);
|
|
126
|
+
case 1:
|
|
127
|
+
case "end":
|
|
128
|
+
return _context3.stop();
|
|
129
|
+
}
|
|
130
|
+
}, _callee3);
|
|
131
|
+
})));
|
|
132
|
+
case 5:
|
|
133
|
+
expect(onFormLoadCalled).toBeTruthy();
|
|
134
|
+
case 6:
|
|
135
|
+
case "end":
|
|
136
|
+
return _context4.stop();
|
|
191
137
|
}
|
|
192
138
|
}, _callee4);
|
|
193
139
|
})));
|
|
194
|
-
it('should navigate to the first editable page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
140
|
+
it('should navigate to the first editable page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
195
141
|
var ON_PAGE_CHANGE_CALLS, ON_PAGE_CHANGE, HOOKS, form, hub, _hub$childNodes, civilServantList, link, page, pageHeading;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
ON_PAGE_CHANGE_CALLS
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
expect(ON_PAGE_CHANGE_CALLS[0]).toEqual(_userProfile.default.pages[1].id); // The form layout should have changed to the current page.
|
|
241
|
-
|
|
242
|
-
expect(form.childNodes.length).toEqual(1); // Just the page.
|
|
243
|
-
|
|
244
|
-
page = form.childNodes[0];
|
|
245
|
-
pageHeading = page.childNodes[0];
|
|
246
|
-
expect(pageHeading.tagName).toEqual('H1');
|
|
247
|
-
expect(pageHeading.textContent).toEqual(_userProfile.default.pages[1].title);
|
|
248
|
-
|
|
249
|
-
case 18:
|
|
250
|
-
case "end":
|
|
251
|
-
return _context6.stop();
|
|
252
|
-
}
|
|
142
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
143
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
144
|
+
case 0:
|
|
145
|
+
ON_PAGE_CHANGE_CALLS = [];
|
|
146
|
+
ON_PAGE_CHANGE = function ON_PAGE_CHANGE(pageId) {
|
|
147
|
+
ON_PAGE_CHANGE_CALLS.push(pageId);
|
|
148
|
+
};
|
|
149
|
+
HOOKS = {
|
|
150
|
+
onPageChange: ON_PAGE_CHANGE
|
|
151
|
+
};
|
|
152
|
+
_context6.next = 5;
|
|
153
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
154
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
155
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
156
|
+
case 0:
|
|
157
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
158
|
+
data: _userProfileData.default,
|
|
159
|
+
hooks: HOOKS
|
|
160
|
+
})), container);
|
|
161
|
+
case 1:
|
|
162
|
+
case "end":
|
|
163
|
+
return _context5.stop();
|
|
164
|
+
}
|
|
165
|
+
}, _callee5);
|
|
166
|
+
})));
|
|
167
|
+
case 5:
|
|
168
|
+
form = checkForm(container);
|
|
169
|
+
hub = form.childNodes[1]; // Hub = CYA
|
|
170
|
+
_hub$childNodes = _slicedToArray(hub.childNodes, 3), civilServantList = _hub$childNodes[2];
|
|
171
|
+
link = getChangeLink(civilServantList);
|
|
172
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(0);
|
|
173
|
+
_react.fireEvent.click(link, {});
|
|
174
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(1);
|
|
175
|
+
expect(ON_PAGE_CHANGE_CALLS[0]).toEqual(_userProfile.default.pages[1].id);
|
|
176
|
+
|
|
177
|
+
// The form layout should have changed to the current page.
|
|
178
|
+
expect(form.childNodes.length).toEqual(1); // Just the page.
|
|
179
|
+
page = form.childNodes[0];
|
|
180
|
+
pageHeading = page.childNodes[0];
|
|
181
|
+
expect(pageHeading.tagName).toEqual('H1');
|
|
182
|
+
expect(pageHeading.textContent).toEqual(_userProfile.default.pages[1].title);
|
|
183
|
+
case 18:
|
|
184
|
+
case "end":
|
|
185
|
+
return _context6.stop();
|
|
253
186
|
}
|
|
254
187
|
}, _callee6);
|
|
255
188
|
})));
|
|
256
|
-
it('should handle a page submission', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
189
|
+
it('should handle a page submission', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
257
190
|
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, form, hub, _hub$childNodes2, civilServantList, link, page, continueButton, title;
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
ON_SUBMIT_CALLS
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
expect(ON_SUBMIT_CALLS.length).toEqual(1);
|
|
321
|
-
expect(ON_SUBMIT_CALLS[0].type).toEqual(_models.PageAction.TYPES.SUBMIT);
|
|
322
|
-
expect(ON_SUBMIT_CALLS[0].payload.areYouACivilServant).toEqual('no-contractor');
|
|
323
|
-
expect(ON_SUBMIT_CALLS[0].fieldName).toEqual('Are you a civil servant?');
|
|
324
|
-
expect(ON_SUBMIT_CALLS[0].fieldValue).toEqual("No, I'm a contractor"); // And we should be back on the hub.
|
|
325
|
-
|
|
326
|
-
expect(form.childNodes.length).toEqual(2); // Title + Hub page (= CYA)
|
|
327
|
-
|
|
328
|
-
title = form.childNodes[0];
|
|
329
|
-
expect(title.tagName).toEqual('H1');
|
|
330
|
-
expect(title.textContent).toEqual(_userProfile.default.title);
|
|
331
|
-
|
|
332
|
-
case 24:
|
|
333
|
-
case "end":
|
|
334
|
-
return _context8.stop();
|
|
335
|
-
}
|
|
191
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
192
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
193
|
+
case 0:
|
|
194
|
+
ON_SUBMIT_CALLS = [];
|
|
195
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError, fieldName, fieldValue) {
|
|
196
|
+
ON_SUBMIT_CALLS.push({
|
|
197
|
+
type: type,
|
|
198
|
+
payload: payload,
|
|
199
|
+
onSuccess: onSuccess,
|
|
200
|
+
onError: onError,
|
|
201
|
+
fieldName: fieldName,
|
|
202
|
+
fieldValue: fieldValue
|
|
203
|
+
});
|
|
204
|
+
onSuccess();
|
|
205
|
+
};
|
|
206
|
+
HOOKS = {
|
|
207
|
+
onSubmit: ON_SUBMIT
|
|
208
|
+
};
|
|
209
|
+
_context8.next = 5;
|
|
210
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
211
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
212
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
213
|
+
case 0:
|
|
214
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
215
|
+
data: _userProfileData.default,
|
|
216
|
+
hooks: HOOKS,
|
|
217
|
+
type: _models.FormTypes.HUB
|
|
218
|
+
})), container);
|
|
219
|
+
case 1:
|
|
220
|
+
case "end":
|
|
221
|
+
return _context7.stop();
|
|
222
|
+
}
|
|
223
|
+
}, _callee7);
|
|
224
|
+
})));
|
|
225
|
+
case 5:
|
|
226
|
+
form = checkForm(container); // Navigate to the "Are you a civil servant?" page.
|
|
227
|
+
hub = form.childNodes[1]; // Hub = CYA
|
|
228
|
+
_hub$childNodes2 = _slicedToArray(hub.childNodes, 3), civilServantList = _hub$childNodes2[2];
|
|
229
|
+
link = getChangeLink(civilServantList);
|
|
230
|
+
_react.fireEvent.click(link, {});
|
|
231
|
+
|
|
232
|
+
// Should already be answered "Yes", but select "No, I'm a contractor" option to generate patch
|
|
233
|
+
// and then click "Continue".
|
|
234
|
+
_react.fireEvent.click(_react.screen.getByText("No, I'm a contractor"));
|
|
235
|
+
page = form.childNodes[0];
|
|
236
|
+
continueButton = getContinueButton(page);
|
|
237
|
+
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
238
|
+
_react.fireEvent.click(continueButton, {});
|
|
239
|
+
expect(ON_SUBMIT_CALLS.length).toEqual(1);
|
|
240
|
+
expect(ON_SUBMIT_CALLS[0].type).toEqual(_models.PageAction.TYPES.SUBMIT);
|
|
241
|
+
expect(ON_SUBMIT_CALLS[0].payload.areYouACivilServant).toEqual('no-contractor');
|
|
242
|
+
expect(ON_SUBMIT_CALLS[0].fieldName).toEqual('Are you a civil servant?');
|
|
243
|
+
expect(ON_SUBMIT_CALLS[0].fieldValue).toEqual("No, I'm a contractor");
|
|
244
|
+
|
|
245
|
+
// And we should be back on the hub.
|
|
246
|
+
expect(form.childNodes.length).toEqual(2); // Title + Hub page (= CYA)
|
|
247
|
+
title = form.childNodes[0];
|
|
248
|
+
expect(title.tagName).toEqual('H1');
|
|
249
|
+
expect(title.textContent).toEqual(_userProfile.default.title);
|
|
250
|
+
case 24:
|
|
251
|
+
case "end":
|
|
252
|
+
return _context8.stop();
|
|
336
253
|
}
|
|
337
254
|
}, _callee8);
|
|
338
255
|
})));
|
|
339
|
-
it('should handle a page submission error', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
256
|
+
it('should handle a page submission error', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
340
257
|
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, form, hub, _hub$childNodes3, civilServantList, link, page, continueButton, pageHeading;
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
ON_SUBMIT_CALLS
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
expect(ON_SUBMIT_CALLS.length).toEqual(1);
|
|
401
|
-
expect(ON_SUBMIT_CALLS[0].type).toEqual(_models.PageAction.TYPES.SUBMIT);
|
|
402
|
-
expect(ON_SUBMIT_CALLS[0].payload.areYouACivilServant).toEqual('yes'); // And we should be kept on the same page.
|
|
403
|
-
|
|
404
|
-
expect(form.childNodes.length).toEqual(1); // Just the page.
|
|
405
|
-
|
|
406
|
-
pageHeading = form.childNodes[0].childNodes[1];
|
|
407
|
-
expect(pageHeading.tagName).toEqual('H1');
|
|
408
|
-
expect(pageHeading.textContent).toEqual(_userProfile.default.pages[1].title);
|
|
409
|
-
|
|
410
|
-
case 21:
|
|
411
|
-
case "end":
|
|
412
|
-
return _context10.stop();
|
|
413
|
-
}
|
|
258
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
259
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
260
|
+
case 0:
|
|
261
|
+
ON_SUBMIT_CALLS = [];
|
|
262
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
|
|
263
|
+
ON_SUBMIT_CALLS.push({
|
|
264
|
+
type: type,
|
|
265
|
+
payload: payload,
|
|
266
|
+
onSuccess: onSuccess,
|
|
267
|
+
onError: onError
|
|
268
|
+
});
|
|
269
|
+
onError([{
|
|
270
|
+
id: 'unknown',
|
|
271
|
+
error: 'Something went wrong'
|
|
272
|
+
}]);
|
|
273
|
+
};
|
|
274
|
+
HOOKS = {
|
|
275
|
+
onSubmit: ON_SUBMIT
|
|
276
|
+
};
|
|
277
|
+
_context10.next = 5;
|
|
278
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
279
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
280
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
281
|
+
case 0:
|
|
282
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
283
|
+
data: _userProfileData.default,
|
|
284
|
+
hooks: HOOKS
|
|
285
|
+
})), container);
|
|
286
|
+
case 1:
|
|
287
|
+
case "end":
|
|
288
|
+
return _context9.stop();
|
|
289
|
+
}
|
|
290
|
+
}, _callee9);
|
|
291
|
+
})));
|
|
292
|
+
case 5:
|
|
293
|
+
form = checkForm(container); // Navigate to the "Are you a civil servant?" page.
|
|
294
|
+
hub = form.childNodes[1]; // Hub = CYA
|
|
295
|
+
_hub$childNodes3 = _slicedToArray(hub.childNodes, 3), civilServantList = _hub$childNodes3[2];
|
|
296
|
+
link = getChangeLink(civilServantList);
|
|
297
|
+
_react.fireEvent.click(link, {});
|
|
298
|
+
|
|
299
|
+
// Should already be answered "Yes", so simply click "Continue".
|
|
300
|
+
page = form.childNodes[0];
|
|
301
|
+
continueButton = getContinueButton(page);
|
|
302
|
+
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
303
|
+
_react.fireEvent.click(continueButton, {});
|
|
304
|
+
expect(ON_SUBMIT_CALLS.length).toEqual(1);
|
|
305
|
+
expect(ON_SUBMIT_CALLS[0].type).toEqual(_models.PageAction.TYPES.SUBMIT);
|
|
306
|
+
expect(ON_SUBMIT_CALLS[0].payload.areYouACivilServant).toEqual('yes');
|
|
307
|
+
|
|
308
|
+
// And we should be kept on the same page.
|
|
309
|
+
expect(form.childNodes.length).toEqual(1); // Just the page.
|
|
310
|
+
pageHeading = form.childNodes[0].childNodes[1];
|
|
311
|
+
expect(pageHeading.tagName).toEqual('H1');
|
|
312
|
+
expect(pageHeading.textContent).toEqual(_userProfile.default.pages[1].title);
|
|
313
|
+
case 21:
|
|
314
|
+
case "end":
|
|
315
|
+
return _context10.stop();
|
|
414
316
|
}
|
|
415
317
|
}, _callee10);
|
|
416
318
|
})));
|
|
417
|
-
it('should handle page navigation', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
319
|
+
it('should handle page navigation', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
418
320
|
var ON_PAGE_CHANGE_CALLS, ON_PAGE_CHANGE, HOOKS, form, hub, _hub$childNodes4, lineManagerList, link, page, pageHeading, continueButton, newPageHeading;
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
ON_PAGE_CHANGE_CALLS
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(1);
|
|
472
|
-
|
|
473
|
-
_react.fireEvent.click(continueButton, {});
|
|
474
|
-
|
|
475
|
-
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(2);
|
|
476
|
-
expect(ON_PAGE_CHANGE_CALLS[1]).toEqual(_userProfile.default.pages[5].id);
|
|
477
|
-
newPageHeading = form.childNodes[0].childNodes[0];
|
|
478
|
-
expect(newPageHeading.tagName).toEqual('H1');
|
|
479
|
-
expect(newPageHeading.textContent).toEqual(_userProfile.default.pages[5].title);
|
|
480
|
-
|
|
481
|
-
case 24:
|
|
482
|
-
case "end":
|
|
483
|
-
return _context12.stop();
|
|
484
|
-
}
|
|
321
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
322
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
323
|
+
case 0:
|
|
324
|
+
ON_PAGE_CHANGE_CALLS = [];
|
|
325
|
+
ON_PAGE_CHANGE = function ON_PAGE_CHANGE(pageId) {
|
|
326
|
+
ON_PAGE_CHANGE_CALLS.push(pageId);
|
|
327
|
+
};
|
|
328
|
+
HOOKS = {
|
|
329
|
+
onPageChange: ON_PAGE_CHANGE
|
|
330
|
+
};
|
|
331
|
+
_context12.next = 5;
|
|
332
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
333
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
334
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
335
|
+
case 0:
|
|
336
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
337
|
+
data: _userProfileData.default,
|
|
338
|
+
hooks: HOOKS
|
|
339
|
+
})), container);
|
|
340
|
+
case 1:
|
|
341
|
+
case "end":
|
|
342
|
+
return _context11.stop();
|
|
343
|
+
}
|
|
344
|
+
}, _callee11);
|
|
345
|
+
})));
|
|
346
|
+
case 5:
|
|
347
|
+
form = checkForm(container); // Navigate to the "Add or change a line manager" page.
|
|
348
|
+
hub = form.childNodes[1]; // Hub = CYA
|
|
349
|
+
_hub$childNodes4 = _slicedToArray(hub.childNodes, 6), lineManagerList = _hub$childNodes4[5];
|
|
350
|
+
link = getChangeLink(lineManagerList);
|
|
351
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(0);
|
|
352
|
+
_react.fireEvent.click(link, {});
|
|
353
|
+
expect(ON_PAGE_CHANGE_CALLS[0]).toEqual(_userProfile.default.pages[4].id);
|
|
354
|
+
|
|
355
|
+
// Should be on the page explaining what changing the line manager means.
|
|
356
|
+
page = form.childNodes[0];
|
|
357
|
+
pageHeading = page.childNodes[0];
|
|
358
|
+
expect(pageHeading.tagName).toEqual('H1');
|
|
359
|
+
expect(pageHeading.textContent).toEqual(_userProfile.default.pages[4].title);
|
|
360
|
+
|
|
361
|
+
// Now click on the "Continue" button on here.
|
|
362
|
+
continueButton = getContinueButton(page);
|
|
363
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(1);
|
|
364
|
+
_react.fireEvent.click(continueButton, {});
|
|
365
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(2);
|
|
366
|
+
expect(ON_PAGE_CHANGE_CALLS[1]).toEqual(_userProfile.default.pages[5].id);
|
|
367
|
+
newPageHeading = form.childNodes[0].childNodes[0];
|
|
368
|
+
expect(newPageHeading.tagName).toEqual('H1');
|
|
369
|
+
expect(newPageHeading.textContent).toEqual(_userProfile.default.pages[5].title);
|
|
370
|
+
case 24:
|
|
371
|
+
case "end":
|
|
372
|
+
return _context12.stop();
|
|
485
373
|
}
|
|
486
374
|
}, _callee12);
|
|
487
375
|
})));
|
|
488
|
-
it('should show no title when hide_title is set to true', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
376
|
+
it('should show no title when hide_title is set to true', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
489
377
|
var form, hub;
|
|
490
|
-
return
|
|
491
|
-
while (1) {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
return (
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
hub = form.childNodes[0];
|
|
518
|
-
expect(hub.tagName).toEqual('DIV');
|
|
519
|
-
expect(hub.classList).toContain(_CheckYourAnswers.DEFAULT_CLASS);
|
|
520
|
-
|
|
521
|
-
case 7:
|
|
522
|
-
case "end":
|
|
523
|
-
return _context14.stop();
|
|
524
|
-
}
|
|
378
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
379
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
380
|
+
case 0:
|
|
381
|
+
_context14.next = 2;
|
|
382
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
383
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
384
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
385
|
+
case 0:
|
|
386
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
387
|
+
data: _userProfileData.default,
|
|
388
|
+
hide_title: true
|
|
389
|
+
})), container);
|
|
390
|
+
case 1:
|
|
391
|
+
case "end":
|
|
392
|
+
return _context13.stop();
|
|
393
|
+
}
|
|
394
|
+
}, _callee13);
|
|
395
|
+
})));
|
|
396
|
+
case 2:
|
|
397
|
+
form = checkForm(container);
|
|
398
|
+
expect(form.childNodes.length).toEqual(1); //Hub page (= CYA)
|
|
399
|
+
hub = form.childNodes[0];
|
|
400
|
+
expect(hub.tagName).toEqual('DIV');
|
|
401
|
+
expect(hub.classList).toContain(_CheckYourAnswers.DEFAULT_CLASS);
|
|
402
|
+
case 7:
|
|
403
|
+
case "end":
|
|
404
|
+
return _context14.stop();
|
|
525
405
|
}
|
|
526
406
|
}, _callee14);
|
|
527
407
|
})));
|
|
528
|
-
it('should render a tasklist', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
408
|
+
it('should render a tasklist', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
529
409
|
var taskList;
|
|
530
|
-
return
|
|
531
|
-
while (1) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
return (
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
taskList = container.childNodes[0].childNodes[1];
|
|
552
|
-
expect(taskList.classList).toContain(_TaskList.DEFAULT_CLASS);
|
|
553
|
-
|
|
554
|
-
case 4:
|
|
555
|
-
case "end":
|
|
556
|
-
return _context16.stop();
|
|
557
|
-
}
|
|
410
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
411
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
412
|
+
case 0:
|
|
413
|
+
_context16.next = 2;
|
|
414
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
415
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
416
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
417
|
+
case 0:
|
|
418
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _taskList.default), container);
|
|
419
|
+
case 1:
|
|
420
|
+
case "end":
|
|
421
|
+
return _context15.stop();
|
|
422
|
+
}
|
|
423
|
+
}, _callee15);
|
|
424
|
+
})));
|
|
425
|
+
case 2:
|
|
426
|
+
taskList = container.childNodes[0].childNodes[1];
|
|
427
|
+
expect(taskList.classList).toContain(_TaskList.DEFAULT_CLASS);
|
|
428
|
+
case 4:
|
|
429
|
+
case "end":
|
|
430
|
+
return _context16.stop();
|
|
558
431
|
}
|
|
559
432
|
}, _callee16);
|
|
560
433
|
})));
|
|
561
|
-
it('should render a cya page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
434
|
+
it('should render a cya page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
562
435
|
var cya;
|
|
563
|
-
return
|
|
564
|
-
while (1) {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
return (
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
cya = container.childNodes[0];
|
|
585
|
-
expect(cya.classList).toContain('hods-form');
|
|
586
|
-
|
|
587
|
-
case 4:
|
|
588
|
-
case "end":
|
|
589
|
-
return _context18.stop();
|
|
590
|
-
}
|
|
436
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
437
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
438
|
+
case 0:
|
|
439
|
+
_context18.next = 2;
|
|
440
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
441
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
442
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
443
|
+
case 0:
|
|
444
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _firstForm.default), container);
|
|
445
|
+
case 1:
|
|
446
|
+
case "end":
|
|
447
|
+
return _context17.stop();
|
|
448
|
+
}
|
|
449
|
+
}, _callee17);
|
|
450
|
+
})));
|
|
451
|
+
case 2:
|
|
452
|
+
cya = container.childNodes[0];
|
|
453
|
+
expect(cya.classList).toContain('hods-form');
|
|
454
|
+
case 4:
|
|
455
|
+
case "end":
|
|
456
|
+
return _context18.stop();
|
|
591
457
|
}
|
|
592
458
|
}, _callee18);
|
|
593
459
|
})));
|
|
594
|
-
it('should load tasklist with notes', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
460
|
+
it('should load tasklist with notes', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
595
461
|
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, TASK_LIST_WITH_NOTES, taskList;
|
|
596
|
-
return
|
|
597
|
-
while (1) {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
case 7:
|
|
640
|
-
taskList = container.childNodes[0].childNodes[1];
|
|
641
|
-
expect(taskList.childNodes[5].textContent).toEqual("test text");
|
|
642
|
-
expect(taskList.childNodes[5].classList).toContain('govuk-textarea');
|
|
643
|
-
|
|
644
|
-
case 10:
|
|
645
|
-
case "end":
|
|
646
|
-
return _context20.stop();
|
|
647
|
-
}
|
|
462
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
463
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
464
|
+
case 0:
|
|
465
|
+
ON_SUBMIT_CALLS = [];
|
|
466
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
|
|
467
|
+
ON_SUBMIT_CALLS.push(payload);
|
|
468
|
+
onSuccess();
|
|
469
|
+
};
|
|
470
|
+
HOOKS = {
|
|
471
|
+
onSubmit: ON_SUBMIT
|
|
472
|
+
};
|
|
473
|
+
TASK_LIST_WITH_NOTES = JSON.parse(JSON.stringify(_taskList.default));
|
|
474
|
+
TASK_LIST_WITH_NOTES.hub.notes = {
|
|
475
|
+
title: "test title",
|
|
476
|
+
text: "test text",
|
|
477
|
+
show_when: [{
|
|
478
|
+
"op": "=",
|
|
479
|
+
"field": "areYouACivilServant",
|
|
480
|
+
"value": "yes"
|
|
481
|
+
}]
|
|
482
|
+
};
|
|
483
|
+
_context20.next = 7;
|
|
484
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
485
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
486
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
487
|
+
case 0:
|
|
488
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_WITH_NOTES, {
|
|
489
|
+
data: _userProfileData.default,
|
|
490
|
+
hooks: HOOKS
|
|
491
|
+
})), container);
|
|
492
|
+
case 1:
|
|
493
|
+
case "end":
|
|
494
|
+
return _context19.stop();
|
|
495
|
+
}
|
|
496
|
+
}, _callee19);
|
|
497
|
+
})));
|
|
498
|
+
case 7:
|
|
499
|
+
taskList = container.childNodes[0].childNodes[1];
|
|
500
|
+
expect(taskList.childNodes[5].textContent).toEqual("test text");
|
|
501
|
+
expect(taskList.childNodes[5].classList).toContain('govuk-textarea');
|
|
502
|
+
case 10:
|
|
503
|
+
case "end":
|
|
504
|
+
return _context20.stop();
|
|
648
505
|
}
|
|
649
506
|
}, _callee20);
|
|
650
507
|
})));
|
|
651
|
-
it('should not load tasklist with notes', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
508
|
+
it('should not load tasklist with notes', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
652
509
|
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, TASK_LIST_WITH_NOTES, taskList;
|
|
653
|
-
return
|
|
654
|
-
while (1) {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
console.log("taskList, child = ".concat(JSON.stringify(child.textContent)));
|
|
700
|
-
});
|
|
701
|
-
expect(taskList.childNodes[5].textContent).not.toEqual("test text");
|
|
702
|
-
expect(taskList.childNodes[5].classList).not.toContain('govuk-textarea');
|
|
703
|
-
|
|
704
|
-
case 11:
|
|
705
|
-
case "end":
|
|
706
|
-
return _context22.stop();
|
|
707
|
-
}
|
|
510
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
511
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
512
|
+
case 0:
|
|
513
|
+
ON_SUBMIT_CALLS = [];
|
|
514
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
|
|
515
|
+
ON_SUBMIT_CALLS.push(payload);
|
|
516
|
+
onSuccess();
|
|
517
|
+
};
|
|
518
|
+
HOOKS = {
|
|
519
|
+
onSubmit: ON_SUBMIT
|
|
520
|
+
};
|
|
521
|
+
TASK_LIST_WITH_NOTES = JSON.parse(JSON.stringify(_taskList.default));
|
|
522
|
+
TASK_LIST_WITH_NOTES.hub.notes = {
|
|
523
|
+
title: "test title",
|
|
524
|
+
text: "test text",
|
|
525
|
+
show_when: [{
|
|
526
|
+
"op": "!=",
|
|
527
|
+
"field": "changeSummary",
|
|
528
|
+
"value": undefined
|
|
529
|
+
}]
|
|
530
|
+
};
|
|
531
|
+
_context22.next = 7;
|
|
532
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
533
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
534
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
535
|
+
case 0:
|
|
536
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_WITH_NOTES, {
|
|
537
|
+
data: _userProfileData.default,
|
|
538
|
+
hooks: HOOKS
|
|
539
|
+
})), container);
|
|
540
|
+
case 1:
|
|
541
|
+
case "end":
|
|
542
|
+
return _context21.stop();
|
|
543
|
+
}
|
|
544
|
+
}, _callee21);
|
|
545
|
+
})));
|
|
546
|
+
case 7:
|
|
547
|
+
taskList = container.childNodes[0].childNodes[1];
|
|
548
|
+
taskList.childNodes.forEach(function (child) {
|
|
549
|
+
console.log("taskList, child = ".concat(JSON.stringify(child.textContent)));
|
|
550
|
+
});
|
|
551
|
+
expect(taskList.childNodes[5].textContent).not.toEqual("test text");
|
|
552
|
+
expect(taskList.childNodes[5].classList).not.toContain('govuk-textarea');
|
|
553
|
+
case 11:
|
|
554
|
+
case "end":
|
|
555
|
+
return _context22.stop();
|
|
708
556
|
}
|
|
709
557
|
}, _callee22);
|
|
710
558
|
})));
|
|
711
|
-
it('should handle navigating between task list pages', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
559
|
+
it('should handle navigating between task list pages', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
712
560
|
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, taskList, firstTaskStatus, secondTaskStatus, firstTask, newPage, continueButton, seaButton, cyaPageChange, modeChangeLink, changePage, airButton, cyaPage, finalSubmit;
|
|
713
|
-
return
|
|
714
|
-
while (1) {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
})), container);
|
|
736
|
-
|
|
737
|
-
case 1:
|
|
738
|
-
case "end":
|
|
739
|
-
return _context23.stop();
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
}, _callee23);
|
|
743
|
-
})));
|
|
744
|
-
|
|
745
|
-
case 5:
|
|
746
|
-
taskList = container.childNodes[0].childNodes[1]; //Check statuses are correct
|
|
747
|
-
|
|
748
|
-
firstTaskStatus = taskList.childNodes[3].childNodes[1].childNodes[1];
|
|
749
|
-
expect(firstTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.NOT_STARTED].label);
|
|
750
|
-
secondTaskStatus = taskList.childNodes[3].childNodes[2].childNodes[1];
|
|
751
|
-
expect(secondTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.CANNOT_START_YET].label); //Launch first task
|
|
752
|
-
|
|
753
|
-
firstTask = taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0];
|
|
754
|
-
expect(firstTask.textContent).toEqual('Date, location and mode details');
|
|
755
|
-
|
|
756
|
-
_react.fireEvent.click(firstTask, {}); //Fill first page and navigate
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
newPage = container.childNodes[0].childNodes[0];
|
|
760
|
-
expect(newPage.childNodes[0].textContent).toEqual('Event Date');
|
|
761
|
-
|
|
762
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0].childNodes[1], {
|
|
763
|
-
target: {
|
|
764
|
-
name: 'date-day',
|
|
765
|
-
value: '7'
|
|
766
|
-
}
|
|
767
|
-
});
|
|
768
|
-
|
|
769
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[1], {
|
|
770
|
-
target: {
|
|
771
|
-
name: 'date-month',
|
|
772
|
-
value: '7'
|
|
561
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
562
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
563
|
+
case 0:
|
|
564
|
+
ON_SUBMIT_CALLS = [];
|
|
565
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
|
|
566
|
+
ON_SUBMIT_CALLS.push(payload);
|
|
567
|
+
onSuccess();
|
|
568
|
+
};
|
|
569
|
+
HOOKS = {
|
|
570
|
+
onSubmit: ON_SUBMIT
|
|
571
|
+
};
|
|
572
|
+
_context24.next = 5;
|
|
573
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
574
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
575
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
576
|
+
case 0:
|
|
577
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _taskList.default, {
|
|
578
|
+
hooks: HOOKS
|
|
579
|
+
})), container);
|
|
580
|
+
case 1:
|
|
581
|
+
case "end":
|
|
582
|
+
return _context23.stop();
|
|
773
583
|
}
|
|
774
|
-
});
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
584
|
+
}, _callee23);
|
|
585
|
+
})));
|
|
586
|
+
case 5:
|
|
587
|
+
taskList = container.childNodes[0].childNodes[1]; //Check statuses are correct
|
|
588
|
+
firstTaskStatus = taskList.childNodes[3].childNodes[1].childNodes[1];
|
|
589
|
+
expect(firstTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.NOT_STARTED].label);
|
|
590
|
+
secondTaskStatus = taskList.childNodes[3].childNodes[2].childNodes[1];
|
|
591
|
+
expect(secondTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.CANNOT_START_YET].label);
|
|
592
|
+
|
|
593
|
+
//Launch first task
|
|
594
|
+
firstTask = taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0];
|
|
595
|
+
expect(firstTask.textContent).toEqual('Date, location and mode details');
|
|
596
|
+
_react.fireEvent.click(firstTask, {});
|
|
597
|
+
|
|
598
|
+
//Fill first page and navigate
|
|
599
|
+
newPage = container.childNodes[0].childNodes[0];
|
|
600
|
+
expect(newPage.childNodes[0].textContent).toEqual('Event Date');
|
|
601
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0].childNodes[1], {
|
|
602
|
+
target: {
|
|
603
|
+
name: 'date-day',
|
|
604
|
+
value: '7'
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[1], {
|
|
608
|
+
target: {
|
|
609
|
+
name: 'date-month',
|
|
610
|
+
value: '7'
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[0].childNodes[1], {
|
|
614
|
+
target: {
|
|
615
|
+
name: 'date-year',
|
|
616
|
+
value: '2022'
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
continueButton = newPage.childNodes[2].childNodes[0];
|
|
620
|
+
_react.fireEvent.click(continueButton, {});
|
|
621
|
+
|
|
622
|
+
//Fill second page and navigate
|
|
623
|
+
newPage = container.childNodes[0].childNodes[0];
|
|
624
|
+
expect(newPage.childNodes[0].textContent).toEqual('Event Mode');
|
|
625
|
+
seaButton = newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0];
|
|
626
|
+
expect(seaButton.textContent).toEqual('Sea');
|
|
627
|
+
_react.fireEvent.click(seaButton.childNodes[0], {});
|
|
628
|
+
continueButton = newPage.childNodes[2].childNodes[0];
|
|
629
|
+
_react.fireEvent.click(continueButton, {});
|
|
630
|
+
|
|
631
|
+
//Click change to mode on CYA page
|
|
632
|
+
cyaPageChange = container.childNodes[0].childNodes[0];
|
|
633
|
+
expect(cyaPageChange.childNodes[0].textContent).toEqual('Check your answers');
|
|
634
|
+
modeChangeLink = cyaPageChange.childNodes[4].childNodes[0].childNodes[0].childNodes[2].childNodes[0];
|
|
635
|
+
expect(modeChangeLink.textContent).toEqual('Change Event Mode');
|
|
636
|
+
_react.fireEvent.click(modeChangeLink, {});
|
|
637
|
+
changePage = container.childNodes[0].childNodes[0];
|
|
638
|
+
expect(changePage.childNodes[0].textContent).toEqual('Event Mode');
|
|
639
|
+
// Click on radio for 'Air'
|
|
640
|
+
airButton = changePage.childNodes[1].childNodes[0].childNodes[2].childNodes[1];
|
|
641
|
+
expect(airButton.textContent).toEqual('Air');
|
|
642
|
+
_react.fireEvent.click(airButton.childNodes[0]);
|
|
643
|
+
// Continue again to CYA page
|
|
644
|
+
expect(changePage.childNodes[2].childNodes[0].textContent).toEqual('Save and continue');
|
|
645
|
+
continueButton = changePage.childNodes[2].childNodes[0];
|
|
646
|
+
_react.fireEvent.click(continueButton, {});
|
|
647
|
+
|
|
648
|
+
//Continue on from CYA page
|
|
649
|
+
cyaPage = container.childNodes[0].childNodes[0];
|
|
650
|
+
expect(cyaPage.childNodes[0].textContent).toEqual('Check your answers');
|
|
651
|
+
expect(cyaPage.childNodes[5].childNodes[0].textContent).toEqual('Save and continue');
|
|
652
|
+
expect(cyaPage.childNodes[5].childNodes[1].textContent).toEqual('Save and return later');
|
|
653
|
+
_react.fireEvent.click(cyaPage.childNodes[5].childNodes[0], {});
|
|
654
|
+
|
|
655
|
+
//Should be back at task list
|
|
656
|
+
expect(container.childNodes[0].childNodes[0].textContent).toEqual('Task List Form');
|
|
657
|
+
|
|
658
|
+
//Check statuses are correct
|
|
659
|
+
firstTaskStatus = container.childNodes[0].childNodes[1].childNodes[3].childNodes[1].childNodes[1];
|
|
660
|
+
expect(firstTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.COMPLETE].label);
|
|
661
|
+
secondTaskStatus = container.childNodes[0].childNodes[1].childNodes[3].childNodes[2].childNodes[1];
|
|
662
|
+
expect(secondTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.NOT_STARTED].label);
|
|
663
|
+
|
|
664
|
+
//Check final data submitted to backend is as expected
|
|
665
|
+
finalSubmit = ON_SUBMIT_CALLS[ON_SUBMIT_CALLS.length - 1];
|
|
666
|
+
expect(finalSubmit.date).toEqual('7-7-2022');
|
|
667
|
+
expect(finalSubmit.mode).toEqual('air');
|
|
668
|
+
expect(finalSubmit.formStatus.tasks['Date, location and mode details'].complete).toEqual(true);
|
|
669
|
+
case 54:
|
|
670
|
+
case "end":
|
|
671
|
+
return _context24.stop();
|
|
846
672
|
}
|
|
847
673
|
}, _callee24);
|
|
848
674
|
})));
|
|
849
|
-
it('should go straight to CYA page if a complete task is selected', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
675
|
+
it('should go straight to CYA page if a complete task is selected', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
850
676
|
var ON_SUBMIT, HOOKS, taskList, newPage;
|
|
851
|
-
return
|
|
852
|
-
while (1) {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
case 1:
|
|
873
|
-
case "end":
|
|
874
|
-
return _context25.stop();
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
}, _callee25);
|
|
878
|
-
})));
|
|
879
|
-
|
|
880
|
-
case 4:
|
|
881
|
-
taskList = container.childNodes[0].childNodes[1]; //Launch first task
|
|
882
|
-
|
|
883
|
-
_react.fireEvent.click(taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0], {}); //Fill first page and navigate
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
newPage = container.childNodes[0].childNodes[0];
|
|
887
|
-
|
|
888
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0].childNodes[1], {
|
|
889
|
-
target: {
|
|
890
|
-
name: 'date-day',
|
|
891
|
-
value: '7'
|
|
677
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
678
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
679
|
+
case 0:
|
|
680
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
|
|
681
|
+
onSuccess();
|
|
682
|
+
};
|
|
683
|
+
HOOKS = {
|
|
684
|
+
onSubmit: ON_SUBMIT
|
|
685
|
+
};
|
|
686
|
+
_context26.next = 4;
|
|
687
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
688
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
689
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
690
|
+
case 0:
|
|
691
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _taskList.default, {
|
|
692
|
+
hooks: HOOKS
|
|
693
|
+
})), container);
|
|
694
|
+
case 1:
|
|
695
|
+
case "end":
|
|
696
|
+
return _context25.stop();
|
|
892
697
|
}
|
|
893
|
-
});
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
698
|
+
}, _callee25);
|
|
699
|
+
})));
|
|
700
|
+
case 4:
|
|
701
|
+
taskList = container.childNodes[0].childNodes[1]; //Launch first task
|
|
702
|
+
_react.fireEvent.click(taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
703
|
+
|
|
704
|
+
//Fill first page and navigate
|
|
705
|
+
newPage = container.childNodes[0].childNodes[0];
|
|
706
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0].childNodes[1], {
|
|
707
|
+
target: {
|
|
708
|
+
name: 'date-day',
|
|
709
|
+
value: '7'
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[1], {
|
|
713
|
+
target: {
|
|
714
|
+
name: 'date-month',
|
|
715
|
+
value: '7'
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[0].childNodes[1], {
|
|
719
|
+
target: {
|
|
720
|
+
name: 'date-year',
|
|
721
|
+
value: '2022'
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
725
|
+
|
|
726
|
+
//Fill second page and navigate
|
|
727
|
+
newPage = container.childNodes[0].childNodes[0];
|
|
728
|
+
_react.fireEvent.click(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0], {});
|
|
729
|
+
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
730
|
+
|
|
731
|
+
//Continue on from CYA page
|
|
732
|
+
_react.fireEvent.click(container.childNodes[0].childNodes[0].childNodes[5].childNodes[0], {});
|
|
733
|
+
|
|
734
|
+
//Launch same task again
|
|
735
|
+
_react.fireEvent.click(container.childNodes[0].childNodes[1].childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
736
|
+
|
|
737
|
+
//Should be at CYA page
|
|
738
|
+
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Check your answers');
|
|
739
|
+
case 17:
|
|
740
|
+
case "end":
|
|
741
|
+
return _context26.stop();
|
|
931
742
|
}
|
|
932
743
|
}, _callee26);
|
|
933
744
|
})));
|
|
934
|
-
it('should go to incomplete page when selecting in-progress task', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
745
|
+
it('should go to incomplete page when selecting in-progress task', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
935
746
|
var ON_SUBMIT, HOOKS, DATA, taskList;
|
|
936
|
-
return
|
|
937
|
-
while (1) {
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
"
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
"
|
|
952
|
-
"complete": false,
|
|
953
|
-
"currentPage": "eventMode"
|
|
954
|
-
}
|
|
955
|
-
},
|
|
956
|
-
"taskPage": "eventMode"
|
|
957
|
-
}
|
|
958
|
-
};
|
|
959
|
-
_context28.next = 5;
|
|
960
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee27() {
|
|
961
|
-
return regeneratorRuntime.wrap(function _callee27$(_context27) {
|
|
962
|
-
while (1) {
|
|
963
|
-
switch (_context27.prev = _context27.next) {
|
|
964
|
-
case 0:
|
|
965
|
-
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _taskList.default, {
|
|
966
|
-
hooks: HOOKS,
|
|
967
|
-
data: DATA
|
|
968
|
-
})), container);
|
|
969
|
-
|
|
970
|
-
case 1:
|
|
971
|
-
case "end":
|
|
972
|
-
return _context27.stop();
|
|
973
|
-
}
|
|
747
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
748
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
749
|
+
case 0:
|
|
750
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
|
|
751
|
+
onSuccess();
|
|
752
|
+
};
|
|
753
|
+
HOOKS = {
|
|
754
|
+
onSubmit: ON_SUBMIT
|
|
755
|
+
};
|
|
756
|
+
DATA = {
|
|
757
|
+
"date": "7-7-2022",
|
|
758
|
+
"formStatus": {
|
|
759
|
+
"tasks": {
|
|
760
|
+
"Date, location and mode details": {
|
|
761
|
+
"complete": false,
|
|
762
|
+
"currentPage": "eventMode"
|
|
974
763
|
}
|
|
975
|
-
},
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
764
|
+
},
|
|
765
|
+
"taskPage": "eventMode"
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
_context28.next = 5;
|
|
769
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
770
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
771
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
772
|
+
case 0:
|
|
773
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _taskList.default, {
|
|
774
|
+
hooks: HOOKS,
|
|
775
|
+
data: DATA
|
|
776
|
+
})), container);
|
|
777
|
+
case 1:
|
|
778
|
+
case "end":
|
|
779
|
+
return _context27.stop();
|
|
780
|
+
}
|
|
781
|
+
}, _callee27);
|
|
782
|
+
})));
|
|
783
|
+
case 5:
|
|
784
|
+
taskList = container.childNodes[0].childNodes[1]; //Launch first task
|
|
785
|
+
_react.fireEvent.click(taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
786
|
+
|
|
787
|
+
//Should be at Event Mode page
|
|
788
|
+
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Event Mode');
|
|
789
|
+
case 8:
|
|
790
|
+
case "end":
|
|
791
|
+
return _context28.stop();
|
|
990
792
|
}
|
|
991
793
|
}, _callee28);
|
|
992
794
|
})));
|
|
993
|
-
it('should go to the first page of a complete task if noTaskCYAs specified', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
795
|
+
it('should go to the first page of a complete task if noTaskCYAs specified', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
994
796
|
var ON_SUBMIT, HOOKS, TASK_LIST_WITH_NO_TASK_CYAS, taskList, newPage;
|
|
995
|
-
return
|
|
996
|
-
while (1) {
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
case 1:
|
|
1023
|
-
case "end":
|
|
1024
|
-
return _context29.stop();
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
}, _callee29);
|
|
1028
|
-
})));
|
|
1029
|
-
|
|
1030
|
-
case 7:
|
|
1031
|
-
taskList = container.childNodes[0].childNodes[1]; // Launch first task
|
|
1032
|
-
|
|
1033
|
-
_react.fireEvent.click(taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0], {}); // Fill first page and navigate
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
newPage = container.childNodes[0].childNodes[0];
|
|
1037
|
-
|
|
1038
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0].childNodes[1], {
|
|
1039
|
-
target: {
|
|
1040
|
-
name: 'date-day',
|
|
1041
|
-
value: '7'
|
|
797
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
798
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
799
|
+
case 0:
|
|
800
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
|
|
801
|
+
onSuccess();
|
|
802
|
+
};
|
|
803
|
+
HOOKS = {
|
|
804
|
+
onSubmit: ON_SUBMIT
|
|
805
|
+
};
|
|
806
|
+
TASK_LIST_WITH_NO_TASK_CYAS = JSON.parse(JSON.stringify(_taskList.default));
|
|
807
|
+
TASK_LIST_WITH_NO_TASK_CYAS.hub.noTaskCYAs = true;
|
|
808
|
+
TASK_LIST_WITH_NO_TASK_CYAS.pages[1].actions[0] = {
|
|
809
|
+
type: 'save',
|
|
810
|
+
complete: true
|
|
811
|
+
};
|
|
812
|
+
_context30.next = 7;
|
|
813
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
814
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
815
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
816
|
+
case 0:
|
|
817
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_WITH_NO_TASK_CYAS, {
|
|
818
|
+
hooks: HOOKS
|
|
819
|
+
})), container);
|
|
820
|
+
case 1:
|
|
821
|
+
case "end":
|
|
822
|
+
return _context29.stop();
|
|
1042
823
|
}
|
|
1043
|
-
});
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
824
|
+
}, _callee29);
|
|
825
|
+
})));
|
|
826
|
+
case 7:
|
|
827
|
+
taskList = container.childNodes[0].childNodes[1]; // Launch first task
|
|
828
|
+
_react.fireEvent.click(taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
829
|
+
|
|
830
|
+
// Fill first page and navigate
|
|
831
|
+
newPage = container.childNodes[0].childNodes[0];
|
|
832
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0].childNodes[1], {
|
|
833
|
+
target: {
|
|
834
|
+
name: 'date-day',
|
|
835
|
+
value: '7'
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[1], {
|
|
839
|
+
target: {
|
|
840
|
+
name: 'date-month',
|
|
841
|
+
value: '7'
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[0].childNodes[1], {
|
|
845
|
+
target: {
|
|
846
|
+
name: 'date-year',
|
|
847
|
+
value: '2022'
|
|
848
|
+
}
|
|
849
|
+
});
|
|
850
|
+
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
851
|
+
|
|
852
|
+
// Fill second page
|
|
853
|
+
newPage = container.childNodes[0].childNodes[0];
|
|
854
|
+
// expect(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0]).toEqual('');
|
|
855
|
+
_react.fireEvent.click(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0], {});
|
|
856
|
+
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
857
|
+
|
|
858
|
+
// Launch same task again
|
|
859
|
+
_react.fireEvent.click(container.childNodes[0].childNodes[1].childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
860
|
+
|
|
861
|
+
// Should be on the first page
|
|
862
|
+
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Event Date');
|
|
863
|
+
case 19:
|
|
864
|
+
case "end":
|
|
865
|
+
return _context30.stop();
|
|
1078
866
|
}
|
|
1079
867
|
}, _callee30);
|
|
1080
868
|
})));
|
|
1081
|
-
it('should handle cancellation from a page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
869
|
+
it('should handle cancellation from a page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
1082
870
|
var ON_CANCEL_CALLS, ON_CANCEL, HOOKS, form, hub, _hub$childNodes5, civilServantList, link, page, cancel;
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
ON_CANCEL_CALLS
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
_react.fireEvent.click(link, {}); // Should already be answered "Yes", so simply click "Continue".
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
page = form.childNodes[0];
|
|
1128
|
-
cancel = getCancelButton(page);
|
|
1129
|
-
expect(ON_CANCEL_CALLS.length).toEqual(0);
|
|
1130
|
-
|
|
1131
|
-
_react.fireEvent.click(cancel, {});
|
|
1132
|
-
|
|
1133
|
-
expect(ON_CANCEL_CALLS.length).toEqual(1);
|
|
1134
|
-
|
|
1135
|
-
case 15:
|
|
1136
|
-
case "end":
|
|
1137
|
-
return _context32.stop();
|
|
1138
|
-
}
|
|
871
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
872
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
873
|
+
case 0:
|
|
874
|
+
ON_CANCEL_CALLS = [];
|
|
875
|
+
ON_CANCEL = function ON_CANCEL() {
|
|
876
|
+
ON_CANCEL_CALLS.push(undefined);
|
|
877
|
+
};
|
|
878
|
+
HOOKS = {
|
|
879
|
+
onCancel: ON_CANCEL
|
|
880
|
+
};
|
|
881
|
+
_context32.next = 5;
|
|
882
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
883
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
884
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
885
|
+
case 0:
|
|
886
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
887
|
+
data: _userProfileData.default,
|
|
888
|
+
hooks: HOOKS
|
|
889
|
+
})), container);
|
|
890
|
+
case 1:
|
|
891
|
+
case "end":
|
|
892
|
+
return _context31.stop();
|
|
893
|
+
}
|
|
894
|
+
}, _callee31);
|
|
895
|
+
})));
|
|
896
|
+
case 5:
|
|
897
|
+
form = checkForm(container); // Navigate to the "Are you a civil servant?" page.
|
|
898
|
+
hub = form.childNodes[1]; // Hub = CYA
|
|
899
|
+
_hub$childNodes5 = _slicedToArray(hub.childNodes, 3), civilServantList = _hub$childNodes5[2];
|
|
900
|
+
link = getChangeLink(civilServantList);
|
|
901
|
+
_react.fireEvent.click(link, {});
|
|
902
|
+
|
|
903
|
+
// Should already be answered "Yes", so simply click "Continue".
|
|
904
|
+
page = form.childNodes[0];
|
|
905
|
+
cancel = getCancelButton(page);
|
|
906
|
+
expect(ON_CANCEL_CALLS.length).toEqual(0);
|
|
907
|
+
_react.fireEvent.click(cancel, {});
|
|
908
|
+
expect(ON_CANCEL_CALLS.length).toEqual(1);
|
|
909
|
+
case 15:
|
|
910
|
+
case "end":
|
|
911
|
+
return _context32.stop();
|
|
1139
912
|
}
|
|
1140
913
|
}, _callee32);
|
|
1141
914
|
})));
|
|
1142
|
-
it('should navigate to a specific page at the beginning of a task if it is set as the firstPage of a task', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/
|
|
915
|
+
it('should navigate to a specific page at the beginning of a task if it is set as the firstPage of a task', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
1143
916
|
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, TASK_LIST_NON_SEQUENTIAL, taskList, firstTask, newPage;
|
|
1144
|
-
return
|
|
1145
|
-
while (1) {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
_react.fireEvent.click(firstTask, {}); // Should be at Surname page
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
newPage = container.childNodes[0].childNodes[0];
|
|
1188
|
-
expect(newPage.childNodes[0].textContent).toEqual('Surname');
|
|
1189
|
-
|
|
1190
|
-
case 13:
|
|
1191
|
-
case "end":
|
|
1192
|
-
return _context34.stop();
|
|
1193
|
-
}
|
|
917
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
918
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
919
|
+
case 0:
|
|
920
|
+
ON_SUBMIT_CALLS = [];
|
|
921
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
|
|
922
|
+
ON_SUBMIT_CALLS.push(payload);
|
|
923
|
+
onSuccess();
|
|
924
|
+
};
|
|
925
|
+
HOOKS = {
|
|
926
|
+
onSubmit: ON_SUBMIT
|
|
927
|
+
};
|
|
928
|
+
TASK_LIST_NON_SEQUENTIAL = JSON.parse(JSON.stringify(_taskList.default));
|
|
929
|
+
TASK_LIST_NON_SEQUENTIAL.hub.nonSequential = true;
|
|
930
|
+
_context34.next = 7;
|
|
931
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
932
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
933
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
934
|
+
case 0:
|
|
935
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_NON_SEQUENTIAL, {
|
|
936
|
+
hooks: HOOKS
|
|
937
|
+
})), container);
|
|
938
|
+
case 1:
|
|
939
|
+
case "end":
|
|
940
|
+
return _context33.stop();
|
|
941
|
+
}
|
|
942
|
+
}, _callee33);
|
|
943
|
+
})));
|
|
944
|
+
case 7:
|
|
945
|
+
taskList = container.childNodes[0].childNodes[1]; // Launch first task of second section
|
|
946
|
+
firstTask = taskList.childNodes[5].childNodes[1].childNodes[0].childNodes[0];
|
|
947
|
+
expect(firstTask.textContent).toEqual('People details');
|
|
948
|
+
_react.fireEvent.click(firstTask, {});
|
|
949
|
+
|
|
950
|
+
// Should be at Surname page
|
|
951
|
+
newPage = container.childNodes[0].childNodes[0];
|
|
952
|
+
expect(newPage.childNodes[0].textContent).toEqual('Surname');
|
|
953
|
+
case 13:
|
|
954
|
+
case "end":
|
|
955
|
+
return _context34.stop();
|
|
1194
956
|
}
|
|
1195
957
|
}, _callee34);
|
|
1196
958
|
})));
|