@wise/dynamic-flow-client 3.9.1-experimental-152372b → 3.9.2-experimental-535221d
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/legacy/dynamicFlow/DynamicFlow.js +5 -5
- package/build/legacy/dynamicFlow/tests/Actions.spec.js +50 -3
- package/build/legacy/formControl/FormControl.js +6 -4
- package/build/legacy/jsonSchemaForm/JsonSchemaForm.end-to-end.spec.js +0 -29
- package/build/legacy/jsonSchemaForm/oneOfSchema/OneOfSchema.js +1 -1
- package/build/legacy/jsonSchemaForm/schemaFormControl/SchemaFormControl.js +6 -2
- package/build/main.js +1241 -1183
- package/build/main.min.js +1 -1
- package/build/main.mjs +943 -885
- package/build/revamp/DynamicFlowCore.js +2 -3
- package/build/revamp/DynamicFragmentWise.js +1 -1
- package/build/revamp/flow/executeSubmission.js +2 -2
- package/build/revamp/tests/RefreshOnChange.with.Segmented.spec.js +447 -0
- package/build/revamp/tests/RefreshOnChange.with.Tabs.spec.js +57 -0
- package/build/revamp/tests/SegmentedControl.spec.js +48 -0
- package/build/revamp/tests/legacy/Actions.spec.js +242 -0
- package/build/revamp/wise/renderers/ButtonRenderer.js +1 -1
- package/build/revamp/wise/renderers/DecisionRenderer.js +1 -1
- package/build/revamp/wise/renderers/SearchRenderer/BlockSearchRendererComponent.js +1 -1
- package/build/revamp/wise/renderers/SearchRenderer/InlineSearchRendererComponent.js +1 -1
- package/build/revamp/wise/renderers/SelectInputRenderer/SegmentedInputRendererComponent.js +21 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/SelectInputRenderer.js +3 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/SelectInputRendererComponent.js +2 -2
- package/build/revamp/wise/renderers/getWiseRenderers.js +2 -0
- package/build/revamp/{renderers → wise/renderers}/step/ExternalConfirmationDialog.js +1 -1
- package/build/types/legacy/jsonSchemaForm/schemaFormControl/SchemaFormControl.d.ts +1 -0
- package/build/types/legacy/layout/utils/index.d.ts +1 -1
- package/build/types/revamp/wise/renderers/SelectInputRenderer/SegmentedInputRendererComponent.d.ts +2 -0
- package/build/types/revamp/wise/renderers/getWiseRenderers.d.ts +1 -1
- package/build/types/revamp/{renderers → wise/renderers}/step/BackButton.d.ts +1 -1
- package/build/types/revamp/wise/renderers/step/StepRenderer.d.ts +2 -0
- package/build/types/revamp/{renderers → wise/renderers}/step/StepRendererContext.d.ts +2 -2
- package/build/types/revamp/wise/renderers/utils/layout-utils.d.ts +1 -1
- package/package.json +3 -3
- package/build/types/revamp/renderers/step/StepRenderer.d.ts +0 -2
- /package/build/revamp/{renderers → wise/renderers}/step/BackButton.js +0 -0
- /package/build/revamp/{renderers → wise/renderers}/step/StepRenderer.js +0 -0
- /package/build/revamp/{renderers → wise/renderers}/step/StepRendererContext.js +0 -0
- /package/build/revamp/{renderers → wise/renderers}/step/useExternal.js +0 -0
- /package/build/types/revamp/{renderers → wise/renderers}/step/ExternalConfirmationDialog.d.ts +0 -0
- /package/build/types/revamp/{renderers → wise/renderers}/step/useExternal.d.ts +0 -0
|
@@ -9,15 +9,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { useMemo } from 'react';
|
|
12
|
+
import ErrorBoundary from '../common/errorBoundary/ErrorBoundary';
|
|
12
13
|
import { CoreContainerRenderer } from './renderers/CoreContainerRenderer';
|
|
13
14
|
import { getRenderFunction } from './renderers/getRenderFunction';
|
|
14
|
-
import { StepRenderer } from './renderers/step/StepRenderer';
|
|
15
15
|
import { useDynamicFlowCore } from './useDynamicFlowCore';
|
|
16
|
-
import ErrorBoundary from '../common/errorBoundary/ErrorBoundary';
|
|
17
16
|
export function DynamicFlowCore(props) {
|
|
18
17
|
var stepComponentRef = useDynamicFlowCore(props).stepComponentRef;
|
|
19
18
|
var renderers = props.renderers, onEvent = props.onEvent, onError = props.onError;
|
|
20
|
-
var render = useMemo(function () { return getRenderFunction(__spreadArray(
|
|
19
|
+
var render = useMemo(function () { return getRenderFunction(__spreadArray([CoreContainerRenderer], renderers, true)); }, [renderers]);
|
|
21
20
|
return (_jsx(ErrorBoundary, { onError: function (error) {
|
|
22
21
|
onEvent === null || onEvent === void 0 ? void 0 : onEvent('Dynamic Flow - Failed', { error: error });
|
|
23
22
|
onError === null || onError === void 0 ? void 0 : onError(error);
|
|
@@ -49,7 +49,7 @@ import ErrorBoundary from '../common/errorBoundary/ErrorBoundary';
|
|
|
49
49
|
import { HttpClientProvider } from '../common/httpClientContext';
|
|
50
50
|
import { CoreContainerRenderer } from './renderers/CoreContainerRenderer';
|
|
51
51
|
import { getRenderFunction } from './renderers/getRenderFunction';
|
|
52
|
-
import { StepRenderer } from './renderers/step/StepRenderer';
|
|
52
|
+
import { StepRenderer } from './wise/renderers/step/StepRenderer';
|
|
53
53
|
import { useDynamicFlowCore } from './useDynamicFlowCore';
|
|
54
54
|
import { getWiseRenderers } from './wise/renderers/getWiseRenderers';
|
|
55
55
|
var wiseRenderers = getWiseRenderers();
|
|
@@ -92,7 +92,7 @@ export var executeSubmission = function (props) { return __awaiter(void 0, void
|
|
|
92
92
|
case 6:
|
|
93
93
|
body = _d.sent();
|
|
94
94
|
if (exit) {
|
|
95
|
-
return [2 /*return*/, { type: 'complete', result: mergeModels(
|
|
95
|
+
return [2 /*return*/, { type: 'complete', result: mergeModels(body, result) }];
|
|
96
96
|
}
|
|
97
97
|
_c = responseType;
|
|
98
98
|
switch (_c) {
|
|
@@ -112,7 +112,7 @@ export var executeSubmission = function (props) { return __awaiter(void 0, void
|
|
|
112
112
|
case 8:
|
|
113
113
|
{
|
|
114
114
|
trackSubmissionEvent('Action Succeeded', { actionId: actionId });
|
|
115
|
-
return [2 /*return*/, { type: 'complete', result: mergeModels(
|
|
115
|
+
return [2 /*return*/, { type: 'complete', result: mergeModels(body, result) }];
|
|
116
116
|
}
|
|
117
117
|
_d.label = 9;
|
|
118
118
|
case 9:
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
|
+
import { screen, waitFor } from '@testing-library/react';
|
|
50
|
+
import { userEvent } from '@testing-library/user-event';
|
|
51
|
+
import { renderWithProviders, respondWith } from '../../test-utils';
|
|
52
|
+
import DynamicFlowWise from '../DynamicFlowWise';
|
|
53
|
+
import { isObject, isString } from '../utils/type-validators';
|
|
54
|
+
var user = userEvent.setup();
|
|
55
|
+
var getProps = function () { return ({
|
|
56
|
+
flowId: 'flow-id',
|
|
57
|
+
initialStep: initialStep,
|
|
58
|
+
httpClient: (function (input, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
+
var payload, currency, step;
|
|
60
|
+
var _a, _b;
|
|
61
|
+
return __generator(this, function (_c) {
|
|
62
|
+
payload = JSON.parse((_b = (_a = init === null || init === void 0 ? void 0 : init.body) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "{}");
|
|
63
|
+
currency = isObject(payload) && isString(payload.currency) ? payload.currency : 'GBP';
|
|
64
|
+
step = steps[currency];
|
|
65
|
+
return [2 /*return*/, respondWith(step)];
|
|
66
|
+
});
|
|
67
|
+
}); }),
|
|
68
|
+
onCompletion: jest.fn(),
|
|
69
|
+
onError: jest.fn(),
|
|
70
|
+
onEvent: jest.fn(),
|
|
71
|
+
onLog: jest.fn(),
|
|
72
|
+
}); };
|
|
73
|
+
describe('RefreshOnChange with SegmentedControl', function () {
|
|
74
|
+
describe('given a oneOf schema with refresh-on-change and the child schemas contain a oneOf with control segmented', function () {
|
|
75
|
+
it('selects the fist tab by default', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (_a.label) {
|
|
78
|
+
case 0:
|
|
79
|
+
renderWithProviders(_jsx(DynamicFlowWise, __assign({}, getProps())));
|
|
80
|
+
return [4 /*yield*/, waitFor(function () {
|
|
81
|
+
expect(screen.getByText(initialStep.title)).toBeInTheDocument();
|
|
82
|
+
})];
|
|
83
|
+
case 1:
|
|
84
|
+
_a.sent();
|
|
85
|
+
expect(screen.getByText('IBAN')).toBeInTheDocument();
|
|
86
|
+
return [2 /*return*/];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}); });
|
|
90
|
+
it('selects the first tab by default, even after a refresh-on-change', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
93
|
+
case 0:
|
|
94
|
+
renderWithProviders(_jsx(DynamicFlowWise, __assign({}, getProps())));
|
|
95
|
+
return [4 /*yield*/, waitFor(function () {
|
|
96
|
+
expect(screen.getByText(initialStep.title)).toBeInTheDocument();
|
|
97
|
+
})];
|
|
98
|
+
case 1:
|
|
99
|
+
_a.sent();
|
|
100
|
+
return [4 /*yield*/, user.click(screen.getByText('EUR'))];
|
|
101
|
+
case 2:
|
|
102
|
+
_a.sent();
|
|
103
|
+
return [4 /*yield*/, user.click(screen.getByText('GBP'))];
|
|
104
|
+
case 3:
|
|
105
|
+
_a.sent();
|
|
106
|
+
return [4 /*yield*/, waitFor(function () {
|
|
107
|
+
expect(screen.getByText('UK sort code')).toBeInTheDocument();
|
|
108
|
+
})];
|
|
109
|
+
case 4:
|
|
110
|
+
_a.sent();
|
|
111
|
+
return [2 /*return*/];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}); });
|
|
115
|
+
describe('when another value in the form has been entered and causes a refresh', function () {
|
|
116
|
+
it('selects the matching tab, not the first', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
117
|
+
var mockHttpClient, props;
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
|
+
case 0:
|
|
121
|
+
mockHttpClient = jest.fn().mockImplementation(function (input, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
122
|
+
return __generator(this, function (_a) {
|
|
123
|
+
return [2 /*return*/, respondWith(__assign(__assign({}, steps.GBP), { model: {
|
|
124
|
+
currency: 'GBP',
|
|
125
|
+
type: 'SwiftCode',
|
|
126
|
+
} }))];
|
|
127
|
+
});
|
|
128
|
+
}); });
|
|
129
|
+
props = __assign(__assign({}, getProps()), { initialStep: steps.GBP, httpClient: mockHttpClient });
|
|
130
|
+
renderWithProviders(_jsx(DynamicFlowWise, __assign({}, props)));
|
|
131
|
+
return [4 /*yield*/, user.click(screen.getByText('SWIFT'))];
|
|
132
|
+
case 1:
|
|
133
|
+
_a.sent();
|
|
134
|
+
return [4 /*yield*/, user.type(screen.getByText('SWIFT / BIC code'), '12345')];
|
|
135
|
+
case 2:
|
|
136
|
+
_a.sent();
|
|
137
|
+
return [4 /*yield*/, user.click(screen.getByText('IBAN'))];
|
|
138
|
+
case 3:
|
|
139
|
+
_a.sent();
|
|
140
|
+
return [4 /*yield*/, user.type(screen.getByText('Refresh Field'), 'some value')];
|
|
141
|
+
case 4:
|
|
142
|
+
_a.sent();
|
|
143
|
+
return [4 /*yield*/, user.tab()];
|
|
144
|
+
case 5:
|
|
145
|
+
_a.sent();
|
|
146
|
+
return [4 /*yield*/, waitFor(function () {
|
|
147
|
+
expect(mockHttpClient).toHaveBeenCalledTimes(1);
|
|
148
|
+
})];
|
|
149
|
+
case 6:
|
|
150
|
+
_a.sent();
|
|
151
|
+
// we show the correct child content
|
|
152
|
+
return [4 /*yield*/, waitFor(function () {
|
|
153
|
+
expect(screen.getByText('SWIFT / BIC code')).toBeInTheDocument();
|
|
154
|
+
})];
|
|
155
|
+
case 7:
|
|
156
|
+
// we show the correct child content
|
|
157
|
+
_a.sent();
|
|
158
|
+
// the correct tab is shown to be selected
|
|
159
|
+
expect(screen.getByRole('tab', { name: 'SWIFT' })).toHaveAttribute('aria-selected', 'true');
|
|
160
|
+
return [2 /*return*/];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}); });
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
var currencyObjectSchema = {
|
|
168
|
+
type: 'object',
|
|
169
|
+
displayOrder: ['currency'],
|
|
170
|
+
properties: {
|
|
171
|
+
currency: {
|
|
172
|
+
title: 'Currency',
|
|
173
|
+
analyticsId: 'currency-select',
|
|
174
|
+
oneOf: [
|
|
175
|
+
{
|
|
176
|
+
title: 'EUR',
|
|
177
|
+
analyticsId: 'EUR',
|
|
178
|
+
icon: { name: 'flag-eur' },
|
|
179
|
+
description: 'Euro',
|
|
180
|
+
const: 'EUR',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
title: 'GBP',
|
|
184
|
+
analyticsId: 'GBP',
|
|
185
|
+
icon: { name: 'flag-gbp' },
|
|
186
|
+
description: 'British pound',
|
|
187
|
+
const: 'GBP',
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
refreshStepOnChange: true,
|
|
191
|
+
default: 'EUR',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
var steps = {
|
|
196
|
+
GBP: {
|
|
197
|
+
id: 'account',
|
|
198
|
+
type: 'form',
|
|
199
|
+
title: 'Enter their account details',
|
|
200
|
+
actions: [
|
|
201
|
+
{
|
|
202
|
+
title: 'Confirm',
|
|
203
|
+
url: '/submit',
|
|
204
|
+
type: 'primary',
|
|
205
|
+
method: 'POST',
|
|
206
|
+
$id: 'submit',
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
schemas: [
|
|
210
|
+
{
|
|
211
|
+
allOf: [
|
|
212
|
+
currencyObjectSchema,
|
|
213
|
+
{
|
|
214
|
+
title: 'Bank details',
|
|
215
|
+
analyticsId: 'recipient-type',
|
|
216
|
+
oneOf: [
|
|
217
|
+
{
|
|
218
|
+
title: 'Local bank account',
|
|
219
|
+
type: 'object',
|
|
220
|
+
analyticsId: 'SortCode',
|
|
221
|
+
icon: { name: 'bank', type: 'icon' },
|
|
222
|
+
displayOrder: ['name', 'details', 'type'],
|
|
223
|
+
properties: {
|
|
224
|
+
name: {
|
|
225
|
+
title: 'Full name of the account holder',
|
|
226
|
+
type: 'string',
|
|
227
|
+
},
|
|
228
|
+
details: {
|
|
229
|
+
type: 'object',
|
|
230
|
+
displayOrder: ['sortCode', 'accountNumber'],
|
|
231
|
+
properties: {
|
|
232
|
+
sortCode: {
|
|
233
|
+
title: 'UK sort code',
|
|
234
|
+
type: 'string',
|
|
235
|
+
placeholder: '40-30-20',
|
|
236
|
+
format: 'numeric',
|
|
237
|
+
},
|
|
238
|
+
accountNumber: {
|
|
239
|
+
title: 'Account number',
|
|
240
|
+
type: 'string',
|
|
241
|
+
placeholder: '12345678',
|
|
242
|
+
format: 'numeric',
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
type: {
|
|
247
|
+
const: 'SortCode',
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
title: 'IBAN',
|
|
253
|
+
type: 'object',
|
|
254
|
+
analyticsId: 'Iban',
|
|
255
|
+
icon: { name: 'bank', type: 'icon' },
|
|
256
|
+
displayOrder: ['name', 'details', 'type'],
|
|
257
|
+
properties: {
|
|
258
|
+
name: {
|
|
259
|
+
title: 'Full name of the account holder',
|
|
260
|
+
type: 'string',
|
|
261
|
+
},
|
|
262
|
+
details: {
|
|
263
|
+
type: 'object',
|
|
264
|
+
displayOrder: ['bic', 'iban'],
|
|
265
|
+
properties: {
|
|
266
|
+
bic: {
|
|
267
|
+
title: 'Bank code (BIC/SWIFT)',
|
|
268
|
+
type: 'string',
|
|
269
|
+
hidden: true,
|
|
270
|
+
placeholder: "Please choose recipient's bank",
|
|
271
|
+
},
|
|
272
|
+
iban: {
|
|
273
|
+
title: 'IBAN',
|
|
274
|
+
type: 'string',
|
|
275
|
+
placeholder: 'DE12345678901234567890',
|
|
276
|
+
displayFormat: '**** **** **** **** **** **** **** ****',
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
type: {
|
|
281
|
+
const: 'Iban',
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
title: 'SWIFT',
|
|
287
|
+
type: 'object',
|
|
288
|
+
analyticsId: 'SwiftCode',
|
|
289
|
+
icon: { name: 'bank', type: 'icon' },
|
|
290
|
+
displayOrder: ['name', 'details', 'type'],
|
|
291
|
+
properties: {
|
|
292
|
+
name: {
|
|
293
|
+
title: 'Full name of the account holder',
|
|
294
|
+
type: 'string',
|
|
295
|
+
},
|
|
296
|
+
details: {
|
|
297
|
+
type: 'object',
|
|
298
|
+
displayOrder: ['bic', 'accountNumber'],
|
|
299
|
+
properties: {
|
|
300
|
+
bic: {
|
|
301
|
+
title: 'SWIFT / BIC code',
|
|
302
|
+
type: 'string',
|
|
303
|
+
placeholder: 'BUKBGB22',
|
|
304
|
+
},
|
|
305
|
+
accountNumber: {
|
|
306
|
+
title: 'IBAN / Account number',
|
|
307
|
+
type: 'string',
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
type: {
|
|
312
|
+
const: 'SwiftCode',
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
control: 'segmented',
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
$id: 'form',
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
$id: '#refresh',
|
|
324
|
+
type: 'string',
|
|
325
|
+
title: 'Refresh Field',
|
|
326
|
+
refreshStepOnChange: true,
|
|
327
|
+
},
|
|
328
|
+
],
|
|
329
|
+
refreshFormUrl: '/refresh',
|
|
330
|
+
model: {
|
|
331
|
+
currency: 'GBP',
|
|
332
|
+
details: {},
|
|
333
|
+
},
|
|
334
|
+
layout: [
|
|
335
|
+
{ schema: { $ref: 'form' }, type: 'form' },
|
|
336
|
+
{ schema: { $ref: '#refresh' }, type: 'form' },
|
|
337
|
+
{ type: 'button', action: { $ref: 'submit' } },
|
|
338
|
+
],
|
|
339
|
+
},
|
|
340
|
+
EUR: {
|
|
341
|
+
id: 'account',
|
|
342
|
+
type: 'form',
|
|
343
|
+
title: 'Enter their account details',
|
|
344
|
+
actions: [
|
|
345
|
+
{
|
|
346
|
+
title: 'Confirm',
|
|
347
|
+
url: '/submit',
|
|
348
|
+
type: 'primary',
|
|
349
|
+
method: 'POST',
|
|
350
|
+
$id: 'submit',
|
|
351
|
+
},
|
|
352
|
+
],
|
|
353
|
+
schemas: [
|
|
354
|
+
{
|
|
355
|
+
allOf: [
|
|
356
|
+
currencyObjectSchema,
|
|
357
|
+
{
|
|
358
|
+
title: 'Bank details',
|
|
359
|
+
analyticsId: 'recipient-type',
|
|
360
|
+
oneOf: [
|
|
361
|
+
{
|
|
362
|
+
title: 'Inside Europe',
|
|
363
|
+
type: 'object',
|
|
364
|
+
analyticsId: 'Iban',
|
|
365
|
+
icon: { name: 'bank', type: 'icon' },
|
|
366
|
+
displayOrder: ['name', 'details', 'type'],
|
|
367
|
+
properties: {
|
|
368
|
+
name: {
|
|
369
|
+
title: 'Full name of the account holder',
|
|
370
|
+
type: 'string',
|
|
371
|
+
},
|
|
372
|
+
details: {
|
|
373
|
+
type: 'object',
|
|
374
|
+
displayOrder: ['bic', 'iban'],
|
|
375
|
+
properties: {
|
|
376
|
+
bic: {
|
|
377
|
+
title: 'Bank code (BIC/SWIFT)',
|
|
378
|
+
type: 'string',
|
|
379
|
+
hidden: true,
|
|
380
|
+
placeholder: 'BARCGB22XXX',
|
|
381
|
+
},
|
|
382
|
+
iban: {
|
|
383
|
+
title: 'IBAN',
|
|
384
|
+
type: 'string',
|
|
385
|
+
placeholder: 'DE12345678901234567890',
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
type: {
|
|
390
|
+
const: 'Iban',
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
required: ['type', 'name', 'details'],
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
title: 'Outside Europe',
|
|
397
|
+
type: 'object',
|
|
398
|
+
analyticsId: 'SwiftCode',
|
|
399
|
+
icon: { name: 'bank', type: 'icon' },
|
|
400
|
+
displayOrder: ['name', 'details', 'type'],
|
|
401
|
+
properties: {
|
|
402
|
+
name: {
|
|
403
|
+
title: 'Full name of the account holder',
|
|
404
|
+
type: 'string',
|
|
405
|
+
},
|
|
406
|
+
details: {
|
|
407
|
+
type: 'object',
|
|
408
|
+
displayOrder: ['bic', 'accountNumber'],
|
|
409
|
+
properties: {
|
|
410
|
+
bic: {
|
|
411
|
+
title: 'SWIFT / BIC code',
|
|
412
|
+
type: 'string',
|
|
413
|
+
placeholder: 'BUKBGB22',
|
|
414
|
+
},
|
|
415
|
+
accountNumber: {
|
|
416
|
+
title: 'IBAN / Account number',
|
|
417
|
+
type: 'string',
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
required: ['bic', 'accountNumber'],
|
|
421
|
+
},
|
|
422
|
+
type: {
|
|
423
|
+
const: 'SwiftCode',
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
required: ['type', 'name', 'details'],
|
|
427
|
+
},
|
|
428
|
+
],
|
|
429
|
+
control: 'segmented',
|
|
430
|
+
placeholder: 'Please select where you are sending to',
|
|
431
|
+
},
|
|
432
|
+
],
|
|
433
|
+
$id: 'form',
|
|
434
|
+
},
|
|
435
|
+
],
|
|
436
|
+
refreshFormUrl: '/refresh',
|
|
437
|
+
model: {
|
|
438
|
+
currency: 'EUR',
|
|
439
|
+
details: {},
|
|
440
|
+
},
|
|
441
|
+
layout: [
|
|
442
|
+
{ schema: { $ref: 'form' }, type: 'form' },
|
|
443
|
+
{ type: 'button', action: { $ref: 'submit' } },
|
|
444
|
+
],
|
|
445
|
+
},
|
|
446
|
+
};
|
|
447
|
+
var initialStep = steps.EUR;
|
|
@@ -112,6 +112,56 @@ describe('RefreshOnChange with Tabs', function () {
|
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
}); });
|
|
115
|
+
describe('when another value in the form has been entered and causes a refresh', function () {
|
|
116
|
+
it('selects the matching tab, not the first', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
117
|
+
var mockHttpClient, props;
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
|
+
case 0:
|
|
121
|
+
mockHttpClient = jest.fn().mockImplementation(function (input, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
122
|
+
return __generator(this, function (_a) {
|
|
123
|
+
return [2 /*return*/, respondWith(__assign(__assign({}, steps.GBP), { model: {
|
|
124
|
+
currency: 'GBP',
|
|
125
|
+
type: 'SwiftCode',
|
|
126
|
+
} }))];
|
|
127
|
+
});
|
|
128
|
+
}); });
|
|
129
|
+
props = __assign(__assign({}, getProps()), { initialStep: steps.GBP, httpClient: mockHttpClient });
|
|
130
|
+
renderWithProviders(_jsx(DynamicFlowWise, __assign({}, props)));
|
|
131
|
+
return [4 /*yield*/, user.click(screen.getByText('SWIFT'))];
|
|
132
|
+
case 1:
|
|
133
|
+
_a.sent();
|
|
134
|
+
return [4 /*yield*/, user.type(screen.getByText('SWIFT / BIC code'), '12345')];
|
|
135
|
+
case 2:
|
|
136
|
+
_a.sent();
|
|
137
|
+
return [4 /*yield*/, user.click(screen.getByText('IBAN'))];
|
|
138
|
+
case 3:
|
|
139
|
+
_a.sent();
|
|
140
|
+
return [4 /*yield*/, user.type(screen.getByText('Refresh Field'), 'some value')];
|
|
141
|
+
case 4:
|
|
142
|
+
_a.sent();
|
|
143
|
+
return [4 /*yield*/, user.tab()];
|
|
144
|
+
case 5:
|
|
145
|
+
_a.sent();
|
|
146
|
+
return [4 /*yield*/, waitFor(function () {
|
|
147
|
+
expect(mockHttpClient).toHaveBeenCalledTimes(1);
|
|
148
|
+
})];
|
|
149
|
+
case 6:
|
|
150
|
+
_a.sent();
|
|
151
|
+
// we show the correct child content
|
|
152
|
+
return [4 /*yield*/, waitFor(function () {
|
|
153
|
+
expect(screen.getByText('SWIFT / BIC code')).toBeInTheDocument();
|
|
154
|
+
})];
|
|
155
|
+
case 7:
|
|
156
|
+
// we show the correct child content
|
|
157
|
+
_a.sent();
|
|
158
|
+
// the correct tab is shown to be selected
|
|
159
|
+
expect(screen.getByRole('tab', { name: 'SWIFT' })).toHaveAttribute('aria-selected', 'true');
|
|
160
|
+
return [2 /*return*/];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}); });
|
|
164
|
+
});
|
|
115
165
|
});
|
|
116
166
|
});
|
|
117
167
|
var currencyObjectSchema = {
|
|
@@ -269,6 +319,12 @@ var steps = {
|
|
|
269
319
|
],
|
|
270
320
|
$id: 'form',
|
|
271
321
|
},
|
|
322
|
+
{
|
|
323
|
+
$id: '#refresh',
|
|
324
|
+
type: 'string',
|
|
325
|
+
title: 'Refresh Field',
|
|
326
|
+
refreshStepOnChange: true,
|
|
327
|
+
},
|
|
272
328
|
],
|
|
273
329
|
refreshFormUrl: '/refresh',
|
|
274
330
|
model: {
|
|
@@ -277,6 +333,7 @@ var steps = {
|
|
|
277
333
|
},
|
|
278
334
|
layout: [
|
|
279
335
|
{ schema: { $ref: 'form' }, type: 'form' },
|
|
336
|
+
{ schema: { $ref: '#refresh' }, type: 'form' },
|
|
280
337
|
{ type: 'button', action: { $ref: 'submit' } },
|
|
281
338
|
],
|
|
282
339
|
},
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { renderWithProviders } from '../../test-utils';
|
|
3
|
+
import DynamicFlowWise from '../DynamicFlowWise';
|
|
4
|
+
import { screen } from '@testing-library/react';
|
|
5
|
+
describe('given a step with a oneOf schema with control segmented', function () {
|
|
6
|
+
var makeConstSchema = function (options) { return ({
|
|
7
|
+
oneOf: Array(options)
|
|
8
|
+
.fill(0)
|
|
9
|
+
.map(function (value, index) { return ({
|
|
10
|
+
const: String(index),
|
|
11
|
+
title: "Option ".concat(index + 1),
|
|
12
|
+
}); }),
|
|
13
|
+
title: '',
|
|
14
|
+
control: 'segmented',
|
|
15
|
+
}); };
|
|
16
|
+
var initialStep = function (options) { return ({
|
|
17
|
+
id: 'step-id',
|
|
18
|
+
title: 'title',
|
|
19
|
+
layout: [
|
|
20
|
+
{
|
|
21
|
+
type: 'form',
|
|
22
|
+
schemaId: '#schema',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
schemas: [
|
|
26
|
+
{
|
|
27
|
+
$id: '#schema',
|
|
28
|
+
type: 'object',
|
|
29
|
+
displayOrder: ['paymentMethod'],
|
|
30
|
+
properties: {
|
|
31
|
+
paymentMethod: makeConstSchema(options),
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
}); };
|
|
36
|
+
it('when it has 3 or fewer children, a SegmentedControl is rendered', function () {
|
|
37
|
+
renderWithProviders(_jsx(DynamicFlowWise, { flowId: "flow", initialStep: initialStep(3), httpClient: jest.fn(), onError: jest.fn(), onCompletion: jest.fn() }));
|
|
38
|
+
expect(screen.getByText('Option 1')).toBeInTheDocument();
|
|
39
|
+
expect(screen.getByText('Option 2')).toBeInTheDocument();
|
|
40
|
+
expect(screen.getByText('Option 3')).toBeInTheDocument();
|
|
41
|
+
});
|
|
42
|
+
it('when it has more than 3 children, a select is rendered', function () {
|
|
43
|
+
renderWithProviders(_jsx(DynamicFlowWise, { flowId: "flow", initialStep: initialStep(4), httpClient: jest.fn(), onError: jest.fn(), onCompletion: jest.fn() }));
|
|
44
|
+
expect(screen.queryByText('Option 1')).not.toBeInTheDocument();
|
|
45
|
+
expect(screen.queryByText('Option 2')).not.toBeInTheDocument();
|
|
46
|
+
expect(screen.queryByText('Option 3')).not.toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
});
|