@wise/dynamic-flow-client-internal 5.31.0-experimental-a2135d6 → 5.31.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.
Files changed (56) hide show
  1. package/build/dynamicFlow/DynamicFlow.js +11 -0
  2. package/build/dynamicFlow/DynamicFlowModal.js +21 -0
  3. package/build/dynamicFlow/DynamicFlowWiseProps.js +1 -0
  4. package/build/dynamicFlow/DynamicFlowWithRef.js +19 -0
  5. package/build/dynamicFlow/context-menu/useContextMenu.js +33 -0
  6. package/build/dynamicFlow/context-menu/useDFContextMenu.js +135 -0
  7. package/build/dynamicFlow/context-menu/useDFContextMenu.test.js +101 -0
  8. package/build/dynamicFlow/getMergedRenderers.js +36 -0
  9. package/build/dynamicFlow/messages.js +13 -0
  10. package/build/dynamicFlow/renderers.js +10 -0
  11. package/build/dynamicFlow/telemetry/app-version.js +4 -0
  12. package/build/dynamicFlow/telemetry/dispatchAnalyticsEvent.js +8 -0
  13. package/build/dynamicFlow/telemetry/getLogEvent.js +22 -0
  14. package/build/dynamicFlow/telemetry/getTrackEvent.js +39 -0
  15. package/build/dynamicFlow/telemetry/index.js +2 -0
  16. package/build/dynamicFlow/useCreateSnackBar.js +9 -0
  17. package/build/dynamicFlow/useOnCopy.js +16 -0
  18. package/build/dynamicFlow/useWiseHttpClient.js +24 -0
  19. package/build/dynamicFlow/useWiseToCoreProps.js +42 -0
  20. package/build/i18n/en.json +0 -2
  21. package/build/i18n/index.js +43 -0
  22. package/build/index.js +6 -0
  23. package/build/main.js +67 -296
  24. package/build/main.mjs +56 -286
  25. package/build/stories/ButtonLoader.story.js +109 -0
  26. package/build/stories/ContainerQueries.story.js +74 -0
  27. package/build/stories/DynamicFlow.story.js +37 -0
  28. package/build/stories/DynamicFlowWithRef.story.js +72 -0
  29. package/build/stories/Editable.story.js +58 -0
  30. package/build/stories/Initialisation.story.js +33 -0
  31. package/build/stories/PinnedButtons.story.js +94 -0
  32. package/build/stories/SCAIntegration.story.js +67 -0
  33. package/build/stories/utils/fixtureHttpClient.js +59 -0
  34. package/build/test-utils/NeptuneProviders.js +11 -0
  35. package/build/test-utils/index.js +4 -0
  36. package/build/test-utils/respond-with.js +6 -0
  37. package/build/test-utils/rtl-utils.js +7 -0
  38. package/build/test-utils/wait.js +3 -0
  39. package/build/tests/DynamicFlow.test.js +177 -0
  40. package/build/tests/HideStepTitle.test.js +58 -0
  41. package/build/tests/RequestCache.test.js +34 -0
  42. package/build/tests/SCARejectionHandling.test.js +71 -0
  43. package/build/tests/Subflow.Wise.test.js +650 -0
  44. package/build/tests/events.test.js +124 -0
  45. package/build/tests/logging.test.js +12 -0
  46. package/build/tests/onNotification.test.js +96 -0
  47. package/build/tests/renderers/ControlAndTags.test.js +225 -0
  48. package/build/tests/renderers/ImageRenderer.test.js +129 -0
  49. package/build/tests/renderers/RadioInputRendererComponent.test.js +89 -0
  50. package/build/tests/renderers/ReviewRenderer.test.js +41 -0
  51. package/build/tests/renderers/TextInputRenderer.test.js +44 -0
  52. package/build/tests/renderers/TimeZoneHeader.test.js +19 -0
  53. package/build/tests/renderers/UploadInputRenderer.maxSize.test.js +22 -0
  54. package/build/tests/renderers/value-utils.test.js +24 -0
  55. package/build/tsconfig.types.tsbuildinfo +1 -1
  56. package/package.json +4 -4
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { screen, waitFor } from '@testing-library/react';
3
+ import { DynamicFlow } from '../dynamicFlow/DynamicFlow';
4
+ import { renderWithProviders, respondWith } from '../test-utils';
5
+ describe('Initialising DF with a request cache', () => {
6
+ const defaultProps = {
7
+ flowId: 'test',
8
+ initialAction: { url: '/initial-request', method: 'GET' },
9
+ onCompletion: vi.fn(),
10
+ onError: vi.fn(),
11
+ };
12
+ const initialStep = {
13
+ id: 'step-id',
14
+ title: 'Cached step',
15
+ layout: [],
16
+ schemas: [],
17
+ };
18
+ it('uses the cache value instead of making a network request', async () => {
19
+ const mockHttpClient = vi.fn().mockImplementation((input, init) => {
20
+ return respondWith(Object.assign(Object.assign({}, initialStep), { title: 'Fetched step' }));
21
+ });
22
+ const cache = [
23
+ [
24
+ ['/initial-request', { method: 'GET', headers: [['content-type', 'application/json']] }],
25
+ Promise.resolve(respondWith(initialStep)),
26
+ ],
27
+ ];
28
+ renderWithProviders(_jsx(DynamicFlow, Object.assign({}, defaultProps, { requestCache: cache, customFetch: mockHttpClient })));
29
+ await waitFor(() => {
30
+ expect(screen.getByText('Cached step')).toBeInTheDocument();
31
+ });
32
+ expect(mockHttpClient).not.toHaveBeenCalled();
33
+ });
34
+ });
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { act, screen, waitFor } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { vi } from 'vitest';
5
+ import { DynamicFlow } from '../dynamicFlow/DynamicFlow';
6
+ import { wait } from '../test-utils';
7
+ import { renderWithProviders } from '../test-utils/rtl-utils';
8
+ const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });
9
+ describe('SCA rejection handling', () => {
10
+ const initialStep = {
11
+ id: 'step-id',
12
+ title: 'SCA Integration',
13
+ schemas: [],
14
+ layout: [
15
+ {
16
+ type: 'button',
17
+ title: 'Submit',
18
+ behavior: {
19
+ type: 'action',
20
+ action: { url: '/sca-request' },
21
+ },
22
+ },
23
+ ],
24
+ };
25
+ describe('when SCA modal is closed (the SCA request rejects with `new Error("SCA_MODAL_CLOSED")`)', () => {
26
+ it('should show NOT show an error message', async () => {
27
+ const props = {
28
+ flowId: 'test',
29
+ initialStep,
30
+ customFetch: async () => {
31
+ await wait(1);
32
+ throw new Error('SCA_MODAL_CLOSED');
33
+ },
34
+ onCompletion: vi.fn(),
35
+ onError: vi.fn(),
36
+ };
37
+ renderWithProviders(_jsx(DynamicFlow, Object.assign({}, props)));
38
+ // renderWithProviders results in one <div role="alert" class="snackbar"> which is empty
39
+ expect(screen.getAllByRole('alert')).toHaveLength(1);
40
+ // click submit button
41
+ await user.click(screen.getByRole('button', { name: /submit/i }));
42
+ // wait for the SCA modal to be closed (simulated)
43
+ await act(async () => vi.advanceTimersByTimeAsync(200));
44
+ // we should not see any other alerts in this screen
45
+ expect(screen.getAllByRole('alert')).toHaveLength(1); // same as before submission
46
+ });
47
+ });
48
+ describe('when SCA request rejects with a different error', () => {
49
+ it('should show an error message', async () => {
50
+ const props = {
51
+ flowId: 'test',
52
+ initialStep,
53
+ customFetch: async () => {
54
+ await wait(1);
55
+ throw new Error('SCA_REQUEST_REJECTED');
56
+ },
57
+ onCompletion: vi.fn(),
58
+ onError: vi.fn(),
59
+ };
60
+ renderWithProviders(_jsx(DynamicFlow, Object.assign({}, props)));
61
+ // renderWithProviders results in one <div role="alert" class="snackbar"> which is empty
62
+ expect(screen.getAllByRole('alert')).toHaveLength(1);
63
+ // click submit button
64
+ await user.click(screen.getByRole('button', { name: /submit/i }));
65
+ // wait for the SCA modal to be closed (simulated)
66
+ await waitFor(() => {
67
+ expect(screen.getByText(/something went wrong/i)).toBeInTheDocument();
68
+ });
69
+ });
70
+ });
71
+ });