@wise/dynamic-flow-client 5.9.1 → 5.9.2-logging-bf0bd22
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/main.js +7 -1
- package/build/main.mjs +7 -1
- package/package.json +9 -8
- package/build/DynamicFlowCore.js +0 -5
- package/build/common/errorBoundary/ErrorBoundary.js +0 -26
- package/build/common/errorBoundary/ErrorBoundary.test.js +0 -29
- package/build/common/errorBoundary/ErrorBoundaryAlert.js +0 -11
- package/build/common/makeHttpClient/api-utils.js +0 -3
- package/build/common/makeHttpClient/index.js +0 -1
- package/build/common/makeHttpClient/makeHttpClient.js +0 -10
- package/build/common/makeHttpClient/makeHttpClient.test.js +0 -186
- package/build/common/messages/external-confirmation.messages.js +0 -23
- package/build/common/messages/file-upload.messages.js +0 -13
- package/build/common/messages/generic-error.messages.js +0 -18
- package/build/common/messages/help.messages.js +0 -8
- package/build/common/messages/multi-file-upload.messages.js +0 -18
- package/build/common/messages/multi-select.messages.js +0 -8
- package/build/common/messages/paragraph.messages.js +0 -13
- package/build/common/messages/repeatable.messages.js +0 -23
- package/build/common/messages/search.messages.js +0 -8
- package/build/common/messages/validation.array.messages.js +0 -13
- package/build/common/messages/validation.messages.js +0 -53
- package/build/controller/FlowController.js +0 -368
- package/build/controller/executePoll.js +0 -49
- package/build/controller/executeRefresh.js +0 -39
- package/build/controller/executeRequest.js +0 -77
- package/build/controller/executeSubmission.js +0 -69
- package/build/controller/getErrorMessage.js +0 -7
- package/build/controller/getRequestAbortController.js +0 -13
- package/build/controller/getResponseType.js +0 -35
- package/build/controller/getSafeHttpClient.js +0 -8
- package/build/controller/getStepCounter.js +0 -16
- package/build/controller/handleErrorResponse.js +0 -26
- package/build/controller/makeSafeHttpClient.js +0 -8
- package/build/controller/response-utils.js +0 -72
- package/build/domain/components/AlertComponent.js +0 -1
- package/build/domain/components/AllOfComponent.js +0 -40
- package/build/domain/components/BooleanInputComponent.js +0 -50
- package/build/domain/components/BoxComponent.js +0 -3
- package/build/domain/components/ButtonComponent.js +0 -1
- package/build/domain/components/ColumnsComponent.js +0 -3
- package/build/domain/components/ConstComponent.js +0 -18
- package/build/domain/components/ContainerComponent.js +0 -3
- package/build/domain/components/DateInputComponent.js +0 -75
- package/build/domain/components/DecisionComponent.js +0 -1
- package/build/domain/components/DividerComponent.js +0 -1
- package/build/domain/components/FormComponent.js +0 -3
- package/build/domain/components/FormattedValueComponent.js +0 -44
- package/build/domain/components/HeadingComponent.js +0 -1
- package/build/domain/components/ImageComponent.js +0 -1
- package/build/domain/components/InstructionsComponent.js +0 -1
- package/build/domain/components/IntegerInputComponent.js +0 -74
- package/build/domain/components/ListComponent.js +0 -1
- package/build/domain/components/LoadingIndicatorComponent.js +0 -1
- package/build/domain/components/MarkdownComponent.js +0 -1
- package/build/domain/components/MediaComponent.js +0 -1
- package/build/domain/components/ModalComponent.js +0 -16
- package/build/domain/components/ModalLayoutComponent.js +0 -3
- package/build/domain/components/MoneyInputComponent.js +0 -57
- package/build/domain/components/MultiSelectInputComponent.js +0 -81
- package/build/domain/components/MultiUploadInputComponent.js +0 -88
- package/build/domain/components/NumberInputComponent.js +0 -73
- package/build/domain/components/ObjectComponent.js +0 -45
- package/build/domain/components/ParagraphComponent.js +0 -1
- package/build/domain/components/PersistAsyncComponent.js +0 -92
- package/build/domain/components/ProgressComponent.js +0 -1
- package/build/domain/components/RepeatableComponent.js +0 -103
- package/build/domain/components/ReviewComponent.js +0 -1
- package/build/domain/components/RootDomainComponent.js +0 -173
- package/build/domain/components/SectionComponent.js +0 -5
- package/build/domain/components/SelectInputComponent.js +0 -88
- package/build/domain/components/StatusListComponent.js +0 -1
- package/build/domain/components/SubflowDomainComponent.js +0 -9
- package/build/domain/components/TabsComponent.js +0 -1
- package/build/domain/components/TextInputComponent.js +0 -76
- package/build/domain/components/TupleComponent.js +0 -41
- package/build/domain/components/UploadInputComponent.js +0 -83
- package/build/domain/components/UpsellComponent.js +0 -25
- package/build/domain/components/searchComponent/SearchComponent.js +0 -92
- package/build/domain/components/searchComponent/SearchComponent.test.js +0 -190
- package/build/domain/components/step/ExternalConfirmationComponent.js +0 -28
- package/build/domain/components/step/StepDomainComponent.js +0 -78
- package/build/domain/components/step/ToolbarComponent.js +0 -1
- package/build/domain/components/utils/WithUpdate.js +0 -1
- package/build/domain/components/utils/component-utils.js +0 -12
- package/build/domain/components/utils/debounce.js +0 -34
- package/build/domain/components/utils/debounce.test.js +0 -67
- package/build/domain/components/utils/file-utils.js +0 -21
- package/build/domain/components/utils/file-utils.test.js +0 -27
- package/build/domain/components/utils/getRandomId.js +0 -1
- package/build/domain/components/utils/isExactLocalValueMatch.js +0 -14
- package/build/domain/components/utils/isOrWasValid.js +0 -5
- package/build/domain/components/utils/isPartialModelMatch.js +0 -18
- package/build/domain/components/utils/isPartialModelMatch.test.js +0 -74
- package/build/domain/features/eventNames.js +0 -24
- package/build/domain/features/events.js +0 -1
- package/build/domain/features/persistAsync/getComponentMultiPersistAsync.js +0 -50
- package/build/domain/features/persistAsync/getInitialPersistedState.js +0 -7
- package/build/domain/features/persistAsync/getPerformPersistAsync.js +0 -43
- package/build/domain/features/persistAsync/getPerformPersistAsync.test.js +0 -139
- package/build/domain/features/polling/getStepPolling.js +0 -43
- package/build/domain/features/polling/getStepPolling.test.js +0 -90
- package/build/domain/features/prefetch/getStepPrefetch.js +0 -43
- package/build/domain/features/prefetch/request-cache.js +0 -49
- package/build/domain/features/prefetch/request-cache.test.js +0 -70
- package/build/domain/features/refreshAfter/getStepRefreshAfter.js +0 -24
- package/build/domain/features/refreshAfter/getStepRefreshAfter.test.js +0 -40
- package/build/domain/features/schema-on-change/getDebouncedSchemaOnChange.js +0 -50
- package/build/domain/features/schema-on-change/getSchemaOnChange.js +0 -34
- package/build/domain/features/search/getPerformSearchFunction.js +0 -75
- package/build/domain/features/search/getPerformSearchFunction.test.js +0 -301
- package/build/domain/features/summary/summary-utils.js +0 -40
- package/build/domain/features/summary/summary-utils.test.js +0 -125
- package/build/domain/features/utils/http-utils.js +0 -21
- package/build/domain/features/utils/response-utils.js +0 -9
- package/build/domain/features/validation/spec-utils.js +0 -19
- package/build/domain/features/validation/validateStringPattern.js +0 -24
- package/build/domain/features/validation/validation-functions.js +0 -6
- package/build/domain/features/validation/validation-functions.test.js +0 -108
- package/build/domain/features/validation/value-checks.js +0 -125
- package/build/domain/features/validation/value-checks.test.js +0 -262
- package/build/domain/features/validationAsync/getComponentValidationAsync.js +0 -53
- package/build/domain/features/validationAsync/getComponentValidationAsync.test.js +0 -67
- package/build/domain/features/validationAsync/getInitialValidationAsyncState.js +0 -5
- package/build/domain/features/validationAsync/getPerformValidationAsync.js +0 -45
- package/build/domain/features/validationAsync/getPerformValidationAsync.test.js +0 -143
- package/build/domain/mappers/layout/alertLayoutToComponent.js +0 -16
- package/build/domain/mappers/layout/boxLayoutToComponent.js +0 -13
- package/build/domain/mappers/layout/buttonLayoutToComponent.js +0 -77
- package/build/domain/mappers/layout/columnsLayoutToComponent.js +0 -13
- package/build/domain/mappers/layout/decisionLayoutToComponent.js +0 -22
- package/build/domain/mappers/layout/deprecatedListLayoutToComponent.js +0 -30
- package/build/domain/mappers/layout/dividerLayoutToComponent.js +0 -2
- package/build/domain/mappers/layout/formLayoutToComponent.js +0 -19
- package/build/domain/mappers/layout/headingLayoutToComponent.js +0 -12
- package/build/domain/mappers/layout/imageLayoutToComponent.js +0 -20
- package/build/domain/mappers/layout/infoLayoutToComponent.js +0 -12
- package/build/domain/mappers/layout/instructionsLayoutToComponent.js +0 -12
- package/build/domain/mappers/layout/listLayoutToComponent.js +0 -39
- package/build/domain/mappers/layout/loadingIndicatorLayoutToComponent.js +0 -9
- package/build/domain/mappers/layout/markdownLayoutToComponent.js +0 -12
- package/build/domain/mappers/layout/mediaLayoutToComponent.js +0 -12
- package/build/domain/mappers/layout/modalLayoutToComponent.js +0 -17
- package/build/domain/mappers/layout/modalToComponent.js +0 -8
- package/build/domain/mappers/layout/paragraphLayoutToComponent.js +0 -12
- package/build/domain/mappers/layout/progressLayoutToComponent.js +0 -15
- package/build/domain/mappers/layout/reviewLayoutToComponent.js +0 -48
- package/build/domain/mappers/layout/searchLayoutToComponent.js +0 -44
- package/build/domain/mappers/layout/sectionLayoutToComponent.js +0 -15
- package/build/domain/mappers/layout/statusListLayoutToComponent.js +0 -15
- package/build/domain/mappers/layout/tabsLayoutToComponent.js +0 -16
- package/build/domain/mappers/layout/upsellLayoutToComponent.js +0 -25
- package/build/domain/mappers/mapLayoutToComponent.js +0 -81
- package/build/domain/mappers/mapSchemaToComponent.js +0 -61
- package/build/domain/mappers/mapSchemaToComponent.test.js +0 -112
- package/build/domain/mappers/mapStepSchemas.js +0 -15
- package/build/domain/mappers/mapStepToComponent.js +0 -133
- package/build/domain/mappers/mapStepToComponent.test.js +0 -221
- package/build/domain/mappers/mapToolbarToComponent.js +0 -15
- package/build/domain/mappers/schema/allOfSchemaToComponent.js +0 -16
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.js +0 -26
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiSelectComponent.js +0 -55
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiUploadComponent.js +0 -67
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.js +0 -57
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToTupleComponent.js +0 -20
- package/build/domain/mappers/schema/blobSchemaToComponent.js +0 -15
- package/build/domain/mappers/schema/booleanSchemaToComponent.js +0 -29
- package/build/domain/mappers/schema/constSchemaToComponent.js +0 -23
- package/build/domain/mappers/schema/integerSchemaToComponent.js +0 -28
- package/build/domain/mappers/schema/numberSchemaToComponent.js +0 -26
- package/build/domain/mappers/schema/objectSchemaToComponent/assertDisplayOrder.js +0 -23
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToFormattedValueComponent.js +0 -9
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToMoneyInputComponent.js +0 -119
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToMoneyInputComponent.test.js +0 -96
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToObjectComponent.js +0 -31
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToObjectComponent.test.js +0 -99
- package/build/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.js +0 -66
- package/build/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.test.js +0 -225
- package/build/domain/mappers/schema/persistAsyncSchemaToComponent.js +0 -29
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.js +0 -18
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.test.js +0 -133
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.js +0 -48
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToTextInputComponent.js +0 -37
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.js +0 -28
- package/build/domain/mappers/schema/tests/test-utils.js +0 -16
- package/build/domain/mappers/schema/types.js +0 -1
- package/build/domain/mappers/schema/utils/getPerformPersistAsyncFn.js +0 -19
- package/build/domain/mappers/schema/utils/getValidationAsyncInitialState.js +0 -23
- package/build/domain/mappers/schema/utils/mapCommonSchemaProps.js +0 -16
- package/build/domain/mappers/types.js +0 -1
- package/build/domain/mappers/utils/FeatureFlags.js +0 -22
- package/build/domain/mappers/utils/behavior-utils.js +0 -44
- package/build/domain/mappers/utils/call-to-action-utils.js +0 -21
- package/build/domain/mappers/utils/getAutocompleteString.js +0 -76
- package/build/domain/mappers/utils/getAutocompleteString.test.js +0 -21
- package/build/domain/mappers/utils/groupLayoutByPinned.js +0 -38
- package/build/domain/mappers/utils/groupLayoutByPinned.test.js +0 -166
- package/build/domain/mappers/utils/image.js +0 -9
- package/build/domain/mappers/utils/layout-utils.js +0 -11
- package/build/domain/mappers/utils/legacy-utils.js +0 -49
- package/build/domain/mappers/utils/media-utils.js +0 -14
- package/build/domain/mappers/utils/suggestions-utils.js +0 -26
- package/build/domain/mappers/utils/suggestions-utils.test.js +0 -36
- package/build/domain/mappers/utils/tags-utils.js +0 -1
- package/build/domain/mappers/utils/utils.js +0 -35
- package/build/domain/types.js +0 -1
- package/build/getSubflowCallbacks.js +0 -38
- package/build/i18n/index.js +0 -40
- package/build/index.js +0 -8
- package/build/renderers/CoreContainerRenderer.js +0 -5
- package/build/renderers/CoreRootRenderer.js +0 -12
- package/build/renderers/EmptyLoadingStateRenderer.js +0 -5
- package/build/renderers/getRenderFunction.js +0 -24
- package/build/renderers/getSchemaErrorMessageFunction.js +0 -97
- package/build/renderers/mappers/alertComponentToProps.js +0 -2
- package/build/renderers/mappers/allOfComponentToProps.js +0 -6
- package/build/renderers/mappers/booleanInputComponentToProps.js +0 -5
- package/build/renderers/mappers/boxComponentToProps.js +0 -13
- package/build/renderers/mappers/buttonComponentToProps.js +0 -4
- package/build/renderers/mappers/columnsComponentToProps.js +0 -11
- package/build/renderers/mappers/componentToRendererProps.js +0 -164
- package/build/renderers/mappers/constComponentToProps.js +0 -5
- package/build/renderers/mappers/containerComponentToProps.js +0 -7
- package/build/renderers/mappers/dateInputComponentToProps.js +0 -2
- package/build/renderers/mappers/decisionComponentToProps.js +0 -16
- package/build/renderers/mappers/dividerComponentToProps.js +0 -2
- package/build/renderers/mappers/externalComponentToProps.js +0 -3
- package/build/renderers/mappers/formComponentToProps.js +0 -12
- package/build/renderers/mappers/formattedValueComponentToProps.js +0 -5
- package/build/renderers/mappers/headingComponentToProps.js +0 -2
- package/build/renderers/mappers/hiddenComponentToProps.js +0 -4
- package/build/renderers/mappers/imageComponentToProps.js +0 -2
- package/build/renderers/mappers/instructionsComponentToProps.js +0 -2
- package/build/renderers/mappers/integerInputComponentToProps.js +0 -2
- package/build/renderers/mappers/listComponentToProps.js +0 -2
- package/build/renderers/mappers/loadingIndicatorComponentToProps.js +0 -2
- package/build/renderers/mappers/markdownComponentToProps.js +0 -2
- package/build/renderers/mappers/mediaComponentToProps.js +0 -2
- package/build/renderers/mappers/modalComponentToProps.js +0 -11
- package/build/renderers/mappers/modalLayoutComponentToProps.js +0 -16
- package/build/renderers/mappers/moneyInputComponentToProps.js +0 -36
- package/build/renderers/mappers/multiSelectComponentToProps.js +0 -23
- package/build/renderers/mappers/multiUploadInputComponentToProps.js +0 -12
- package/build/renderers/mappers/numberInputComponentToProps.js +0 -2
- package/build/renderers/mappers/objectComponentToProps.js +0 -8
- package/build/renderers/mappers/paragraphComponentToProps.js +0 -2
- package/build/renderers/mappers/persistAsyncComponentToProps.js +0 -8
- package/build/renderers/mappers/progressComponentToProps.js +0 -2
- package/build/renderers/mappers/repeatableComponentToProps.js +0 -30
- package/build/renderers/mappers/reviewComponentToProps.js +0 -2
- package/build/renderers/mappers/rootComponentToProps.js +0 -21
- package/build/renderers/mappers/searchComponentToProps.js +0 -57
- package/build/renderers/mappers/sectionComponentToProps.js +0 -6
- package/build/renderers/mappers/selectInputComponentToProps.js +0 -34
- package/build/renderers/mappers/statusListComponentToProps.js +0 -2
- package/build/renderers/mappers/subflowComponentToRendererProps.js +0 -4
- package/build/renderers/mappers/tabsComponentToProps.js +0 -14
- package/build/renderers/mappers/textInputComponentToProps.js +0 -2
- package/build/renderers/mappers/tupleComponentToProps.js +0 -8
- package/build/renderers/mappers/uploadInputComponentToProps.js +0 -8
- package/build/renderers/mappers/upsellComponentToProps.js +0 -2
- package/build/renderers/mappers/utils/getValidationState.js +0 -12
- package/build/renderers/mappers/utils/inputComponentToProps.js +0 -26
- package/build/renderers/mappers/utils/mapErrorsToValidationState.js +0 -9
- package/build/renderers/mappers/utils/pick.js +0 -8
- package/build/renderers/mappers/utils/selectInputOptionsToProps.js +0 -11
- package/build/renderers/stepComponentToProps.js +0 -32
- package/build/renderers/utils.js +0 -69
- package/build/renderers/utils.test.js +0 -70
- package/build/stories/dev-tools/ContainerQueries.story.js +0 -66
- package/build/stories/dev-tools/Debugger.story.js +0 -38
- package/build/stories/dev-tools/FixtureSelect.story.js +0 -23
- package/build/stories/dev-tools/TestServer.story.js +0 -32
- package/build/stories/examples/NativeFlow.story.js +0 -80
- package/build/stories/examples/Recipients.story.js +0 -568
- package/build/stories/spec/behavior/Copy.story.js +0 -59
- package/build/stories/spec/behavior/Modal.story.js +0 -76
- package/build/stories/spec/behavior/Subflow.story.js +0 -267
- package/build/stories/spec/layouts/Decision.story.js +0 -241
- package/build/stories/spec/layouts/Image.story.js +0 -42
- package/build/stories/spec/layouts/Modal.story.js +0 -81
- package/build/stories/spec/layouts/Search.story.js +0 -325
- package/build/stories/spec/layouts/Upsell.story.js +0 -55
- package/build/stories/spec/layouts/button/Button.story.js +0 -100
- package/build/stories/spec/layouts/button/PinnedButton.story.js +0 -81
- package/build/stories/spec/response/ActionResponse.story.js +0 -66
- package/build/stories/spec/schemas/MultiSelect.story.js +0 -148
- package/build/stories/spec/schemas/Upload.story.js +0 -168
- package/build/stories/spec/schemas/const/ConstLayout.story.js +0 -159
- package/build/stories/spec/schemas/const/ObjectConst.story.js +0 -94
- package/build/stories/spec/schemas/features/PersistAsync.story.js +0 -211
- package/build/stories/spec/schemas/features/ValidationAsync.story.js +0 -103
- package/build/stories/spec/schemas/object/FormattedValue.story.js +0 -92
- package/build/stories/spec/schemas/object/MoneyInput.story.js +0 -240
- package/build/stories/spec/schemas/oneOf/OneOfInitialisation.story.js +0 -55
- package/build/stories/spec/schemas/oneOf/OneOfWithSingleOption.story.js +0 -114
- package/build/stories/spec/step/Controls.story.js +0 -109
- package/build/stories/spec/step/DFModal.story.js +0 -58
- package/build/stories/spec/step/Footer.story.js +0 -70
- package/build/stories/spec/step/Navigation.story.js +0 -20
- package/build/stories/spec/step/Tags.story.js +0 -39
- package/build/stories/spec/step/ToolBar.story.js +0 -60
- package/build/stories/spec/step/features/ErrorHandling.story.js +0 -92
- package/build/stories/spec/step/features/External.story.js +0 -44
- package/build/stories/spec/step/features/Polling.story.js +0 -108
- package/build/stories/spec/step/features/RefreshAfter.story.js +0 -92
- package/build/stories/spec/step/features/refresh/Refresh.story.js +0 -258
- package/build/stories/spec/step/features/refresh/RefreshWithPersistAsync.story.js +0 -958
- package/build/stories/types.js +0 -1
- package/build/stories/utils/fixtureHttpClient.js +0 -70
- package/build/stories/utils/getBasicStep.js +0 -223
- package/build/stories/utils/mockSearchHandler.js +0 -71
- package/build/stories/utils/render-utils.js +0 -41
- package/build/stories/visual-tests/layouts/NotUsingListItem.story.js +0 -17
- package/build/test-utils/DynamicFlowWise.js +0 -32
- package/build/test-utils/DynamicFlowWiseModal.js +0 -34
- package/build/test-utils/NeptuneProviders.js +0 -11
- package/build/test-utils/component-utils.js +0 -5
- package/build/test-utils/fetch-utils.js +0 -45
- package/build/test-utils/getMergedTestRenderers.js +0 -34
- package/build/test-utils/getRandomId.js +0 -1
- package/build/test-utils/index.js +0 -3
- package/build/test-utils/rtl-utils.js +0 -7
- package/build/test-utils/step-utils.js +0 -6
- package/build/test-utils/wait.js +0 -3
- package/build/tests/AlertLayout.test.js +0 -78
- package/build/tests/ArrayTuple.test.js +0 -118
- package/build/tests/ButtonLayout.test.js +0 -308
- package/build/tests/ConstLayout.test.js +0 -95
- package/build/tests/DateInput.test.js +0 -163
- package/build/tests/DecisionLayout.test.js +0 -146
- package/build/tests/DynamicFlow.test.js +0 -147
- package/build/tests/External.test.js +0 -169
- package/build/tests/Flow.test.js +0 -328
- package/build/tests/FormLayout.test.js +0 -28
- package/build/tests/FormattedValue.test.js +0 -107
- package/build/tests/ImageRenderer.test.js +0 -78
- package/build/tests/InitialAction.test.js +0 -179
- package/build/tests/InitialStep.test.js +0 -168
- package/build/tests/InstructionsLayout.test.js +0 -45
- package/build/tests/ListLayout.test.js +0 -145
- package/build/tests/Logging.test.js +0 -53
- package/build/tests/ModalBehavior.test.js +0 -149
- package/build/tests/MoneyInput.test.js +0 -316
- package/build/tests/MultiUpload.test.js +0 -293
- package/build/tests/NativeBack.test.js +0 -267
- package/build/tests/OneOfInitialisation.test.js +0 -571
- package/build/tests/PersistAsync.test.js +0 -686
- package/build/tests/Polling.test.js +0 -617
- package/build/tests/Prefetching.test.js +0 -230
- package/build/tests/RefreshAfter.test.js +0 -63
- package/build/tests/RefreshOnChange.ResponseHandling.test.js +0 -205
- package/build/tests/RefreshOnChange.test.js +0 -233
- package/build/tests/RefreshOnChange.with.Segmented.test.js +0 -348
- package/build/tests/RefreshOnChange.with.Tabs.test.js +0 -358
- package/build/tests/RefreshOnChangePreserve.test.js +0 -224
- package/build/tests/RendererProps.test.js +0 -342
- package/build/tests/Repeatable.test.js +0 -107
- package/build/tests/Rerendering.test.js +0 -67
- package/build/tests/ReviewLayout.test.js +0 -274
- package/build/tests/SchemaOnChange.test.js +0 -133
- package/build/tests/SchemaReferences.test.js +0 -88
- package/build/tests/ScrollToError.test.js +0 -217
- package/build/tests/SegmentedControl.test.js +0 -49
- package/build/tests/SingleFileUpload.test.js +0 -88
- package/build/tests/StatusList.test.js +0 -85
- package/build/tests/Subflow.test.js +0 -710
- package/build/tests/Submission.ResponseHandling.test.js +0 -557
- package/build/tests/Submission.merging.test.js +0 -202
- package/build/tests/Submission.test.js +0 -603
- package/build/tests/Tags.test.js +0 -475
- package/build/tests/Upsell.test.js +0 -126
- package/build/tests/ValidationAsync.test.js +0 -295
- package/build/tests/legacy/Actions.test.js +0 -158
- package/build/tests/legacy/BackButton.test.js +0 -114
- package/build/tests/legacy/HiddenSchemas.test.js +0 -246
- package/build/tests/legacy/MultiSelect.test.js +0 -497
- package/build/tests/legacy/MultipleFileUploadSchema.test.js +0 -341
- package/build/tests/legacy/PersistAsync.blob-schema.test.js +0 -224
- package/build/tests/legacy/PersistAsync.string-schema.test.js +0 -211
- package/build/tests/legacy/RefreshStepOnChange.debouncing.test.js +0 -209
- package/build/tests/legacy/RefreshStepOnChange.test.js +0 -424
- package/build/tests/legacy/Search.test.js +0 -437
- package/build/tests/renderers/MultiSelectInputRendererProps.test.js +0 -58
- package/build/tests/renderers/SelectInputRendererProps.test.js +0 -43
- package/build/tests/renderers/TextInputRenderer.test.js +0 -51
- package/build/types.js +0 -1
- package/build/useDynamicFlow.js +0 -104
- package/build/useDynamicFlowModal.js +0 -58
- package/build/utils/analyse-step.js +0 -14
- package/build/utils/component-utils.js +0 -8
- package/build/utils/component-utils.test.js +0 -113
- package/build/utils/getScrollToTop.js +0 -12
- package/build/utils/normalise-flow-id.js +0 -1
- package/build/utils/normalise-flow-id.test.js +0 -24
- package/build/utils/openLinkInNewTab.js +0 -10
- package/build/utils/recursiveMerge.js +0 -40
- package/build/utils/recursiveMerge.test.js +0 -93
- package/build/utils/type-utils.js +0 -21
- package/build/utils/type-validators.js +0 -11
- package/build/utils/type-validators.test.js +0 -180
- package/build/utils/useStableCallback.js +0 -15
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { screen } from '@testing-library/react';
|
|
3
|
-
import { userEvent } from '@testing-library/user-event';
|
|
4
|
-
import { vi } from 'vitest';
|
|
5
|
-
import { createFlowController } from '../controller/FlowController';
|
|
6
|
-
import { FeatureFlags } from '../domain/mappers/utils/FeatureFlags';
|
|
7
|
-
import { renderWithProviders } from '../test-utils';
|
|
8
|
-
import DynamicFlowWise from '../test-utils/DynamicFlowWise';
|
|
9
|
-
import { respondWith } from '../test-utils/fetch-utils';
|
|
10
|
-
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });
|
|
11
|
-
describe('Prefetching actions in a step', () => {
|
|
12
|
-
const initialStep = () => ({
|
|
13
|
-
id: 'step',
|
|
14
|
-
title: 'Step Title',
|
|
15
|
-
schemas: [
|
|
16
|
-
{
|
|
17
|
-
$id: 'schema-1',
|
|
18
|
-
type: 'string',
|
|
19
|
-
title: 'A string schema',
|
|
20
|
-
default: 'a string value',
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
layout: [
|
|
24
|
-
{
|
|
25
|
-
type: 'form',
|
|
26
|
-
schemaId: 'schema-1',
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
type: 'review',
|
|
30
|
-
callToAction: {
|
|
31
|
-
title: 'Edit',
|
|
32
|
-
behavior: { type: 'action', action: { url: '/edit', prefetch: true } },
|
|
33
|
-
},
|
|
34
|
-
fields: [
|
|
35
|
-
{
|
|
36
|
-
label: 'Field A',
|
|
37
|
-
value: 'A value',
|
|
38
|
-
callToAction: {
|
|
39
|
-
title: 'Edit Field A',
|
|
40
|
-
behavior: { type: 'action', action: { url: '/edit-field-a', prefetch: true } },
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
type: 'button',
|
|
47
|
-
title: 'Button 1',
|
|
48
|
-
behavior: {
|
|
49
|
-
type: 'action',
|
|
50
|
-
action: { url: '/button-1', prefetch: true },
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
type: 'button',
|
|
55
|
-
title: 'Button 2',
|
|
56
|
-
behavior: {
|
|
57
|
-
type: 'action',
|
|
58
|
-
action: { url: '/button-2' },
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
});
|
|
63
|
-
const secondStep = () => ({
|
|
64
|
-
id: 'second-step',
|
|
65
|
-
title: 'Second Step',
|
|
66
|
-
schemas: [],
|
|
67
|
-
layout: [],
|
|
68
|
-
});
|
|
69
|
-
it('prefetches actions marked for prefetching', async () => {
|
|
70
|
-
const mockHttpClient = vi.fn(async () => {
|
|
71
|
-
return respondWith(secondStep());
|
|
72
|
-
});
|
|
73
|
-
const eventCountByName = {};
|
|
74
|
-
const onEvent = vi.fn((eventName) => {
|
|
75
|
-
var _a;
|
|
76
|
-
eventCountByName[eventName] = ((_a = eventCountByName[eventName]) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
77
|
-
});
|
|
78
|
-
const onError = vi.fn();
|
|
79
|
-
renderWithProviders(_jsx(DynamicFlowWise, { flowId: "prefetching-flow", httpClient: mockHttpClient, initialStep: initialStep(), onEvent: onEvent, onCompletion: () => { }, onError: onError }));
|
|
80
|
-
expect(eventCountByName['Dynamic Flow - Step Shown']).toBe(1); // the initial step shown
|
|
81
|
-
expect(mockHttpClient).toHaveBeenCalledTimes(3); // three prefetches
|
|
82
|
-
await user.click(screen.getByRole('button', { name: 'Edit' })); // trigger prefetched action
|
|
83
|
-
expect(mockHttpClient).toHaveBeenCalledTimes(3); // no extra requests
|
|
84
|
-
expect(eventCountByName['Dynamic Flow - Step Shown']).toBe(2); // the second step shown
|
|
85
|
-
expect(onError).not.toHaveBeenCalled();
|
|
86
|
-
});
|
|
87
|
-
it('does not prefetch actions not marked for prefetching', async () => {
|
|
88
|
-
const mockHttpClient = vi.fn(async () => {
|
|
89
|
-
return respondWith(secondStep());
|
|
90
|
-
});
|
|
91
|
-
const eventCountByName = {};
|
|
92
|
-
const onEvent = vi.fn((eventName) => {
|
|
93
|
-
var _a;
|
|
94
|
-
eventCountByName[eventName] = ((_a = eventCountByName[eventName]) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
95
|
-
});
|
|
96
|
-
const onError = vi.fn();
|
|
97
|
-
renderWithProviders(_jsx(DynamicFlowWise, { flowId: "prefetching-flow", httpClient: mockHttpClient, initialStep: initialStep(), onEvent: onEvent, onCompletion: () => { }, onError: onError }));
|
|
98
|
-
expect(eventCountByName['Dynamic Flow - Step Shown']).toBe(1); // the initial step shown
|
|
99
|
-
expect(mockHttpClient).toHaveBeenCalledTimes(3); // three prefetches
|
|
100
|
-
await user.click(screen.getByRole('button', { name: 'Button 2' })); // trigger non-prefetched action
|
|
101
|
-
expect(mockHttpClient).toHaveBeenCalledTimes(4); // one extra request
|
|
102
|
-
expect(eventCountByName['Dynamic Flow - Step Shown']).toBe(2); // the second step shown
|
|
103
|
-
expect(onError).not.toHaveBeenCalled();
|
|
104
|
-
});
|
|
105
|
-
it('includes schema values and headers in prefetching requests', async () => {
|
|
106
|
-
const mockHttpClient = vi.fn(async () => {
|
|
107
|
-
return respondWith(secondStep());
|
|
108
|
-
});
|
|
109
|
-
renderWithProviders(_jsx(DynamicFlowWise, { flowId: "prefetching-flow", httpClient: mockHttpClient, initialStep: initialStep(), onCompletion: () => { }, onError: () => { } }));
|
|
110
|
-
const expectedRequestInit = {
|
|
111
|
-
method: 'POST',
|
|
112
|
-
body: '"a string value"',
|
|
113
|
-
headers: { 'Content-Type': 'application/json' },
|
|
114
|
-
};
|
|
115
|
-
expect(mockHttpClient).toHaveBeenCalledWith('/edit', expectedRequestInit);
|
|
116
|
-
expect(mockHttpClient).toHaveBeenCalledWith('/edit-field-a', expectedRequestInit);
|
|
117
|
-
expect(mockHttpClient).toHaveBeenCalledWith('/button-1', expectedRequestInit);
|
|
118
|
-
});
|
|
119
|
-
it('does not use cached responses when their status code is not OK', async () => {
|
|
120
|
-
const step = {
|
|
121
|
-
id: 'initial-step',
|
|
122
|
-
title: 'Initial Step Title',
|
|
123
|
-
schemas: [],
|
|
124
|
-
layout: [
|
|
125
|
-
{
|
|
126
|
-
type: 'button',
|
|
127
|
-
title: 'Button 1',
|
|
128
|
-
behavior: {
|
|
129
|
-
type: 'action',
|
|
130
|
-
action: { url: '/button-1', prefetch: true },
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
};
|
|
135
|
-
const mockHttpClient = vi
|
|
136
|
-
.fn()
|
|
137
|
-
.mockResolvedValueOnce(await respondWith(null, { status: 500 }))
|
|
138
|
-
.mockResolvedValueOnce(await respondWith(secondStep()));
|
|
139
|
-
renderWithProviders(_jsx(DynamicFlowWise, { flowId: "prefetching-flow", httpClient: mockHttpClient, initialStep: step, onCompletion: () => { }, onError: () => { } }));
|
|
140
|
-
expect(mockHttpClient).toHaveBeenCalledTimes(1); // one prefetch attempt
|
|
141
|
-
await user.click(screen.getByRole('button', { name: 'Button 1' })); // trigger action from initial step
|
|
142
|
-
expect(mockHttpClient).toHaveBeenCalledTimes(2); // one extra request due to non-OK cached response
|
|
143
|
-
});
|
|
144
|
-
it('only performs one request for identical actions', () => {
|
|
145
|
-
const step = Object.assign(Object.assign({}, initialStep()), { layout: [
|
|
146
|
-
...initialStep().layout,
|
|
147
|
-
{
|
|
148
|
-
type: 'button',
|
|
149
|
-
title: 'Button 1 again',
|
|
150
|
-
behavior: {
|
|
151
|
-
type: 'action',
|
|
152
|
-
action: { url: '/button-1', prefetch: true },
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
] });
|
|
156
|
-
const mockHttpClient = vi.fn().mockImplementation(() => respondWith((Object.assign(Object.assign({}, initialStep()), { title: 'This is a new step' }))));
|
|
157
|
-
renderWithProviders(_jsx(DynamicFlowWise, { flowId: "prefetching-flow", httpClient: mockHttpClient, initialStep: step, onCompletion: () => { }, onError: () => { } }));
|
|
158
|
-
expect(mockHttpClient).toHaveBeenCalledTimes(3);
|
|
159
|
-
});
|
|
160
|
-
describe('Prefetching scope is constrained to the step', () => {
|
|
161
|
-
it('does not use prefetched actions from previous steps', async () => {
|
|
162
|
-
const secondStepLocal = () => ({
|
|
163
|
-
id: 'step',
|
|
164
|
-
title: 'Second Step Title',
|
|
165
|
-
schemas: [
|
|
166
|
-
{
|
|
167
|
-
$id: 'schema-1',
|
|
168
|
-
type: 'string',
|
|
169
|
-
title: 'A string schema',
|
|
170
|
-
default: 'a string value',
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
layout: [
|
|
174
|
-
{
|
|
175
|
-
type: 'form',
|
|
176
|
-
schemaId: 'schema-1',
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
type: 'button',
|
|
180
|
-
title: 'Button 1',
|
|
181
|
-
behavior: {
|
|
182
|
-
type: 'action',
|
|
183
|
-
action: { url: '/button-1' },
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
],
|
|
187
|
-
});
|
|
188
|
-
const mockHttpClient = vi.fn(async () => {
|
|
189
|
-
return respondWith(secondStepLocal());
|
|
190
|
-
});
|
|
191
|
-
const eventCountByName = {};
|
|
192
|
-
const onEvent = vi.fn((eventName) => {
|
|
193
|
-
var _a;
|
|
194
|
-
eventCountByName[eventName] = ((_a = eventCountByName[eventName]) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
195
|
-
});
|
|
196
|
-
const onError = vi.fn();
|
|
197
|
-
renderWithProviders(_jsx(DynamicFlowWise, { flowId: "prefetching-flow", httpClient: mockHttpClient, initialStep: initialStep(), onEvent: onEvent, onCompletion: () => { }, onError: onError }));
|
|
198
|
-
expect(eventCountByName['Dynamic Flow - Step Shown']).toBe(1); // the initial step shown
|
|
199
|
-
expect(mockHttpClient).toHaveBeenCalledTimes(3); // three prefetches
|
|
200
|
-
await user.click(screen.getByRole('button', { name: 'Button 1' })); // trigger action from initial step
|
|
201
|
-
expect(mockHttpClient).toHaveBeenCalledTimes(3); // no extra requests
|
|
202
|
-
expect(eventCountByName['Dynamic Flow - Step Shown']).toBe(2); // the second step shown
|
|
203
|
-
await user.click(screen.getByRole('button', { name: 'Button 1' })); // trigger action from second step
|
|
204
|
-
expect(mockHttpClient).toHaveBeenCalledTimes(4); // one extra request -- no prefetching from previous step
|
|
205
|
-
expect(onError).not.toHaveBeenCalled(); // no errors
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
describe('Initialisation', () => {
|
|
209
|
-
it('does not prefetch before the DF controller is started', async () => {
|
|
210
|
-
const mockHttpClient = vi.fn();
|
|
211
|
-
const df = createFlowController({
|
|
212
|
-
flowId: 'prefetching-flow',
|
|
213
|
-
backConfig: { isNativeBackEnabled: true, isFlowCancellable: true },
|
|
214
|
-
features: new FeatureFlags({}),
|
|
215
|
-
initialStep: initialStep(),
|
|
216
|
-
httpClient: mockHttpClient,
|
|
217
|
-
scrollToTop: vi.fn(),
|
|
218
|
-
onCompletion: vi.fn(),
|
|
219
|
-
onError: vi.fn(),
|
|
220
|
-
onLink: vi.fn(),
|
|
221
|
-
getErrorMessageFunctions: vi.fn(),
|
|
222
|
-
onChange: vi.fn(),
|
|
223
|
-
onValueChange: vi.fn(),
|
|
224
|
-
});
|
|
225
|
-
expect(mockHttpClient).not.toHaveBeenCalled();
|
|
226
|
-
df.start();
|
|
227
|
-
expect(mockHttpClient).toHaveBeenCalledTimes(3); // prefetches after starting
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { act, waitFor } from '@testing-library/react';
|
|
3
|
-
import { renderWithProviders } from '../test-utils';
|
|
4
|
-
import DynamicFlowWise from '../test-utils/DynamicFlowWise';
|
|
5
|
-
import { vi } from 'vitest';
|
|
6
|
-
describe('given a step with a refreshAfter value', () => {
|
|
7
|
-
const getStep = (refreshAfter) => ({
|
|
8
|
-
id: 'step',
|
|
9
|
-
title: 'Step',
|
|
10
|
-
layout: [
|
|
11
|
-
{
|
|
12
|
-
type: 'paragraph',
|
|
13
|
-
text: refreshAfter
|
|
14
|
-
? `This step will refresh at ${refreshAfter}`
|
|
15
|
-
: 'This step will not refresh',
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
schemas: [],
|
|
19
|
-
refreshUrl: '/refresh',
|
|
20
|
-
refreshAfter,
|
|
21
|
-
});
|
|
22
|
-
describe('when refreshAfter is in the future', () => {
|
|
23
|
-
it('triggers a refresh when the time is reached', async () => {
|
|
24
|
-
const httpClient = vi.fn();
|
|
25
|
-
renderWithProviders(_jsx(DynamicFlowWise, { flowId: "flow-id", initialStep: getStep(new Date(Date.now() + 3000).toISOString()), httpClient: httpClient, onCompletion: () => { }, onError: () => { } }));
|
|
26
|
-
await act(async () => {
|
|
27
|
-
vi.advanceTimersByTime(2900);
|
|
28
|
-
});
|
|
29
|
-
await waitFor(() => {
|
|
30
|
-
expect(httpClient).not.toHaveBeenCalled();
|
|
31
|
-
});
|
|
32
|
-
await act(async () => {
|
|
33
|
-
vi.advanceTimersByTime(100); // 2900ms + 100ms = 3000ms
|
|
34
|
-
});
|
|
35
|
-
await waitFor(() => {
|
|
36
|
-
expect(httpClient).toHaveBeenCalledWith('/refresh', expect.anything());
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('when refreshAfter is in the past', () => {
|
|
41
|
-
it('triggers a refresh after one second, not immediately', async () => {
|
|
42
|
-
const httpClient = vi.fn();
|
|
43
|
-
renderWithProviders(_jsx(DynamicFlowWise, { flowId: "flow-id", initialStep: getStep(new Date(Date.now() - 2000).toISOString()), httpClient: httpClient, onCompletion: () => { }, onError: () => { } }));
|
|
44
|
-
await act(async () => {
|
|
45
|
-
vi.advanceTimersByTime(900);
|
|
46
|
-
});
|
|
47
|
-
expect(httpClient).not.toHaveBeenCalled();
|
|
48
|
-
await act(async () => {
|
|
49
|
-
vi.advanceTimersByTime(100); // 900ms + 100ms = 1 second
|
|
50
|
-
});
|
|
51
|
-
expect(httpClient).toHaveBeenCalledWith('/refresh', expect.anything());
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
describe('when refreshAfter is invalid', () => {
|
|
55
|
-
it('fails the flow, triggering onError', async () => {
|
|
56
|
-
const onError = vi.fn();
|
|
57
|
-
renderWithProviders(_jsx(DynamicFlowWise, { flowId: "flow-id", initialStep: getStep('banana'), httpClient: vi.fn(), onCompletion: () => { }, onError: onError }));
|
|
58
|
-
await waitFor(() => {
|
|
59
|
-
expect(onError).toHaveBeenCalledWith(new Error('Invalid refreshAfter value: banana'), undefined);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/* eslint-disable testing-library/render-result-naming-convention */
|
|
3
|
-
import { act, screen, waitFor } from '@testing-library/react';
|
|
4
|
-
import { userEvent } from '@testing-library/user-event';
|
|
5
|
-
import { vi } from 'vitest';
|
|
6
|
-
import { renderWithProviders, respondWith } from '../test-utils';
|
|
7
|
-
import DynamicFlowWise from '../test-utils/DynamicFlowWise';
|
|
8
|
-
import { abortableDelay } from '../test-utils/fetch-utils';
|
|
9
|
-
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });
|
|
10
|
-
const getProps = () => ({
|
|
11
|
-
flowId: 'flow-id',
|
|
12
|
-
onCompletion: vi.fn(),
|
|
13
|
-
onError: vi.fn(),
|
|
14
|
-
onEvent: vi.fn(),
|
|
15
|
-
onLog: vi.fn(),
|
|
16
|
-
});
|
|
17
|
-
const initialStep = {
|
|
18
|
-
id: 'step-id',
|
|
19
|
-
title: 'Submission test',
|
|
20
|
-
schemas: [
|
|
21
|
-
{
|
|
22
|
-
$id: '#form',
|
|
23
|
-
type: 'object',
|
|
24
|
-
displayOrder: ['color'],
|
|
25
|
-
properties: {
|
|
26
|
-
color: {
|
|
27
|
-
title: 'Color',
|
|
28
|
-
control: 'radio',
|
|
29
|
-
analyticsId: '#color-schema',
|
|
30
|
-
oneOf: [
|
|
31
|
-
{ const: 'red', title: 'Red' },
|
|
32
|
-
{ const: 'blue', title: 'Blue' },
|
|
33
|
-
{ const: 'green', title: 'Green' },
|
|
34
|
-
],
|
|
35
|
-
refreshStepOnChange: true,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
layout: [
|
|
41
|
-
{
|
|
42
|
-
type: 'form',
|
|
43
|
-
schemaId: '#form',
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
type: 'button',
|
|
47
|
-
title: 'Submit',
|
|
48
|
-
action: { id: 'action-id', url: '/submit', method: 'POST' },
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
refreshUrl: '/refresh',
|
|
52
|
-
};
|
|
53
|
-
const renderAndRefresh = async (httpClient) => {
|
|
54
|
-
const props = Object.assign(Object.assign({}, getProps()), { initialStep, httpClient });
|
|
55
|
-
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
56
|
-
await waitFor(() => {
|
|
57
|
-
expect(screen.getByText(initialStep.title)).toBeInTheDocument();
|
|
58
|
-
});
|
|
59
|
-
await user.click(screen.getByText('Red'));
|
|
60
|
-
return props;
|
|
61
|
-
};
|
|
62
|
-
describe('RefreshOnChange response handling', () => {
|
|
63
|
-
describe('When the fetch call throws', () => {
|
|
64
|
-
it('should trigger onError and the "Action Failed" and "Failed" events', async () => {
|
|
65
|
-
const httpClient = vi.fn().mockRejectedValue(new Error('Network error'));
|
|
66
|
-
const props = await renderAndRefresh(httpClient);
|
|
67
|
-
await waitFor(() => {
|
|
68
|
-
expect(props.onError).toHaveBeenCalledWith(expect.any(Error), undefined);
|
|
69
|
-
});
|
|
70
|
-
expect(props.onEvent).toHaveBeenCalledWith('Dynamic Flow - Refresh Failed', expect.objectContaining({
|
|
71
|
-
flowId: 'flow-id',
|
|
72
|
-
stepId: 'step-id',
|
|
73
|
-
stepCount: 0,
|
|
74
|
-
schema: '#color-schema',
|
|
75
|
-
}));
|
|
76
|
-
expect(props.onEvent).toHaveBeenCalledWith('Dynamic Flow - Failed', expect.objectContaining({
|
|
77
|
-
flowId: 'flow-id',
|
|
78
|
-
stepId: 'step-id',
|
|
79
|
-
stepCount: 0,
|
|
80
|
-
}));
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
describe('Status 2xx (response.ok)', () => {
|
|
84
|
-
describe('when the response is a valid step', () => {
|
|
85
|
-
it('should render the new step, and trigger the "Refresh Succeeded" event', async () => {
|
|
86
|
-
const httpClient = vi
|
|
87
|
-
.fn()
|
|
88
|
-
.mockResolvedValue(respondWith(Object.assign(Object.assign({}, initialStep), { title: 'Refreshed', model: { color: 'red' } })));
|
|
89
|
-
const props = await renderAndRefresh(httpClient);
|
|
90
|
-
await waitFor(() => {
|
|
91
|
-
expect(screen.getByText('Refreshed')).toBeInTheDocument();
|
|
92
|
-
});
|
|
93
|
-
expect(screen.queryByText(props.initialStep.title)).not.toBeInTheDocument();
|
|
94
|
-
expect(props.onEvent).toHaveBeenCalledWith('Dynamic Flow - Refresh Succeeded', expect.objectContaining({
|
|
95
|
-
flowId: 'flow-id',
|
|
96
|
-
stepId: 'step-id',
|
|
97
|
-
stepCount: 0,
|
|
98
|
-
schema: '#color-schema',
|
|
99
|
-
}));
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
describe('when the response is an invalid step', () => {
|
|
103
|
-
it('should trigger onError and the "Action Failed" and "Failed" events', async () => {
|
|
104
|
-
const httpClient = vi.fn().mockResolvedValue(respondWith('not a step, just a string'));
|
|
105
|
-
const props = await renderAndRefresh(httpClient);
|
|
106
|
-
await waitFor(() => {
|
|
107
|
-
expect(props.onError).toHaveBeenCalledWith(expect.any(Error), undefined);
|
|
108
|
-
});
|
|
109
|
-
expect(props.onEvent).toHaveBeenCalledWith('Dynamic Flow - Refresh Failed', expect.objectContaining({
|
|
110
|
-
flowId: 'flow-id',
|
|
111
|
-
stepId: 'step-id',
|
|
112
|
-
stepCount: 0,
|
|
113
|
-
schema: '#color-schema',
|
|
114
|
-
}));
|
|
115
|
-
expect(props.onEvent).toHaveBeenCalledWith('Dynamic Flow - Failed', expect.objectContaining({
|
|
116
|
-
flowId: 'flow-id',
|
|
117
|
-
stepId: 'step-id',
|
|
118
|
-
stepCount: 0,
|
|
119
|
-
}));
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
describe('Status 304', () => {
|
|
124
|
-
it('should trigger the "Refresh Succeeded" event and not change the step', async () => {
|
|
125
|
-
const httpClient = vi.fn().mockResolvedValue(respondWith(null, { status: 304 }));
|
|
126
|
-
const props = await renderAndRefresh(httpClient);
|
|
127
|
-
await waitFor(() => {
|
|
128
|
-
expect(screen.getByText(initialStep.title)).toBeInTheDocument();
|
|
129
|
-
});
|
|
130
|
-
expect(props.onEvent).toHaveBeenCalledWith('Dynamic Flow - Refresh Succeeded', expect.objectContaining({
|
|
131
|
-
flowId: 'flow-id',
|
|
132
|
-
stepId: 'step-id',
|
|
133
|
-
stepCount: 0,
|
|
134
|
-
schema: '#color-schema',
|
|
135
|
-
}));
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
describe('Status 4xx or 5xx', () => {
|
|
139
|
-
describe('When the response body can be parsed as an ErrorResponseBody', () => {
|
|
140
|
-
const getHttpClient = () => vi.fn().mockResolvedValue(respondWith({
|
|
141
|
-
analytics: { shopping: 'list' },
|
|
142
|
-
}, { status: 422 }));
|
|
143
|
-
it('should trigger a "Refresh failed" and "Failed" events with analytics', async () => {
|
|
144
|
-
const props = await renderAndRefresh(getHttpClient());
|
|
145
|
-
expect(props.onEvent).toHaveBeenCalledWith('Dynamic Flow - Refresh Failed', expect.objectContaining({
|
|
146
|
-
flowId: 'flow-id',
|
|
147
|
-
stepId: 'step-id',
|
|
148
|
-
schema: '#color-schema',
|
|
149
|
-
shopping: 'list',
|
|
150
|
-
statusCode: 422,
|
|
151
|
-
}));
|
|
152
|
-
expect(props.onEvent).toHaveBeenLastCalledWith('Dynamic Flow - Failed', expect.objectContaining({
|
|
153
|
-
flowId: 'flow-id',
|
|
154
|
-
stepId: 'step-id',
|
|
155
|
-
shopping: 'list',
|
|
156
|
-
}));
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
describe('When the response body can NOT be parsed as an ErrorResponseBody', () => {
|
|
160
|
-
const getHttpClient = () => vi.fn().mockResolvedValue(respondWith('', { status: 422 }));
|
|
161
|
-
it('should trigger a "Refresh failed" and "Failed" events', async () => {
|
|
162
|
-
const props = await renderAndRefresh(getHttpClient());
|
|
163
|
-
expect(props.onEvent).toHaveBeenCalledWith('Dynamic Flow - Refresh Failed', expect.objectContaining({
|
|
164
|
-
flowId: 'flow-id',
|
|
165
|
-
stepId: 'step-id',
|
|
166
|
-
schema: '#color-schema',
|
|
167
|
-
statusCode: 422,
|
|
168
|
-
}));
|
|
169
|
-
expect(props.onEvent).toHaveBeenLastCalledWith('Dynamic Flow - Failed', expect.objectContaining({
|
|
170
|
-
flowId: 'flow-id',
|
|
171
|
-
stepId: 'step-id',
|
|
172
|
-
}));
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
describe('Aborting a refresh request', () => {
|
|
177
|
-
describe('When a second refresh request is made', () => {
|
|
178
|
-
it('should abort the first request and only use the response from the second request', async () => {
|
|
179
|
-
// The first request takes 100ms to respond
|
|
180
|
-
// The second request takes only 10ms to respond
|
|
181
|
-
const httpClient = vi
|
|
182
|
-
.fn()
|
|
183
|
-
.mockImplementationOnce(async (input, init) => {
|
|
184
|
-
var _a;
|
|
185
|
-
return abortableDelay(200, (_a = init === null || init === void 0 ? void 0 : init.signal) !== null && _a !== void 0 ? _a : null).then(async () => respondWith(Object.assign(Object.assign({}, initialStep), { title: 'Refreshed One', model: { color: 'red' } })));
|
|
186
|
-
})
|
|
187
|
-
.mockImplementationOnce(async (input, init) => {
|
|
188
|
-
var _a;
|
|
189
|
-
return abortableDelay(100, (_a = init === null || init === void 0 ? void 0 : init.signal) !== null && _a !== void 0 ? _a : null).then(async () => respondWith(Object.assign(Object.assign({}, initialStep), { title: 'Refreshed Two', model: { color: 'blue' } })));
|
|
190
|
-
});
|
|
191
|
-
await renderAndRefresh(httpClient);
|
|
192
|
-
await user.click(screen.getByText('Blue'));
|
|
193
|
-
await waitFor(() => {
|
|
194
|
-
expect(screen.getByText('Refreshed Two')).toBeInTheDocument();
|
|
195
|
-
});
|
|
196
|
-
// wait enough time for the first request to finish
|
|
197
|
-
// had it not been cancelled, it would have resolved after 100ms
|
|
198
|
-
await act(async () => vi.advanceTimersByTimeAsync(100));
|
|
199
|
-
// We expect the first request to be cancelled and not to have updated the UI
|
|
200
|
-
expect(screen.queryByText('Refreshed One')).not.toBeInTheDocument();
|
|
201
|
-
expect(screen.getByText('Refreshed Two')).toBeInTheDocument();
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
});
|