@ukhomeoffice/cop-react-form-renderer 5.0.0-alpha → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +18 -7
- package/dist/components/CheckYourAnswers/Answer.test.js +137 -0
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +70 -46
- package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +410 -0
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +551 -0
- package/dist/components/CollectionPage/CollectionPage.js +15 -10
- package/dist/components/CollectionPage/CollectionPage.test.js +382 -0
- package/dist/components/FormComponent/Collection.js +91 -48
- package/dist/components/FormComponent/Collection.scss +2 -1
- package/dist/components/FormComponent/Collection.test.js +807 -0
- package/dist/components/FormComponent/Container.js +35 -16
- package/dist/components/FormComponent/Container.test.js +370 -0
- package/dist/components/FormComponent/FormComponent.js +39 -13
- package/dist/components/FormComponent/FormComponent.stories.mdx +184 -0
- package/dist/components/FormComponent/FormComponent.test.js +226 -0
- package/dist/components/FormComponent/helpers/addLabel.js +5 -4
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +16 -0
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +29 -0
- package/dist/components/FormComponent/helpers/index.js +8 -1
- package/dist/components/FormPage/FormPage.js +69 -30
- package/dist/components/FormPage/FormPage.stories.mdx +155 -0
- package/dist/components/FormPage/FormPage.test.js +330 -0
- package/dist/components/FormRenderer/FormRenderer.js +142 -228
- package/dist/components/FormRenderer/FormRenderer.stories.mdx +183 -0
- package/dist/components/FormRenderer/FormRenderer.test.js +968 -0
- package/dist/components/FormRenderer/handlers/index.js +1 -2
- package/dist/components/FormRenderer/handlers/navigate.js +3 -1
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +35 -14
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +88 -5
- package/dist/components/FormRenderer/helpers/getCYA.js +11 -2
- package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -7
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +10 -2
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -1
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +2 -2
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +6 -2
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +171 -51
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +307 -24
- package/dist/components/FormRenderer/helpers/index.js +1 -2
- package/dist/components/FormRenderer/onCYAAction.js +108 -0
- package/dist/components/FormRenderer/onCYAAction.test.js +583 -0
- package/dist/components/FormRenderer/onPageAction.js +145 -0
- package/dist/components/FormRenderer/onPageAction.test.js +678 -0
- package/dist/components/FormRenderer/onTaskAction.js +48 -0
- package/dist/components/FormRenderer/onTaskAction.test.js +217 -0
- package/dist/components/PageActions/ActionButton.js +0 -3
- package/dist/components/PageActions/ActionButton.test.js +93 -0
- package/dist/components/PageActions/PageActions.js +2 -2
- package/dist/components/PageActions/PageActions.stories.mdx +74 -0
- package/dist/components/PageActions/PageActions.test.js +132 -0
- package/dist/components/SummaryList/GroupAction.js +2 -2
- package/dist/components/SummaryList/GroupAction.test.js +80 -0
- package/dist/components/SummaryList/RowAction.js +2 -2
- package/dist/components/SummaryList/RowAction.test.js +80 -0
- package/dist/components/SummaryList/SummaryList.js +29 -12
- package/dist/components/SummaryList/SummaryList.scss +19 -0
- package/dist/components/SummaryList/SummaryList.stories.mdx +90 -0
- package/dist/components/SummaryList/SummaryList.test.js +400 -0
- package/dist/components/SummaryList/SummaryListHeadingRow.js +30 -0
- package/dist/components/SummaryList/SummaryListRow.js +5 -2
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +2 -1
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +2 -1
- package/dist/components/TaskList/Task.js +3 -3
- package/dist/components/TaskList/Task.test.js +167 -0
- package/dist/components/TaskList/TaskList.js +73 -22
- package/dist/components/TaskList/TaskList.stories.mdx +164 -0
- package/dist/components/TaskList/TaskList.test.js +389 -0
- package/dist/components/TaskList/TaskState.js +2 -2
- package/dist/components/TaskList/TaskState.test.js +86 -0
- package/dist/components/index.js +14 -0
- package/dist/context/HooksContext/HooksContext.js +72 -8
- package/dist/context/HooksContext/HooksContext.test.js +44 -0
- package/dist/context/ValidationContext/ValidationContext.js +38 -28
- package/dist/context/ValidationContext/ValidationContext.test.js +84 -0
- package/dist/hooks/useAxios.js +10 -12
- package/dist/hooks/useGetRequest.js +48 -49
- package/dist/hooks/useRefData.js +7 -4
- package/dist/index.js +34 -1
- package/dist/json/addressDetails.json +149 -0
- package/dist/json/areYouACivilServant.json +7 -0
- package/dist/json/firstForm.json +94 -0
- package/dist/json/grade.json +108 -0
- package/dist/json/group.data.json +21 -0
- package/dist/json/group.json +402 -0
- package/dist/json/groupOfRow.json +137 -0
- package/dist/json/groupOfRowData.json +15 -0
- package/dist/json/port.json +346 -0
- package/dist/json/saveAndContinue.json +98 -0
- package/dist/json/sublocation.json +859 -0
- package/dist/json/taskList.json +265 -0
- package/dist/json/team.json +17351 -0
- package/dist/json/terminal.json +81 -0
- package/dist/json/userProfile.data.json +21 -0
- package/dist/json/userProfile.json +276 -0
- package/dist/models/ComponentTypes.js +8 -0
- package/dist/models/PageAction.js +4 -1
- package/dist/models/TaskStates.js +10 -2
- package/dist/models/index.js +16 -1
- package/dist/setupTests.js +46 -0
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +121 -0
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +6 -2
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +71 -0
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +6 -2
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +55 -0
- package/dist/utils/CheckYourAnswers/getCYARow.js +14 -11
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +291 -0
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +4 -1
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +70 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +15 -10
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +288 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +94 -36
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +414 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +21 -7
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +486 -0
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +11 -3
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +346 -0
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +19 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +143 -0
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +5 -1
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +40 -0
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +53 -0
- package/dist/utils/CollectionPage/mergeCollectionPages.js +25 -17
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +130 -0
- package/dist/utils/Component/addShowWhen.js +44 -0
- package/dist/utils/Component/addShowWhen.test.js +216 -0
- package/dist/utils/Component/applyToComponentTree.js +71 -0
- package/dist/utils/Component/applyToComponentTree.test.js +127 -0
- package/dist/utils/Component/cleanAttributes.js +8 -2
- package/dist/utils/Component/cleanAttributes.test.js +68 -0
- package/dist/utils/Component/elevateNestedComponents.js +4 -1
- package/dist/utils/Component/elevateNestedComponents.test.js +122 -0
- package/dist/utils/Component/getComponent.js +80 -11
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +4 -4
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +25 -24
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +66 -5
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +9 -7
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +44 -0
- package/dist/utils/Component/getComponentTests/{getComponent.textarea.test.js → getComponent.multifile.test.js} +29 -21
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +159 -83
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +43 -0
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +55 -5
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +3 -9
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +109 -0
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +7 -7
- package/dist/utils/Component/getDefaultValue.js +4 -1
- package/dist/utils/Component/getDefaultValue.test.js +50 -0
- package/dist/utils/Component/index.js +2 -0
- package/dist/utils/Component/isEditable.js +2 -2
- package/dist/utils/Component/isEditable.test.js +43 -0
- package/dist/utils/Component/optionIsSelected.js +22 -0
- package/dist/utils/Component/optionIsSelected.test.js +42 -0
- package/dist/utils/Component/setupContainerComponentsPath.js +40 -0
- package/dist/utils/Component/setupContainerComponentsPath.test.js +78 -0
- package/dist/utils/Component/showComponent.test.js +156 -0
- package/dist/utils/Component/wrapInFormGroup.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.test.js +61 -0
- package/dist/utils/Condition/meetsCondition.js +74 -4
- package/dist/utils/Condition/meetsCondition.test.js +763 -0
- package/dist/utils/Condition/meetsOneCondition.js +1 -1
- package/dist/utils/Condition/meetsOneCondition.test.js +100 -0
- package/dist/utils/Condition/setupConditions.js +6 -3
- package/dist/utils/Condition/setupConditions.test.js +33 -0
- package/dist/utils/Container/getEditableComponents.test.js +135 -0
- package/dist/utils/Container/setupNesting.js +21 -2
- package/dist/utils/Container/setupNesting.test.js +145 -0
- package/dist/utils/Container/showContainer.test.js +178 -0
- package/dist/utils/Data/applyFormula.js +20 -11
- package/dist/utils/Data/applyFormula.test.js +263 -0
- package/dist/utils/Data/getAutocompleteSource.js +6 -2
- package/dist/utils/Data/getAutocompleteSource.test.js +352 -0
- package/dist/utils/Data/getDataPath.test.js +48 -0
- package/dist/utils/Data/getOptions.js +17 -3
- package/dist/utils/Data/getOptions.test.js +140 -0
- package/dist/utils/Data/getSourceData.js +2 -2
- package/dist/utils/Data/getSourceData.test.js +153 -0
- package/dist/utils/Data/refDataToOptions.js +4 -1
- package/dist/utils/Data/refDataToOptions.test.js +196 -0
- package/dist/utils/Data/setDataItem.test.js +110 -0
- package/dist/utils/Data/setupFormData.js +39 -16
- package/dist/utils/Data/setupFormData.test.js +410 -0
- package/dist/utils/Data/setupRefDataUrlForComponent.js +4 -1
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +131 -0
- package/dist/utils/FormPage/applyConditionalProperties.js +35 -0
- package/dist/utils/FormPage/applyConditionalProperties.test.js +61 -0
- package/dist/utils/FormPage/getFormPage.js +5 -2
- package/dist/utils/FormPage/getFormPage.test.js +206 -0
- package/dist/utils/FormPage/getFormPages.js +4 -1
- package/dist/utils/FormPage/getFormPages.test.js +97 -0
- package/dist/utils/FormPage/getPageActions.js +8 -4
- package/dist/utils/FormPage/getPageActions.test.js +114 -0
- package/dist/utils/FormPage/getParagraphFromText.test.js +27 -0
- package/dist/utils/FormPage/index.js +2 -0
- package/dist/utils/FormPage/showFormPage.js +2 -2
- package/dist/utils/FormPage/showFormPage.test.js +180 -0
- package/dist/utils/FormPage/showFormPageCYA.js +1 -0
- package/dist/utils/FormPage/showFormPageCYA.test.js +28 -0
- package/dist/utils/FormPage/useComponent.js +29 -14
- package/dist/utils/FormPage/useComponent.test.js +167 -0
- package/dist/utils/Format/formatData.test.js +45 -0
- package/dist/utils/Format/formatDataForComponent.js +2 -1
- package/dist/utils/Format/formatDataForComponent.test.js +142 -0
- package/dist/utils/Format/formatDataForForm.js +4 -1
- package/dist/utils/Format/formatDataForForm.test.js +81 -0
- package/dist/utils/Format/formatDataForPage.test.js +99 -0
- package/dist/utils/Hub/getFormHub.test.js +105 -0
- package/dist/utils/Meta/documents/getDocuments.test.js +4 -1
- package/dist/utils/Meta/documents/index.js +2 -2
- package/dist/utils/Meta/documents/setDocumentsForField.js +31 -0
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +59 -0
- package/dist/utils/Operate/checkValueIsTruthy.test.js +42 -0
- package/dist/utils/Operate/getFirstOf.js +31 -0
- package/dist/utils/Operate/getFirstOf.test.js +86 -0
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +163 -0
- package/dist/utils/Operate/persistValueInFormData.js +2 -1
- package/dist/utils/Operate/persistValueInFormData.test.js +115 -0
- package/dist/utils/Operate/runPageOperations.js +3 -1
- package/dist/utils/Operate/runPageOperations.test.js +105 -0
- package/dist/utils/Operate/setValueInFormData.test.js +44 -0
- package/dist/utils/Operate/shouldRun.js +16 -13
- package/dist/utils/Operate/shouldRun.test.js +66 -0
- package/dist/utils/Validate/additional/conditionallyRequired.js +24 -0
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +73 -0
- package/dist/utils/Validate/additional/index.js +13 -4
- package/dist/utils/Validate/additional/mustBeAfter.js +8 -6
- package/dist/utils/Validate/additional/mustBeAfter.test.js +15 -1
- package/dist/utils/Validate/additional/mustBeBefore.js +9 -5
- package/dist/utils/Validate/additional/mustBeBefore.test.js +14 -0
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +1 -1
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +6 -3
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +22 -0
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +56 -0
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +1 -1
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -5
- package/dist/utils/Validate/additional/mustBeLessThan.js +7 -6
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +11 -1
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +9 -5
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +10 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +1 -0
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +4 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +19 -0
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +36 -0
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +29 -0
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +52 -0
- package/dist/utils/Validate/additional/utils.js +18 -18
- package/dist/utils/Validate/index.js +6 -0
- package/dist/utils/Validate/validateCollection.js +20 -5
- package/dist/utils/Validate/validateCollection.test.js +125 -0
- package/dist/utils/Validate/validateComponent.js +36 -20
- package/dist/utils/Validate/validateComponent.test.js +365 -0
- package/dist/utils/Validate/validateContainer.js +9 -3
- package/dist/utils/Validate/validateContainer.test.js +75 -0
- package/dist/utils/Validate/validateDate.js +4 -3
- package/dist/utils/Validate/validateDate.test.js +114 -0
- package/dist/utils/Validate/validateEmail.js +14 -1
- package/dist/utils/Validate/validateEmail.test.js +74 -0
- package/dist/utils/Validate/validateMultifile.js +32 -0
- package/dist/utils/Validate/validateMultifile.test.js +47 -0
- package/dist/utils/Validate/validatePage.js +12 -6
- package/dist/utils/Validate/validatePage.test.js +472 -0
- package/dist/utils/Validate/validateRegex.js +2 -5
- package/dist/utils/Validate/validateRegex.test.js +42 -0
- package/dist/utils/Validate/validateRequired.js +2 -4
- package/dist/utils/Validate/validateRequired.test.js +63 -0
- package/dist/utils/Validate/validateTextArea.js +37 -0
- package/dist/utils/Validate/validateTextArea.test.js +42 -0
- package/dist/utils/Validate/validateTime.js +2 -2
- package/dist/utils/Validate/validateTime.test.js +59 -0
- package/dist/utils/index.js +4 -1
- package/package.json +35 -50
- package/dist/utils/Meta/documents/setDocumentForField.js +0 -29
- package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -49
|
@@ -0,0 +1,968 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
var _react = require("@testing-library/react");
|
|
5
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
6
|
+
var _axiosMockAdapter = _interopRequireDefault(require("axios-mock-adapter"));
|
|
7
|
+
var _react2 = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactDom = require("react-dom");
|
|
9
|
+
var _testUtils = require("react-dom/test-utils");
|
|
10
|
+
var _models = require("../../models");
|
|
11
|
+
var _CheckYourAnswers = require("../CheckYourAnswers/CheckYourAnswers");
|
|
12
|
+
var _TaskList = require("../TaskList/TaskList");
|
|
13
|
+
var _FormRenderer = _interopRequireWildcard(require("./FormRenderer"));
|
|
14
|
+
var _areYouACivilServant = _interopRequireDefault(require("../../json/areYouACivilServant.json"));
|
|
15
|
+
var _grade = _interopRequireDefault(require("../../json/grade.json"));
|
|
16
|
+
var _team = _interopRequireDefault(require("../../json/team.json"));
|
|
17
|
+
var _userProfileData = _interopRequireDefault(require("../../json/userProfile.data.json"));
|
|
18
|
+
var _userProfile = _interopRequireDefault(require("../../json/userProfile.json"));
|
|
19
|
+
var _taskList = _interopRequireDefault(require("../../json/taskList.json"));
|
|
20
|
+
var _firstForm = _interopRequireDefault(require("../../json/firstForm.json"));
|
|
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); }
|
|
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; }
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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
|
+
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); }
|
|
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); } }
|
|
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); }); }; }
|
|
28
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
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."); }
|
|
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); }
|
|
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; } }
|
|
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 () {
|
|
42
|
+
container = document.createElement('div');
|
|
43
|
+
document.body.appendChild(container);
|
|
44
|
+
mockAxios.reset();
|
|
45
|
+
mockAxios.onGet(refDataUrl('areYouACivilServant')).reply(200, _areYouACivilServant.default);
|
|
46
|
+
mockAxios.onGet(refDataUrl('grade')).reply(200, _grade.default);
|
|
47
|
+
mockAxios.onGet(refDataUrl('team')).reply(200, _team.default);
|
|
48
|
+
});
|
|
49
|
+
afterEach(function () {
|
|
50
|
+
(0, _reactDom.unmountComponentAtNode)(container);
|
|
51
|
+
container.remove();
|
|
52
|
+
container = null;
|
|
53
|
+
});
|
|
54
|
+
var checkForm = function checkForm(formContainer) {
|
|
55
|
+
var formWrapper = formContainer;
|
|
56
|
+
var form = formWrapper.childNodes[0];
|
|
57
|
+
expect(form.tagName).toEqual('DIV');
|
|
58
|
+
expect(form.classList).toContain(_FormRenderer.DEFAULT_CLASS);
|
|
59
|
+
return form;
|
|
60
|
+
};
|
|
61
|
+
var getChangeLink = function getChangeLink(summaryList) {
|
|
62
|
+
var _summaryList$childNod = _slicedToArray(summaryList.childNodes[0].childNodes[0].childNodes, 3),
|
|
63
|
+
actions = _summaryList$childNod[2];
|
|
64
|
+
return actions.childNodes[0];
|
|
65
|
+
};
|
|
66
|
+
var getContinueButton = function getContinueButton(page) {
|
|
67
|
+
return page.childNodes[page.childNodes.length - 1].childNodes[0].childNodes[0];
|
|
68
|
+
};
|
|
69
|
+
var getCancelButton = function getCancelButton(page) {
|
|
70
|
+
return page.childNodes[page.childNodes.length - 1].childNodes[1].childNodes[0];
|
|
71
|
+
};
|
|
72
|
+
it('should start on the hub page correctly and display the title', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
73
|
+
var form, title, hub;
|
|
74
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
75
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
_context2.next = 2;
|
|
78
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
79
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
80
|
+
while (1) switch (_context.prev = _context.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
83
|
+
data: _userProfileData.default
|
|
84
|
+
})), container);
|
|
85
|
+
case 1:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context.stop();
|
|
88
|
+
}
|
|
89
|
+
}, _callee);
|
|
90
|
+
})));
|
|
91
|
+
case 2:
|
|
92
|
+
form = checkForm(container);
|
|
93
|
+
expect(form.childNodes.length).toEqual(2); // Title + Hub page (= CYA)
|
|
94
|
+
title = form.childNodes[0];
|
|
95
|
+
expect(title.tagName).toEqual('H1');
|
|
96
|
+
expect(title.textContent).toEqual(_userProfile.default.title);
|
|
97
|
+
hub = form.childNodes[1];
|
|
98
|
+
expect(hub.tagName).toEqual('DIV');
|
|
99
|
+
expect(hub.classList).toContain(_CheckYourAnswers.DEFAULT_CLASS);
|
|
100
|
+
case 10:
|
|
101
|
+
case "end":
|
|
102
|
+
return _context2.stop();
|
|
103
|
+
}
|
|
104
|
+
}, _callee2);
|
|
105
|
+
})));
|
|
106
|
+
it('should fire the onFormLoad method passed in the hooks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
107
|
+
var onFormLoadCalled, ON_FORM_LOAD, HOOKS;
|
|
108
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
109
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
110
|
+
case 0:
|
|
111
|
+
onFormLoadCalled = false;
|
|
112
|
+
ON_FORM_LOAD = function ON_FORM_LOAD() {
|
|
113
|
+
onFormLoadCalled = true;
|
|
114
|
+
};
|
|
115
|
+
HOOKS = {
|
|
116
|
+
onFormLoad: ON_FORM_LOAD
|
|
117
|
+
};
|
|
118
|
+
_context4.next = 5;
|
|
119
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
120
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
121
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
122
|
+
case 0:
|
|
123
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
124
|
+
data: _userProfileData.default,
|
|
125
|
+
hooks: HOOKS
|
|
126
|
+
})), container);
|
|
127
|
+
case 1:
|
|
128
|
+
case "end":
|
|
129
|
+
return _context3.stop();
|
|
130
|
+
}
|
|
131
|
+
}, _callee3);
|
|
132
|
+
})));
|
|
133
|
+
case 5:
|
|
134
|
+
expect(onFormLoadCalled).toBeTruthy();
|
|
135
|
+
case 6:
|
|
136
|
+
case "end":
|
|
137
|
+
return _context4.stop();
|
|
138
|
+
}
|
|
139
|
+
}, _callee4);
|
|
140
|
+
})));
|
|
141
|
+
it('should navigate to the first editable page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
142
|
+
var ON_PAGE_CHANGE_CALLS, ON_PAGE_CHANGE, HOOKS, form, hub, _hub$childNodes, civilServantList, link, page, pageHeading;
|
|
143
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
144
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
145
|
+
case 0:
|
|
146
|
+
ON_PAGE_CHANGE_CALLS = [];
|
|
147
|
+
ON_PAGE_CHANGE = function ON_PAGE_CHANGE(pageId) {
|
|
148
|
+
ON_PAGE_CHANGE_CALLS.push(pageId);
|
|
149
|
+
};
|
|
150
|
+
HOOKS = {
|
|
151
|
+
onPageChange: ON_PAGE_CHANGE
|
|
152
|
+
};
|
|
153
|
+
_context6.next = 5;
|
|
154
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
155
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
156
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
157
|
+
case 0:
|
|
158
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
159
|
+
data: _userProfileData.default,
|
|
160
|
+
hooks: HOOKS
|
|
161
|
+
})), container);
|
|
162
|
+
case 1:
|
|
163
|
+
case "end":
|
|
164
|
+
return _context5.stop();
|
|
165
|
+
}
|
|
166
|
+
}, _callee5);
|
|
167
|
+
})));
|
|
168
|
+
case 5:
|
|
169
|
+
form = checkForm(container);
|
|
170
|
+
hub = form.childNodes[1]; // Hub = CYA
|
|
171
|
+
_hub$childNodes = _slicedToArray(hub.childNodes, 3), civilServantList = _hub$childNodes[2];
|
|
172
|
+
link = getChangeLink(civilServantList);
|
|
173
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(0);
|
|
174
|
+
_react.fireEvent.click(link, {});
|
|
175
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(1);
|
|
176
|
+
expect(ON_PAGE_CHANGE_CALLS[0]).toEqual(_userProfile.default.pages[1].id);
|
|
177
|
+
|
|
178
|
+
// The form layout should have changed to the current page.
|
|
179
|
+
expect(form.childNodes.length).toEqual(1); // Just the page.
|
|
180
|
+
page = form.childNodes[0];
|
|
181
|
+
pageHeading = page.childNodes[0];
|
|
182
|
+
expect(pageHeading.tagName).toEqual('H1');
|
|
183
|
+
expect(pageHeading.textContent).toEqual(_userProfile.default.pages[1].title);
|
|
184
|
+
case 18:
|
|
185
|
+
case "end":
|
|
186
|
+
return _context6.stop();
|
|
187
|
+
}
|
|
188
|
+
}, _callee6);
|
|
189
|
+
})));
|
|
190
|
+
it('should handle a page submission', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
191
|
+
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, form, hub, _hub$childNodes2, civilServantList, link, page, continueButton, title;
|
|
192
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
193
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
194
|
+
case 0:
|
|
195
|
+
ON_SUBMIT_CALLS = [];
|
|
196
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError, fieldName, fieldValue) {
|
|
197
|
+
ON_SUBMIT_CALLS.push({
|
|
198
|
+
type: type,
|
|
199
|
+
payload: payload,
|
|
200
|
+
onSuccess: onSuccess,
|
|
201
|
+
onError: onError,
|
|
202
|
+
fieldName: fieldName,
|
|
203
|
+
fieldValue: fieldValue
|
|
204
|
+
});
|
|
205
|
+
onSuccess();
|
|
206
|
+
};
|
|
207
|
+
HOOKS = {
|
|
208
|
+
onSubmit: ON_SUBMIT
|
|
209
|
+
};
|
|
210
|
+
_context8.next = 5;
|
|
211
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
212
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
213
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
214
|
+
case 0:
|
|
215
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
216
|
+
data: _userProfileData.default,
|
|
217
|
+
hooks: HOOKS,
|
|
218
|
+
type: _models.FormTypes.HUB
|
|
219
|
+
})), container);
|
|
220
|
+
case 1:
|
|
221
|
+
case "end":
|
|
222
|
+
return _context7.stop();
|
|
223
|
+
}
|
|
224
|
+
}, _callee7);
|
|
225
|
+
})));
|
|
226
|
+
case 5:
|
|
227
|
+
form = checkForm(container); // Navigate to the "Are you a civil servant?" page.
|
|
228
|
+
hub = form.childNodes[1]; // Hub = CYA
|
|
229
|
+
_hub$childNodes2 = _slicedToArray(hub.childNodes, 3), civilServantList = _hub$childNodes2[2];
|
|
230
|
+
link = getChangeLink(civilServantList);
|
|
231
|
+
_react.fireEvent.click(link, {});
|
|
232
|
+
|
|
233
|
+
// Should already be answered "Yes", but select "No, I'm a contractor" option to generate patch
|
|
234
|
+
// and then click "Continue".
|
|
235
|
+
_react.fireEvent.click(_react.screen.getByText("No, I'm a contractor"));
|
|
236
|
+
page = form.childNodes[0];
|
|
237
|
+
continueButton = getContinueButton(page);
|
|
238
|
+
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
239
|
+
_react.fireEvent.click(continueButton, {});
|
|
240
|
+
expect(ON_SUBMIT_CALLS.length).toEqual(1);
|
|
241
|
+
expect(ON_SUBMIT_CALLS[0].type).toEqual(_models.PageAction.TYPES.SUBMIT);
|
|
242
|
+
expect(ON_SUBMIT_CALLS[0].payload.areYouACivilServant).toEqual('no-contractor');
|
|
243
|
+
expect(ON_SUBMIT_CALLS[0].fieldName).toEqual('Are you a civil servant?');
|
|
244
|
+
expect(ON_SUBMIT_CALLS[0].fieldValue).toEqual("No, I'm a contractor");
|
|
245
|
+
|
|
246
|
+
// And we should be back on the hub.
|
|
247
|
+
expect(form.childNodes.length).toEqual(2); // Title + Hub page (= CYA)
|
|
248
|
+
title = form.childNodes[0];
|
|
249
|
+
expect(title.tagName).toEqual('H1');
|
|
250
|
+
expect(title.textContent).toEqual(_userProfile.default.title);
|
|
251
|
+
case 24:
|
|
252
|
+
case "end":
|
|
253
|
+
return _context8.stop();
|
|
254
|
+
}
|
|
255
|
+
}, _callee8);
|
|
256
|
+
})));
|
|
257
|
+
it('should handle a page submission error', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
258
|
+
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, form, hub, _hub$childNodes3, civilServantList, link, page, continueButton, pageHeading;
|
|
259
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
260
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
261
|
+
case 0:
|
|
262
|
+
ON_SUBMIT_CALLS = [];
|
|
263
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
|
|
264
|
+
ON_SUBMIT_CALLS.push({
|
|
265
|
+
type: type,
|
|
266
|
+
payload: payload,
|
|
267
|
+
onSuccess: onSuccess,
|
|
268
|
+
onError: onError
|
|
269
|
+
});
|
|
270
|
+
onError([{
|
|
271
|
+
id: 'unknown',
|
|
272
|
+
error: 'Something went wrong'
|
|
273
|
+
}]);
|
|
274
|
+
};
|
|
275
|
+
HOOKS = {
|
|
276
|
+
onSubmit: ON_SUBMIT,
|
|
277
|
+
onAction: function onAction(formData, patch) {
|
|
278
|
+
return {
|
|
279
|
+
formData: formData,
|
|
280
|
+
patch: patch
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
_context10.next = 5;
|
|
285
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
286
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
287
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
288
|
+
case 0:
|
|
289
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
290
|
+
data: _userProfileData.default,
|
|
291
|
+
hooks: HOOKS
|
|
292
|
+
})), container);
|
|
293
|
+
case 1:
|
|
294
|
+
case "end":
|
|
295
|
+
return _context9.stop();
|
|
296
|
+
}
|
|
297
|
+
}, _callee9);
|
|
298
|
+
})));
|
|
299
|
+
case 5:
|
|
300
|
+
form = checkForm(container); // Navigate to the "Are you a civil servant?" page.
|
|
301
|
+
hub = form.childNodes[1]; // Hub = CYA
|
|
302
|
+
_hub$childNodes3 = _slicedToArray(hub.childNodes, 3), civilServantList = _hub$childNodes3[2];
|
|
303
|
+
link = getChangeLink(civilServantList);
|
|
304
|
+
_react.fireEvent.click(link, {});
|
|
305
|
+
|
|
306
|
+
// Should already be answered "Yes", so simply click "Continue".
|
|
307
|
+
page = form.childNodes[0];
|
|
308
|
+
continueButton = getContinueButton(page);
|
|
309
|
+
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
310
|
+
_react.fireEvent.click(continueButton, {});
|
|
311
|
+
expect(ON_SUBMIT_CALLS.length).toEqual(1);
|
|
312
|
+
expect(ON_SUBMIT_CALLS[0].type).toEqual(_models.PageAction.TYPES.SUBMIT);
|
|
313
|
+
expect(ON_SUBMIT_CALLS[0].payload.areYouACivilServant).toEqual('yes');
|
|
314
|
+
|
|
315
|
+
// And we should be kept on the same page.
|
|
316
|
+
expect(form.childNodes.length).toEqual(1); // Just the page.
|
|
317
|
+
pageHeading = form.childNodes[0].childNodes[1];
|
|
318
|
+
expect(pageHeading.tagName).toEqual('H1');
|
|
319
|
+
expect(pageHeading.textContent).toEqual(_userProfile.default.pages[1].title);
|
|
320
|
+
case 21:
|
|
321
|
+
case "end":
|
|
322
|
+
return _context10.stop();
|
|
323
|
+
}
|
|
324
|
+
}, _callee10);
|
|
325
|
+
})));
|
|
326
|
+
it('should handle page navigation', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
327
|
+
var ON_PAGE_CHANGE_CALLS, ON_PAGE_CHANGE, HOOKS, form, hub, _hub$childNodes4, lineManagerList, link, page, pageHeading, continueButton, newPageHeading;
|
|
328
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
329
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
330
|
+
case 0:
|
|
331
|
+
ON_PAGE_CHANGE_CALLS = [];
|
|
332
|
+
ON_PAGE_CHANGE = function ON_PAGE_CHANGE(pageId) {
|
|
333
|
+
ON_PAGE_CHANGE_CALLS.push(pageId);
|
|
334
|
+
};
|
|
335
|
+
HOOKS = {
|
|
336
|
+
onPageChange: ON_PAGE_CHANGE
|
|
337
|
+
};
|
|
338
|
+
_context12.next = 5;
|
|
339
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
340
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
341
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
342
|
+
case 0:
|
|
343
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
344
|
+
data: _userProfileData.default,
|
|
345
|
+
hooks: HOOKS
|
|
346
|
+
})), container);
|
|
347
|
+
case 1:
|
|
348
|
+
case "end":
|
|
349
|
+
return _context11.stop();
|
|
350
|
+
}
|
|
351
|
+
}, _callee11);
|
|
352
|
+
})));
|
|
353
|
+
case 5:
|
|
354
|
+
form = checkForm(container); // Navigate to the "Add or change a line manager" page.
|
|
355
|
+
hub = form.childNodes[1]; // Hub = CYA
|
|
356
|
+
_hub$childNodes4 = _slicedToArray(hub.childNodes, 6), lineManagerList = _hub$childNodes4[5];
|
|
357
|
+
link = getChangeLink(lineManagerList);
|
|
358
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(0);
|
|
359
|
+
_react.fireEvent.click(link, {});
|
|
360
|
+
expect(ON_PAGE_CHANGE_CALLS[0]).toEqual(_userProfile.default.pages[4].id);
|
|
361
|
+
|
|
362
|
+
// Should be on the page explaining what changing the line manager means.
|
|
363
|
+
page = form.childNodes[0];
|
|
364
|
+
pageHeading = page.childNodes[0];
|
|
365
|
+
expect(pageHeading.tagName).toEqual('H1');
|
|
366
|
+
expect(pageHeading.textContent).toEqual(_userProfile.default.pages[4].title);
|
|
367
|
+
|
|
368
|
+
// Now click on the "Continue" button on here.
|
|
369
|
+
continueButton = getContinueButton(page);
|
|
370
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(1);
|
|
371
|
+
_react.fireEvent.click(continueButton, {});
|
|
372
|
+
expect(ON_PAGE_CHANGE_CALLS.length).toEqual(2);
|
|
373
|
+
expect(ON_PAGE_CHANGE_CALLS[1]).toEqual(_userProfile.default.pages[5].id);
|
|
374
|
+
newPageHeading = form.childNodes[0].childNodes[0];
|
|
375
|
+
expect(newPageHeading.tagName).toEqual('H1');
|
|
376
|
+
expect(newPageHeading.textContent).toEqual(_userProfile.default.pages[5].title);
|
|
377
|
+
case 24:
|
|
378
|
+
case "end":
|
|
379
|
+
return _context12.stop();
|
|
380
|
+
}
|
|
381
|
+
}, _callee12);
|
|
382
|
+
})));
|
|
383
|
+
it('should show no title when hide_title is set to true', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
384
|
+
var form, hub;
|
|
385
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
386
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
387
|
+
case 0:
|
|
388
|
+
_context14.next = 2;
|
|
389
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
390
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
391
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
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();
|
|
438
|
+
}
|
|
439
|
+
}, _callee16);
|
|
440
|
+
})));
|
|
441
|
+
it('should render a cya page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
442
|
+
var cya;
|
|
443
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
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();
|
|
464
|
+
}
|
|
465
|
+
}, _callee18);
|
|
466
|
+
})));
|
|
467
|
+
it('should load tasklist with notes', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
468
|
+
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, TASK_LIST_WITH_NOTES, taskList;
|
|
469
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
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();
|
|
512
|
+
}
|
|
513
|
+
}, _callee20);
|
|
514
|
+
})));
|
|
515
|
+
it('should not load tasklist with notes', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
516
|
+
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, TASK_LIST_WITH_NOTES, taskList;
|
|
517
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
518
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
519
|
+
case 0:
|
|
520
|
+
ON_SUBMIT_CALLS = [];
|
|
521
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess) {
|
|
522
|
+
ON_SUBMIT_CALLS.push(payload);
|
|
523
|
+
onSuccess();
|
|
524
|
+
};
|
|
525
|
+
HOOKS = {
|
|
526
|
+
onSubmit: ON_SUBMIT
|
|
527
|
+
};
|
|
528
|
+
TASK_LIST_WITH_NOTES = JSON.parse(JSON.stringify(_taskList.default));
|
|
529
|
+
TASK_LIST_WITH_NOTES.hub.notes = {
|
|
530
|
+
title: "test title",
|
|
531
|
+
text: "test text",
|
|
532
|
+
show_when: [{
|
|
533
|
+
"op": "!=",
|
|
534
|
+
"field": "changeSummary",
|
|
535
|
+
"value": undefined
|
|
536
|
+
}]
|
|
537
|
+
};
|
|
538
|
+
_context22.next = 7;
|
|
539
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
540
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
541
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
542
|
+
case 0:
|
|
543
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_WITH_NOTES, {
|
|
544
|
+
data: _userProfileData.default,
|
|
545
|
+
hooks: HOOKS
|
|
546
|
+
})), container);
|
|
547
|
+
case 1:
|
|
548
|
+
case "end":
|
|
549
|
+
return _context21.stop();
|
|
550
|
+
}
|
|
551
|
+
}, _callee21);
|
|
552
|
+
})));
|
|
553
|
+
case 7:
|
|
554
|
+
taskList = container.childNodes[0].childNodes[1];
|
|
555
|
+
taskList.childNodes.forEach(function (child) {
|
|
556
|
+
// eslint-disable-next-line no-console
|
|
557
|
+
console.log("taskList, child = ".concat(JSON.stringify(child.textContent)));
|
|
558
|
+
});
|
|
559
|
+
expect(taskList.childNodes[5].textContent).not.toEqual("test text");
|
|
560
|
+
expect(taskList.childNodes[5].classList).not.toContain('govuk-textarea');
|
|
561
|
+
case 11:
|
|
562
|
+
case "end":
|
|
563
|
+
return _context22.stop();
|
|
564
|
+
}
|
|
565
|
+
}, _callee22);
|
|
566
|
+
})));
|
|
567
|
+
it('should handle navigating between task list pages', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
568
|
+
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, taskList, firstTaskStatus, secondTaskStatus, firstTask, newPage, continueButton, seaButton, cyaPageChange, modeChangeLink, changePage, airButton, cyaPage, finalSubmit;
|
|
569
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
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();
|
|
680
|
+
}
|
|
681
|
+
}, _callee24);
|
|
682
|
+
})));
|
|
683
|
+
it('should go straight to CYA page if a complete task is selected', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
684
|
+
var ON_SUBMIT, HOOKS, taskList, newPage;
|
|
685
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
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();
|
|
750
|
+
}
|
|
751
|
+
}, _callee26);
|
|
752
|
+
})));
|
|
753
|
+
it('should go to incomplete page when selecting in-progress task', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
754
|
+
var ON_SUBMIT, HOOKS, DATA, taskList;
|
|
755
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
756
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
757
|
+
case 0:
|
|
758
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess) {
|
|
759
|
+
onSuccess();
|
|
760
|
+
};
|
|
761
|
+
HOOKS = {
|
|
762
|
+
onSubmit: ON_SUBMIT
|
|
763
|
+
};
|
|
764
|
+
DATA = {
|
|
765
|
+
"date": "7-7-2022",
|
|
766
|
+
"formStatus": {
|
|
767
|
+
"tasks": {
|
|
768
|
+
"Date, location and mode details": {
|
|
769
|
+
"complete": false,
|
|
770
|
+
"currentPage": "eventMode"
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
"taskPage": "eventMode"
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
_context28.next = 5;
|
|
777
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
778
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
779
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
780
|
+
case 0:
|
|
781
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _taskList.default, {
|
|
782
|
+
hooks: HOOKS,
|
|
783
|
+
data: DATA
|
|
784
|
+
})), container);
|
|
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();
|
|
800
|
+
}
|
|
801
|
+
}, _callee28);
|
|
802
|
+
})));
|
|
803
|
+
it('should go to the first page of a complete task if noTaskCYAs specified', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
804
|
+
var ON_SUBMIT, HOOKS, TASK_LIST_WITH_NO_TASK_CYAS, taskList, newPage;
|
|
805
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
806
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
807
|
+
case 0:
|
|
808
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess) {
|
|
809
|
+
onSuccess();
|
|
810
|
+
};
|
|
811
|
+
HOOKS = {
|
|
812
|
+
onSubmit: ON_SUBMIT
|
|
813
|
+
};
|
|
814
|
+
TASK_LIST_WITH_NO_TASK_CYAS = JSON.parse(JSON.stringify(_taskList.default));
|
|
815
|
+
TASK_LIST_WITH_NO_TASK_CYAS.hub.noTaskCYAs = true;
|
|
816
|
+
TASK_LIST_WITH_NO_TASK_CYAS.pages[1].actions[0] = {
|
|
817
|
+
type: 'save',
|
|
818
|
+
complete: true
|
|
819
|
+
};
|
|
820
|
+
_context30.next = 7;
|
|
821
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
822
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
823
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
824
|
+
case 0:
|
|
825
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_WITH_NO_TASK_CYAS, {
|
|
826
|
+
hooks: HOOKS
|
|
827
|
+
})), container);
|
|
828
|
+
case 1:
|
|
829
|
+
case "end":
|
|
830
|
+
return _context29.stop();
|
|
831
|
+
}
|
|
832
|
+
}, _callee29);
|
|
833
|
+
})));
|
|
834
|
+
case 7:
|
|
835
|
+
taskList = container.childNodes[0].childNodes[1]; // Launch first task
|
|
836
|
+
_react.fireEvent.click(taskList.childNodes[3].childNodes[1].childNodes[0].childNodes[0], {});
|
|
837
|
+
|
|
838
|
+
// Fill first page and navigate
|
|
839
|
+
newPage = container.childNodes[0].childNodes[0];
|
|
840
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[1], {
|
|
841
|
+
target: {
|
|
842
|
+
name: 'date-day',
|
|
843
|
+
value: '7'
|
|
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();
|
|
874
|
+
}
|
|
875
|
+
}, _callee30);
|
|
876
|
+
})));
|
|
877
|
+
it('should handle cancellation from a page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
878
|
+
var ON_CANCEL_CALLS, ON_CANCEL, HOOKS, form, hub, _hub$childNodes5, civilServantList, link, page, cancel;
|
|
879
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
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();
|
|
920
|
+
}
|
|
921
|
+
}, _callee32);
|
|
922
|
+
})));
|
|
923
|
+
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() {
|
|
924
|
+
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, TASK_LIST_NON_SEQUENTIAL, taskList, firstTask, newPage;
|
|
925
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
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();
|
|
964
|
+
}
|
|
965
|
+
}, _callee34);
|
|
966
|
+
})));
|
|
967
|
+
});
|
|
968
|
+
});
|