@ukhomeoffice/cop-react-form-renderer 5.14.2 → 5.14.4
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 +15 -15
- package/dist/components/CheckYourAnswers/Answer.test.js +94 -128
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +99 -129
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +291 -501
- package/dist/components/CheckYourAnswers/index.js +2 -3
- package/dist/components/CollectionPage/CollectionPage.js +64 -58
- package/dist/components/CollectionPage/CollectionPage.test.js +212 -238
- package/dist/components/CollectionPage/index.js +2 -3
- package/dist/components/FormComponent/Collection.js +77 -113
- package/dist/components/FormComponent/Collection.test.js +688 -787
- package/dist/components/FormComponent/Container.js +44 -43
- package/dist/components/FormComponent/Container.test.js +316 -346
- package/dist/components/FormComponent/FormComponent.js +58 -64
- package/dist/components/FormComponent/FormComponent.test.js +180 -219
- package/dist/components/FormComponent/helpers/addLabel.js +5 -9
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +2 -3
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +8 -8
- package/dist/components/FormComponent/helpers/getComponentError.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +2 -2
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +7 -7
- package/dist/components/FormComponent/helpers/index.js +5 -5
- package/dist/components/FormComponent/index.js +2 -3
- package/dist/components/FormPage/FormPage.js +65 -79
- package/dist/components/FormPage/FormPage.test.js +134 -170
- package/dist/components/FormPage/index.js +2 -3
- package/dist/components/FormRenderer/FormRenderer.js +151 -193
- package/dist/components/FormRenderer/FormRenderer.test.js +598 -920
- package/dist/components/FormRenderer/handlers/cyaAction.js +4 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +2 -5
- package/dist/components/FormRenderer/handlers/getPageId.test.js +15 -15
- package/dist/components/FormRenderer/handlers/handlers.test.js +33 -33
- package/dist/components/FormRenderer/handlers/index.js +3 -4
- package/dist/components/FormRenderer/handlers/navigate.js +5 -6
- package/dist/components/FormRenderer/handlers/submissionError.js +2 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.js +2 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +10 -10
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +2 -5
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +19 -27
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +17 -17
- package/dist/components/FormRenderer/helpers/getCYA.js +6 -9
- package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getFormState.js +7 -10
- package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getNextPageId.js +19 -34
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
- package/dist/components/FormRenderer/helpers/getPage.js +3 -6
- package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -13
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +12 -13
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +98 -92
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +66 -66
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +72 -79
- package/dist/components/FormRenderer/helpers/index.js +3 -4
- package/dist/components/FormRenderer/index.js +2 -3
- package/dist/components/FormRenderer/onCYAAction.js +52 -62
- package/dist/components/FormRenderer/onCYAAction.test.js +146 -138
- package/dist/components/FormRenderer/onPageAction.js +48 -47
- package/dist/components/FormRenderer/onPageAction.test.js +219 -205
- package/dist/components/FormRenderer/onTaskAction.js +12 -17
- package/dist/components/FormRenderer/onTaskAction.test.js +94 -89
- package/dist/components/PageActions/ActionButton.js +15 -19
- package/dist/components/PageActions/ActionButton.test.js +58 -79
- package/dist/components/PageActions/PageActions.js +12 -13
- package/dist/components/PageActions/PageActions.test.js +88 -116
- package/dist/components/PageActions/index.js +2 -3
- package/dist/components/SummaryList/GroupAction.js +15 -23
- package/dist/components/SummaryList/GroupAction.test.js +41 -37
- package/dist/components/SummaryList/RowAction.js +14 -19
- package/dist/components/SummaryList/RowAction.test.js +41 -37
- package/dist/components/SummaryList/SummaryList.js +25 -30
- package/dist/components/SummaryList/SummaryList.test.js +160 -182
- package/dist/components/SummaryList/SummaryListHeadingRow.js +9 -8
- package/dist/components/SummaryList/SummaryListRow.js +9 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +8 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -8
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +24 -24
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -8
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +24 -24
- package/dist/components/SummaryList/helpers/index.js +2 -2
- package/dist/components/SummaryList/index.js +2 -3
- package/dist/components/TaskList/Task.js +22 -33
- package/dist/components/TaskList/Task.test.js +84 -77
- package/dist/components/TaskList/TaskList.js +46 -75
- package/dist/components/TaskList/TaskList.test.js +118 -113
- package/dist/components/TaskList/TaskState.js +9 -9
- package/dist/components/TaskList/TaskState.test.js +56 -49
- package/dist/components/TaskList/index.js +2 -3
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +59 -85
- package/dist/context/HooksContext/HooksContext.test.js +28 -36
- package/dist/context/HooksContext/index.js +4 -6
- package/dist/context/ValidationContext/ValidationContext.js +35 -76
- package/dist/context/ValidationContext/ValidationContext.test.js +50 -61
- package/dist/context/ValidationContext/index.js +4 -6
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.js +10 -11
- package/dist/hooks/useAxios.js +17 -43
- package/dist/hooks/useGetRequest.js +61 -106
- package/dist/hooks/useHooks.js +2 -5
- package/dist/hooks/useRefData.js +29 -45
- package/dist/hooks/useValidation.js +2 -5
- package/dist/index.js +15 -17
- package/dist/models/CollectionLabels.js +2 -3
- package/dist/models/ComponentTypes.js +25 -26
- package/dist/models/EventTypes.js +5 -6
- package/dist/models/FormPages.js +5 -6
- package/dist/models/FormTypes.js +9 -10
- package/dist/models/HubFormats.js +4 -5
- package/dist/models/PageAction.js +45 -42
- package/dist/models/TaskStates.js +30 -31
- package/dist/models/index.js +11 -12
- package/dist/setupTests.js +20 -24
- package/dist/utils/CheckYourAnswers/getCYAAction.js +6 -7
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +18 -20
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +21 -23
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -21
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +18 -20
- package/dist/utils/CheckYourAnswers/getCYARow.js +8 -10
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +72 -72
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +20 -27
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +41 -47
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +72 -75
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +71 -78
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +133 -114
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +27 -23
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +16 -23
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +77 -83
- package/dist/utils/CheckYourAnswers/index.js +3 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +7 -9
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +9 -16
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +19 -20
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +4 -8
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +15 -15
- package/dist/utils/CollectionPage/index.js +3 -4
- package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -29
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +15 -15
- package/dist/utils/Component/addShowWhen.js +5 -10
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +20 -22
- package/dist/utils/Component/applyToComponentTree.test.js +28 -33
- package/dist/utils/Component/cleanAttributes.js +11 -16
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +7 -9
- package/dist/utils/Component/elevateNestedComponents.test.js +19 -19
- package/dist/utils/Component/getComponent.js +91 -99
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +51 -63
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +41 -49
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -37
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +23 -27
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +12 -11
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +24 -27
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +156 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +59 -73
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +35 -41
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +24 -32
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +10 -9
- package/dist/utils/Component/getDefaultValue.js +7 -9
- package/dist/utils/Component/getDefaultValue.test.js +14 -14
- package/dist/utils/Component/index.js +3 -4
- package/dist/utils/Component/isEditable.js +3 -7
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +2 -3
- package/dist/utils/Component/optionIsSelected.test.js +10 -10
- package/dist/utils/Component/setupContainerComponentsPath.js +30 -33
- package/dist/utils/Component/setupContainerComponentsPath.test.js +16 -16
- package/dist/utils/Component/showComponent.js +4 -6
- package/dist/utils/Component/showComponent.test.js +29 -29
- package/dist/utils/Component/wrapInFormGroup.js +6 -6
- package/dist/utils/Condition/index.js +3 -4
- package/dist/utils/Condition/meetsAllConditions.js +9 -10
- package/dist/utils/Condition/meetsAllConditions.test.js +18 -18
- package/dist/utils/Condition/meetsCondition.js +19 -27
- package/dist/utils/Condition/meetsCondition.test.js +377 -377
- package/dist/utils/Condition/meetsOneCondition.js +7 -8
- package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
- package/dist/utils/Condition/setupConditions.js +15 -21
- package/dist/utils/Condition/setupConditions.test.js +8 -8
- package/dist/utils/Container/getEditableComponents.js +5 -8
- package/dist/utils/Container/getEditableComponents.test.js +44 -46
- package/dist/utils/Container/index.js +3 -4
- package/dist/utils/Container/setupNesting.js +17 -24
- package/dist/utils/Container/setupNesting.test.js +28 -31
- package/dist/utils/Container/showContainer.js +5 -10
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +41 -52
- package/dist/utils/Data/applyFormula.test.js +26 -26
- package/dist/utils/Data/getAutocompleteSource.js +11 -14
- package/dist/utils/Data/getAutocompleteSource.test.js +59 -59
- package/dist/utils/Data/getDataPath.js +21 -32
- package/dist/utils/Data/getDataPath.test.js +20 -20
- package/dist/utils/Data/getOptions.js +22 -28
- package/dist/utils/Data/getOptions.test.js +21 -21
- package/dist/utils/Data/getSourceData.js +7 -21
- package/dist/utils/Data/getSourceData.test.js +85 -81
- package/dist/utils/Data/index.js +3 -4
- package/dist/utils/Data/refDataToOptions.js +12 -17
- package/dist/utils/Data/refDataToOptions.test.js +20 -20
- package/dist/utils/Data/setDataItem.js +8 -10
- package/dist/utils/Data/setDataItem.test.js +38 -38
- package/dist/utils/Data/setupFormData.js +32 -48
- package/dist/utils/Data/setupFormData.test.js +99 -98
- package/dist/utils/Data/setupRefDataUrlForComponent.js +22 -30
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +28 -28
- package/dist/utils/FormPage/applyConditionalProperties.js +7 -12
- package/dist/utils/FormPage/applyConditionalProperties.test.js +16 -19
- package/dist/utils/FormPage/getFormPage.js +17 -19
- package/dist/utils/FormPage/getFormPage.test.js +49 -48
- package/dist/utils/FormPage/getFormPages.js +9 -15
- package/dist/utils/FormPage/getFormPages.test.js +22 -25
- package/dist/utils/FormPage/getPageActions.js +11 -19
- package/dist/utils/FormPage/getPageActions.test.js +33 -33
- package/dist/utils/FormPage/getParagraphFromText.js +6 -9
- package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
- package/dist/utils/FormPage/index.js +3 -4
- package/dist/utils/FormPage/showFormPage.js +5 -10
- package/dist/utils/FormPage/showFormPage.test.js +33 -33
- package/dist/utils/FormPage/showFormPageCYA.js +4 -5
- package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
- package/dist/utils/FormPage/useComponent.js +21 -29
- package/dist/utils/FormPage/useComponent.test.js +71 -73
- package/dist/utils/Format/formatData.js +2 -3
- package/dist/utils/Format/formatData.test.js +19 -19
- package/dist/utils/Format/formatDataForComponent.js +6 -9
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +7 -10
- package/dist/utils/Format/formatDataForForm.test.js +14 -17
- package/dist/utils/Format/formatDataForPage.js +4 -7
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +3 -4
- package/dist/utils/Hub/getFormHub.js +3 -4
- package/dist/utils/Hub/getFormHub.test.js +29 -32
- package/dist/utils/Hub/index.js +3 -4
- package/dist/utils/Meta/constants.js +2 -4
- package/dist/utils/Meta/documents/getDocuments.js +2 -6
- package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
- package/dist/utils/Meta/documents/index.js +3 -4
- package/dist/utils/Meta/documents/setDocumentsForField.js +16 -19
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +69 -35
- package/dist/utils/Meta/index.js +3 -4
- package/dist/utils/Operate/checkValueIsTruthy.js +5 -6
- package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
- package/dist/utils/Operate/getFirstOf.js +9 -10
- package/dist/utils/Operate/getFirstOf.test.js +33 -33
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +13 -14
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
- package/dist/utils/Operate/index.js +3 -4
- package/dist/utils/Operate/persistValueInFormData.js +7 -8
- package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
- package/dist/utils/Operate/runPageOperations.js +10 -11
- package/dist/utils/Operate/runPageOperations.test.js +36 -37
- package/dist/utils/Operate/setValueInFormData.js +6 -7
- package/dist/utils/Operate/setValueInFormData.test.js +17 -17
- package/dist/utils/Operate/shouldRun.js +9 -10
- package/dist/utils/Operate/shouldRun.test.js +22 -28
- package/dist/utils/Validate/additional/conditionallyRequired.js +5 -7
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
- package/dist/utils/Validate/additional/index.js +8 -9
- package/dist/utils/Validate/additional/index.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeAfter.js +4 -5
- package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
- package/dist/utils/Validate/additional/mustBeBefore.js +4 -5
- package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -14
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +34 -38
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +3 -4
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +5 -6
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeInThePast.js +6 -7
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeLessThan.js +3 -4
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeLongerThan.js +2 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +3 -4
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
- package/dist/utils/Validate/additional/mustBeShorterThan.js +2 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +4 -7
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +2 -3
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +4 -7
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
- package/dist/utils/Validate/additional/utils.js +9 -25
- package/dist/utils/Validate/index.js +3 -4
- package/dist/utils/Validate/validateCollection.js +22 -29
- package/dist/utils/Validate/validateCollection.test.js +85 -77
- package/dist/utils/Validate/validateComponent.js +19 -19
- package/dist/utils/Validate/validateComponent.test.js +169 -147
- package/dist/utils/Validate/validateContainer.js +16 -22
- package/dist/utils/Validate/validateContainer.test.js +52 -48
- package/dist/utils/Validate/validateDate.js +14 -21
- package/dist/utils/Validate/validateDate.test.js +28 -29
- package/dist/utils/Validate/validateEmail.js +8 -11
- package/dist/utils/Validate/validateEmail.test.js +26 -26
- package/dist/utils/Validate/validateMultifile.js +6 -10
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +20 -22
- package/dist/utils/Validate/validatePage.test.js +146 -143
- package/dist/utils/Validate/validateRegex.js +6 -10
- package/dist/utils/Validate/validateRegex.test.js +17 -17
- package/dist/utils/Validate/validateRequired.js +6 -9
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +6 -9
- package/dist/utils/Validate/validateTextArea.test.js +21 -21
- package/dist/utils/Validate/validateTime.js +8 -16
- package/dist/utils/Validate/validateTime.test.js +15 -15
- package/dist/utils/index.js +10 -12
- package/package.json +9 -6
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
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
3
|
var _react = require("@testing-library/react");
|
|
5
4
|
var _axios = _interopRequireDefault(require("axios"));
|
|
6
5
|
var _axiosMockAdapter = _interopRequireDefault(require("axios-mock-adapter"));
|
|
@@ -18,27 +17,18 @@ var _userProfileData = _interopRequireDefault(require("../../json/userProfile.da
|
|
|
18
17
|
var _userProfile = _interopRequireDefault(require("../../json/userProfile.json"));
|
|
19
18
|
var _taskList = _interopRequireDefault(require("../../json/taskList.json"));
|
|
20
19
|
var _firstForm = _interopRequireDefault(require("../../json/firstForm.json"));
|
|
21
|
-
function _getRequireWildcardCache(
|
|
22
|
-
function _interopRequireWildcard(
|
|
23
|
-
function _interopRequireDefault(
|
|
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; }
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
34
|
-
describe('components', function () {
|
|
35
|
-
describe('FormRenderer', function () {
|
|
36
|
-
var mockAxios = new _axiosMockAdapter.default(_axios.default);
|
|
37
|
-
var container = null;
|
|
38
|
-
var refDataUrl = function refDataUrl(suffix) {
|
|
39
|
-
return "".concat(_userProfileData.default.urls.refData, "/").concat(suffix);
|
|
40
|
-
};
|
|
41
|
-
beforeEach(function () {
|
|
20
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
21
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } // Global imports
|
|
24
|
+
// Local imports
|
|
25
|
+
// JSON
|
|
26
|
+
describe('components', () => {
|
|
27
|
+
describe('FormRenderer', () => {
|
|
28
|
+
const mockAxios = new _axiosMockAdapter.default(_axios.default);
|
|
29
|
+
let container = null;
|
|
30
|
+
const refDataUrl = suffix => `${_userProfileData.default.urls.refData}/${suffix}`;
|
|
31
|
+
beforeEach(() => {
|
|
42
32
|
container = document.createElement('div');
|
|
43
33
|
document.body.appendChild(container);
|
|
44
34
|
mockAxios.reset();
|
|
@@ -46,923 +36,611 @@ describe('components', function () {
|
|
|
46
36
|
mockAxios.onGet(refDataUrl('grade')).reply(200, _grade.default);
|
|
47
37
|
mockAxios.onGet(refDataUrl('team')).reply(200, _team.default);
|
|
48
38
|
});
|
|
49
|
-
afterEach(
|
|
39
|
+
afterEach(() => {
|
|
50
40
|
(0, _reactDom.unmountComponentAtNode)(container);
|
|
51
41
|
container.remove();
|
|
52
42
|
container = null;
|
|
53
43
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
const checkForm = formContainer => {
|
|
45
|
+
const formWrapper = formContainer;
|
|
46
|
+
const form = formWrapper.childNodes[0];
|
|
57
47
|
expect(form.tagName).toEqual('DIV');
|
|
58
48
|
expect(form.classList).toContain(_FormRenderer.DEFAULT_CLASS);
|
|
59
49
|
return form;
|
|
60
50
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
actions = _summaryList$childNod[2];
|
|
51
|
+
const getChangeLink = summaryList => {
|
|
52
|
+
const [,, actions] = summaryList.childNodes[0].childNodes[0].childNodes;
|
|
64
53
|
return actions.childNodes[0];
|
|
65
54
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
-
case 0:
|
|
393
|
-
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
394
|
-
data: _userProfileData.default,
|
|
395
|
-
hide_title: true
|
|
396
|
-
})), container);
|
|
397
|
-
case 1:
|
|
398
|
-
case "end":
|
|
399
|
-
return _context13.stop();
|
|
400
|
-
}
|
|
401
|
-
}, _callee13);
|
|
402
|
-
})));
|
|
403
|
-
case 2:
|
|
404
|
-
form = checkForm(container);
|
|
405
|
-
expect(form.childNodes.length).toEqual(1); // Hub page (= CYA)
|
|
406
|
-
hub = form.childNodes[0];
|
|
407
|
-
expect(hub.tagName).toEqual('DIV');
|
|
408
|
-
expect(hub.classList).toContain(_CheckYourAnswers.DEFAULT_CLASS);
|
|
409
|
-
case 7:
|
|
410
|
-
case "end":
|
|
411
|
-
return _context14.stop();
|
|
412
|
-
}
|
|
413
|
-
}, _callee14);
|
|
414
|
-
})));
|
|
415
|
-
it('should render a tasklist', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
416
|
-
var taskList;
|
|
417
|
-
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
418
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
419
|
-
case 0:
|
|
420
|
-
_context16.next = 2;
|
|
421
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
422
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
423
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
424
|
-
case 0:
|
|
425
|
-
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _taskList.default), container);
|
|
426
|
-
case 1:
|
|
427
|
-
case "end":
|
|
428
|
-
return _context15.stop();
|
|
429
|
-
}
|
|
430
|
-
}, _callee15);
|
|
431
|
-
})));
|
|
432
|
-
case 2:
|
|
433
|
-
taskList = container.childNodes[0].childNodes[1];
|
|
434
|
-
expect(taskList.classList).toContain(_TaskList.DEFAULT_CLASS);
|
|
435
|
-
case 4:
|
|
436
|
-
case "end":
|
|
437
|
-
return _context16.stop();
|
|
55
|
+
const getContinueButton = page => page.childNodes[page.childNodes.length - 1].childNodes[0].childNodes[0];
|
|
56
|
+
const getCancelButton = page => page.childNodes[page.childNodes.length - 1].childNodes[1].childNodes[0];
|
|
57
|
+
it('should start on the hub page correctly and display the title', async () => {
|
|
58
|
+
await (0, _testUtils.act)(async () => {
|
|
59
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
60
|
+
data: _userProfileData.default
|
|
61
|
+
})), container);
|
|
62
|
+
});
|
|
63
|
+
const form = checkForm(container);
|
|
64
|
+
expect(form.childNodes.length).toEqual(2); // Title + Hub page (= CYA)
|
|
65
|
+
const title = form.childNodes[0];
|
|
66
|
+
expect(title.tagName).toEqual('H1');
|
|
67
|
+
expect(title.textContent).toEqual(_userProfile.default.title);
|
|
68
|
+
const hub = form.childNodes[1];
|
|
69
|
+
expect(hub.tagName).toEqual('DIV');
|
|
70
|
+
expect(hub.classList).toContain(_CheckYourAnswers.DEFAULT_CLASS);
|
|
71
|
+
});
|
|
72
|
+
it('should fire the onFormLoad method passed in the hooks', async () => {
|
|
73
|
+
let onFormLoadCalled = false;
|
|
74
|
+
const ON_FORM_LOAD = () => {
|
|
75
|
+
onFormLoadCalled = true;
|
|
76
|
+
};
|
|
77
|
+
const HOOKS = {
|
|
78
|
+
onFormLoad: ON_FORM_LOAD
|
|
79
|
+
};
|
|
80
|
+
await (0, _testUtils.act)(async () => {
|
|
81
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
82
|
+
data: _userProfileData.default,
|
|
83
|
+
hooks: HOOKS
|
|
84
|
+
})), container);
|
|
85
|
+
});
|
|
86
|
+
expect(onFormLoadCalled).toBeTruthy();
|
|
87
|
+
});
|
|
88
|
+
it('should navigate to the first editable page', async () => {
|
|
89
|
+
const ON_PAGE_CHANGE_CALLS = [];
|
|
90
|
+
const ON_PAGE_CHANGE = pageId => {
|
|
91
|
+
ON_PAGE_CHANGE_CALLS.push(pageId);
|
|
92
|
+
};
|
|
93
|
+
const HOOKS = {
|
|
94
|
+
onPageChange: ON_PAGE_CHANGE
|
|
95
|
+
};
|
|
96
|
+
await (0, _testUtils.act)(async () => {
|
|
97
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
98
|
+
data: _userProfileData.default,
|
|
99
|
+
hooks: HOOKS
|
|
100
|
+
})), container);
|
|
101
|
+
});
|
|
102
|
+
const form = checkForm(container);
|
|
103
|
+
const hub = form.childNodes[1]; // Hub = CYA
|
|
104
|
+
const [,, civilServantList] = hub.childNodes;
|
|
105
|
+
const link = getChangeLink(civilServantList);
|
|
106
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(0);
|
|
107
|
+
_react.fireEvent.click(link, {});
|
|
108
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(1);
|
|
109
|
+
expect(ON_PAGE_CHANGE_CALLS[0]).toEqual(_userProfile.default.pages[1].id);
|
|
110
|
+
|
|
111
|
+
// The form layout should have changed to the current page.
|
|
112
|
+
expect(form.childNodes.length).toEqual(1); // Just the page.
|
|
113
|
+
const page = form.childNodes[0];
|
|
114
|
+
const pageHeading = page.childNodes[0];
|
|
115
|
+
expect(pageHeading.tagName).toEqual('H1');
|
|
116
|
+
expect(pageHeading.textContent).toEqual(_userProfile.default.pages[1].title);
|
|
117
|
+
});
|
|
118
|
+
it('should handle a page submission', async () => {
|
|
119
|
+
const ON_SUBMIT_CALLS = [];
|
|
120
|
+
const ON_SUBMIT = (type, payload, onSuccess, onError, fieldName, fieldValue) => {
|
|
121
|
+
ON_SUBMIT_CALLS.push({
|
|
122
|
+
type,
|
|
123
|
+
payload,
|
|
124
|
+
onSuccess,
|
|
125
|
+
onError,
|
|
126
|
+
fieldName,
|
|
127
|
+
fieldValue
|
|
128
|
+
});
|
|
129
|
+
onSuccess();
|
|
130
|
+
};
|
|
131
|
+
const HOOKS = {
|
|
132
|
+
onSubmit: ON_SUBMIT
|
|
133
|
+
};
|
|
134
|
+
await (0, _testUtils.act)(async () => {
|
|
135
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
136
|
+
data: _userProfileData.default,
|
|
137
|
+
hooks: HOOKS,
|
|
138
|
+
type: _models.FormTypes.HUB
|
|
139
|
+
})), container);
|
|
140
|
+
});
|
|
141
|
+
const form = checkForm(container);
|
|
142
|
+
|
|
143
|
+
// Navigate to the "Are you a civil servant?" page.
|
|
144
|
+
const hub = form.childNodes[1]; // Hub = CYA
|
|
145
|
+
const [,, civilServantList] = hub.childNodes;
|
|
146
|
+
const link = getChangeLink(civilServantList);
|
|
147
|
+
_react.fireEvent.click(link, {});
|
|
148
|
+
|
|
149
|
+
// Should already be answered "Yes", but select "No, I'm a contractor" option to generate patch
|
|
150
|
+
// and then click "Continue".
|
|
151
|
+
_react.fireEvent.click(_react.screen.getByText("No, I'm a contractor"));
|
|
152
|
+
const page = form.childNodes[0];
|
|
153
|
+
const continueButton = getContinueButton(page);
|
|
154
|
+
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
155
|
+
_react.fireEvent.click(continueButton, {});
|
|
156
|
+
expect(ON_SUBMIT_CALLS.length).toEqual(1);
|
|
157
|
+
expect(ON_SUBMIT_CALLS[0].type).toEqual(_models.PageAction.TYPES.SUBMIT);
|
|
158
|
+
expect(ON_SUBMIT_CALLS[0].payload.areYouACivilServant).toEqual('no-contractor');
|
|
159
|
+
expect(ON_SUBMIT_CALLS[0].fieldName).toEqual('Are you a civil servant?');
|
|
160
|
+
expect(ON_SUBMIT_CALLS[0].fieldValue).toEqual("No, I'm a contractor");
|
|
161
|
+
|
|
162
|
+
// And we should be back on the hub.
|
|
163
|
+
expect(form.childNodes.length).toEqual(2); // Title + Hub page (= CYA)
|
|
164
|
+
const title = form.childNodes[0];
|
|
165
|
+
expect(title.tagName).toEqual('H1');
|
|
166
|
+
expect(title.textContent).toEqual(_userProfile.default.title);
|
|
167
|
+
});
|
|
168
|
+
it('should handle a page submission error', async () => {
|
|
169
|
+
const ON_SUBMIT_CALLS = [];
|
|
170
|
+
const ON_SUBMIT = (type, payload, onSuccess, onError) => {
|
|
171
|
+
ON_SUBMIT_CALLS.push({
|
|
172
|
+
type,
|
|
173
|
+
payload,
|
|
174
|
+
onSuccess,
|
|
175
|
+
onError
|
|
176
|
+
});
|
|
177
|
+
onError([{
|
|
178
|
+
id: 'unknown',
|
|
179
|
+
error: 'Something went wrong'
|
|
180
|
+
}]);
|
|
181
|
+
};
|
|
182
|
+
const HOOKS = {
|
|
183
|
+
onSubmit: ON_SUBMIT,
|
|
184
|
+
onAction: (formData, patch) => ({
|
|
185
|
+
formData,
|
|
186
|
+
patch
|
|
187
|
+
})
|
|
188
|
+
};
|
|
189
|
+
await (0, _testUtils.act)(async () => {
|
|
190
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
191
|
+
data: _userProfileData.default,
|
|
192
|
+
hooks: HOOKS
|
|
193
|
+
})), container);
|
|
194
|
+
});
|
|
195
|
+
const form = checkForm(container);
|
|
196
|
+
|
|
197
|
+
// Navigate to the "Are you a civil servant?" page.
|
|
198
|
+
const hub = form.childNodes[1]; // Hub = CYA
|
|
199
|
+
const [,, civilServantList] = hub.childNodes;
|
|
200
|
+
const link = getChangeLink(civilServantList);
|
|
201
|
+
_react.fireEvent.click(link, {});
|
|
202
|
+
|
|
203
|
+
// Should already be answered "Yes", so simply click "Continue".
|
|
204
|
+
const page = form.childNodes[0];
|
|
205
|
+
const continueButton = getContinueButton(page);
|
|
206
|
+
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
207
|
+
_react.fireEvent.click(continueButton, {});
|
|
208
|
+
expect(ON_SUBMIT_CALLS.length).toEqual(1);
|
|
209
|
+
expect(ON_SUBMIT_CALLS[0].type).toEqual(_models.PageAction.TYPES.SUBMIT);
|
|
210
|
+
expect(ON_SUBMIT_CALLS[0].payload.areYouACivilServant).toEqual('yes');
|
|
211
|
+
|
|
212
|
+
// And we should be kept on the same page.
|
|
213
|
+
expect(form.childNodes.length).toEqual(1); // Just the page.
|
|
214
|
+
const pageHeading = form.childNodes[0].childNodes[1];
|
|
215
|
+
expect(pageHeading.tagName).toEqual('H1');
|
|
216
|
+
expect(pageHeading.textContent).toEqual(_userProfile.default.pages[1].title);
|
|
217
|
+
});
|
|
218
|
+
it('should handle page navigation', async () => {
|
|
219
|
+
const ON_PAGE_CHANGE_CALLS = [];
|
|
220
|
+
const ON_PAGE_CHANGE = pageId => {
|
|
221
|
+
ON_PAGE_CHANGE_CALLS.push(pageId);
|
|
222
|
+
};
|
|
223
|
+
const HOOKS = {
|
|
224
|
+
onPageChange: ON_PAGE_CHANGE
|
|
225
|
+
};
|
|
226
|
+
await (0, _testUtils.act)(async () => {
|
|
227
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
228
|
+
data: _userProfileData.default,
|
|
229
|
+
hooks: HOOKS
|
|
230
|
+
})), container);
|
|
231
|
+
});
|
|
232
|
+
const form = checkForm(container);
|
|
233
|
+
|
|
234
|
+
// Navigate to the "Add or change a line manager" page.
|
|
235
|
+
const hub = form.childNodes[1]; // Hub = CYA
|
|
236
|
+
const [,,,,, lineManagerList] = hub.childNodes;
|
|
237
|
+
const link = getChangeLink(lineManagerList);
|
|
238
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(0);
|
|
239
|
+
_react.fireEvent.click(link, {});
|
|
240
|
+
expect(ON_PAGE_CHANGE_CALLS[0]).toEqual(_userProfile.default.pages[4].id);
|
|
241
|
+
|
|
242
|
+
// Should be on the page explaining what changing the line manager means.
|
|
243
|
+
const page = form.childNodes[0];
|
|
244
|
+
const pageHeading = page.childNodes[0];
|
|
245
|
+
expect(pageHeading.tagName).toEqual('H1');
|
|
246
|
+
expect(pageHeading.textContent).toEqual(_userProfile.default.pages[4].title);
|
|
247
|
+
|
|
248
|
+
// Now click on the "Continue" button on here.
|
|
249
|
+
const continueButton = getContinueButton(page);
|
|
250
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(1);
|
|
251
|
+
_react.fireEvent.click(continueButton, {});
|
|
252
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(2);
|
|
253
|
+
expect(ON_PAGE_CHANGE_CALLS[1]).toEqual(_userProfile.default.pages[5].id);
|
|
254
|
+
const newPageHeading = form.childNodes[0].childNodes[0];
|
|
255
|
+
expect(newPageHeading.tagName).toEqual('H1');
|
|
256
|
+
expect(newPageHeading.textContent).toEqual(_userProfile.default.pages[5].title);
|
|
257
|
+
});
|
|
258
|
+
it('should show no title when hide_title is set to true', async () => {
|
|
259
|
+
await (0, _testUtils.act)(async () => {
|
|
260
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
261
|
+
data: _userProfileData.default,
|
|
262
|
+
hide_title: true
|
|
263
|
+
})), container);
|
|
264
|
+
});
|
|
265
|
+
const form = checkForm(container);
|
|
266
|
+
expect(form.childNodes.length).toEqual(1); // Hub page (= CYA)
|
|
267
|
+
const hub = form.childNodes[0];
|
|
268
|
+
expect(hub.tagName).toEqual('DIV');
|
|
269
|
+
expect(hub.classList).toContain(_CheckYourAnswers.DEFAULT_CLASS);
|
|
270
|
+
});
|
|
271
|
+
it('should render a tasklist', async () => {
|
|
272
|
+
await (0, _testUtils.act)(async () => {
|
|
273
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _taskList.default), container);
|
|
274
|
+
});
|
|
275
|
+
const taskList = container.childNodes[0].childNodes[1];
|
|
276
|
+
expect(taskList.classList).toContain(_TaskList.DEFAULT_CLASS);
|
|
277
|
+
});
|
|
278
|
+
it('should render a cya page', async () => {
|
|
279
|
+
await (0, _testUtils.act)(async () => {
|
|
280
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _firstForm.default), container);
|
|
281
|
+
});
|
|
282
|
+
const cya = container.childNodes[0];
|
|
283
|
+
expect(cya.classList).toContain('hods-form');
|
|
284
|
+
});
|
|
285
|
+
it('should load tasklist with notes', async () => {
|
|
286
|
+
const ON_SUBMIT_CALLS = [];
|
|
287
|
+
const ON_SUBMIT = (type, payload, onSuccess) => {
|
|
288
|
+
ON_SUBMIT_CALLS.push(payload);
|
|
289
|
+
onSuccess();
|
|
290
|
+
};
|
|
291
|
+
const HOOKS = {
|
|
292
|
+
onSubmit: ON_SUBMIT
|
|
293
|
+
};
|
|
294
|
+
const TASK_LIST_WITH_NOTES = JSON.parse(JSON.stringify(_taskList.default));
|
|
295
|
+
TASK_LIST_WITH_NOTES.hub.notes = {
|
|
296
|
+
title: "test title",
|
|
297
|
+
text: "test text",
|
|
298
|
+
show_when: [{
|
|
299
|
+
"op": "=",
|
|
300
|
+
"field": "areYouACivilServant",
|
|
301
|
+
"value": "yes"
|
|
302
|
+
}]
|
|
303
|
+
};
|
|
304
|
+
await (0, _testUtils.act)(async () => {
|
|
305
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_WITH_NOTES, {
|
|
306
|
+
data: _userProfileData.default,
|
|
307
|
+
hooks: HOOKS
|
|
308
|
+
})), container);
|
|
309
|
+
});
|
|
310
|
+
const taskList = container.childNodes[0].childNodes[1];
|
|
311
|
+
expect(taskList.childNodes[5].textContent).toEqual("test text");
|
|
312
|
+
expect(taskList.childNodes[5].classList).toContain('govuk-textarea');
|
|
313
|
+
});
|
|
314
|
+
it('should not load tasklist with notes', async () => {
|
|
315
|
+
const ON_SUBMIT_CALLS = [];
|
|
316
|
+
const ON_SUBMIT = (type, payload, onSuccess) => {
|
|
317
|
+
ON_SUBMIT_CALLS.push(payload);
|
|
318
|
+
onSuccess();
|
|
319
|
+
};
|
|
320
|
+
const HOOKS = {
|
|
321
|
+
onSubmit: ON_SUBMIT
|
|
322
|
+
};
|
|
323
|
+
const TASK_LIST_WITH_NOTES = JSON.parse(JSON.stringify(_taskList.default));
|
|
324
|
+
TASK_LIST_WITH_NOTES.hub.notes = {
|
|
325
|
+
title: "test title",
|
|
326
|
+
text: "test text",
|
|
327
|
+
show_when: [{
|
|
328
|
+
"op": "!=",
|
|
329
|
+
"field": "changeSummary",
|
|
330
|
+
"value": undefined
|
|
331
|
+
}]
|
|
332
|
+
};
|
|
333
|
+
await (0, _testUtils.act)(async () => {
|
|
334
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_WITH_NOTES, {
|
|
335
|
+
data: _userProfileData.default,
|
|
336
|
+
hooks: HOOKS
|
|
337
|
+
})), container);
|
|
338
|
+
});
|
|
339
|
+
const taskList = container.childNodes[0].childNodes[1];
|
|
340
|
+
taskList.childNodes.forEach(child => {
|
|
341
|
+
// eslint-disable-next-line no-console
|
|
342
|
+
console.log(`taskList, child = ${JSON.stringify(child.textContent)}`);
|
|
343
|
+
});
|
|
344
|
+
expect(taskList.childNodes[5].textContent).not.toEqual("test text");
|
|
345
|
+
expect(taskList.childNodes[5].classList).not.toContain('govuk-textarea');
|
|
346
|
+
});
|
|
347
|
+
it('should handle navigating between task list pages', async () => {
|
|
348
|
+
const ON_SUBMIT_CALLS = [];
|
|
349
|
+
const ON_SUBMIT = (type, payload, onSuccess) => {
|
|
350
|
+
ON_SUBMIT_CALLS.push(payload);
|
|
351
|
+
onSuccess();
|
|
352
|
+
};
|
|
353
|
+
const HOOKS = {
|
|
354
|
+
onSubmit: ON_SUBMIT
|
|
355
|
+
};
|
|
356
|
+
await (0, _testUtils.act)(async () => {
|
|
357
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _taskList.default, {
|
|
358
|
+
hooks: HOOKS
|
|
359
|
+
})), container);
|
|
360
|
+
});
|
|
361
|
+
const taskList = container.childNodes[0].childNodes[1];
|
|
362
|
+
|
|
363
|
+
// Check statuses are correct
|
|
364
|
+
let firstTaskStatus = taskList.childNodes[3].childNodes[1].childNodes[1];
|
|
365
|
+
expect(firstTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.NOT_STARTED].label);
|
|
366
|
+
let secondTaskStatus = taskList.childNodes[3].childNodes[2].childNodes[1];
|
|
367
|
+
expect(secondTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.CANNOT_START_YET].label);
|
|
368
|
+
|
|
369
|
+
// Launch first task
|
|
370
|
+
const firstTask = taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0];
|
|
371
|
+
expect(firstTask.textContent).toEqual('Date, location and mode details');
|
|
372
|
+
_react.fireEvent.click(firstTask, {});
|
|
373
|
+
|
|
374
|
+
// Fill first page and navigate
|
|
375
|
+
let newPage = container.childNodes[0].childNodes[0];
|
|
376
|
+
expect(newPage.childNodes[0].textContent).toEqual('Event Date');
|
|
377
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[1], {
|
|
378
|
+
target: {
|
|
379
|
+
name: 'date-day',
|
|
380
|
+
value: '7'
|
|
438
381
|
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
445
|
-
case 0:
|
|
446
|
-
_context18.next = 2;
|
|
447
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
448
|
-
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
449
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
450
|
-
case 0:
|
|
451
|
-
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _firstForm.default), container);
|
|
452
|
-
case 1:
|
|
453
|
-
case "end":
|
|
454
|
-
return _context17.stop();
|
|
455
|
-
}
|
|
456
|
-
}, _callee17);
|
|
457
|
-
})));
|
|
458
|
-
case 2:
|
|
459
|
-
cya = container.childNodes[0];
|
|
460
|
-
expect(cya.classList).toContain('hods-form');
|
|
461
|
-
case 4:
|
|
462
|
-
case "end":
|
|
463
|
-
return _context18.stop();
|
|
382
|
+
});
|
|
383
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[1], {
|
|
384
|
+
target: {
|
|
385
|
+
name: 'date-month',
|
|
386
|
+
value: '7'
|
|
464
387
|
}
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
while (1) switch (_context20.prev = _context20.next) {
|
|
471
|
-
case 0:
|
|
472
|
-
ON_SUBMIT_CALLS = [];
|
|
473
|
-
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess) {
|
|
474
|
-
ON_SUBMIT_CALLS.push(payload);
|
|
475
|
-
onSuccess();
|
|
476
|
-
};
|
|
477
|
-
HOOKS = {
|
|
478
|
-
onSubmit: ON_SUBMIT
|
|
479
|
-
};
|
|
480
|
-
TASK_LIST_WITH_NOTES = JSON.parse(JSON.stringify(_taskList.default));
|
|
481
|
-
TASK_LIST_WITH_NOTES.hub.notes = {
|
|
482
|
-
title: "test title",
|
|
483
|
-
text: "test text",
|
|
484
|
-
show_when: [{
|
|
485
|
-
"op": "=",
|
|
486
|
-
"field": "areYouACivilServant",
|
|
487
|
-
"value": "yes"
|
|
488
|
-
}]
|
|
489
|
-
};
|
|
490
|
-
_context20.next = 7;
|
|
491
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
492
|
-
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
493
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
494
|
-
case 0:
|
|
495
|
-
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_WITH_NOTES, {
|
|
496
|
-
data: _userProfileData.default,
|
|
497
|
-
hooks: HOOKS
|
|
498
|
-
})), container);
|
|
499
|
-
case 1:
|
|
500
|
-
case "end":
|
|
501
|
-
return _context19.stop();
|
|
502
|
-
}
|
|
503
|
-
}, _callee19);
|
|
504
|
-
})));
|
|
505
|
-
case 7:
|
|
506
|
-
taskList = container.childNodes[0].childNodes[1];
|
|
507
|
-
expect(taskList.childNodes[5].textContent).toEqual("test text");
|
|
508
|
-
expect(taskList.childNodes[5].classList).toContain('govuk-textarea');
|
|
509
|
-
case 10:
|
|
510
|
-
case "end":
|
|
511
|
-
return _context20.stop();
|
|
388
|
+
});
|
|
389
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[1], {
|
|
390
|
+
target: {
|
|
391
|
+
name: 'date-year',
|
|
392
|
+
value: '2022'
|
|
512
393
|
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
394
|
+
});
|
|
395
|
+
let continueButton = newPage.childNodes[2].childNodes[0];
|
|
396
|
+
_react.fireEvent.click(continueButton, {});
|
|
397
|
+
|
|
398
|
+
// Fill second page and navigate
|
|
399
|
+
newPage = container.childNodes[0].childNodes[0];
|
|
400
|
+
expect(newPage.childNodes[0].textContent).toEqual('Event Mode');
|
|
401
|
+
const seaButton = newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0];
|
|
402
|
+
expect(seaButton.textContent).toEqual('Sea');
|
|
403
|
+
_react.fireEvent.click(seaButton.childNodes[0], {});
|
|
404
|
+
continueButton = newPage.childNodes[2].childNodes[0];
|
|
405
|
+
_react.fireEvent.click(continueButton, {});
|
|
406
|
+
|
|
407
|
+
// Click change to mode on CYA page
|
|
408
|
+
const cyaPageChange = container.childNodes[0].childNodes[0];
|
|
409
|
+
expect(cyaPageChange.childNodes[0].textContent).toEqual('Check your answers');
|
|
410
|
+
const modeChangeLink = cyaPageChange.childNodes[4].childNodes[0].childNodes[0].childNodes[2].childNodes[0];
|
|
411
|
+
expect(modeChangeLink.textContent).toEqual('Change Event Mode');
|
|
412
|
+
_react.fireEvent.click(modeChangeLink, {});
|
|
413
|
+
const changePage = container.childNodes[0].childNodes[0];
|
|
414
|
+
expect(changePage.childNodes[0].textContent).toEqual('Event Mode');
|
|
415
|
+
// Click on radio for 'Air'
|
|
416
|
+
const airButton = changePage.childNodes[1].childNodes[0].childNodes[2].childNodes[1];
|
|
417
|
+
expect(airButton.textContent).toEqual('Air');
|
|
418
|
+
_react.fireEvent.click(airButton.childNodes[0]);
|
|
419
|
+
// Continue again to CYA page
|
|
420
|
+
expect(changePage.childNodes[2].childNodes[0].textContent).toEqual('Save and continue');
|
|
421
|
+
continueButton = changePage.childNodes[2].childNodes[0];
|
|
422
|
+
_react.fireEvent.click(continueButton, {});
|
|
423
|
+
|
|
424
|
+
// Continue on from CYA page
|
|
425
|
+
const cyaPage = container.childNodes[0].childNodes[0];
|
|
426
|
+
expect(cyaPage.childNodes[0].textContent).toEqual('Check your answers');
|
|
427
|
+
expect(cyaPage.childNodes[5].childNodes[0].textContent).toEqual('Save and continue');
|
|
428
|
+
expect(cyaPage.childNodes[5].childNodes[1].textContent).toEqual('Save and return later');
|
|
429
|
+
_react.fireEvent.click(cyaPage.childNodes[5].childNodes[0], {});
|
|
430
|
+
|
|
431
|
+
// Should be back at task list
|
|
432
|
+
expect(container.childNodes[0].childNodes[0].textContent).toEqual('Task List Form');
|
|
433
|
+
|
|
434
|
+
// Check statuses are correct
|
|
435
|
+
firstTaskStatus = container.childNodes[0].childNodes[1].childNodes[3].childNodes[1].childNodes[1];
|
|
436
|
+
expect(firstTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.COMPLETE].label);
|
|
437
|
+
secondTaskStatus = container.childNodes[0].childNodes[1].childNodes[3].childNodes[2].childNodes[1];
|
|
438
|
+
expect(secondTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.NOT_STARTED].label);
|
|
439
|
+
|
|
440
|
+
// Check final data submitted to backend is as expected
|
|
441
|
+
const finalSubmit = ON_SUBMIT_CALLS[ON_SUBMIT_CALLS.length - 1];
|
|
442
|
+
expect(finalSubmit.date).toEqual('7-7-2022');
|
|
443
|
+
expect(finalSubmit.mode).toEqual('air');
|
|
444
|
+
expect(finalSubmit.formStatus.tasks['Date, location and mode details'].complete).toEqual(true);
|
|
445
|
+
});
|
|
446
|
+
it('should go straight to CYA page if a complete task is selected', async () => {
|
|
447
|
+
const ON_SUBMIT = (type, payload, onSuccess) => {
|
|
448
|
+
onSuccess();
|
|
449
|
+
};
|
|
450
|
+
const HOOKS = {
|
|
451
|
+
onSubmit: ON_SUBMIT
|
|
452
|
+
};
|
|
453
|
+
await (0, _testUtils.act)(async () => {
|
|
454
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _taskList.default, {
|
|
455
|
+
hooks: HOOKS
|
|
456
|
+
})), container);
|
|
457
|
+
});
|
|
458
|
+
const taskList = container.childNodes[0].childNodes[1];
|
|
459
|
+
|
|
460
|
+
// Launch first task
|
|
461
|
+
_react.fireEvent.click(taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
462
|
+
|
|
463
|
+
// Fill first page and navigate
|
|
464
|
+
let newPage = container.childNodes[0].childNodes[0];
|
|
465
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[1], {
|
|
466
|
+
target: {
|
|
467
|
+
name: 'date-day',
|
|
468
|
+
value: '7'
|
|
564
469
|
}
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
while (1) switch (_context24.prev = _context24.next) {
|
|
571
|
-
case 0:
|
|
572
|
-
ON_SUBMIT_CALLS = [];
|
|
573
|
-
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess) {
|
|
574
|
-
ON_SUBMIT_CALLS.push(payload);
|
|
575
|
-
onSuccess();
|
|
576
|
-
};
|
|
577
|
-
HOOKS = {
|
|
578
|
-
onSubmit: ON_SUBMIT
|
|
579
|
-
};
|
|
580
|
-
_context24.next = 5;
|
|
581
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
582
|
-
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
583
|
-
while (1) switch (_context23.prev = _context23.next) {
|
|
584
|
-
case 0:
|
|
585
|
-
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _taskList.default, {
|
|
586
|
-
hooks: HOOKS
|
|
587
|
-
})), container);
|
|
588
|
-
case 1:
|
|
589
|
-
case "end":
|
|
590
|
-
return _context23.stop();
|
|
591
|
-
}
|
|
592
|
-
}, _callee23);
|
|
593
|
-
})));
|
|
594
|
-
case 5:
|
|
595
|
-
taskList = container.childNodes[0].childNodes[1]; // Check statuses are correct
|
|
596
|
-
firstTaskStatus = taskList.childNodes[3].childNodes[1].childNodes[1];
|
|
597
|
-
expect(firstTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.NOT_STARTED].label);
|
|
598
|
-
secondTaskStatus = taskList.childNodes[3].childNodes[2].childNodes[1];
|
|
599
|
-
expect(secondTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.CANNOT_START_YET].label);
|
|
600
|
-
|
|
601
|
-
// Launch first task
|
|
602
|
-
firstTask = taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0];
|
|
603
|
-
expect(firstTask.textContent).toEqual('Date, location and mode details');
|
|
604
|
-
_react.fireEvent.click(firstTask, {});
|
|
605
|
-
|
|
606
|
-
// Fill first page and navigate
|
|
607
|
-
newPage = container.childNodes[0].childNodes[0];
|
|
608
|
-
expect(newPage.childNodes[0].textContent).toEqual('Event Date');
|
|
609
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[1], {
|
|
610
|
-
target: {
|
|
611
|
-
name: 'date-day',
|
|
612
|
-
value: '7'
|
|
613
|
-
}
|
|
614
|
-
});
|
|
615
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[1], {
|
|
616
|
-
target: {
|
|
617
|
-
name: 'date-month',
|
|
618
|
-
value: '7'
|
|
619
|
-
}
|
|
620
|
-
});
|
|
621
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[1], {
|
|
622
|
-
target: {
|
|
623
|
-
name: 'date-year',
|
|
624
|
-
value: '2022'
|
|
625
|
-
}
|
|
626
|
-
});
|
|
627
|
-
continueButton = newPage.childNodes[2].childNodes[0];
|
|
628
|
-
_react.fireEvent.click(continueButton, {});
|
|
629
|
-
|
|
630
|
-
// Fill second page and navigate
|
|
631
|
-
newPage = container.childNodes[0].childNodes[0];
|
|
632
|
-
expect(newPage.childNodes[0].textContent).toEqual('Event Mode');
|
|
633
|
-
seaButton = newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0];
|
|
634
|
-
expect(seaButton.textContent).toEqual('Sea');
|
|
635
|
-
_react.fireEvent.click(seaButton.childNodes[0], {});
|
|
636
|
-
continueButton = newPage.childNodes[2].childNodes[0];
|
|
637
|
-
_react.fireEvent.click(continueButton, {});
|
|
638
|
-
|
|
639
|
-
// Click change to mode on CYA page
|
|
640
|
-
cyaPageChange = container.childNodes[0].childNodes[0];
|
|
641
|
-
expect(cyaPageChange.childNodes[0].textContent).toEqual('Check your answers');
|
|
642
|
-
modeChangeLink = cyaPageChange.childNodes[4].childNodes[0].childNodes[0].childNodes[2].childNodes[0];
|
|
643
|
-
expect(modeChangeLink.textContent).toEqual('Change Event Mode');
|
|
644
|
-
_react.fireEvent.click(modeChangeLink, {});
|
|
645
|
-
changePage = container.childNodes[0].childNodes[0];
|
|
646
|
-
expect(changePage.childNodes[0].textContent).toEqual('Event Mode');
|
|
647
|
-
// Click on radio for 'Air'
|
|
648
|
-
airButton = changePage.childNodes[1].childNodes[0].childNodes[2].childNodes[1];
|
|
649
|
-
expect(airButton.textContent).toEqual('Air');
|
|
650
|
-
_react.fireEvent.click(airButton.childNodes[0]);
|
|
651
|
-
// Continue again to CYA page
|
|
652
|
-
expect(changePage.childNodes[2].childNodes[0].textContent).toEqual('Save and continue');
|
|
653
|
-
continueButton = changePage.childNodes[2].childNodes[0];
|
|
654
|
-
_react.fireEvent.click(continueButton, {});
|
|
655
|
-
|
|
656
|
-
// Continue on from CYA page
|
|
657
|
-
cyaPage = container.childNodes[0].childNodes[0];
|
|
658
|
-
expect(cyaPage.childNodes[0].textContent).toEqual('Check your answers');
|
|
659
|
-
expect(cyaPage.childNodes[5].childNodes[0].textContent).toEqual('Save and continue');
|
|
660
|
-
expect(cyaPage.childNodes[5].childNodes[1].textContent).toEqual('Save and return later');
|
|
661
|
-
_react.fireEvent.click(cyaPage.childNodes[5].childNodes[0], {});
|
|
662
|
-
|
|
663
|
-
// Should be back at task list
|
|
664
|
-
expect(container.childNodes[0].childNodes[0].textContent).toEqual('Task List Form');
|
|
665
|
-
|
|
666
|
-
// Check statuses are correct
|
|
667
|
-
firstTaskStatus = container.childNodes[0].childNodes[1].childNodes[3].childNodes[1].childNodes[1];
|
|
668
|
-
expect(firstTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.COMPLETE].label);
|
|
669
|
-
secondTaskStatus = container.childNodes[0].childNodes[1].childNodes[3].childNodes[2].childNodes[1];
|
|
670
|
-
expect(secondTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.NOT_STARTED].label);
|
|
671
|
-
|
|
672
|
-
// Check final data submitted to backend is as expected
|
|
673
|
-
finalSubmit = ON_SUBMIT_CALLS[ON_SUBMIT_CALLS.length - 1];
|
|
674
|
-
expect(finalSubmit.date).toEqual('7-7-2022');
|
|
675
|
-
expect(finalSubmit.mode).toEqual('air');
|
|
676
|
-
expect(finalSubmit.formStatus.tasks['Date, location and mode details'].complete).toEqual(true);
|
|
677
|
-
case 54:
|
|
678
|
-
case "end":
|
|
679
|
-
return _context24.stop();
|
|
470
|
+
});
|
|
471
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[1], {
|
|
472
|
+
target: {
|
|
473
|
+
name: 'date-month',
|
|
474
|
+
value: '7'
|
|
680
475
|
}
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
while (1) switch (_context26.prev = _context26.next) {
|
|
687
|
-
case 0:
|
|
688
|
-
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess) {
|
|
689
|
-
onSuccess();
|
|
690
|
-
};
|
|
691
|
-
HOOKS = {
|
|
692
|
-
onSubmit: ON_SUBMIT
|
|
693
|
-
};
|
|
694
|
-
_context26.next = 4;
|
|
695
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
696
|
-
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
697
|
-
while (1) switch (_context25.prev = _context25.next) {
|
|
698
|
-
case 0:
|
|
699
|
-
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _taskList.default, {
|
|
700
|
-
hooks: HOOKS
|
|
701
|
-
})), container);
|
|
702
|
-
case 1:
|
|
703
|
-
case "end":
|
|
704
|
-
return _context25.stop();
|
|
705
|
-
}
|
|
706
|
-
}, _callee25);
|
|
707
|
-
})));
|
|
708
|
-
case 4:
|
|
709
|
-
taskList = container.childNodes[0].childNodes[1]; // Launch first task
|
|
710
|
-
_react.fireEvent.click(taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
711
|
-
|
|
712
|
-
// Fill first page and navigate
|
|
713
|
-
newPage = container.childNodes[0].childNodes[0];
|
|
714
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[1], {
|
|
715
|
-
target: {
|
|
716
|
-
name: 'date-day',
|
|
717
|
-
value: '7'
|
|
718
|
-
}
|
|
719
|
-
});
|
|
720
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[1], {
|
|
721
|
-
target: {
|
|
722
|
-
name: 'date-month',
|
|
723
|
-
value: '7'
|
|
724
|
-
}
|
|
725
|
-
});
|
|
726
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[1], {
|
|
727
|
-
target: {
|
|
728
|
-
name: 'date-year',
|
|
729
|
-
value: '2022'
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
733
|
-
|
|
734
|
-
// Fill second page and navigate
|
|
735
|
-
newPage = container.childNodes[0].childNodes[0];
|
|
736
|
-
_react.fireEvent.click(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0], {});
|
|
737
|
-
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
738
|
-
|
|
739
|
-
// Continue on from CYA page
|
|
740
|
-
_react.fireEvent.click(container.childNodes[0].childNodes[0].childNodes[5].childNodes[0], {});
|
|
741
|
-
|
|
742
|
-
// Launch same task again
|
|
743
|
-
_react.fireEvent.click(container.childNodes[0].childNodes[1].childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
744
|
-
|
|
745
|
-
// Should be at CYA page
|
|
746
|
-
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Check your answers');
|
|
747
|
-
case 17:
|
|
748
|
-
case "end":
|
|
749
|
-
return _context26.stop();
|
|
476
|
+
});
|
|
477
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[1], {
|
|
478
|
+
target: {
|
|
479
|
+
name: 'date-year',
|
|
480
|
+
value: '2022'
|
|
750
481
|
}
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
case 1:
|
|
786
|
-
case "end":
|
|
787
|
-
return _context27.stop();
|
|
788
|
-
}
|
|
789
|
-
}, _callee27);
|
|
790
|
-
})));
|
|
791
|
-
case 5:
|
|
792
|
-
taskList = container.childNodes[0].childNodes[1]; // Launch first task
|
|
793
|
-
_react.fireEvent.click(taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
794
|
-
|
|
795
|
-
// Should be at Event Mode page
|
|
796
|
-
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Event Mode');
|
|
797
|
-
case 8:
|
|
798
|
-
case "end":
|
|
799
|
-
return _context28.stop();
|
|
482
|
+
});
|
|
483
|
+
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
484
|
+
|
|
485
|
+
// Fill second page and navigate
|
|
486
|
+
newPage = container.childNodes[0].childNodes[0];
|
|
487
|
+
_react.fireEvent.click(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0], {});
|
|
488
|
+
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
489
|
+
|
|
490
|
+
// Continue on from CYA page
|
|
491
|
+
_react.fireEvent.click(container.childNodes[0].childNodes[0].childNodes[5].childNodes[0], {});
|
|
492
|
+
|
|
493
|
+
// Launch same task again
|
|
494
|
+
_react.fireEvent.click(container.childNodes[0].childNodes[1].childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
495
|
+
|
|
496
|
+
// Should be at CYA page
|
|
497
|
+
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Check your answers');
|
|
498
|
+
});
|
|
499
|
+
it('should go to incomplete page when selecting in-progress task', async () => {
|
|
500
|
+
const ON_SUBMIT = (type, payload, onSuccess) => {
|
|
501
|
+
onSuccess();
|
|
502
|
+
};
|
|
503
|
+
const HOOKS = {
|
|
504
|
+
onSubmit: ON_SUBMIT
|
|
505
|
+
};
|
|
506
|
+
const DATA = {
|
|
507
|
+
"date": "7-7-2022",
|
|
508
|
+
"formStatus": {
|
|
509
|
+
"tasks": {
|
|
510
|
+
"Date, location and mode details": {
|
|
511
|
+
"complete": false,
|
|
512
|
+
"currentPage": "eventMode"
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
"taskPage": "eventMode"
|
|
800
516
|
}
|
|
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
|
-
});
|
|
846
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[1], {
|
|
847
|
-
target: {
|
|
848
|
-
name: 'date-month',
|
|
849
|
-
value: '7'
|
|
850
|
-
}
|
|
851
|
-
});
|
|
852
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[1], {
|
|
853
|
-
target: {
|
|
854
|
-
name: 'date-year',
|
|
855
|
-
value: '2022'
|
|
856
|
-
}
|
|
857
|
-
});
|
|
858
|
-
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
859
|
-
|
|
860
|
-
// Fill second page
|
|
861
|
-
newPage = container.childNodes[0].childNodes[0];
|
|
862
|
-
// expect(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0]).toEqual('');
|
|
863
|
-
_react.fireEvent.click(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0], {});
|
|
864
|
-
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
865
|
-
|
|
866
|
-
// Launch same task again
|
|
867
|
-
_react.fireEvent.click(container.childNodes[0].childNodes[1].childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
868
|
-
|
|
869
|
-
// Should be on the first page
|
|
870
|
-
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Event Date');
|
|
871
|
-
case 19:
|
|
872
|
-
case "end":
|
|
873
|
-
return _context30.stop();
|
|
517
|
+
};
|
|
518
|
+
await (0, _testUtils.act)(async () => {
|
|
519
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _taskList.default, {
|
|
520
|
+
hooks: HOOKS,
|
|
521
|
+
data: DATA
|
|
522
|
+
})), container);
|
|
523
|
+
});
|
|
524
|
+
const taskList = container.childNodes[0].childNodes[1];
|
|
525
|
+
|
|
526
|
+
// Launch first task
|
|
527
|
+
_react.fireEvent.click(taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
528
|
+
|
|
529
|
+
// Should be at Event Mode page
|
|
530
|
+
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Event Mode');
|
|
531
|
+
});
|
|
532
|
+
it('should go to the first page of a complete task if noTaskCYAs specified', async () => {
|
|
533
|
+
const ON_SUBMIT = (type, payload, onSuccess) => {
|
|
534
|
+
onSuccess();
|
|
535
|
+
};
|
|
536
|
+
const HOOKS = {
|
|
537
|
+
onSubmit: ON_SUBMIT
|
|
538
|
+
};
|
|
539
|
+
const TASK_LIST_WITH_NO_TASK_CYAS = JSON.parse(JSON.stringify(_taskList.default));
|
|
540
|
+
TASK_LIST_WITH_NO_TASK_CYAS.hub.noTaskCYAs = true;
|
|
541
|
+
TASK_LIST_WITH_NO_TASK_CYAS.pages[1].actions[0] = {
|
|
542
|
+
type: 'save',
|
|
543
|
+
complete: true
|
|
544
|
+
};
|
|
545
|
+
await (0, _testUtils.act)(async () => {
|
|
546
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_WITH_NO_TASK_CYAS, {
|
|
547
|
+
hooks: HOOKS
|
|
548
|
+
})), container);
|
|
549
|
+
});
|
|
550
|
+
const taskList = container.childNodes[0].childNodes[1];
|
|
551
|
+
|
|
552
|
+
// Launch first task
|
|
553
|
+
_react.fireEvent.click(taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
554
|
+
|
|
555
|
+
// Fill first page and navigate
|
|
556
|
+
let newPage = container.childNodes[0].childNodes[0];
|
|
557
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[1], {
|
|
558
|
+
target: {
|
|
559
|
+
name: 'date-day',
|
|
560
|
+
value: '7'
|
|
874
561
|
}
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
while (1) switch (_context32.prev = _context32.next) {
|
|
881
|
-
case 0:
|
|
882
|
-
ON_CANCEL_CALLS = [];
|
|
883
|
-
ON_CANCEL = function ON_CANCEL() {
|
|
884
|
-
ON_CANCEL_CALLS.push(undefined);
|
|
885
|
-
};
|
|
886
|
-
HOOKS = {
|
|
887
|
-
onCancel: ON_CANCEL
|
|
888
|
-
};
|
|
889
|
-
_context32.next = 5;
|
|
890
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
891
|
-
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
892
|
-
while (1) switch (_context31.prev = _context31.next) {
|
|
893
|
-
case 0:
|
|
894
|
-
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
895
|
-
data: _userProfileData.default,
|
|
896
|
-
hooks: HOOKS
|
|
897
|
-
})), container);
|
|
898
|
-
case 1:
|
|
899
|
-
case "end":
|
|
900
|
-
return _context31.stop();
|
|
901
|
-
}
|
|
902
|
-
}, _callee31);
|
|
903
|
-
})));
|
|
904
|
-
case 5:
|
|
905
|
-
form = checkForm(container); // Navigate to the "Are you a civil servant?" page.
|
|
906
|
-
hub = form.childNodes[1]; // Hub = CYA
|
|
907
|
-
_hub$childNodes5 = _slicedToArray(hub.childNodes, 3), civilServantList = _hub$childNodes5[2];
|
|
908
|
-
link = getChangeLink(civilServantList);
|
|
909
|
-
_react.fireEvent.click(link, {});
|
|
910
|
-
|
|
911
|
-
// Should already be answered "Yes", so simply click "Continue".
|
|
912
|
-
page = form.childNodes[0];
|
|
913
|
-
cancel = getCancelButton(page);
|
|
914
|
-
expect(ON_CANCEL_CALLS.length).toEqual(0);
|
|
915
|
-
_react.fireEvent.click(cancel, {});
|
|
916
|
-
expect(ON_CANCEL_CALLS.length).toEqual(1);
|
|
917
|
-
case 15:
|
|
918
|
-
case "end":
|
|
919
|
-
return _context32.stop();
|
|
562
|
+
});
|
|
563
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[1], {
|
|
564
|
+
target: {
|
|
565
|
+
name: 'date-month',
|
|
566
|
+
value: '7'
|
|
920
567
|
}
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
while (1) switch (_context34.prev = _context34.next) {
|
|
927
|
-
case 0:
|
|
928
|
-
ON_SUBMIT_CALLS = [];
|
|
929
|
-
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess) {
|
|
930
|
-
ON_SUBMIT_CALLS.push(payload);
|
|
931
|
-
onSuccess();
|
|
932
|
-
};
|
|
933
|
-
HOOKS = {
|
|
934
|
-
onSubmit: ON_SUBMIT
|
|
935
|
-
};
|
|
936
|
-
TASK_LIST_NON_SEQUENTIAL = JSON.parse(JSON.stringify(_taskList.default));
|
|
937
|
-
TASK_LIST_NON_SEQUENTIAL.hub.nonSequential = true;
|
|
938
|
-
_context34.next = 7;
|
|
939
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
940
|
-
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
941
|
-
while (1) switch (_context33.prev = _context33.next) {
|
|
942
|
-
case 0:
|
|
943
|
-
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_NON_SEQUENTIAL, {
|
|
944
|
-
hooks: HOOKS
|
|
945
|
-
})), container);
|
|
946
|
-
case 1:
|
|
947
|
-
case "end":
|
|
948
|
-
return _context33.stop();
|
|
949
|
-
}
|
|
950
|
-
}, _callee33);
|
|
951
|
-
})));
|
|
952
|
-
case 7:
|
|
953
|
-
taskList = container.childNodes[0].childNodes[1]; // Launch first task of second section
|
|
954
|
-
firstTask = taskList.childNodes[5].childNodes[1].childNodes[0].childNodes[0];
|
|
955
|
-
expect(firstTask.textContent).toEqual('People details');
|
|
956
|
-
_react.fireEvent.click(firstTask, {});
|
|
957
|
-
|
|
958
|
-
// Should be at Surname page
|
|
959
|
-
newPage = container.childNodes[0].childNodes[0];
|
|
960
|
-
expect(newPage.childNodes[0].textContent).toEqual('Surname');
|
|
961
|
-
case 13:
|
|
962
|
-
case "end":
|
|
963
|
-
return _context34.stop();
|
|
568
|
+
});
|
|
569
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[1], {
|
|
570
|
+
target: {
|
|
571
|
+
name: 'date-year',
|
|
572
|
+
value: '2022'
|
|
964
573
|
}
|
|
965
|
-
}
|
|
966
|
-
|
|
574
|
+
});
|
|
575
|
+
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
576
|
+
|
|
577
|
+
// Fill second page
|
|
578
|
+
newPage = container.childNodes[0].childNodes[0];
|
|
579
|
+
// expect(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0]).toEqual('');
|
|
580
|
+
_react.fireEvent.click(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0], {});
|
|
581
|
+
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
582
|
+
|
|
583
|
+
// Launch same task again
|
|
584
|
+
_react.fireEvent.click(container.childNodes[0].childNodes[1].childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
585
|
+
|
|
586
|
+
// Should be on the first page
|
|
587
|
+
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Event Date');
|
|
588
|
+
});
|
|
589
|
+
it('should handle cancellation from a page', async () => {
|
|
590
|
+
const ON_CANCEL_CALLS = [];
|
|
591
|
+
const ON_CANCEL = () => {
|
|
592
|
+
ON_CANCEL_CALLS.push(undefined);
|
|
593
|
+
};
|
|
594
|
+
const HOOKS = {
|
|
595
|
+
onCancel: ON_CANCEL
|
|
596
|
+
};
|
|
597
|
+
await (0, _testUtils.act)(async () => {
|
|
598
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
599
|
+
data: _userProfileData.default,
|
|
600
|
+
hooks: HOOKS
|
|
601
|
+
})), container);
|
|
602
|
+
});
|
|
603
|
+
const form = checkForm(container);
|
|
604
|
+
|
|
605
|
+
// Navigate to the "Are you a civil servant?" page.
|
|
606
|
+
const hub = form.childNodes[1]; // Hub = CYA
|
|
607
|
+
const [,, civilServantList] = hub.childNodes;
|
|
608
|
+
const link = getChangeLink(civilServantList);
|
|
609
|
+
_react.fireEvent.click(link, {});
|
|
610
|
+
|
|
611
|
+
// Should already be answered "Yes", so simply click "Continue".
|
|
612
|
+
const page = form.childNodes[0];
|
|
613
|
+
const cancel = getCancelButton(page);
|
|
614
|
+
expect(ON_CANCEL_CALLS.length).toEqual(0);
|
|
615
|
+
_react.fireEvent.click(cancel, {});
|
|
616
|
+
expect(ON_CANCEL_CALLS.length).toEqual(1);
|
|
617
|
+
});
|
|
618
|
+
it('should navigate to a specific page at the beginning of a task if it is set as the firstPage of a task', async () => {
|
|
619
|
+
const ON_SUBMIT_CALLS = [];
|
|
620
|
+
const ON_SUBMIT = (type, payload, onSuccess) => {
|
|
621
|
+
ON_SUBMIT_CALLS.push(payload);
|
|
622
|
+
onSuccess();
|
|
623
|
+
};
|
|
624
|
+
const HOOKS = {
|
|
625
|
+
onSubmit: ON_SUBMIT
|
|
626
|
+
};
|
|
627
|
+
const TASK_LIST_NON_SEQUENTIAL = JSON.parse(JSON.stringify(_taskList.default));
|
|
628
|
+
TASK_LIST_NON_SEQUENTIAL.hub.nonSequential = true;
|
|
629
|
+
await (0, _testUtils.act)(async () => {
|
|
630
|
+
(0, _reactDom.render)(/*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_NON_SEQUENTIAL, {
|
|
631
|
+
hooks: HOOKS
|
|
632
|
+
})), container);
|
|
633
|
+
});
|
|
634
|
+
const taskList = container.childNodes[0].childNodes[1];
|
|
635
|
+
|
|
636
|
+
// Launch first task of second section
|
|
637
|
+
const firstTask = taskList.childNodes[5].childNodes[1].childNodes[0].childNodes[0];
|
|
638
|
+
expect(firstTask.textContent).toEqual('People details');
|
|
639
|
+
_react.fireEvent.click(firstTask, {});
|
|
640
|
+
|
|
641
|
+
// Should be at Surname page
|
|
642
|
+
const newPage = container.childNodes[0].childNodes[0];
|
|
643
|
+
expect(newPage.childNodes[0].textContent).toEqual('Surname');
|
|
644
|
+
});
|
|
967
645
|
});
|
|
968
646
|
});
|