@wise/dynamic-flow-client 3.7.2-experimental-1ba6fef → 3.8.0-beta-ba9b66e

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.
@@ -7,8 +7,7 @@ export function useExternal(url) {
7
7
  useEffect(function () {
8
8
  if (url) {
9
9
  setHasManuallyTriggered(false);
10
- setExternalWindow(null);
11
- // setExternalWindow(window.open(url, '_blank'));
10
+ setExternalWindow(window.open(url, '_blank'));
12
11
  }
13
12
  }, [url]);
14
13
  var requiresManualTrigger = Boolean(url && !externalWindow && !hasManuallyTriggered);
@@ -65,16 +65,24 @@ describe('useExternal', function () {
65
65
  layout: [{ type: 'paragraph', text: 'This is a paragraph in the step layout' }],
66
66
  schemas: [],
67
67
  };
68
- // it('attempts to open the specified URL, but ONLY ONCE', async () => {
69
- // jest.spyOn(window, 'open');
70
- // mockWindowOpenSuccess();
71
- // renderComponent(step);
72
- // expect(window.open).toHaveBeenCalledTimes(1);
73
- // expect(window.open).toHaveBeenCalledWith('https://third-party.website', '_blank');
74
- // await waitFor(() => {
75
- // expect(window.open).toHaveBeenCalledTimes(1);
76
- // });
77
- // });
68
+ it('attempts to open the specified URL, but ONLY ONCE', function () { return __awaiter(void 0, void 0, void 0, function () {
69
+ return __generator(this, function (_a) {
70
+ switch (_a.label) {
71
+ case 0:
72
+ jest.spyOn(window, 'open');
73
+ mockWindowOpenSuccess();
74
+ renderComponent(step);
75
+ expect(window.open).toHaveBeenCalledTimes(1);
76
+ expect(window.open).toHaveBeenCalledWith('https://third-party.website', '_blank');
77
+ return [4 /*yield*/, waitFor(function () {
78
+ expect(window.open).toHaveBeenCalledTimes(1);
79
+ })];
80
+ case 1:
81
+ _a.sent();
82
+ return [2 /*return*/];
83
+ }
84
+ });
85
+ }); });
78
86
  describe('when the window/tab fails to open', function () {
79
87
  it('displays a confirmation UI (ExternalConfirmationStep)', function () { return __awaiter(void 0, void 0, void 0, function () {
80
88
  return __generator(this, function (_a) {
@@ -181,17 +189,23 @@ describe('useExternal', function () {
181
189
  }); });
182
190
  });
183
191
  });
184
- // describe('when the window/tab opens successfully', () => {
185
- // it('displays the step normally', async () => {
186
- // jest.spyOn(window, 'open');
187
- // mockWindowOpenSuccess();
188
- // renderComponent(step);
189
- // await expect(
190
- // screen.findByText('This is a paragraph in the step layout'),
191
- // ).resolves.toBeInTheDocument();
192
- // expect(screen.queryByText('Please confirm')).not.toBeInTheDocument();
193
- // });
194
- // });
192
+ describe('when the window/tab opens successfully', function () {
193
+ it('displays the step normally', function () { return __awaiter(void 0, void 0, void 0, function () {
194
+ return __generator(this, function (_a) {
195
+ switch (_a.label) {
196
+ case 0:
197
+ jest.spyOn(window, 'open');
198
+ mockWindowOpenSuccess();
199
+ renderComponent(step);
200
+ return [4 /*yield*/, expect(screen.findByText('This is a paragraph in the step layout')).resolves.toBeInTheDocument()];
201
+ case 1:
202
+ _a.sent();
203
+ expect(screen.queryByText('Please confirm')).not.toBeInTheDocument();
204
+ return [2 /*return*/];
205
+ }
206
+ });
207
+ }); });
208
+ });
195
209
  });
196
210
  describe('Given a step with a malformed "external" property', function () {
197
211
  var step = {
package/build/main.js CHANGED
@@ -1460,7 +1460,7 @@ function useExternal(url) {
1460
1460
  (0, import_react7.useEffect)(() => {
1461
1461
  if (url) {
1462
1462
  setHasManuallyTriggered(false);
1463
- setExternalWindow(null);
1463
+ setExternalWindow(window.open(url, "_blank"));
1464
1464
  }
1465
1465
  }, [url]);
1466
1466
  const requiresManualTrigger = Boolean(url && !externalWindow && !hasManuallyTriggered);