@wise/dynamic-flow-client-internal 5.28.2 → 5.28.3

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 (54) hide show
  1. package/build/main.js +1 -1
  2. package/build/main.mjs +1 -1
  3. package/package.json +2 -2
  4. package/build/dynamicFlow/DynamicFlow.js +0 -11
  5. package/build/dynamicFlow/DynamicFlowModal.js +0 -21
  6. package/build/dynamicFlow/DynamicFlowWiseProps.js +0 -1
  7. package/build/dynamicFlow/DynamicFlowWithRef.js +0 -19
  8. package/build/dynamicFlow/context-menu/useContextMenu.js +0 -33
  9. package/build/dynamicFlow/context-menu/useDFContextMenu.js +0 -135
  10. package/build/dynamicFlow/context-menu/useDFContextMenu.test.js +0 -101
  11. package/build/dynamicFlow/getMergedRenderers.js +0 -36
  12. package/build/dynamicFlow/messages.js +0 -13
  13. package/build/dynamicFlow/renderers.js +0 -10
  14. package/build/dynamicFlow/telemetry/app-version.js +0 -4
  15. package/build/dynamicFlow/telemetry/dispatchAnalyticsEvent.js +0 -8
  16. package/build/dynamicFlow/telemetry/getLogEvent.js +0 -22
  17. package/build/dynamicFlow/telemetry/getTrackEvent.js +0 -39
  18. package/build/dynamicFlow/telemetry/index.js +0 -2
  19. package/build/dynamicFlow/useCreateSnackBar.js +0 -9
  20. package/build/dynamicFlow/useOnCopy.js +0 -16
  21. package/build/dynamicFlow/useWiseHttpClient.js +0 -24
  22. package/build/dynamicFlow/useWiseToCoreProps.js +0 -42
  23. package/build/i18n/index.js +0 -43
  24. package/build/index.js +0 -6
  25. package/build/stories/ButtonLoader.story.js +0 -109
  26. package/build/stories/ContainerQueries.story.js +0 -74
  27. package/build/stories/DynamicFlow.story.js +0 -37
  28. package/build/stories/DynamicFlowWithRef.story.js +0 -72
  29. package/build/stories/Editable.story.js +0 -58
  30. package/build/stories/Initialisation.story.js +0 -33
  31. package/build/stories/PinnedButtons.story.js +0 -94
  32. package/build/stories/SCAIntegration.story.js +0 -67
  33. package/build/stories/utils/fixtureHttpClient.js +0 -59
  34. package/build/test-utils/NeptuneProviders.js +0 -11
  35. package/build/test-utils/index.js +0 -4
  36. package/build/test-utils/respond-with.js +0 -6
  37. package/build/test-utils/rtl-utils.js +0 -7
  38. package/build/test-utils/wait.js +0 -3
  39. package/build/tests/DynamicFlow.test.js +0 -177
  40. package/build/tests/HideStepTitle.test.js +0 -58
  41. package/build/tests/RequestCache.test.js +0 -34
  42. package/build/tests/SCARejectionHandling.test.js +0 -71
  43. package/build/tests/Subflow.Wise.test.js +0 -650
  44. package/build/tests/events.test.js +0 -124
  45. package/build/tests/logging.test.js +0 -12
  46. package/build/tests/onNotification.test.js +0 -96
  47. package/build/tests/renderers/ControlAndTags.test.js +0 -225
  48. package/build/tests/renderers/ImageRenderer.test.js +0 -129
  49. package/build/tests/renderers/RadioInputRendererComponent.test.js +0 -89
  50. package/build/tests/renderers/ReviewRenderer.test.js +0 -41
  51. package/build/tests/renderers/TextInputRenderer.test.js +0 -44
  52. package/build/tests/renderers/TimeZoneHeader.test.js +0 -19
  53. package/build/tests/renderers/UploadInputRenderer.maxSize.test.js +0 -22
  54. package/build/tests/renderers/value-utils.test.js +0 -24
@@ -1,177 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { screen, waitFor } from '@testing-library/react';
3
- import { userEvent } from '@testing-library/user-event';
4
- import { vi } from 'vitest';
5
- import { DynamicFlow } from '../dynamicFlow/DynamicFlow';
6
- import { DynamicFlowWithRef } from '../dynamicFlow/DynamicFlowWithRef';
7
- import { renderWithProviders, wait } from '../test-utils';
8
- import { DynamicFlowModal } from '../dynamicFlow/DynamicFlowModal';
9
- const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });
10
- const cases = [
11
- { name: 'DynamicFlow', DFComponent: DynamicFlow },
12
- { name: 'DynamicFlowWithRef', DFComponent: DynamicFlowWithRef },
13
- { name: 'DynamicFlowModal', DFComponent: DynamicFlowModal },
14
- ];
15
- describe.each(cases)('Wise-Specific Headers', ({ name, DFComponent }) => {
16
- it(`${name} - makes an initial request with additional RequestInit parameters, as specified in the wise-specific fetcher`, async () => {
17
- const props = {
18
- flowId: 'test',
19
- initialAction: { url: '/initial' },
20
- onCompletion: vi.fn(),
21
- onError: vi.fn(),
22
- };
23
- const customFetch = vi.fn();
24
- renderWithProviders(_jsx(DFComponent, Object.assign({}, props, { customFetch: customFetch })));
25
- await waitFor(() => {
26
- expect(customFetch).toHaveBeenCalledWith('/initial', expect.anything());
27
- });
28
- const requestInit = customFetch.mock.calls[0][1];
29
- const credentials = requestInit === null || requestInit === void 0 ? void 0 : requestInit.credentials;
30
- expect(credentials).toBe('include');
31
- const headers = Array.from(new Headers(requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers).entries());
32
- expect(headers).toContainEqual(['accept-language', 'en-GB']);
33
- expect(headers).toContainEqual(['content-type', 'application/json']);
34
- });
35
- });
36
- describe.each(cases)('Usage of customFetch function', ({ name, DFComponent }) => {
37
- it(`${name} - uses provided customFetch for image-fetching`, async () => {
38
- const props = {
39
- flowId: 'test',
40
- initialStep: {
41
- id: 'step-id',
42
- title: 'Image Step',
43
- layout: [
44
- {
45
- type: 'image',
46
- url: '/image',
47
- },
48
- ],
49
- schemas: [],
50
- },
51
- onCompletion: vi.fn(),
52
- onError: vi.fn(),
53
- };
54
- const customFetch = vi.fn();
55
- renderWithProviders(_jsx(DFComponent, Object.assign({}, props, { customFetch: customFetch })));
56
- await waitFor(() => {
57
- expect(customFetch).toHaveBeenCalledWith('/image', expect.anything());
58
- });
59
- });
60
- });
61
- describe.each(cases)('onEvent is triggered', ({ name, DFComponent }) => {
62
- it(`${name} - triggers provided onEvent when an event is emitted`, async () => {
63
- const props = {
64
- flowId: 'test',
65
- initialAction: { url: '/initial' },
66
- customFetch: vi.fn(),
67
- onCompletion: vi.fn(),
68
- onError: vi.fn(),
69
- };
70
- const onEvent = vi.fn();
71
- renderWithProviders(_jsx(DFComponent, Object.assign({}, props, { onEvent: onEvent })));
72
- await waitFor(() => {
73
- expect(onEvent).toHaveBeenCalledWith('Dynamic Flow - Initiated', expect.objectContaining({ flowId: 'test', integrationId: 'test' }));
74
- });
75
- });
76
- });
77
- describe.each(cases)('Renderer Context', ({ name, DFComponent }) => {
78
- it(`${name} - sets buttons to loading while submitting, and then re-enables them `, async () => {
79
- const initialStep = {
80
- id: 'initial-step',
81
- title: 'Initial step',
82
- layout: [{ type: 'button', title: 'Submit', action: { id: 'action-id', url: '/submit' } }],
83
- schemas: [],
84
- model: { name: 'Name', number: '12345' },
85
- };
86
- const customFetch = vi.fn().mockImplementation(async () => {
87
- await wait(100);
88
- return new Response(JSON.stringify({
89
- id: 'next-step',
90
- title: 'Next step',
91
- layout: [
92
- { type: 'button', title: 'Finish', action: { id: 'action-id', url: '/submit' } },
93
- ],
94
- schemas: [],
95
- }));
96
- });
97
- const props = {
98
- flowId: 'test',
99
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
100
- initialStep: initialStep,
101
- customFetch,
102
- onCompletion: vi.fn(),
103
- onError: vi.fn(),
104
- };
105
- renderWithProviders(_jsx(DFComponent, Object.assign({}, props)));
106
- const submitButton = screen.getByRole('button', { name: 'Submit' });
107
- await user.click(submitButton);
108
- expect(submitButton).toHaveAttribute('aria-disabled', 'true');
109
- await waitFor(() => {
110
- const submitButton2 = screen.getByRole('button', { name: 'Finish' });
111
- expect(submitButton2).toBeEnabled();
112
- });
113
- });
114
- it(`${name} - re-enables button if validation fails`, async () => {
115
- const initialStep = {
116
- id: 'initial-step',
117
- title: 'Initial step',
118
- layout: [
119
- { type: 'form', schemaId: '#schema' },
120
- { type: 'button', title: 'Submit', action: { id: 'action-id', url: '/submit' } },
121
- ],
122
- schemas: [{ type: 'string', $id: '#schema', title: 'Name' }],
123
- };
124
- const customFetch = vi.fn();
125
- const props = {
126
- flowId: 'test',
127
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
128
- initialStep: initialStep,
129
- customFetch,
130
- onCompletion: vi.fn(),
131
- onError: vi.fn(),
132
- };
133
- renderWithProviders(_jsx(DFComponent, Object.assign({}, props)));
134
- const submitButton = screen.getByText('Submit');
135
- await user.click(submitButton);
136
- await waitFor(() => {
137
- expect(submitButton).toBeEnabled();
138
- expect(submitButton).not.toHaveAttribute('aria-busy', 'true');
139
- });
140
- });
141
- it(`${name} - only shows loader on the button that was clicked`, async () => {
142
- const initialStep = {
143
- id: 'initial-step',
144
- title: 'Initial step',
145
- layout: [
146
- { type: 'button', title: 'Submit', action: { id: 'action-id', url: '/submit' } },
147
- { type: 'button', title: 'Continue', action: { id: 'action-id', url: '/submit' } },
148
- ],
149
- schemas: [],
150
- model: { name: 'Name', number: '12345' },
151
- };
152
- const customFetch = vi.fn().mockImplementation(async () => {
153
- return new Response(JSON.stringify({
154
- id: 'next-step',
155
- title: 'Next step',
156
- layout: [
157
- { type: 'button', title: 'Finish', action: { id: 'action-id', url: '/submit' } },
158
- ],
159
- schemas: [],
160
- }));
161
- });
162
- const props = {
163
- flowId: 'test',
164
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
165
- initialStep: initialStep,
166
- customFetch,
167
- onCompletion: vi.fn(),
168
- onError: vi.fn(),
169
- };
170
- renderWithProviders(_jsx(DFComponent, Object.assign({}, props)));
171
- const submitButton = screen.getByRole('button', { name: 'Submit' });
172
- const continueButton = screen.getByRole('button', { name: 'Continue' });
173
- await user.click(submitButton);
174
- expect(submitButton).toHaveAttribute('aria-disabled', 'true');
175
- expect(continueButton).not.toHaveAttribute('aria-disabled', 'true');
176
- });
177
- });
@@ -1,58 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { screen } from '@testing-library/react';
3
- import { vi } from 'vitest';
4
- import { DynamicFlow } from '../dynamicFlow/DynamicFlow';
5
- import { renderWithProviders } from '../test-utils/rtl-utils';
6
- const props = {
7
- flowId: 'test',
8
- initialStep: {
9
- id: 'step-id',
10
- title: 'Step Title',
11
- description: 'Step description.',
12
- schemas: [],
13
- layout: [],
14
- },
15
- onCompletion: vi.fn(),
16
- onError: vi.fn(),
17
- customFetch: vi.fn(),
18
- };
19
- describe('When the "displayStepTitle" flag is set to "false"', () => {
20
- it('hides the step title in the StepRenderer', () => {
21
- renderWithProviders(_jsx(DynamicFlow, Object.assign({}, props, { displayStepTitle: false })));
22
- expect(screen.queryByText('Step description.')).toBeInTheDocument();
23
- expect(screen.queryByText('Step Title')).not.toBeInTheDocument();
24
- });
25
- });
26
- describe('When the "displayStepTitle" flag is set to "true"', () => {
27
- it('shows the step title in the StepRenderer', () => {
28
- renderWithProviders(_jsx(DynamicFlow, Object.assign({}, props, { displayStepTitle: true })));
29
- expect(screen.queryByText('Step description.')).toBeInTheDocument();
30
- expect(screen.queryByText('Step Title')).toBeInTheDocument();
31
- });
32
- });
33
- describe('When the "hideStepTitle" feature is provided', () => {
34
- it('hides the step title in the StepRenderer', () => {
35
- renderWithProviders(_jsx(DynamicFlow, Object.assign({}, props, { features: { hideStepTitle: true } })));
36
- expect(screen.queryByText('Step description.')).toBeInTheDocument();
37
- expect(screen.queryByText('Step Title')).not.toBeInTheDocument();
38
- });
39
- });
40
- describe('When the "hideStepTitle" feature is provided as "false"', () => {
41
- it('shows the step title in the StepRenderer', () => {
42
- renderWithProviders(_jsx(DynamicFlow, Object.assign({}, props, { features: { hideStepTitle: false } })));
43
- expect(screen.queryByText('Step description.')).toBeInTheDocument();
44
- expect(screen.queryByText('Step Title')).toBeInTheDocument();
45
- });
46
- });
47
- describe('When both "displayStepTitle" flag and "hideStepTitle" feature are provided', () => {
48
- it('gives precedence to the "hideStepTitle" feature to hide the step title', () => {
49
- renderWithProviders(_jsx(DynamicFlow, Object.assign({}, props, { displayStepTitle: true, features: { hideStepTitle: true } })));
50
- expect(screen.queryByText('Step description.')).toBeInTheDocument();
51
- expect(screen.queryByText('Step Title')).not.toBeInTheDocument();
52
- });
53
- it('gives precedence to the "hideStepTitle" feature (even when false) to show the step title', () => {
54
- renderWithProviders(_jsx(DynamicFlow, Object.assign({}, props, { displayStepTitle: true, features: { hideStepTitle: false } })));
55
- expect(screen.queryByText('Step description.')).toBeInTheDocument();
56
- expect(screen.queryByText('Step Title')).toBeInTheDocument();
57
- });
58
- });
@@ -1,34 +0,0 @@
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
- });
@@ -1,71 +0,0 @@
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
- });