@wise/dynamic-flow-client 5.8.1 → 5.9.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/build/DynamicFlowCore.js +5 -0
- package/build/common/errorBoundary/ErrorBoundary.js +26 -0
- package/build/common/errorBoundary/ErrorBoundary.test.js +29 -0
- package/build/common/errorBoundary/ErrorBoundaryAlert.js +11 -0
- package/build/common/makeHttpClient/api-utils.js +3 -0
- package/build/common/makeHttpClient/index.js +1 -0
- package/build/common/makeHttpClient/makeHttpClient.js +10 -0
- package/build/common/makeHttpClient/makeHttpClient.test.js +186 -0
- package/build/common/messages/external-confirmation.messages.js +23 -0
- package/build/common/messages/file-upload.messages.js +13 -0
- package/build/common/messages/generic-error.messages.js +18 -0
- package/build/common/messages/help.messages.js +8 -0
- package/build/common/messages/multi-file-upload.messages.js +18 -0
- package/build/common/messages/multi-select.messages.js +8 -0
- package/build/common/messages/paragraph.messages.js +13 -0
- package/build/common/messages/repeatable.messages.js +23 -0
- package/build/common/messages/search.messages.js +8 -0
- package/build/common/messages/validation.array.messages.js +13 -0
- package/build/common/messages/validation.messages.js +53 -0
- package/build/controller/FlowController.js +368 -0
- package/build/controller/executePoll.js +49 -0
- package/build/controller/executeRefresh.js +39 -0
- package/build/controller/executeRequest.js +77 -0
- package/build/controller/executeSubmission.js +69 -0
- package/build/controller/getErrorMessage.js +7 -0
- package/build/controller/getRequestAbortController.js +13 -0
- package/build/controller/getResponseType.js +35 -0
- package/build/controller/getSafeHttpClient.js +8 -0
- package/build/controller/getStepCounter.js +16 -0
- package/build/controller/handleErrorResponse.js +26 -0
- package/build/controller/makeSafeHttpClient.js +8 -0
- package/build/controller/response-utils.js +72 -0
- package/build/domain/components/AlertComponent.js +1 -0
- package/build/domain/components/AllOfComponent.js +40 -0
- package/build/domain/components/BooleanInputComponent.js +50 -0
- package/build/domain/components/BoxComponent.js +3 -0
- package/build/domain/components/ButtonComponent.js +1 -0
- package/build/domain/components/ColumnsComponent.js +3 -0
- package/build/domain/components/ConstComponent.js +18 -0
- package/build/domain/components/ContainerComponent.js +3 -0
- package/build/domain/components/DateInputComponent.js +75 -0
- package/build/domain/components/DecisionComponent.js +1 -0
- package/build/domain/components/DividerComponent.js +1 -0
- package/build/domain/components/FormComponent.js +3 -0
- package/build/domain/components/FormattedValueComponent.js +44 -0
- package/build/domain/components/HeadingComponent.js +1 -0
- package/build/domain/components/ImageComponent.js +1 -0
- package/build/domain/components/InstructionsComponent.js +1 -0
- package/build/domain/components/IntegerInputComponent.js +74 -0
- package/build/domain/components/ListComponent.js +1 -0
- package/build/domain/components/LoadingIndicatorComponent.js +1 -0
- package/build/domain/components/MarkdownComponent.js +1 -0
- package/build/domain/components/MediaComponent.js +1 -0
- package/build/domain/components/ModalComponent.js +16 -0
- package/build/domain/components/ModalLayoutComponent.js +3 -0
- package/build/domain/components/MoneyInputComponent.js +57 -0
- package/build/domain/components/MultiSelectInputComponent.js +81 -0
- package/build/domain/components/MultiUploadInputComponent.js +88 -0
- package/build/domain/components/NumberInputComponent.js +73 -0
- package/build/domain/components/ObjectComponent.js +45 -0
- package/build/domain/components/ParagraphComponent.js +1 -0
- package/build/domain/components/PersistAsyncComponent.js +92 -0
- package/build/domain/components/ProgressComponent.js +1 -0
- package/build/domain/components/RepeatableComponent.js +103 -0
- package/build/domain/components/ReviewComponent.js +1 -0
- package/build/domain/components/RootDomainComponent.js +173 -0
- package/build/domain/components/SectionComponent.js +5 -0
- package/build/domain/components/SelectInputComponent.js +88 -0
- package/build/domain/components/StatusListComponent.js +1 -0
- package/build/domain/components/SubflowDomainComponent.js +9 -0
- package/build/domain/components/TabsComponent.js +1 -0
- package/build/domain/components/TextInputComponent.js +76 -0
- package/build/domain/components/TupleComponent.js +41 -0
- package/build/domain/components/UploadInputComponent.js +83 -0
- package/build/domain/components/UpsellComponent.js +25 -0
- package/build/domain/components/searchComponent/SearchComponent.js +92 -0
- package/build/domain/components/searchComponent/SearchComponent.test.js +190 -0
- package/build/domain/components/step/ExternalConfirmationComponent.js +28 -0
- package/build/domain/components/step/StepDomainComponent.js +73 -0
- package/build/domain/components/step/ToolbarComponent.js +1 -0
- package/build/domain/components/utils/WithUpdate.js +1 -0
- package/build/domain/components/utils/component-utils.js +12 -0
- package/build/domain/components/utils/debounce.js +34 -0
- package/build/domain/components/utils/debounce.test.js +67 -0
- package/build/domain/components/utils/file-utils.js +21 -0
- package/build/domain/components/utils/file-utils.test.js +27 -0
- package/build/domain/components/utils/getRandomId.js +1 -0
- package/build/domain/components/utils/isExactLocalValueMatch.js +14 -0
- package/build/domain/components/utils/isOrWasValid.js +5 -0
- package/build/domain/components/utils/isPartialModelMatch.js +18 -0
- package/build/domain/components/utils/isPartialModelMatch.test.js +74 -0
- package/build/domain/features/eventNames.js +24 -0
- package/build/domain/features/events.js +1 -0
- package/build/domain/features/persistAsync/getComponentMultiPersistAsync.js +50 -0
- package/build/domain/features/persistAsync/getInitialPersistedState.js +7 -0
- package/build/domain/features/persistAsync/getPerformPersistAsync.js +43 -0
- package/build/domain/features/persistAsync/getPerformPersistAsync.test.js +139 -0
- package/build/domain/features/polling/getStepPolling.js +43 -0
- package/build/domain/features/polling/getStepPolling.test.js +90 -0
- package/build/domain/features/prefetch/getStepPrefetch.js +43 -0
- package/build/domain/features/prefetch/request-cache.js +49 -0
- package/build/domain/features/prefetch/request-cache.test.js +70 -0
- package/build/domain/features/refreshAfter/getStepRefreshAfter.js +24 -0
- package/build/domain/features/refreshAfter/getStepRefreshAfter.test.js +40 -0
- package/build/domain/features/schema-on-change/getDebouncedSchemaOnChange.js +50 -0
- package/build/domain/features/schema-on-change/getSchemaOnChange.js +34 -0
- package/build/domain/features/search/getPerformSearchFunction.js +75 -0
- package/build/domain/features/search/getPerformSearchFunction.test.js +301 -0
- package/build/domain/features/summary/summary-utils.js +40 -0
- package/build/domain/features/summary/summary-utils.test.js +125 -0
- package/build/domain/features/utils/http-utils.js +21 -0
- package/build/domain/features/utils/response-utils.js +9 -0
- package/build/domain/features/validation/spec-utils.js +19 -0
- package/build/domain/features/validation/validateStringPattern.js +24 -0
- package/build/domain/features/validation/validation-functions.js +6 -0
- package/build/domain/features/validation/validation-functions.test.js +108 -0
- package/build/domain/features/validation/value-checks.js +125 -0
- package/build/domain/features/validation/value-checks.test.js +262 -0
- package/build/domain/features/validationAsync/getComponentValidationAsync.js +53 -0
- package/build/domain/features/validationAsync/getComponentValidationAsync.test.js +67 -0
- package/build/domain/features/validationAsync/getInitialValidationAsyncState.js +5 -0
- package/build/domain/features/validationAsync/getPerformValidationAsync.js +45 -0
- package/build/domain/features/validationAsync/getPerformValidationAsync.test.js +143 -0
- package/build/domain/mappers/layout/alertLayoutToComponent.js +16 -0
- package/build/domain/mappers/layout/boxLayoutToComponent.js +13 -0
- package/build/domain/mappers/layout/buttonLayoutToComponent.js +77 -0
- package/build/domain/mappers/layout/columnsLayoutToComponent.js +13 -0
- package/build/domain/mappers/layout/decisionLayoutToComponent.js +22 -0
- package/build/domain/mappers/layout/deprecatedListLayoutToComponent.js +30 -0
- package/build/domain/mappers/layout/dividerLayoutToComponent.js +2 -0
- package/build/domain/mappers/layout/formLayoutToComponent.js +19 -0
- package/build/domain/mappers/layout/headingLayoutToComponent.js +12 -0
- package/build/domain/mappers/layout/imageLayoutToComponent.js +20 -0
- package/build/domain/mappers/layout/infoLayoutToComponent.js +12 -0
- package/build/domain/mappers/layout/instructionsLayoutToComponent.js +12 -0
- package/build/domain/mappers/layout/listLayoutToComponent.js +39 -0
- package/build/domain/mappers/layout/loadingIndicatorLayoutToComponent.js +9 -0
- package/build/domain/mappers/layout/markdownLayoutToComponent.js +12 -0
- package/build/domain/mappers/layout/mediaLayoutToComponent.js +12 -0
- package/build/domain/mappers/layout/modalLayoutToComponent.js +17 -0
- package/build/domain/mappers/layout/modalToComponent.js +8 -0
- package/build/domain/mappers/layout/paragraphLayoutToComponent.js +12 -0
- package/build/domain/mappers/layout/progressLayoutToComponent.js +15 -0
- package/build/domain/mappers/layout/reviewLayoutToComponent.js +48 -0
- package/build/domain/mappers/layout/searchLayoutToComponent.js +44 -0
- package/build/domain/mappers/layout/sectionLayoutToComponent.js +15 -0
- package/build/domain/mappers/layout/statusListLayoutToComponent.js +15 -0
- package/build/domain/mappers/layout/tabsLayoutToComponent.js +16 -0
- package/build/domain/mappers/layout/upsellLayoutToComponent.js +25 -0
- package/build/domain/mappers/mapLayoutToComponent.js +81 -0
- package/build/domain/mappers/mapSchemaToComponent.js +61 -0
- package/build/domain/mappers/mapSchemaToComponent.test.js +112 -0
- package/build/domain/mappers/mapStepSchemas.js +17 -0
- package/build/domain/mappers/mapStepToComponent.js +132 -0
- package/build/domain/mappers/mapStepToComponent.test.js +221 -0
- package/build/domain/mappers/mapToolbarToComponent.js +15 -0
- package/build/domain/mappers/schema/allOfSchemaToComponent.js +16 -0
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.js +26 -0
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiSelectComponent.js +55 -0
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiUploadComponent.js +67 -0
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.js +57 -0
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToTupleComponent.js +20 -0
- package/build/domain/mappers/schema/blobSchemaToComponent.js +15 -0
- package/build/domain/mappers/schema/booleanSchemaToComponent.js +29 -0
- package/build/domain/mappers/schema/constSchemaToComponent.js +23 -0
- package/build/domain/mappers/schema/integerSchemaToComponent.js +28 -0
- package/build/domain/mappers/schema/numberSchemaToComponent.js +26 -0
- package/build/domain/mappers/schema/objectSchemaToComponent/assertDisplayOrder.js +23 -0
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToFormattedValueComponent.js +9 -0
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToMoneyInputComponent.js +119 -0
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToMoneyInputComponent.test.js +96 -0
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToObjectComponent.js +31 -0
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToObjectComponent.test.js +99 -0
- package/build/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.js +76 -0
- package/build/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.test.js +265 -0
- package/build/domain/mappers/schema/persistAsyncSchemaToComponent.js +29 -0
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.js +18 -0
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.test.js +133 -0
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.js +48 -0
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToTextInputComponent.js +37 -0
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.js +28 -0
- package/build/domain/mappers/schema/tests/test-utils.js +16 -0
- package/build/domain/mappers/schema/types.js +1 -0
- package/build/domain/mappers/schema/utils/getPerformPersistAsyncFn.js +19 -0
- package/build/domain/mappers/schema/utils/getValidationAsyncInitialState.js +23 -0
- package/build/domain/mappers/schema/utils/mapCommonSchemaProps.js +16 -0
- package/build/domain/mappers/types.js +1 -0
- package/build/domain/mappers/utils/FeatureFlags.js +22 -0
- package/build/domain/mappers/utils/behavior-utils.js +44 -0
- package/build/domain/mappers/utils/call-to-action-utils.js +21 -0
- package/build/domain/mappers/utils/getAutocompleteString.js +76 -0
- package/build/domain/mappers/utils/getAutocompleteString.test.js +21 -0
- package/build/domain/mappers/utils/groupLayoutByPinned.js +38 -0
- package/build/domain/mappers/utils/groupLayoutByPinned.test.js +166 -0
- package/build/domain/mappers/utils/image.js +9 -0
- package/build/domain/mappers/utils/layout-utils.js +11 -0
- package/build/domain/mappers/utils/legacy-utils.js +49 -0
- package/build/domain/mappers/utils/media-utils.js +14 -0
- package/build/domain/mappers/utils/suggestions-utils.js +26 -0
- package/build/domain/mappers/utils/suggestions-utils.test.js +36 -0
- package/build/domain/mappers/utils/tags-utils.js +1 -0
- package/build/domain/mappers/utils/utils.js +35 -0
- package/build/domain/types.js +1 -0
- package/build/getSubflowCallbacks.js +38 -0
- package/build/i18n/index.js +40 -0
- package/build/index.js +8 -0
- package/build/main.js +112 -54
- package/build/main.mjs +111 -53
- package/build/renderers/CoreContainerRenderer.js +5 -0
- package/build/renderers/CoreRootRenderer.js +12 -0
- package/build/renderers/EmptyLoadingStateRenderer.js +5 -0
- package/build/renderers/getRenderFunction.js +24 -0
- package/build/renderers/getSchemaErrorMessageFunction.js +97 -0
- package/build/renderers/mappers/alertComponentToProps.js +2 -0
- package/build/renderers/mappers/allOfComponentToProps.js +6 -0
- package/build/renderers/mappers/booleanInputComponentToProps.js +5 -0
- package/build/renderers/mappers/boxComponentToProps.js +13 -0
- package/build/renderers/mappers/buttonComponentToProps.js +4 -0
- package/build/renderers/mappers/columnsComponentToProps.js +11 -0
- package/build/renderers/mappers/componentToRendererProps.js +164 -0
- package/build/renderers/mappers/constComponentToProps.js +5 -0
- package/build/renderers/mappers/containerComponentToProps.js +7 -0
- package/build/renderers/mappers/dateInputComponentToProps.js +2 -0
- package/build/renderers/mappers/decisionComponentToProps.js +16 -0
- package/build/renderers/mappers/dividerComponentToProps.js +2 -0
- package/build/renderers/mappers/externalComponentToProps.js +3 -0
- package/build/renderers/mappers/formComponentToProps.js +12 -0
- package/build/renderers/mappers/formattedValueComponentToProps.js +5 -0
- package/build/renderers/mappers/headingComponentToProps.js +2 -0
- package/build/renderers/mappers/hiddenComponentToProps.js +4 -0
- package/build/renderers/mappers/imageComponentToProps.js +2 -0
- package/build/renderers/mappers/instructionsComponentToProps.js +2 -0
- package/build/renderers/mappers/integerInputComponentToProps.js +2 -0
- package/build/renderers/mappers/listComponentToProps.js +2 -0
- package/build/renderers/mappers/loadingIndicatorComponentToProps.js +2 -0
- package/build/renderers/mappers/markdownComponentToProps.js +2 -0
- package/build/renderers/mappers/mediaComponentToProps.js +2 -0
- package/build/renderers/mappers/modalComponentToProps.js +11 -0
- package/build/renderers/mappers/modalLayoutComponentToProps.js +16 -0
- package/build/renderers/mappers/moneyInputComponentToProps.js +36 -0
- package/build/renderers/mappers/multiSelectComponentToProps.js +23 -0
- package/build/renderers/mappers/multiUploadInputComponentToProps.js +12 -0
- package/build/renderers/mappers/numberInputComponentToProps.js +2 -0
- package/build/renderers/mappers/objectComponentToProps.js +8 -0
- package/build/renderers/mappers/paragraphComponentToProps.js +2 -0
- package/build/renderers/mappers/persistAsyncComponentToProps.js +8 -0
- package/build/renderers/mappers/progressComponentToProps.js +2 -0
- package/build/renderers/mappers/repeatableComponentToProps.js +30 -0
- package/build/renderers/mappers/reviewComponentToProps.js +2 -0
- package/build/renderers/mappers/rootComponentToProps.js +21 -0
- package/build/renderers/mappers/searchComponentToProps.js +57 -0
- package/build/renderers/mappers/sectionComponentToProps.js +6 -0
- package/build/renderers/mappers/selectInputComponentToProps.js +26 -0
- package/build/renderers/mappers/statusListComponentToProps.js +2 -0
- package/build/renderers/mappers/subflowComponentToRendererProps.js +4 -0
- package/build/renderers/mappers/tabsComponentToProps.js +14 -0
- package/build/renderers/mappers/textInputComponentToProps.js +2 -0
- package/build/renderers/mappers/tupleComponentToProps.js +8 -0
- package/build/renderers/mappers/uploadInputComponentToProps.js +8 -0
- package/build/renderers/mappers/upsellComponentToProps.js +2 -0
- package/build/renderers/mappers/utils/getValidationState.js +12 -0
- package/build/renderers/mappers/utils/inputComponentToProps.js +26 -0
- package/build/renderers/mappers/utils/mapErrorsToValidationState.js +9 -0
- package/build/renderers/mappers/utils/pick.js +8 -0
- package/build/renderers/mappers/utils/selectInputOptionsToProps.js +11 -0
- package/build/renderers/stepComponentToProps.js +32 -0
- package/build/renderers/utils.js +69 -0
- package/build/renderers/utils.test.js +70 -0
- package/build/stories/dev-tools/ContainerQueries.story.js +66 -0
- package/build/stories/dev-tools/Debugger.story.js +38 -0
- package/build/stories/dev-tools/FixtureSelect.story.js +23 -0
- package/build/stories/dev-tools/TestServer.story.js +32 -0
- package/build/stories/examples/NativeFlow.story.js +80 -0
- package/build/stories/examples/Recipients.story.js +568 -0
- package/build/stories/spec/behavior/Copy.story.js +59 -0
- package/build/stories/spec/behavior/Modal.story.js +76 -0
- package/build/stories/spec/behavior/Subflow.story.js +267 -0
- package/build/stories/spec/layouts/Decision.story.js +241 -0
- package/build/stories/spec/layouts/Image.story.js +42 -0
- package/build/stories/spec/layouts/Modal.story.js +81 -0
- package/build/stories/spec/layouts/Search.story.js +325 -0
- package/build/stories/spec/layouts/Upsell.story.js +55 -0
- package/build/stories/spec/layouts/button/Button.story.js +100 -0
- package/build/stories/spec/layouts/button/PinnedButton.story.js +81 -0
- package/build/stories/spec/response/ActionResponse.story.js +66 -0
- package/build/stories/spec/schemas/MultiSelect.story.js +148 -0
- package/build/stories/spec/schemas/Upload.story.js +168 -0
- package/build/stories/spec/schemas/const/ConstLayout.story.js +159 -0
- package/build/stories/spec/schemas/const/ObjectConst.story.js +94 -0
- package/build/stories/spec/schemas/features/PersistAsync.story.js +176 -0
- package/build/stories/spec/schemas/features/ValidationAsync.story.js +103 -0
- package/build/stories/spec/schemas/object/FormattedValue.story.js +92 -0
- package/build/stories/spec/schemas/object/MoneyInput.story.js +240 -0
- package/build/stories/spec/schemas/oneOf/OneOfInitialisation.story.js +55 -0
- package/build/stories/spec/step/Controls.story.js +109 -0
- package/build/stories/spec/step/DFModal.story.js +58 -0
- package/build/stories/spec/step/Footer.story.js +70 -0
- package/build/stories/spec/step/Navigation.story.js +20 -0
- package/build/stories/spec/step/Tags.story.js +39 -0
- package/build/stories/spec/step/ToolBar.story.js +60 -0
- package/build/stories/spec/step/features/ErrorHandling.story.js +92 -0
- package/build/stories/spec/step/features/External.story.js +44 -0
- package/build/stories/spec/step/features/Polling.story.js +108 -0
- package/build/stories/spec/step/features/RefreshAfter.story.js +92 -0
- package/build/stories/spec/step/features/refresh/Refresh.story.js +258 -0
- package/build/stories/spec/step/features/refresh/RefreshWithPersistAsync.story.js +958 -0
- package/build/stories/types.js +1 -0
- package/build/stories/utils/fixtureHttpClient.js +70 -0
- package/build/stories/utils/getBasicStep.js +223 -0
- package/build/stories/utils/mockSearchHandler.js +71 -0
- package/build/stories/utils/render-utils.js +41 -0
- package/build/stories/visual-tests/layouts/NotUsingListItem.story.js +17 -0
- package/build/test-utils/DynamicFlowWise.js +32 -0
- package/build/test-utils/DynamicFlowWiseModal.js +34 -0
- package/build/test-utils/NeptuneProviders.js +11 -0
- package/build/test-utils/component-utils.js +5 -0
- package/build/test-utils/fetch-utils.js +45 -0
- package/build/test-utils/getMergedTestRenderers.js +34 -0
- package/build/test-utils/getRandomId.js +1 -0
- package/build/test-utils/index.js +3 -0
- package/build/test-utils/rtl-utils.js +7 -0
- package/build/test-utils/step-utils.js +6 -0
- package/build/test-utils/wait.js +3 -0
- package/build/tests/AlertLayout.test.js +78 -0
- package/build/tests/ArrayTuple.test.js +118 -0
- package/build/tests/ButtonLayout.test.js +308 -0
- package/build/tests/ConstLayout.test.js +95 -0
- package/build/tests/DateInput.test.js +163 -0
- package/build/tests/DecisionLayout.test.js +146 -0
- package/build/tests/DynamicFlow.test.js +147 -0
- package/build/tests/External.test.js +169 -0
- package/build/tests/Flow.test.js +328 -0
- package/build/tests/FormLayout.test.js +28 -0
- package/build/tests/FormattedValue.test.js +107 -0
- package/build/tests/ImageRenderer.test.js +78 -0
- package/build/tests/InitialAction.test.js +179 -0
- package/build/tests/InitialStep.test.js +168 -0
- package/build/tests/InstructionsLayout.test.js +45 -0
- package/build/tests/ListLayout.test.js +145 -0
- package/build/tests/Logging.test.js +53 -0
- package/build/tests/ModalBehavior.test.js +149 -0
- package/build/tests/MoneyInput.test.js +316 -0
- package/build/tests/MultiUpload.test.js +293 -0
- package/build/tests/NativeBack.test.js +267 -0
- package/build/tests/OneOfInitialisation.test.js +571 -0
- package/build/tests/PersistAsync.test.js +653 -0
- package/build/tests/Polling.test.js +617 -0
- package/build/tests/Prefetching.test.js +230 -0
- package/build/tests/RefreshAfter.test.js +63 -0
- package/build/tests/RefreshOnChange.ResponseHandling.test.js +205 -0
- package/build/tests/RefreshOnChange.test.js +233 -0
- package/build/tests/RefreshOnChange.with.Segmented.test.js +348 -0
- package/build/tests/RefreshOnChange.with.Tabs.test.js +358 -0
- package/build/tests/RefreshOnChangePreserve.test.js +224 -0
- package/build/tests/RendererProps.test.js +342 -0
- package/build/tests/Repeatable.test.js +107 -0
- package/build/tests/Rerendering.test.js +67 -0
- package/build/tests/ReviewLayout.test.js +274 -0
- package/build/tests/SchemaOnChange.test.js +133 -0
- package/build/tests/ScrollToError.test.js +217 -0
- package/build/tests/SegmentedControl.test.js +49 -0
- package/build/tests/SingleFileUpload.test.js +88 -0
- package/build/tests/StatusList.test.js +85 -0
- package/build/tests/Subflow.test.js +710 -0
- package/build/tests/Submission.ResponseHandling.test.js +557 -0
- package/build/tests/Submission.merging.test.js +202 -0
- package/build/tests/Submission.test.js +523 -0
- package/build/tests/Tags.test.js +475 -0
- package/build/tests/Upsell.test.js +126 -0
- package/build/tests/ValidationAsync.test.js +295 -0
- package/build/tests/legacy/Actions.test.js +158 -0
- package/build/tests/legacy/BackButton.test.js +114 -0
- package/build/tests/legacy/HiddenSchemas.test.js +246 -0
- package/build/tests/legacy/MultiSelect.test.js +497 -0
- package/build/tests/legacy/MultipleFileUploadSchema.test.js +341 -0
- package/build/tests/legacy/PersistAsync.blob-schema.test.js +224 -0
- package/build/tests/legacy/PersistAsync.string-schema.test.js +211 -0
- package/build/tests/legacy/RefreshStepOnChange.debouncing.test.js +209 -0
- package/build/tests/legacy/RefreshStepOnChange.test.js +424 -0
- package/build/tests/legacy/Search.test.js +437 -0
- package/build/tests/renderers/MultiSelectInputRendererProps.test.js +58 -0
- package/build/tests/renderers/SelectInputRendererProps.test.js +42 -0
- package/build/tests/renderers/TextInputRenderer.test.js +51 -0
- package/build/types/domain/components/UpsellComponent.d.ts +2 -3
- package/build/types/domain/components/UpsellComponent.d.ts.map +1 -1
- package/build/types/domain/components/searchComponent/SearchComponent.d.ts +5 -4
- package/build/types/domain/components/searchComponent/SearchComponent.d.ts.map +1 -1
- package/build/types/domain/features/search/getPerformSearchFunction.d.ts +1 -1
- package/build/types/domain/features/search/getPerformSearchFunction.d.ts.map +1 -1
- package/build/types/domain/mappers/layout/searchLayoutToComponent.d.ts +2 -1
- package/build/types/domain/mappers/layout/searchLayoutToComponent.d.ts.map +1 -1
- package/build/types/domain/mappers/layout/upsellLayoutToComponent.d.ts +1 -1
- package/build/types/domain/mappers/layout/upsellLayoutToComponent.d.ts.map +1 -1
- package/build/types/renderers/EmptyLoadingStateRenderer.d.ts +3 -0
- package/build/types/renderers/EmptyLoadingStateRenderer.d.ts.map +1 -0
- package/build/types/renderers/mappers/rootComponentToProps.d.ts.map +1 -1
- package/build/types/renderers/mappers/searchComponentToProps.d.ts +1 -1
- package/build/types/renderers/mappers/searchComponentToProps.d.ts.map +1 -1
- package/build/types/renderers/mappers/upsellComponentToProps.d.ts +2 -2
- package/build/types/renderers/mappers/upsellComponentToProps.d.ts.map +1 -1
- package/build/types/test-utils/getMergedTestRenderers.d.ts +1 -1
- package/build/types/test-utils/getMergedTestRenderers.d.ts.map +1 -1
- package/build/types/useDynamicFlow.d.ts.map +1 -1
- package/build/types.js +1 -0
- package/build/useDynamicFlow.js +104 -0
- package/build/useDynamicFlowModal.js +58 -0
- package/build/utils/analyse-step.js +14 -0
- package/build/utils/component-utils.js +8 -0
- package/build/utils/component-utils.test.js +113 -0
- package/build/utils/getScrollToTop.js +12 -0
- package/build/utils/normalise-flow-id.js +1 -0
- package/build/utils/normalise-flow-id.test.js +24 -0
- package/build/utils/openLinkInNewTab.js +10 -0
- package/build/utils/recursiveMerge.js +40 -0
- package/build/utils/recursiveMerge.test.js +93 -0
- package/build/utils/type-utils.js +21 -0
- package/build/utils/type-validators.js +11 -0
- package/build/utils/type-validators.test.js +180 -0
- package/build/utils/useStableCallback.js +15 -0
- package/package.json +4 -4
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import { userEvent } from '@testing-library/user-event';
|
|
4
|
+
import { renderWithProviders, respondWith } from '../test-utils';
|
|
5
|
+
import DynamicFlowWise from '../test-utils/DynamicFlowWise';
|
|
6
|
+
import { isObject, isString } from '../utils/type-validators';
|
|
7
|
+
import { vi } from 'vitest';
|
|
8
|
+
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });
|
|
9
|
+
const getProps = () => ({
|
|
10
|
+
flowId: 'flow-id',
|
|
11
|
+
initialStep,
|
|
12
|
+
httpClient: vi.fn(async (input, init) => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const payload = JSON.parse((_b = (_a = init === null || init === void 0 ? void 0 : init.body) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : `{}`);
|
|
15
|
+
const currency = isObject(payload) && isString(payload.currency) ? payload.currency : 'GBP';
|
|
16
|
+
const step = steps[currency];
|
|
17
|
+
return respondWith(step);
|
|
18
|
+
}),
|
|
19
|
+
onCompletion: vi.fn(),
|
|
20
|
+
onError: vi.fn(),
|
|
21
|
+
onEvent: vi.fn(),
|
|
22
|
+
onLog: vi.fn(),
|
|
23
|
+
});
|
|
24
|
+
describe('RefreshOnChange with Tabs', () => {
|
|
25
|
+
describe('given a oneOf schema with refresh-on-change and the child schemas contain tabs', () => {
|
|
26
|
+
it('selects the fist tab by default', async () => {
|
|
27
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, getProps())));
|
|
28
|
+
await waitFor(() => {
|
|
29
|
+
expect(screen.getByText(initialStep.title)).toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
expect(screen.getByText('IBAN')).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
it('when configured, it does NOT trigger a refresh upon intitialisation', async () => {
|
|
34
|
+
const props = Object.assign(Object.assign({}, getProps()), { initialStep: steps.EUR_REFRESH });
|
|
35
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
36
|
+
await waitFor(() => {
|
|
37
|
+
expect(screen.getByText(initialStep.title)).toBeInTheDocument();
|
|
38
|
+
});
|
|
39
|
+
await waitFor(() => {
|
|
40
|
+
expect(props.httpClient).not.toHaveBeenCalled();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
it('selects the first tab by default, even after a refresh-on-change', async () => {
|
|
44
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, getProps())));
|
|
45
|
+
await waitFor(() => {
|
|
46
|
+
expect(screen.getByText(initialStep.title)).toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
await user.click(screen.getByText('EUR'));
|
|
49
|
+
await user.click(screen.getByText('GBP'));
|
|
50
|
+
await waitFor(() => {
|
|
51
|
+
expect(screen.getByText('UK sort code')).toBeInTheDocument();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
describe('when another value in the form has been entered and causes a refresh', () => {
|
|
55
|
+
it('selects the matching tab, not the first', async () => {
|
|
56
|
+
const mockHttpClient = vi.fn().mockImplementation(async (input, init) => respondWith(Object.assign(Object.assign({}, steps.GBP), { model: {
|
|
57
|
+
currency: 'GBP',
|
|
58
|
+
type: 'SwiftCode',
|
|
59
|
+
} })));
|
|
60
|
+
const props = Object.assign(Object.assign({}, getProps()), { initialStep: steps.GBP, httpClient: mockHttpClient });
|
|
61
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
62
|
+
await user.click(screen.getByText('SWIFT'));
|
|
63
|
+
await user.type(screen.getByText('SWIFT / BIC code'), '12345');
|
|
64
|
+
await user.click(screen.getByText('IBAN'));
|
|
65
|
+
await user.type(screen.getByText('Refresh Field'), 'some value');
|
|
66
|
+
await user.tab();
|
|
67
|
+
await waitFor(() => {
|
|
68
|
+
expect(mockHttpClient).toHaveBeenCalledTimes(1);
|
|
69
|
+
});
|
|
70
|
+
// we show the correct child content
|
|
71
|
+
await waitFor(() => {
|
|
72
|
+
expect(screen.getByText('SWIFT / BIC code')).toBeInTheDocument();
|
|
73
|
+
});
|
|
74
|
+
// the correct tab is shown to be selected
|
|
75
|
+
expect(screen.getByRole('tab', { name: 'SWIFT' })).toHaveAttribute('aria-selected', 'true');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
const currencyObjectSchema = {
|
|
81
|
+
type: 'object',
|
|
82
|
+
displayOrder: ['currency'],
|
|
83
|
+
properties: {
|
|
84
|
+
currency: {
|
|
85
|
+
title: 'Currency',
|
|
86
|
+
analyticsId: 'currency-select',
|
|
87
|
+
oneOf: [
|
|
88
|
+
{
|
|
89
|
+
title: 'EUR',
|
|
90
|
+
analyticsId: 'EUR',
|
|
91
|
+
icon: { name: 'flag-eur' },
|
|
92
|
+
description: 'Euro',
|
|
93
|
+
const: 'EUR',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
title: 'GBP',
|
|
97
|
+
analyticsId: 'GBP',
|
|
98
|
+
icon: { name: 'flag-gbp' },
|
|
99
|
+
description: 'British pound',
|
|
100
|
+
const: 'GBP',
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
refreshStepOnChange: true,
|
|
104
|
+
default: 'EUR',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
const getGBPStep = () => ({
|
|
109
|
+
id: 'account',
|
|
110
|
+
type: 'form',
|
|
111
|
+
title: 'Enter their account details',
|
|
112
|
+
actions: [
|
|
113
|
+
{
|
|
114
|
+
title: 'Confirm',
|
|
115
|
+
url: '/submit',
|
|
116
|
+
type: 'primary',
|
|
117
|
+
method: 'POST',
|
|
118
|
+
$id: 'submit',
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
schemas: [
|
|
122
|
+
{
|
|
123
|
+
allOf: [
|
|
124
|
+
currencyObjectSchema,
|
|
125
|
+
{
|
|
126
|
+
title: 'Bank details',
|
|
127
|
+
analyticsId: 'recipient-type',
|
|
128
|
+
oneOf: [
|
|
129
|
+
{
|
|
130
|
+
title: 'Local bank account',
|
|
131
|
+
type: 'object',
|
|
132
|
+
analyticsId: 'SortCode',
|
|
133
|
+
icon: { name: 'bank', type: 'icon' },
|
|
134
|
+
displayOrder: ['name', 'details', 'type'],
|
|
135
|
+
properties: {
|
|
136
|
+
name: {
|
|
137
|
+
title: 'Full name of the account holder',
|
|
138
|
+
type: 'string',
|
|
139
|
+
},
|
|
140
|
+
details: {
|
|
141
|
+
type: 'object',
|
|
142
|
+
displayOrder: ['sortCode', 'accountNumber'],
|
|
143
|
+
properties: {
|
|
144
|
+
sortCode: {
|
|
145
|
+
title: 'UK sort code',
|
|
146
|
+
type: 'string',
|
|
147
|
+
placeholder: '40-30-20',
|
|
148
|
+
format: 'numeric',
|
|
149
|
+
},
|
|
150
|
+
accountNumber: {
|
|
151
|
+
title: 'Account number',
|
|
152
|
+
type: 'string',
|
|
153
|
+
placeholder: '12345678',
|
|
154
|
+
format: 'numeric',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
type: {
|
|
159
|
+
const: 'SortCode',
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
title: 'IBAN',
|
|
165
|
+
type: 'object',
|
|
166
|
+
analyticsId: 'Iban',
|
|
167
|
+
icon: { name: 'bank', type: 'icon' },
|
|
168
|
+
displayOrder: ['name', 'details', 'type'],
|
|
169
|
+
properties: {
|
|
170
|
+
name: {
|
|
171
|
+
title: 'Full name of the account holder',
|
|
172
|
+
type: 'string',
|
|
173
|
+
},
|
|
174
|
+
details: {
|
|
175
|
+
type: 'object',
|
|
176
|
+
displayOrder: ['bic', 'iban'],
|
|
177
|
+
properties: {
|
|
178
|
+
bic: {
|
|
179
|
+
title: 'Bank code (BIC/SWIFT)',
|
|
180
|
+
type: 'string',
|
|
181
|
+
hidden: true,
|
|
182
|
+
placeholder: "Please choose recipient's bank",
|
|
183
|
+
},
|
|
184
|
+
iban: {
|
|
185
|
+
title: 'IBAN',
|
|
186
|
+
type: 'string',
|
|
187
|
+
placeholder: 'DE12345678901234567890',
|
|
188
|
+
displayFormat: '**** **** **** **** **** **** **** ****',
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
type: {
|
|
193
|
+
const: 'Iban',
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
title: 'SWIFT',
|
|
199
|
+
type: 'object',
|
|
200
|
+
analyticsId: 'SwiftCode',
|
|
201
|
+
icon: { name: 'bank', type: 'icon' },
|
|
202
|
+
displayOrder: ['name', 'details', 'type'],
|
|
203
|
+
properties: {
|
|
204
|
+
name: {
|
|
205
|
+
title: 'Full name of the account holder',
|
|
206
|
+
type: 'string',
|
|
207
|
+
},
|
|
208
|
+
details: {
|
|
209
|
+
type: 'object',
|
|
210
|
+
displayOrder: ['bic', 'accountNumber'],
|
|
211
|
+
properties: {
|
|
212
|
+
bic: {
|
|
213
|
+
title: 'SWIFT / BIC code',
|
|
214
|
+
type: 'string',
|
|
215
|
+
placeholder: 'BUKBGB22',
|
|
216
|
+
},
|
|
217
|
+
accountNumber: {
|
|
218
|
+
title: 'IBAN / Account number',
|
|
219
|
+
type: 'string',
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
type: {
|
|
224
|
+
const: 'SwiftCode',
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
control: 'tab',
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
$id: 'form',
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
$id: '#refresh',
|
|
236
|
+
type: 'string',
|
|
237
|
+
title: 'Refresh Field',
|
|
238
|
+
refreshStepOnChange: true,
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
refreshFormUrl: '/refresh',
|
|
242
|
+
model: {
|
|
243
|
+
currency: 'GBP',
|
|
244
|
+
details: {},
|
|
245
|
+
},
|
|
246
|
+
layout: [
|
|
247
|
+
{ schema: { $ref: 'form' }, type: 'form' },
|
|
248
|
+
{ schema: { $ref: '#refresh' }, type: 'form' },
|
|
249
|
+
{ type: 'button', action: { $ref: 'submit' } },
|
|
250
|
+
],
|
|
251
|
+
});
|
|
252
|
+
const getEURStep = (refreshable) => ({
|
|
253
|
+
id: 'account',
|
|
254
|
+
type: 'form',
|
|
255
|
+
title: 'Enter their account details',
|
|
256
|
+
actions: [
|
|
257
|
+
{
|
|
258
|
+
title: 'Confirm',
|
|
259
|
+
url: '/submit',
|
|
260
|
+
type: 'primary',
|
|
261
|
+
method: 'POST',
|
|
262
|
+
$id: 'submit',
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
schemas: [
|
|
266
|
+
{
|
|
267
|
+
allOf: [
|
|
268
|
+
currencyObjectSchema,
|
|
269
|
+
Object.assign(Object.assign({ title: 'Bank details', analyticsId: 'recipient-type' }, (refreshable ? { refreshStepOnChange: true } : {})), { oneOf: [
|
|
270
|
+
{
|
|
271
|
+
title: 'Inside Europe',
|
|
272
|
+
type: 'object',
|
|
273
|
+
analyticsId: 'Iban',
|
|
274
|
+
icon: { name: 'bank', type: 'icon' },
|
|
275
|
+
displayOrder: ['name', 'details', 'type'],
|
|
276
|
+
properties: {
|
|
277
|
+
name: {
|
|
278
|
+
title: 'Full name of the account holder',
|
|
279
|
+
type: 'string',
|
|
280
|
+
},
|
|
281
|
+
details: {
|
|
282
|
+
type: 'object',
|
|
283
|
+
displayOrder: ['bic', 'iban'],
|
|
284
|
+
properties: {
|
|
285
|
+
bic: {
|
|
286
|
+
title: 'Bank code (BIC/SWIFT)',
|
|
287
|
+
type: 'string',
|
|
288
|
+
hidden: true,
|
|
289
|
+
placeholder: 'BARCGB22XXX',
|
|
290
|
+
},
|
|
291
|
+
iban: {
|
|
292
|
+
title: 'IBAN',
|
|
293
|
+
type: 'string',
|
|
294
|
+
placeholder: 'DE12345678901234567890',
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
type: {
|
|
299
|
+
const: 'Iban',
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
required: ['type', 'name', 'details'],
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
title: 'Outside Europe',
|
|
306
|
+
type: 'object',
|
|
307
|
+
analyticsId: 'SwiftCode',
|
|
308
|
+
icon: { name: 'bank', type: 'icon' },
|
|
309
|
+
displayOrder: ['name', 'details', 'type'],
|
|
310
|
+
properties: {
|
|
311
|
+
name: {
|
|
312
|
+
title: 'Full name of the account holder',
|
|
313
|
+
type: 'string',
|
|
314
|
+
},
|
|
315
|
+
details: {
|
|
316
|
+
type: 'object',
|
|
317
|
+
displayOrder: ['bic', 'accountNumber'],
|
|
318
|
+
properties: {
|
|
319
|
+
bic: {
|
|
320
|
+
title: 'SWIFT / BIC code',
|
|
321
|
+
type: 'string',
|
|
322
|
+
placeholder: 'BUKBGB22',
|
|
323
|
+
},
|
|
324
|
+
accountNumber: {
|
|
325
|
+
title: 'IBAN / Account number',
|
|
326
|
+
type: 'string',
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
required: ['bic', 'accountNumber'],
|
|
330
|
+
},
|
|
331
|
+
type: {
|
|
332
|
+
const: 'SwiftCode',
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
required: ['type', 'name', 'details'],
|
|
336
|
+
},
|
|
337
|
+
], control: 'tab', placeholder: 'Please select where you are sending to' }),
|
|
338
|
+
],
|
|
339
|
+
$id: 'form',
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
refreshFormUrl: '/refresh',
|
|
343
|
+
model: {
|
|
344
|
+
currency: 'EUR',
|
|
345
|
+
type: 'Iban',
|
|
346
|
+
details: {},
|
|
347
|
+
},
|
|
348
|
+
layout: [
|
|
349
|
+
{ schema: { $ref: 'form' }, type: 'form' },
|
|
350
|
+
{ type: 'button', action: { $ref: 'submit' } },
|
|
351
|
+
],
|
|
352
|
+
});
|
|
353
|
+
const steps = {
|
|
354
|
+
GBP: getGBPStep(),
|
|
355
|
+
EUR: getEURStep(false),
|
|
356
|
+
EUR_REFRESH: getEURStep(true),
|
|
357
|
+
};
|
|
358
|
+
const initialStep = steps.EUR;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import { userEvent } from '@testing-library/user-event';
|
|
4
|
+
import { renderWithProviders, respondWith } from '../test-utils';
|
|
5
|
+
import { abortableDelay } from '../test-utils/fetch-utils';
|
|
6
|
+
import DynamicFlowWise from '../test-utils/DynamicFlowWise';
|
|
7
|
+
import { vi } from 'vitest';
|
|
8
|
+
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });
|
|
9
|
+
const getProps = () => ({
|
|
10
|
+
flowId: 'flow-id',
|
|
11
|
+
onCompletion: vi.fn(),
|
|
12
|
+
onError: vi.fn(),
|
|
13
|
+
onEvent: vi.fn(),
|
|
14
|
+
onLog: vi.fn(),
|
|
15
|
+
});
|
|
16
|
+
const initialSchema = {
|
|
17
|
+
$id: '#schema',
|
|
18
|
+
type: 'object',
|
|
19
|
+
displayOrder: ['name', 'card'],
|
|
20
|
+
properties: {
|
|
21
|
+
name: { title: 'Name', type: 'string', refreshStepOnChange: true },
|
|
22
|
+
card: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
persistAsync: {
|
|
25
|
+
url: '/persist-card',
|
|
26
|
+
method: 'POST',
|
|
27
|
+
param: 'card',
|
|
28
|
+
idProperty: 'token',
|
|
29
|
+
schema: { type: 'string', title: 'Card Number' },
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const submitButton = {
|
|
35
|
+
type: 'button',
|
|
36
|
+
title: 'Submit',
|
|
37
|
+
action: { url: '/submit' },
|
|
38
|
+
};
|
|
39
|
+
const getStep = (schema, overrides) => {
|
|
40
|
+
var _a;
|
|
41
|
+
return (Object.assign({ id: 'step-id', title: 'Initial Step Title', schemas: [schema], layout: [
|
|
42
|
+
{
|
|
43
|
+
type: 'form',
|
|
44
|
+
schemaId: (_a = schema.$id) !== null && _a !== void 0 ? _a : '',
|
|
45
|
+
},
|
|
46
|
+
submitButton,
|
|
47
|
+
], refreshUrl: '/refresh' }, overrides));
|
|
48
|
+
};
|
|
49
|
+
const finalStep = {
|
|
50
|
+
id: 'final-step',
|
|
51
|
+
title: 'Final Step Title',
|
|
52
|
+
layout: [],
|
|
53
|
+
schemas: [],
|
|
54
|
+
};
|
|
55
|
+
describe('Refresh On Change Preserve', () => {
|
|
56
|
+
describe('When the schema contains a persisted field, and something else refreshes the step', () => {
|
|
57
|
+
var _a;
|
|
58
|
+
const cases = [
|
|
59
|
+
[
|
|
60
|
+
'Case 1: refresh on change without altering the schema or layout',
|
|
61
|
+
getStep(initialSchema),
|
|
62
|
+
getStep(initialSchema, {
|
|
63
|
+
title: 'Refreshed Step Title',
|
|
64
|
+
model: { name: 'John', card: 'TOKEN' },
|
|
65
|
+
}),
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
'Case 2: refresh on change with altered layout',
|
|
69
|
+
getStep(initialSchema),
|
|
70
|
+
getStep(initialSchema, {
|
|
71
|
+
title: 'Refreshed Step Title',
|
|
72
|
+
layout: [
|
|
73
|
+
{
|
|
74
|
+
type: 'paragraph',
|
|
75
|
+
text: 'The step has been refreshed',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: 'form',
|
|
79
|
+
schemaId: (_a = initialSchema.$id) !== null && _a !== void 0 ? _a : '',
|
|
80
|
+
},
|
|
81
|
+
submitButton,
|
|
82
|
+
],
|
|
83
|
+
model: { name: 'John', card: 'TOKEN' },
|
|
84
|
+
}),
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
'Case 3: refresh on change without the model for the persisted field',
|
|
88
|
+
getStep(initialSchema),
|
|
89
|
+
getStep(initialSchema, {
|
|
90
|
+
title: 'Refreshed Step Title',
|
|
91
|
+
model: { name: 'John' },
|
|
92
|
+
}),
|
|
93
|
+
],
|
|
94
|
+
];
|
|
95
|
+
describe.each(cases)('%s', (_, initialStep, refreshedStep) => {
|
|
96
|
+
it('should preserve the value of the persisted field', async () => {
|
|
97
|
+
const httpClient = vi.fn().mockImplementation(async (input, init) => {
|
|
98
|
+
var _a;
|
|
99
|
+
await abortableDelay(1, (_a = init === null || init === void 0 ? void 0 : init.signal) !== null && _a !== void 0 ? _a : null);
|
|
100
|
+
switch (input) {
|
|
101
|
+
case '/persist-card':
|
|
102
|
+
return respondWith({ token: 'TOKEN' });
|
|
103
|
+
case '/refresh':
|
|
104
|
+
return respondWith(refreshedStep);
|
|
105
|
+
case '/submit':
|
|
106
|
+
return respondWith(finalStep);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, getProps(), { initialStep: initialStep, httpClient: httpClient })));
|
|
110
|
+
await waitFor(() => {
|
|
111
|
+
expect(screen.getByText('Initial Step Title')).toBeInTheDocument();
|
|
112
|
+
});
|
|
113
|
+
const button = screen.getByRole('button', { name: 'Submit' });
|
|
114
|
+
await user.type(screen.getByLabelText('Card Number'), '1234 2345 3456 4567');
|
|
115
|
+
await user.tab();
|
|
116
|
+
await user.type(screen.getByLabelText('Name'), 'John');
|
|
117
|
+
await waitFor(() => {
|
|
118
|
+
expect(button).toBeDisabled();
|
|
119
|
+
});
|
|
120
|
+
await waitFor(() => {
|
|
121
|
+
expect(screen.getByText('Refreshed Step Title')).toBeInTheDocument();
|
|
122
|
+
});
|
|
123
|
+
await waitFor(() => {
|
|
124
|
+
expect(screen.getByRole('button', { name: 'Submit' })).toBeEnabled();
|
|
125
|
+
});
|
|
126
|
+
expect(screen.getByLabelText('Card Number')).toHaveValue('1234 2345 3456 4567');
|
|
127
|
+
await user.click(screen.getByRole('button', { name: 'Submit' }));
|
|
128
|
+
await waitFor(() => {
|
|
129
|
+
expect(httpClient).toHaveBeenLastCalledWith('/submit', expect.objectContaining({ body: '{"name":"John","card":"TOKEN"}' }));
|
|
130
|
+
});
|
|
131
|
+
await waitFor(() => {
|
|
132
|
+
expect(screen.getByText('Final Step Title')).toBeInTheDocument();
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
describe('Given a base64url string schema', () => {
|
|
138
|
+
const initialStep = {
|
|
139
|
+
id: 'initial-step',
|
|
140
|
+
title: 'Initial Step Title',
|
|
141
|
+
layout: [
|
|
142
|
+
{
|
|
143
|
+
type: 'form',
|
|
144
|
+
schemaId: '#schema',
|
|
145
|
+
},
|
|
146
|
+
submitButton,
|
|
147
|
+
],
|
|
148
|
+
schemas: [
|
|
149
|
+
{
|
|
150
|
+
$id: '#schema',
|
|
151
|
+
type: 'object',
|
|
152
|
+
displayOrder: ['file', 'tnc'],
|
|
153
|
+
properties: {
|
|
154
|
+
file: {
|
|
155
|
+
type: 'string',
|
|
156
|
+
format: 'base64url',
|
|
157
|
+
title: 'Upload a file',
|
|
158
|
+
},
|
|
159
|
+
tnc: {
|
|
160
|
+
type: 'boolean',
|
|
161
|
+
title: 'I agree to the terms and conditions',
|
|
162
|
+
refreshStepOnChange: true,
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
refreshUrl: '/refresh',
|
|
168
|
+
};
|
|
169
|
+
const expectedBase64url = 'data:image/png;base64,Zm9v';
|
|
170
|
+
describe('When a base64url string schema has a value and the step is refreshed', () => {
|
|
171
|
+
const file = new File(['foo'], 'passport.png', { type: 'image/png' });
|
|
172
|
+
const refreshedStep = Object.assign(Object.assign({}, initialStep), { title: 'Refreshed Step Title', model: { file: expectedBase64url, tnc: true } });
|
|
173
|
+
const httpClient = vi.fn().mockImplementation(async (input, init) => {
|
|
174
|
+
var _a;
|
|
175
|
+
await abortableDelay(1, (_a = init === null || init === void 0 ? void 0 : init.signal) !== null && _a !== void 0 ? _a : null);
|
|
176
|
+
switch (input) {
|
|
177
|
+
case '/initial':
|
|
178
|
+
return respondWith(initialStep);
|
|
179
|
+
case '/refresh':
|
|
180
|
+
return respondWith(refreshedStep);
|
|
181
|
+
case '/submit':
|
|
182
|
+
return respondWith(finalStep);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
it('should preserve the value of the persisted field', async () => {
|
|
186
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, getProps(), { initialAction: { url: '/initial' }, httpClient: httpClient })));
|
|
187
|
+
await waitFor(() => {
|
|
188
|
+
expect(screen.getByText('Initial Step Title')).toBeInTheDocument();
|
|
189
|
+
});
|
|
190
|
+
await user.upload(screen.getByTestId('uploadInput'), file);
|
|
191
|
+
await user.click(screen.getByLabelText('I agree to the terms and conditions'));
|
|
192
|
+
await waitFor(() => {
|
|
193
|
+
expect(httpClient).toHaveBeenLastCalledWith('/refresh', expect.objectContaining({ body: `{"file":"${expectedBase64url}","tnc":true}` }));
|
|
194
|
+
});
|
|
195
|
+
await waitFor(() => {
|
|
196
|
+
expect(screen.getByText('Refreshed Step Title')).toBeInTheDocument();
|
|
197
|
+
});
|
|
198
|
+
// refresh a second time
|
|
199
|
+
await user.click(screen.getByLabelText('I agree to the terms and conditions'));
|
|
200
|
+
await waitFor(() => {
|
|
201
|
+
expect(httpClient).toHaveBeenLastCalledWith('/refresh', expect.objectContaining({ body: `{"file":"${expectedBase64url}","tnc":false}` }));
|
|
202
|
+
});
|
|
203
|
+
await user.click(screen.getByRole('button', { name: 'Submit' }));
|
|
204
|
+
await waitFor(() => {
|
|
205
|
+
expect(httpClient).toHaveBeenLastCalledWith('/submit', expect.objectContaining({ body: `{"file":"${expectedBase64url}","tnc":true}` }));
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
describe('When a base64url string schema has a step.model value and the step is submitted', () => {
|
|
210
|
+
it('should submit the base64url string value', async () => {
|
|
211
|
+
const step = Object.assign(Object.assign({}, initialStep), { title: 'Step Title', model: { file: expectedBase64url } });
|
|
212
|
+
const httpClient = vi.fn();
|
|
213
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, getProps(), { initialStep: step, httpClient: httpClient })));
|
|
214
|
+
await waitFor(() => {
|
|
215
|
+
expect(screen.getByText('Step Title')).toBeInTheDocument();
|
|
216
|
+
});
|
|
217
|
+
await user.click(screen.getByRole('button', { name: 'Submit' }));
|
|
218
|
+
await waitFor(() => {
|
|
219
|
+
expect(httpClient).toHaveBeenLastCalledWith('/submit', expect.objectContaining({ body: `{"file":"${expectedBase64url}","tnc":false}` }));
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
});
|