@player-ui/react 0.15.1--canary.803.31788 → 0.15.1--canary.807.31991
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/package.json
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
"types"
|
|
7
7
|
],
|
|
8
8
|
"name": "@player-ui/react",
|
|
9
|
-
"version": "0.15.1--canary.
|
|
9
|
+
"version": "0.15.1--canary.807.31991",
|
|
10
10
|
"main": "dist/cjs/index.cjs",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@player-ui/metrics-plugin": "0.15.1--canary.
|
|
13
|
-
"@player-ui/partial-match-registry": "0.15.1--canary.
|
|
14
|
-
"@player-ui/player": "0.15.1--canary.
|
|
15
|
-
"@player-ui/react-subscribe": "0.15.1--canary.
|
|
12
|
+
"@player-ui/metrics-plugin": "0.15.1--canary.807.31991",
|
|
13
|
+
"@player-ui/partial-match-registry": "0.15.1--canary.807.31991",
|
|
14
|
+
"@player-ui/player": "0.15.1--canary.807.31991",
|
|
15
|
+
"@player-ui/react-subscribe": "0.15.1--canary.807.31991",
|
|
16
16
|
"react-error-boundary": "^3.1.3",
|
|
17
17
|
"tapable-ts": "^0.2.3",
|
|
18
18
|
"leven": "3.1.0",
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { test, expect, vitest, describe, beforeEach } from "vitest";
|
|
2
2
|
import React, { Suspense } from "react";
|
|
3
3
|
import { makeFlow } from "@player-ui/make-flow";
|
|
4
|
-
import {
|
|
5
|
-
render,
|
|
6
|
-
act,
|
|
7
|
-
configure,
|
|
8
|
-
waitFor,
|
|
9
|
-
screen,
|
|
10
|
-
} from "@testing-library/react";
|
|
4
|
+
import { render, act, configure, screen } from "@testing-library/react";
|
|
11
5
|
import { userEvent } from "@testing-library/user-event";
|
|
12
6
|
import {
|
|
13
7
|
MetricsCorePlugin,
|
|
@@ -83,6 +77,7 @@ describe.each([
|
|
|
83
77
|
|
|
84
78
|
const onComplete = vitest.fn();
|
|
85
79
|
const onError = vitest.fn();
|
|
80
|
+
const onStartedFlow = vitest.fn();
|
|
86
81
|
|
|
87
82
|
const container = render(
|
|
88
83
|
<Suspense fallback="loading">
|
|
@@ -91,6 +86,7 @@ describe.each([
|
|
|
91
86
|
plugins={[new SimpleAssetPlugin(), new MetricsCorePlugin()]}
|
|
92
87
|
onComplete={onComplete}
|
|
93
88
|
onError={onError}
|
|
89
|
+
onStartedFlow={onStartedFlow}
|
|
94
90
|
/>
|
|
95
91
|
</Suspense>,
|
|
96
92
|
{ legacyRoot },
|
|
@@ -98,22 +94,26 @@ describe.each([
|
|
|
98
94
|
|
|
99
95
|
expect(manager.next).toBeCalledWith(undefined);
|
|
100
96
|
const view = await container.findByTestId("flow-1");
|
|
97
|
+
expect(onStartedFlow).toBeCalledTimes(1);
|
|
101
98
|
expect(view).toBeInTheDocument();
|
|
99
|
+
const nextButton = await container.findByText("Continue");
|
|
102
100
|
|
|
103
|
-
|
|
104
|
-
const nextButton = await container.findByText("Continue");
|
|
101
|
+
act(() => {
|
|
105
102
|
nextButton.click();
|
|
106
103
|
});
|
|
107
104
|
|
|
108
|
-
expect(manager.next).toBeCalledTimes(2);
|
|
109
|
-
|
|
110
105
|
const view2 = await container.findByTestId("flow-2");
|
|
111
106
|
expect(view2).toBeInTheDocument();
|
|
107
|
+
expect(manager.next).toBeCalledTimes(2);
|
|
108
|
+
expect(onStartedFlow).toBeCalledTimes(2);
|
|
112
109
|
|
|
113
|
-
await
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
const nextButton2 = await container.findByText("Continue");
|
|
111
|
+
|
|
112
|
+
act(() => {
|
|
113
|
+
nextButton2.click();
|
|
116
114
|
});
|
|
115
|
+
|
|
116
|
+
await container.findByText("loading");
|
|
117
117
|
const getRequestTime = (RequestTimeWebPlugin as any).mock.calls[0][0];
|
|
118
118
|
expect(getRequestTime()).toBeDefined();
|
|
119
119
|
expect(onComplete).toBeCalled();
|
|
@@ -183,21 +183,23 @@ describe.each([
|
|
|
183
183
|
expect(manager.next).toBeCalledWith(undefined);
|
|
184
184
|
const view = await screen.findByTestId("flow-1");
|
|
185
185
|
expect(view).toBeInTheDocument();
|
|
186
|
+
const nextButton = await screen.findByText("Continue");
|
|
186
187
|
|
|
187
|
-
|
|
188
|
-
const nextButton = await screen.findByText("Continue");
|
|
188
|
+
act(() => {
|
|
189
189
|
nextButton.click();
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
-
expect(manager.next).toBeCalledTimes(2);
|
|
193
|
-
|
|
194
192
|
const view2 = await screen.findByTestId("flow-2");
|
|
195
193
|
expect(view2).toBeInTheDocument();
|
|
194
|
+
expect(manager.next).toBeCalledTimes(2);
|
|
196
195
|
|
|
197
|
-
await
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
const nextButton2 = await screen.findByText("Continue");
|
|
197
|
+
|
|
198
|
+
act(() => {
|
|
199
|
+
nextButton2.click();
|
|
200
200
|
});
|
|
201
|
+
|
|
202
|
+
await screen.findByText("loading");
|
|
201
203
|
expect(onComplete).toBeCalledWith(
|
|
202
204
|
expect.objectContaining({
|
|
203
205
|
status: "completed",
|
|
@@ -240,9 +242,7 @@ describe.each([
|
|
|
240
242
|
|
|
241
243
|
const onComplete = vitest.fn();
|
|
242
244
|
const onError = vitest.fn();
|
|
243
|
-
|
|
244
|
-
*
|
|
245
|
-
*/
|
|
245
|
+
|
|
246
246
|
const MyFallback = (props: FallbackProps) => (
|
|
247
247
|
<div>
|
|
248
248
|
<button type="button" onClick={props?.retry}>
|
|
@@ -336,9 +336,6 @@ describe.each([
|
|
|
336
336
|
const onComplete = vitest.fn();
|
|
337
337
|
const onError = vitest.fn();
|
|
338
338
|
|
|
339
|
-
/**
|
|
340
|
-
*
|
|
341
|
-
*/
|
|
342
339
|
const MyFallback = (props: FallbackProps) => (
|
|
343
340
|
<div>
|
|
344
341
|
<button type="button" onClick={props?.retry}>
|
|
@@ -366,25 +363,24 @@ describe.each([
|
|
|
366
363
|
expect(manager.next).toBeCalledWith(undefined);
|
|
367
364
|
const view = await screen.findByTestId("flow-1");
|
|
368
365
|
expect(view).toBeInTheDocument();
|
|
366
|
+
const nextButton = await screen.findByText("Continue");
|
|
369
367
|
|
|
370
|
-
|
|
371
|
-
const nextButton = await screen.findByText("Continue");
|
|
368
|
+
act(() => {
|
|
372
369
|
nextButton.click();
|
|
373
370
|
});
|
|
374
371
|
|
|
375
|
-
await waitFor(() => expect(manager.next).toBeCalledTimes(2));
|
|
376
|
-
|
|
377
372
|
const view2 = await screen.findByTestId("flow-2");
|
|
378
373
|
expect(view2).toBeInTheDocument();
|
|
374
|
+
expect(manager.next).toBeCalledTimes(2);
|
|
379
375
|
|
|
380
|
-
|
|
376
|
+
act(() => {
|
|
381
377
|
view2.click();
|
|
382
378
|
});
|
|
383
379
|
|
|
384
380
|
const retryButton = await screen.findByText("Retry");
|
|
385
381
|
expect(retryButton).toBeInTheDocument();
|
|
386
382
|
|
|
387
|
-
|
|
383
|
+
act(() => {
|
|
388
384
|
retryButton.click();
|
|
389
385
|
});
|
|
390
386
|
|
|
@@ -393,17 +389,18 @@ describe.each([
|
|
|
393
389
|
const view3 = await screen.findByTestId("flow-2");
|
|
394
390
|
expect(view3).toBeInTheDocument();
|
|
395
391
|
|
|
396
|
-
|
|
392
|
+
act(() => {
|
|
397
393
|
view3.click();
|
|
398
394
|
});
|
|
399
395
|
|
|
400
396
|
const resetButton = await screen.findByText("Retry");
|
|
401
397
|
expect(resetButton).toBeInTheDocument();
|
|
402
398
|
|
|
403
|
-
|
|
399
|
+
act(() => {
|
|
404
400
|
resetButton.click();
|
|
405
401
|
});
|
|
406
402
|
|
|
403
|
+
await screen.findByText("loading");
|
|
407
404
|
expect(manager.next).toBeCalledTimes(4);
|
|
408
405
|
expect(onError).toBeCalledTimes(2);
|
|
409
406
|
|