@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,475 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable testing-library/render-result-naming-convention */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
4
|
+
/* eslint-disable react/destructuring-assignment */
|
|
5
|
+
/* eslint-disable react/no-array-index-key */
|
|
6
|
+
import { screen } from '@testing-library/react';
|
|
7
|
+
import { renderWithProviders } from '../test-utils';
|
|
8
|
+
import DynamicFlowWise from '../test-utils/DynamicFlowWise';
|
|
9
|
+
import { vi } from 'vitest';
|
|
10
|
+
const TagRenderer = ({ tags }) => _jsx("pre", { children: `tags:${JSON.stringify(tags)}` });
|
|
11
|
+
const TagRendererWithItems = (props) => {
|
|
12
|
+
const { propName, tags } = props;
|
|
13
|
+
const items = props[propName];
|
|
14
|
+
return (_jsxs("div", { children: [_jsx(TagRenderer, { tags: tags }), items.map((item, i) => (_jsx(TagRenderer, { tags: item.tags }, `item-${i}`)))] }));
|
|
15
|
+
};
|
|
16
|
+
const getDefaultProps = () => ({
|
|
17
|
+
flowId: 'flow-id',
|
|
18
|
+
httpClient: vi.fn(),
|
|
19
|
+
onCompletion: vi.fn(),
|
|
20
|
+
onError: vi.fn(),
|
|
21
|
+
onEvent: vi.fn(),
|
|
22
|
+
onLog: vi.fn(),
|
|
23
|
+
});
|
|
24
|
+
const getStepForLayout = (layout) => ({
|
|
25
|
+
id: 'test-id',
|
|
26
|
+
title: 'Tags in Layout Test Step',
|
|
27
|
+
schemas: [{ $id: '#schema', const: 'value' }],
|
|
28
|
+
layout,
|
|
29
|
+
});
|
|
30
|
+
const getStepForSchema = (schema) => ({
|
|
31
|
+
id: 'test-id',
|
|
32
|
+
title: 'Tags in Schema Test Step',
|
|
33
|
+
schemas: [Object.assign(Object.assign({}, schema), { $id: '#schema' })],
|
|
34
|
+
layout: [{ type: 'form', schemaId: '#schema' }],
|
|
35
|
+
});
|
|
36
|
+
const getLayoutRenderers = () => [
|
|
37
|
+
{ canRenderType: 'alert', render: TagRenderer },
|
|
38
|
+
{ canRenderType: 'box', render: TagRenderer },
|
|
39
|
+
{ canRenderType: 'button', render: TagRenderer },
|
|
40
|
+
{ canRenderType: 'columns', render: TagRenderer },
|
|
41
|
+
{ canRenderType: 'divider', render: TagRenderer },
|
|
42
|
+
{ canRenderType: 'form', render: TagRenderer },
|
|
43
|
+
{ canRenderType: 'heading', render: TagRenderer },
|
|
44
|
+
{ canRenderType: 'image', render: TagRenderer },
|
|
45
|
+
{ canRenderType: 'loading-indicator', render: TagRenderer },
|
|
46
|
+
{ canRenderType: 'markdown', render: TagRenderer },
|
|
47
|
+
{ canRenderType: 'modal-layout', render: TagRenderer },
|
|
48
|
+
{ canRenderType: 'paragraph', render: TagRenderer },
|
|
49
|
+
{ canRenderType: 'progress', render: TagRenderer },
|
|
50
|
+
{ canRenderType: 'search', render: TagRenderer },
|
|
51
|
+
];
|
|
52
|
+
const getSchemaRenderers = () => [
|
|
53
|
+
{ canRenderType: 'form-section', render: TagRenderer },
|
|
54
|
+
{ canRenderType: 'repeatable', render: TagRenderer },
|
|
55
|
+
{ canRenderType: 'input-upload', render: TagRenderer },
|
|
56
|
+
{ canRenderType: 'input-upload-multi', render: TagRenderer },
|
|
57
|
+
{ canRenderType: 'input-checkbox', render: TagRenderer },
|
|
58
|
+
{ canRenderType: 'input-integer', render: TagRenderer },
|
|
59
|
+
{ canRenderType: 'input-number', render: TagRenderer },
|
|
60
|
+
{ canRenderType: 'input-select', render: TagRenderer },
|
|
61
|
+
{ canRenderType: 'input-text', render: TagRenderer },
|
|
62
|
+
];
|
|
63
|
+
const getLayoutWithItemsRenderers = () => [
|
|
64
|
+
{
|
|
65
|
+
canRenderType: 'decision',
|
|
66
|
+
render: (props) => _jsx(TagRendererWithItems, Object.assign({}, props, { propName: "options" })),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
canRenderType: 'list',
|
|
70
|
+
render: (props) => _jsx(TagRendererWithItems, Object.assign({}, props, { propName: "items" })),
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
canRenderType: 'status-list',
|
|
74
|
+
render: (props) => _jsx(TagRendererWithItems, Object.assign({}, props, { propName: "items" })),
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
canRenderType: 'instructions',
|
|
78
|
+
render: (props) => _jsx(TagRendererWithItems, Object.assign({}, props, { propName: "items" })),
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
canRenderType: 'review',
|
|
82
|
+
render: (props) => _jsx(TagRendererWithItems, Object.assign({}, props, { propName: "fields" })),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
canRenderType: 'tabs',
|
|
86
|
+
render: (props) => _jsx(TagRendererWithItems, Object.assign({}, props, { propName: "tabs" })),
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
describe('Tags', () => {
|
|
90
|
+
describe('Step and Toolbar', () => {
|
|
91
|
+
const renderers = [
|
|
92
|
+
{
|
|
93
|
+
canRenderType: 'step',
|
|
94
|
+
render: ({ tags, toolbar }) => {
|
|
95
|
+
return (_jsxs("div", { children: [_jsx(TagRenderer, { tags: tags }), (toolbar === null || toolbar === void 0 ? void 0 : toolbar.tags) && _jsx(TagRenderer, { tags: toolbar.tags }), toolbar === null || toolbar === void 0 ? void 0 : toolbar.items.map((toolbarItem) => {
|
|
96
|
+
var _a;
|
|
97
|
+
return (_jsx(TagRenderer, { tags: toolbarItem.tags }, (_a = toolbarItem.tags) === null || _a === void 0 ? void 0 : _a.join()));
|
|
98
|
+
})] }));
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
const initialStep = {
|
|
103
|
+
id: 'test-id',
|
|
104
|
+
title: 'Tags in Step',
|
|
105
|
+
tags: ['step-tag-1', 'step-tag-2'],
|
|
106
|
+
toolbar: {
|
|
107
|
+
tags: ['toolbar-tag-1', 'toolbar-tag-2'],
|
|
108
|
+
items: [
|
|
109
|
+
{
|
|
110
|
+
type: 'toolbar-button',
|
|
111
|
+
title: '',
|
|
112
|
+
behavior: { type: 'refresh' },
|
|
113
|
+
tags: ['toolbar-button-tag-1', 'toolbar-button-tag-2'],
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
schemas: [],
|
|
118
|
+
layout: [],
|
|
119
|
+
};
|
|
120
|
+
it('passes the step.tags array to the StepRendererProps object', () => {
|
|
121
|
+
const props = Object.assign(Object.assign({}, getDefaultProps()), { renderers, initialStep });
|
|
122
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
123
|
+
expect(screen.getByText(/tags:\["step-tag-1","step-tag-2"\]/)).toBeInTheDocument();
|
|
124
|
+
});
|
|
125
|
+
it('passes the tags for the toolbar', () => {
|
|
126
|
+
const props = Object.assign(Object.assign({}, getDefaultProps()), { renderers, initialStep });
|
|
127
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
128
|
+
expect(screen.getByText(/tags:\["toolbar-tag-1","toolbar-tag-2"\]/)).toBeInTheDocument();
|
|
129
|
+
});
|
|
130
|
+
it('passes the tags for the toolbar buttons', () => {
|
|
131
|
+
const props = Object.assign(Object.assign({}, getDefaultProps()), { renderers, initialStep });
|
|
132
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
133
|
+
expect(screen.getByText(/tags:\["toolbar-button-tag-1","toolbar-button-tag-2"\]/)).toBeInTheDocument();
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
describe('Layout Components', () => {
|
|
137
|
+
const renderers = getLayoutRenderers();
|
|
138
|
+
const cases = [
|
|
139
|
+
['AlertLayout', [{ type: 'alert', markdown: 'Hello', tags: ['tag1', 'tag2'] }]],
|
|
140
|
+
['BoxLayout', [{ type: 'box', components: [], tags: ['tag1', 'tag2'] }]],
|
|
141
|
+
['ButtonLayout', [{ type: 'button', title: 'Click Me', tags: ['tag1', 'tag2'], behavior: { type: 'action', action: { url: '/test' } } }]],
|
|
142
|
+
['ColumnsLayout', [{ type: 'columns', left: [], right: [], tags: ['tag1', 'tag2'] }]],
|
|
143
|
+
['DividerLayout', [{ type: 'divider', tags: ['tag1', 'tag2'] }]],
|
|
144
|
+
['FormLayout', [{ type: 'form', schemaId: '#schema', tags: ['tag1', 'tag2'] }]],
|
|
145
|
+
['HeadingLayout', [{ type: 'heading', text: 'Heading 1', tags: ['tag1', 'tag2'] }]],
|
|
146
|
+
['ImageLayout', [{ type: 'image', tags: ['tag1', 'tag2'] }]],
|
|
147
|
+
['InfoLayout', [{ type: 'info', markdown: 'markdown', tags: ['tag1', 'tag2'] }]],
|
|
148
|
+
['LoadingIndicatorLayout', [{ type: 'loading-indicator', tags: ['tag1', 'tag2'] }]],
|
|
149
|
+
['MarkdownLayout', [{ type: 'markdown', content: 'markdown', tags: ['tag1', 'tag2'] }]],
|
|
150
|
+
[
|
|
151
|
+
'ModalLayout',
|
|
152
|
+
[
|
|
153
|
+
{
|
|
154
|
+
type: 'modal',
|
|
155
|
+
trigger: { title: '' },
|
|
156
|
+
content: { components: [] },
|
|
157
|
+
tags: ['tag1', 'tag2'],
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
],
|
|
161
|
+
['ParagraphLayout', [{ type: 'paragraph', text: 'Paragraph 1', tags: ['tag1', 'tag2'] }]],
|
|
162
|
+
[
|
|
163
|
+
'ProgressLayout',
|
|
164
|
+
[{ type: 'progress', progressText: '50%', progress: 0.5, tags: ['tag1', 'tag2'] }],
|
|
165
|
+
],
|
|
166
|
+
[
|
|
167
|
+
'SearchLayout',
|
|
168
|
+
[{ type: 'search', title: '', method: 'POST', url: '', param: '', tags: ['tag1', 'tag2'] }],
|
|
169
|
+
],
|
|
170
|
+
];
|
|
171
|
+
test.each(cases)('%s passes tags to its renderer', (n, layout) => {
|
|
172
|
+
const step = getStepForLayout(layout);
|
|
173
|
+
const props = Object.assign(Object.assign({}, getDefaultProps()), { renderers, initialStep: step });
|
|
174
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
175
|
+
expect(screen.getByText(/tags:\["tag1","tag2"\]/)).toBeInTheDocument();
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
describe('Layout Components with sub-items', () => {
|
|
179
|
+
const renderers = getLayoutWithItemsRenderers();
|
|
180
|
+
const cases = [
|
|
181
|
+
[
|
|
182
|
+
'DecisionLayout',
|
|
183
|
+
[
|
|
184
|
+
{
|
|
185
|
+
type: 'decision',
|
|
186
|
+
options: [{ title: 'Option 1', tags: ['tag3', 'tag4'] }],
|
|
187
|
+
tags: ['tag1', 'tag2'],
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
],
|
|
191
|
+
[
|
|
192
|
+
'InstructionsLayout',
|
|
193
|
+
[
|
|
194
|
+
{
|
|
195
|
+
type: 'instructions',
|
|
196
|
+
items: [{ text: '', context: 'info', tags: ['tag3', 'tag4'] }],
|
|
197
|
+
tags: ['tag1', 'tag2'],
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
],
|
|
201
|
+
[
|
|
202
|
+
'ListLayout',
|
|
203
|
+
[
|
|
204
|
+
{
|
|
205
|
+
type: 'list',
|
|
206
|
+
items: [
|
|
207
|
+
{
|
|
208
|
+
title: 'Item 1',
|
|
209
|
+
tags: ['tag3', 'tag4'],
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
tags: ['tag1', 'tag2'],
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
],
|
|
216
|
+
[
|
|
217
|
+
'StatusListLayout',
|
|
218
|
+
[
|
|
219
|
+
{
|
|
220
|
+
type: 'status-list',
|
|
221
|
+
items: [
|
|
222
|
+
{
|
|
223
|
+
icon: { name: 'bank' },
|
|
224
|
+
title: 'Item 1',
|
|
225
|
+
tags: ['tag3', 'tag4'],
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
tags: ['tag1', 'tag2'],
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
],
|
|
232
|
+
[
|
|
233
|
+
'TabsLayout',
|
|
234
|
+
[
|
|
235
|
+
{
|
|
236
|
+
type: 'tabs',
|
|
237
|
+
tabs: [
|
|
238
|
+
{
|
|
239
|
+
title: 'Tab 1',
|
|
240
|
+
components: [],
|
|
241
|
+
tags: ['tag3', 'tag4'],
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
tags: ['tag1', 'tag2'],
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
],
|
|
248
|
+
[
|
|
249
|
+
'ReviewLayout',
|
|
250
|
+
[
|
|
251
|
+
{
|
|
252
|
+
type: 'review',
|
|
253
|
+
fields: [
|
|
254
|
+
{
|
|
255
|
+
label: '',
|
|
256
|
+
value: '',
|
|
257
|
+
tags: ['tag3', 'tag4'],
|
|
258
|
+
},
|
|
259
|
+
],
|
|
260
|
+
tags: ['tag1', 'tag2'],
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
],
|
|
264
|
+
];
|
|
265
|
+
test.each(cases)('%s passes tags to its renderer and its sub-items', (n, layout) => {
|
|
266
|
+
const step = getStepForLayout(layout);
|
|
267
|
+
const props = Object.assign(Object.assign({}, getDefaultProps()), { renderers, initialStep: step });
|
|
268
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
269
|
+
expect(screen.getByText(/tags:\["tag1","tag2"\]/)).toBeInTheDocument();
|
|
270
|
+
expect(screen.getByText(/tags:\["tag3","tag4"\]/)).toBeInTheDocument();
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
describe('Layout Components with sub-items (back-compat)', () => {
|
|
274
|
+
const renderers = getLayoutWithItemsRenderers();
|
|
275
|
+
const cases = [
|
|
276
|
+
[
|
|
277
|
+
'DecisionLayout',
|
|
278
|
+
[
|
|
279
|
+
{
|
|
280
|
+
type: 'decision',
|
|
281
|
+
options: [{ title: 'Option 1', tag: 'the-tag' }],
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
],
|
|
285
|
+
[
|
|
286
|
+
'InstructionsLayout',
|
|
287
|
+
[
|
|
288
|
+
{
|
|
289
|
+
type: 'instructions',
|
|
290
|
+
items: [{ text: '', context: 'info', tag: 'the-tag' }],
|
|
291
|
+
},
|
|
292
|
+
],
|
|
293
|
+
],
|
|
294
|
+
[
|
|
295
|
+
'ListLayout',
|
|
296
|
+
[
|
|
297
|
+
{
|
|
298
|
+
type: 'list',
|
|
299
|
+
items: [
|
|
300
|
+
{
|
|
301
|
+
title: 'Item 1',
|
|
302
|
+
tag: 'the-tag',
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
],
|
|
308
|
+
[
|
|
309
|
+
'StatusListLayout',
|
|
310
|
+
[
|
|
311
|
+
{
|
|
312
|
+
type: 'status-list',
|
|
313
|
+
items: [
|
|
314
|
+
{
|
|
315
|
+
icon: { name: 'bank' },
|
|
316
|
+
title: 'Item 1',
|
|
317
|
+
tag: 'the-tag',
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
},
|
|
321
|
+
],
|
|
322
|
+
],
|
|
323
|
+
[
|
|
324
|
+
'TabsLayout',
|
|
325
|
+
[
|
|
326
|
+
{
|
|
327
|
+
type: 'tabs',
|
|
328
|
+
tabs: [
|
|
329
|
+
{
|
|
330
|
+
title: 'Tab 1',
|
|
331
|
+
components: [],
|
|
332
|
+
tag: 'the-tag',
|
|
333
|
+
},
|
|
334
|
+
],
|
|
335
|
+
},
|
|
336
|
+
],
|
|
337
|
+
],
|
|
338
|
+
];
|
|
339
|
+
test.each(cases)('%s passes tags to its renderer and its sub-items', (n, layout) => {
|
|
340
|
+
const step = getStepForLayout(layout);
|
|
341
|
+
const props = Object.assign(Object.assign({}, getDefaultProps()), { renderers, initialStep: step });
|
|
342
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
343
|
+
expect(screen.getByText(/tags:\["the-tag"\]/)).toBeInTheDocument();
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
describe('Schema Components', () => {
|
|
347
|
+
const renderers = getSchemaRenderers();
|
|
348
|
+
const cases = [
|
|
349
|
+
['AllOfSchema', { allOf: [], tags: ['tag1', 'tag2'] }],
|
|
350
|
+
[
|
|
351
|
+
'ArraySchema (list)',
|
|
352
|
+
{
|
|
353
|
+
type: 'array',
|
|
354
|
+
tags: ['tag1', 'tag2'],
|
|
355
|
+
items: { type: 'string' },
|
|
356
|
+
addItemTitle: '',
|
|
357
|
+
editItemTitle: '',
|
|
358
|
+
},
|
|
359
|
+
],
|
|
360
|
+
[
|
|
361
|
+
'ArraySchema (tuple)',
|
|
362
|
+
{
|
|
363
|
+
type: 'array',
|
|
364
|
+
tags: ['tag1', 'tag2'],
|
|
365
|
+
items: [{ type: 'string' }],
|
|
366
|
+
addItemTitle: '',
|
|
367
|
+
editItemTitle: '',
|
|
368
|
+
},
|
|
369
|
+
],
|
|
370
|
+
[
|
|
371
|
+
'BlobSchema',
|
|
372
|
+
{
|
|
373
|
+
type: 'string',
|
|
374
|
+
persistAsync: Object.assign(Object.assign({}, persistAsyncConfig), { schema: { type: 'blob', tags: ['tag1', 'tag2'] } }),
|
|
375
|
+
},
|
|
376
|
+
],
|
|
377
|
+
['BooleanSchema', { type: 'boolean', tags: ['tag1', 'tag2'] }],
|
|
378
|
+
['IntegerSchema', { type: 'integer', tags: ['tag1', 'tag2'] }],
|
|
379
|
+
['NumberSchema', { type: 'number', tags: ['tag1', 'tag2'] }],
|
|
380
|
+
[
|
|
381
|
+
'ObjectSchema',
|
|
382
|
+
{
|
|
383
|
+
type: 'object',
|
|
384
|
+
tags: ['tag1', 'tag2'],
|
|
385
|
+
displayOrder: ['a'],
|
|
386
|
+
properties: {
|
|
387
|
+
a: { type: 'string' },
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
],
|
|
391
|
+
['OneOfSchema', { oneOf: [], tags: ['tag1', 'tag2'] }],
|
|
392
|
+
['StringSchema', { type: 'string', tags: ['tag1', 'tag2'] }],
|
|
393
|
+
];
|
|
394
|
+
test.each(cases)('%s passes tags to its renderer', (n, schema) => {
|
|
395
|
+
const step = getStepForSchema(schema);
|
|
396
|
+
const props = Object.assign(Object.assign({}, getDefaultProps()), { renderers, initialStep: step });
|
|
397
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
398
|
+
expect(screen.getByText(/tags:\["tag1","tag2"\]/)).toBeInTheDocument();
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
describe('Suggestions', () => {
|
|
402
|
+
describe('tags', () => {
|
|
403
|
+
it('passes tags to suggestions renderer', () => {
|
|
404
|
+
const suggestionsRenderers = [
|
|
405
|
+
{
|
|
406
|
+
canRenderType: 'input-text',
|
|
407
|
+
render: ({ suggestions }) => (_jsx(_Fragment, { children: suggestions === null || suggestions === void 0 ? void 0 : suggestions.values.map((sv) => {
|
|
408
|
+
var _a, _b;
|
|
409
|
+
return (_jsx(TagRenderer, { tags: (_a = sv.tags) !== null && _a !== void 0 ? _a : [] }, (_b = sv.value) === null || _b === void 0 ? void 0 : _b.toString()));
|
|
410
|
+
}) })),
|
|
411
|
+
},
|
|
412
|
+
];
|
|
413
|
+
const schema = {
|
|
414
|
+
type: 'string',
|
|
415
|
+
suggestions: { values: [{ label: '', value: '', tags: ['tag1', 'tag2'] }] },
|
|
416
|
+
};
|
|
417
|
+
const step = getStepForSchema(schema);
|
|
418
|
+
const props = Object.assign(Object.assign({}, getDefaultProps()), { renderers: suggestionsRenderers, initialStep: step });
|
|
419
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
420
|
+
expect(screen.getByText(/tags:\["tag1","tag2"\]/)).toBeInTheDocument();
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
describe('tag', () => {
|
|
424
|
+
const suggestionsRenderers = [
|
|
425
|
+
{
|
|
426
|
+
canRenderType: 'input-text',
|
|
427
|
+
render: ({ suggestions }) => (_jsx(_Fragment, { children: suggestions === null || suggestions === void 0 ? void 0 : suggestions.values.map((sv) => {
|
|
428
|
+
var _a, _b;
|
|
429
|
+
return (_jsx(TagRenderer, { tags: (_a = sv.tags) !== null && _a !== void 0 ? _a : [] }, (_b = sv.value) === null || _b === void 0 ? void 0 : _b.toString()));
|
|
430
|
+
}) })),
|
|
431
|
+
},
|
|
432
|
+
];
|
|
433
|
+
it('passes the tag property as tags to suggestions renderer', () => {
|
|
434
|
+
const schema = {
|
|
435
|
+
type: 'string',
|
|
436
|
+
suggestions: { values: [{ label: '', value: '', tag: 'the-tag' }] },
|
|
437
|
+
};
|
|
438
|
+
const step = getStepForSchema(schema);
|
|
439
|
+
const props = Object.assign(Object.assign({}, getDefaultProps()), { renderers: suggestionsRenderers, initialStep: step });
|
|
440
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
441
|
+
expect(screen.getByText(/tags:\["the-tag"\]/)).toBeInTheDocument();
|
|
442
|
+
});
|
|
443
|
+
it('sets the `tag` property to the first element of the tags array even if tag was provided', () => {
|
|
444
|
+
const schema = {
|
|
445
|
+
type: 'string',
|
|
446
|
+
suggestions: {
|
|
447
|
+
values: [{ label: '', value: '', tag: 'tag-must-be-ignored', tags: ['tag1', 'tag2'] }],
|
|
448
|
+
},
|
|
449
|
+
};
|
|
450
|
+
const step = getStepForSchema(schema);
|
|
451
|
+
const props = Object.assign(Object.assign({}, getDefaultProps()), { renderers: suggestionsRenderers, initialStep: step });
|
|
452
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
453
|
+
expect(screen.getByText(/tags:\["tag1","tag2"\]/)).toBeInTheDocument();
|
|
454
|
+
});
|
|
455
|
+
it('sets the `tag` property to the first element of the tags array even if tag was provided and even if the tags array is empty', () => {
|
|
456
|
+
const schema = {
|
|
457
|
+
type: 'string',
|
|
458
|
+
suggestions: {
|
|
459
|
+
values: [{ label: '', value: '', tag: 'tag-must-be-ignored', tags: [] }],
|
|
460
|
+
},
|
|
461
|
+
};
|
|
462
|
+
const step = getStepForSchema(schema);
|
|
463
|
+
const props = Object.assign(Object.assign({}, getDefaultProps()), { renderers: suggestionsRenderers, initialStep: step });
|
|
464
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
465
|
+
expect(screen.getByText(/tags:\[\]/)).toBeInTheDocument();
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
const persistAsyncConfig = {
|
|
471
|
+
url: '',
|
|
472
|
+
method: 'POST',
|
|
473
|
+
param: '',
|
|
474
|
+
idProperty: '',
|
|
475
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
3
|
+
import { 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
|
+
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });
|
|
9
|
+
const getProps = (initialStep) => ({
|
|
10
|
+
flowId: 'flow-id',
|
|
11
|
+
initialStep,
|
|
12
|
+
httpClient: vi.fn(),
|
|
13
|
+
onCompletion: vi.fn(),
|
|
14
|
+
onError: vi.fn(),
|
|
15
|
+
onEvent: vi.fn(),
|
|
16
|
+
onLog: vi.fn(),
|
|
17
|
+
});
|
|
18
|
+
const getCloseButton = () => screen.queryByRole('button', { name: /close/i });
|
|
19
|
+
describe('Upsell component', () => {
|
|
20
|
+
describe('when upsell does not contain onDismiss', () => {
|
|
21
|
+
const props = getProps({
|
|
22
|
+
id: 'step-1',
|
|
23
|
+
title: 'Step 1',
|
|
24
|
+
schemas: [],
|
|
25
|
+
layout: [
|
|
26
|
+
{
|
|
27
|
+
type: 'upsell',
|
|
28
|
+
text: 'Try our premium features!',
|
|
29
|
+
callToAction: {
|
|
30
|
+
title: 'Upgrade now',
|
|
31
|
+
behavior: {
|
|
32
|
+
type: 'link',
|
|
33
|
+
url: '/upgrade',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
it('renders upsell without a close button', () => {
|
|
40
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props)));
|
|
41
|
+
expect(screen.getByText('Try our premium features!')).toBeInTheDocument();
|
|
42
|
+
expect(screen.getByText('Upgrade now')).toBeInTheDocument();
|
|
43
|
+
expect(getCloseButton()).not.toBeInTheDocument();
|
|
44
|
+
});
|
|
45
|
+
describe('when the call to action is clicked', () => {
|
|
46
|
+
it('triggers the specified behavior', async () => {
|
|
47
|
+
const onLink = vi.fn();
|
|
48
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props, { onLink: onLink })));
|
|
49
|
+
const upgradeButton = screen.getByText('Upgrade now');
|
|
50
|
+
await user.click(upgradeButton);
|
|
51
|
+
expect(onLink).toHaveBeenCalledWith('/upgrade');
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('when the upsell has onDismiss', () => {
|
|
56
|
+
const props = getProps({
|
|
57
|
+
id: 'step-1',
|
|
58
|
+
title: 'Step 1',
|
|
59
|
+
schemas: [],
|
|
60
|
+
layout: [
|
|
61
|
+
{
|
|
62
|
+
type: 'upsell',
|
|
63
|
+
text: 'Try our premium features!',
|
|
64
|
+
callToAction: {
|
|
65
|
+
title: 'Upgrade now',
|
|
66
|
+
behavior: {
|
|
67
|
+
type: 'link',
|
|
68
|
+
url: '/upgrade',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
onDismiss: {
|
|
72
|
+
url: '/dismiss-upsell',
|
|
73
|
+
method: 'POST',
|
|
74
|
+
body: { upsellId: 'upsell-123' },
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: 'button',
|
|
79
|
+
title: 'Submit',
|
|
80
|
+
control: 'primary',
|
|
81
|
+
behavior: {
|
|
82
|
+
type: 'action',
|
|
83
|
+
action: { url: '/submit-step', method: 'POST' },
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
it('can be dismissed using the close button, and it becomes hidden', async () => {
|
|
89
|
+
const httpClient = vi.fn().mockResolvedValue({ status: 200 });
|
|
90
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props, { httpClient: httpClient })));
|
|
91
|
+
await user.click(getCloseButton());
|
|
92
|
+
await waitFor(() => {
|
|
93
|
+
expect(screen.queryByText('Try our premium features!')).not.toBeInTheDocument();
|
|
94
|
+
});
|
|
95
|
+
expect(httpClient).toHaveBeenCalledWith('/dismiss-upsell', {
|
|
96
|
+
method: 'POST',
|
|
97
|
+
body: JSON.stringify({ upsellId: 'upsell-123' }),
|
|
98
|
+
});
|
|
99
|
+
expect(screen.queryByText('Try our premium features!')).not.toBeInTheDocument();
|
|
100
|
+
});
|
|
101
|
+
describe('when displaying errors after upsell dismissal', () => {
|
|
102
|
+
it('does not show the upsell again after it has been dismissed', async () => {
|
|
103
|
+
const httpClient = async (url) => {
|
|
104
|
+
if (url === '/dismiss-upsell') {
|
|
105
|
+
return respondWith(null, { status: 200 });
|
|
106
|
+
}
|
|
107
|
+
if (url === '/submit-step') {
|
|
108
|
+
return respondWith({ error: 'There was an error' }, { status: 422 });
|
|
109
|
+
}
|
|
110
|
+
return respondWith(null, { status: 404 });
|
|
111
|
+
};
|
|
112
|
+
renderWithProviders(_jsx(DynamicFlowWise, Object.assign({}, props, { httpClient: httpClient })));
|
|
113
|
+
await user.click(getCloseButton());
|
|
114
|
+
await waitFor(() => {
|
|
115
|
+
expect(screen.queryByText('Try our premium features!')).not.toBeInTheDocument();
|
|
116
|
+
});
|
|
117
|
+
await user.click(screen.getByRole('button', { name: /submit/i }));
|
|
118
|
+
await waitFor(() => {
|
|
119
|
+
expect(screen.getByText('There was an error')).toBeInTheDocument();
|
|
120
|
+
});
|
|
121
|
+
// Ensure the upsell does not re-appear when displaying errors
|
|
122
|
+
expect(screen.queryByText('Try our premium features!')).not.toBeInTheDocument();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|