@transferwise/components 46.84.0 → 46.84.1
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "46.84.
|
|
3
|
+
"version": "46.84.1",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -91,9 +91,9 @@
|
|
|
91
91
|
"rollup": "^4.18.1",
|
|
92
92
|
"rollup-preserve-directives": "^1.1.1",
|
|
93
93
|
"storybook": "^8.2.2",
|
|
94
|
-
"@transferwise/less-config": "3.1.0",
|
|
95
94
|
"@transferwise/neptune-css": "14.20.1",
|
|
96
|
-
"@wise/components-theming": "1.6.1"
|
|
95
|
+
"@wise/components-theming": "1.6.1",
|
|
96
|
+
"@transferwise/less-config": "3.1.0"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"@transferwise/icons": "^3.13.1",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { expect, fn, type Mock, screen, userEvent, within } from '@storybook/test';
|
|
2
|
+
import { expect, fn, type Mock, screen, userEvent, within, waitFor } from '@storybook/test';
|
|
3
3
|
import { Calendar, ChevronDown } from '@transferwise/icons';
|
|
4
4
|
import { Flag } from '@wise/art';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
@@ -75,7 +75,7 @@ export const Months: Story<Month | null> = {
|
|
|
75
75
|
|
|
76
76
|
await step('renders placeholder', async () => {
|
|
77
77
|
const triggerButton = canvas.getByRole('combobox');
|
|
78
|
-
await expect(triggerButton).toHaveTextContent('Month');
|
|
78
|
+
await waitFor(async () => expect(triggerButton).toHaveTextContent('Month'));
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
await step('selects option via mouse', async () => {
|
|
@@ -89,7 +89,7 @@ export const Months: Story<Month | null> = {
|
|
|
89
89
|
});
|
|
90
90
|
await userEvent.click(option);
|
|
91
91
|
|
|
92
|
-
await expect(triggerButton).toHaveTextContent('May');
|
|
92
|
+
await waitFor(async () => expect(triggerButton).toHaveTextContent('May'));
|
|
93
93
|
});
|
|
94
94
|
},
|
|
95
95
|
};
|
|
@@ -189,27 +189,61 @@ const CurrenciesArgs = {
|
|
|
189
189
|
export const Currencies: Story<Currency> = {
|
|
190
190
|
args: CurrenciesArgs,
|
|
191
191
|
play: async ({ step }) => {
|
|
192
|
-
await step('
|
|
192
|
+
await step('Tab to the combobox', async () => {
|
|
193
193
|
await userEvent.tab();
|
|
194
|
-
|
|
194
|
+
});
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
await
|
|
196
|
+
await step('Open the combobox', async () => {
|
|
197
|
+
await userEvent.keyboard(' ');
|
|
198
|
+
});
|
|
198
199
|
|
|
199
|
-
|
|
200
|
+
await step('Check if options are displayed', async () => {
|
|
201
|
+
await waitFor(async () => expect(await screen.findAllByRole('option')).toHaveLength(8));
|
|
202
|
+
await waitFor(async () => expect(screen.getByText(/^Can’t find it?/u)).toBeInTheDocument());
|
|
203
|
+
});
|
|
200
204
|
|
|
201
|
-
|
|
205
|
+
await step('Type "huf" in the combobox', async () => {
|
|
206
|
+
// this is workaround for Chromatic: Firefox and Edge tests failing.
|
|
207
|
+
// Unclear on a proper solution
|
|
208
|
+
await wait(750);
|
|
209
|
+
const input = await screen.findByRole('combobox');
|
|
202
210
|
await userEvent.type(input, 'huf');
|
|
203
|
-
|
|
204
|
-
within(screen.getByRole('listbox')).queryByRole('option'),
|
|
205
|
-
).not.toBeInTheDocument();
|
|
206
|
-
await expect(screen.getByText(/^It’s not possible use HUF yet./u)).toBeInTheDocument();
|
|
211
|
+
});
|
|
207
212
|
|
|
213
|
+
await step('Check if no options are displayed', async () => {
|
|
214
|
+
// this is workaround for Chromatic: Firefox and Edge tests failing.
|
|
215
|
+
// Unclear on a proper solution
|
|
216
|
+
await wait(750);
|
|
217
|
+
await expect(await screen.findByText(/^No results found/u)).toBeInTheDocument();
|
|
218
|
+
await expect(await screen.findByText(/^It’s not possible use HUF yet./u)).toBeInTheDocument();
|
|
219
|
+
await waitFor(
|
|
220
|
+
async () => {
|
|
221
|
+
await expect(screen.queryAllByRole('option')).toHaveLength(0);
|
|
222
|
+
},
|
|
223
|
+
{ timeout: 1500 },
|
|
224
|
+
);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
await step('Remove last two characters', async () => {
|
|
228
|
+
await wait(500);
|
|
229
|
+
const input = await screen.findByRole('combobox');
|
|
208
230
|
await userEvent.type(input, '{Backspace}{Backspace}');
|
|
209
|
-
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
await step('Check if two options are displayed', async () => {
|
|
234
|
+
await waitFor(async () =>
|
|
235
|
+
expect(within(screen.getByRole('listbox')).queryAllByRole('option')).toHaveLength(2),
|
|
236
|
+
);
|
|
237
|
+
});
|
|
210
238
|
|
|
239
|
+
await step('Type "e" in the combobox', async () => {
|
|
240
|
+
const input = await screen.findByRole('combobox');
|
|
211
241
|
await userEvent.type(input, '{Backspace}e');
|
|
212
|
-
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
await step('Check if aria-activedescendant is not set', async () => {
|
|
245
|
+
const input = screen.getByRole('combobox');
|
|
246
|
+
await waitFor(async () => expect(input).toHaveAttribute('aria-activedescendant'));
|
|
213
247
|
});
|
|
214
248
|
},
|
|
215
249
|
};
|
|
@@ -234,18 +268,24 @@ export const MultipleCurrencies: Story<Currency, true> = {
|
|
|
234
268
|
play: async ({ canvasElement, step }) => {
|
|
235
269
|
const canvas = within(canvasElement);
|
|
236
270
|
|
|
237
|
-
await step('
|
|
271
|
+
await step('Open the combobox', async () => {
|
|
238
272
|
const triggerButton = canvas.getByRole('combobox');
|
|
239
|
-
|
|
240
273
|
await userEvent.click(triggerButton);
|
|
274
|
+
await wait(500);
|
|
241
275
|
await userEvent.unhover(triggerButton);
|
|
276
|
+
});
|
|
242
277
|
|
|
278
|
+
await step('Select EUR option', async () => {
|
|
243
279
|
const option = within(screen.getByRole('listbox')).getAllByRole('option', {
|
|
244
280
|
name: /^EUR/u,
|
|
245
281
|
})[0];
|
|
282
|
+
await wait(500);
|
|
246
283
|
await userEvent.click(option);
|
|
284
|
+
});
|
|
247
285
|
|
|
248
|
-
|
|
286
|
+
await step('Check if selected options are displayed', async () => {
|
|
287
|
+
const triggerButton = document.querySelector('button[role="combobox"]');
|
|
288
|
+
await waitFor(async () => expect(triggerButton).toHaveTextContent('USD, EUR'));
|
|
249
289
|
});
|
|
250
290
|
},
|
|
251
291
|
};
|
|
@@ -270,11 +310,13 @@ export const CustomTrigger: Story<Month> = {
|
|
|
270
310
|
),
|
|
271
311
|
onChange: fn() satisfies Mock,
|
|
272
312
|
},
|
|
273
|
-
play: async ({ canvasElement }) => {
|
|
313
|
+
play: async ({ canvasElement, step }) => {
|
|
274
314
|
const canvas = within(canvasElement);
|
|
275
315
|
|
|
276
|
-
|
|
277
|
-
|
|
316
|
+
await step('Open the combobox', async () => {
|
|
317
|
+
const triggerButton = canvas.getByRole('combobox');
|
|
318
|
+
await userEvent.click(triggerButton);
|
|
319
|
+
});
|
|
278
320
|
},
|
|
279
321
|
};
|
|
280
322
|
|
|
@@ -315,11 +357,13 @@ export const Advanced: Story<Month> = {
|
|
|
315
357
|
filterPlaceholder: 'Type a month’s name',
|
|
316
358
|
onChange: fn() satisfies Mock,
|
|
317
359
|
},
|
|
318
|
-
play: async ({ canvasElement }) => {
|
|
360
|
+
play: async ({ canvasElement, step }) => {
|
|
319
361
|
const canvas = within(canvasElement);
|
|
320
362
|
|
|
321
|
-
|
|
322
|
-
|
|
363
|
+
await step('Open the combobox', async () => {
|
|
364
|
+
const triggerButton = canvas.getByRole('combobox');
|
|
365
|
+
await userEvent.click(triggerButton);
|
|
366
|
+
});
|
|
323
367
|
},
|
|
324
368
|
};
|
|
325
369
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { userEvent, within, expect } from '@storybook/test';
|
|
2
|
+
import { userEvent, within, expect, waitFor } from '@storybook/test';
|
|
3
3
|
import { Meta, StoryObj } from '@storybook/react';
|
|
4
|
-
import PrimitiveAnchor from '
|
|
4
|
+
import PrimitiveAnchor from '../src';
|
|
5
5
|
|
|
6
6
|
const meta = {
|
|
7
7
|
title: 'Primitives/Anchor/Tests',
|
|
@@ -22,11 +22,17 @@ const wait = async (duration = 500) =>
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
export const ClickInteraction: Story = {
|
|
25
|
-
play: async ({ canvasElement }) => {
|
|
25
|
+
play: async ({ canvasElement, step }) => {
|
|
26
26
|
const canvas = within(canvasElement);
|
|
27
27
|
const link = canvas.getByRole('link');
|
|
28
|
-
|
|
29
|
-
await
|
|
28
|
+
|
|
29
|
+
await step('Click the link', async () => {
|
|
30
|
+
await userEvent.click(link);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
await step('Check if link text changes to "Clicked!"', async () => {
|
|
34
|
+
await waitFor(async () => expect(link).toHaveTextContent('Clicked!'));
|
|
35
|
+
});
|
|
30
36
|
},
|
|
31
37
|
render: function Render(args) {
|
|
32
38
|
const [clicked, setClicked] = useState(false);
|
|
@@ -46,12 +52,18 @@ export const ClickInteraction: Story = {
|
|
|
46
52
|
};
|
|
47
53
|
|
|
48
54
|
export const FocusInteraction: Story = {
|
|
49
|
-
play: async ({ canvasElement }) => {
|
|
55
|
+
play: async ({ canvasElement, step }) => {
|
|
50
56
|
const canvas = within(canvasElement);
|
|
51
57
|
const link = canvas.getByRole('link');
|
|
52
|
-
|
|
53
|
-
await
|
|
54
|
-
|
|
58
|
+
|
|
59
|
+
await step('Tab to the link', async () => {
|
|
60
|
+
await userEvent.tab();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
await step('Check if link has focus and text changes to "Focused!"', async () => {
|
|
64
|
+
await waitFor(async () => expect(link).toHaveFocus());
|
|
65
|
+
await waitFor(async () => expect(link).toHaveTextContent('Focused!'));
|
|
66
|
+
});
|
|
55
67
|
},
|
|
56
68
|
render: function Render(args) {
|
|
57
69
|
const [focused, setFocused] = useState(false);
|
|
@@ -65,14 +77,26 @@ export const FocusInteraction: Story = {
|
|
|
65
77
|
};
|
|
66
78
|
|
|
67
79
|
export const BlurInteraction: Story = {
|
|
68
|
-
play: async ({ canvasElement }) => {
|
|
80
|
+
play: async ({ canvasElement, step }) => {
|
|
69
81
|
const canvas = within(canvasElement);
|
|
70
82
|
const link = canvas.getByRole('link');
|
|
71
|
-
|
|
72
|
-
await
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
|
|
84
|
+
await step('Tab to the link', async () => {
|
|
85
|
+
await userEvent.tab();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
await step('Check if link has focus', async () => {
|
|
89
|
+
await waitFor(async () => expect(link).toHaveFocus());
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
await step('Tab away from the link', async () => {
|
|
93
|
+
await userEvent.tab();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
await step('Check if link loses focus and text changes to "Blurred!"', async () => {
|
|
97
|
+
await waitFor(async () => expect(link).not.toHaveFocus());
|
|
98
|
+
await waitFor(async () => expect(link).toHaveTextContent('Blurred!'));
|
|
99
|
+
});
|
|
76
100
|
},
|
|
77
101
|
render: function Render(args) {
|
|
78
102
|
const [blurred, setBlurred] = useState(false);
|
|
@@ -86,12 +110,17 @@ export const BlurInteraction: Story = {
|
|
|
86
110
|
};
|
|
87
111
|
|
|
88
112
|
export const MouseEnterInteraction: Story = {
|
|
89
|
-
play: async ({ canvasElement }) => {
|
|
113
|
+
play: async ({ canvasElement, step }) => {
|
|
90
114
|
const canvas = within(canvasElement);
|
|
91
115
|
const link = canvas.getByRole('link');
|
|
92
|
-
|
|
93
|
-
await
|
|
94
|
-
|
|
116
|
+
|
|
117
|
+
await step('Hover over the link', async () => {
|
|
118
|
+
await userEvent.hover(link);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
await step('Check if link text changes to "Hovered!"', async () => {
|
|
122
|
+
await waitFor(async () => expect(link).toHaveTextContent('Hovered!'));
|
|
123
|
+
});
|
|
95
124
|
},
|
|
96
125
|
render: function Render(args) {
|
|
97
126
|
const [hovered, setHovered] = useState(false);
|
|
@@ -105,12 +134,21 @@ export const MouseEnterInteraction: Story = {
|
|
|
105
134
|
};
|
|
106
135
|
|
|
107
136
|
export const MouseLeaveInteraction: Story = {
|
|
108
|
-
play: async ({ canvasElement }) => {
|
|
137
|
+
play: async ({ canvasElement, step }) => {
|
|
109
138
|
const canvas = within(canvasElement);
|
|
110
139
|
const link = canvas.getByRole('link');
|
|
111
|
-
|
|
112
|
-
await
|
|
113
|
-
|
|
140
|
+
|
|
141
|
+
await step('Hover over the link', async () => {
|
|
142
|
+
await userEvent.hover(link);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
await step('Unhover the link', async () => {
|
|
146
|
+
await userEvent.unhover(link);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
await step('Check if link text changes to "Left!"', async () => {
|
|
150
|
+
await waitFor(async () => expect(link).toHaveTextContent('Left!'));
|
|
151
|
+
});
|
|
114
152
|
},
|
|
115
153
|
render: function Render(args) {
|
|
116
154
|
const [left, setLeft] = useState(false);
|
|
@@ -124,14 +162,19 @@ export const MouseLeaveInteraction: Story = {
|
|
|
124
162
|
};
|
|
125
163
|
|
|
126
164
|
export const KeyDownInteraction: Story = {
|
|
127
|
-
play: async ({ canvasElement }) => {
|
|
165
|
+
play: async ({ canvasElement, step }) => {
|
|
128
166
|
const canvas = within(canvasElement);
|
|
129
167
|
const link = canvas.getByRole('link');
|
|
130
|
-
|
|
131
|
-
await
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
168
|
+
|
|
169
|
+
await step('Press ArrowDown key on the link', async () => {
|
|
170
|
+
await userEvent.tab();
|
|
171
|
+
await wait();
|
|
172
|
+
await userEvent.keyboard('{ArrowDown}');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
await step('Check if link text changes to "Key Pressed!"', async () => {
|
|
176
|
+
await waitFor(async () => expect(link).toHaveTextContent('Key Pressed!'));
|
|
177
|
+
});
|
|
135
178
|
},
|
|
136
179
|
render: function Render(args) {
|
|
137
180
|
const [keyPressed, setKeyPressed] = useState(false);
|
|
@@ -153,11 +196,17 @@ export const KeyDownInteraction: Story = {
|
|
|
153
196
|
};
|
|
154
197
|
|
|
155
198
|
export const TabIndexBehavior: Story = {
|
|
156
|
-
play: async ({ canvasElement }) => {
|
|
199
|
+
play: async ({ canvasElement, step }) => {
|
|
157
200
|
const canvas = within(canvasElement);
|
|
158
201
|
const link = canvas.getByRole('link');
|
|
159
|
-
|
|
160
|
-
await
|
|
202
|
+
|
|
203
|
+
await step('Tab to the link', async () => {
|
|
204
|
+
await userEvent.tab();
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
await step('Check if link does not have focus', async () => {
|
|
208
|
+
await waitFor(async () => expect(link).not.toHaveFocus());
|
|
209
|
+
});
|
|
161
210
|
},
|
|
162
211
|
render: function Render(args) {
|
|
163
212
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { userEvent, within, expect } from '@storybook/test';
|
|
2
|
+
import { userEvent, within, expect, waitFor } from '@storybook/test';
|
|
3
3
|
import { Meta, StoryObj } from '@storybook/react';
|
|
4
|
-
import PrimitiveButton from '
|
|
4
|
+
import PrimitiveButton from '../src';
|
|
5
5
|
|
|
6
6
|
const meta = {
|
|
7
7
|
title: 'Primitives/Button/Tests',
|
|
@@ -22,11 +22,17 @@ const wait = async (duration = 500) =>
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
export const ClickInteraction: Story = {
|
|
25
|
-
play: async ({ canvasElement }) => {
|
|
25
|
+
play: async ({ canvasElement, step }) => {
|
|
26
26
|
const canvas = within(canvasElement);
|
|
27
27
|
const button = canvas.getByRole('button');
|
|
28
|
-
|
|
29
|
-
await
|
|
28
|
+
|
|
29
|
+
await step('Click the button', async () => {
|
|
30
|
+
await userEvent.click(button);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
await step('Check if button text changes to "Clicked!"', async () => {
|
|
34
|
+
await waitFor(async () => expect(button).toHaveTextContent('Clicked!'));
|
|
35
|
+
});
|
|
30
36
|
},
|
|
31
37
|
render: function Render(args) {
|
|
32
38
|
const [clicked, setClicked] = useState(false);
|
|
@@ -40,12 +46,18 @@ export const ClickInteraction: Story = {
|
|
|
40
46
|
};
|
|
41
47
|
|
|
42
48
|
export const FocusInteraction: Story = {
|
|
43
|
-
play: async ({ canvasElement }) => {
|
|
49
|
+
play: async ({ canvasElement, step }) => {
|
|
44
50
|
const canvas = within(canvasElement);
|
|
45
51
|
const button = canvas.getByRole('button');
|
|
46
|
-
|
|
47
|
-
await
|
|
48
|
-
|
|
52
|
+
|
|
53
|
+
await step('Tab to the button', async () => {
|
|
54
|
+
await userEvent.tab();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
await step('Check if button has focus and text changes to "Focused!"', async () => {
|
|
58
|
+
await waitFor(async () => expect(button).toHaveFocus());
|
|
59
|
+
await waitFor(async () => expect(button).toHaveTextContent('Focused!'));
|
|
60
|
+
});
|
|
49
61
|
},
|
|
50
62
|
render: function Render(args) {
|
|
51
63
|
const [focused, setFocused] = useState(false);
|
|
@@ -59,14 +71,26 @@ export const FocusInteraction: Story = {
|
|
|
59
71
|
};
|
|
60
72
|
|
|
61
73
|
export const BlurInteraction: Story = {
|
|
62
|
-
play: async ({ canvasElement }) => {
|
|
74
|
+
play: async ({ canvasElement, step }) => {
|
|
63
75
|
const canvas = within(canvasElement);
|
|
64
76
|
const button = canvas.getByRole('button');
|
|
65
|
-
|
|
66
|
-
await
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
|
|
78
|
+
await step('Tab to the button', async () => {
|
|
79
|
+
await userEvent.tab();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
await step('Check if button has focus', async () => {
|
|
83
|
+
await waitFor(async () => expect(button).toHaveFocus());
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
await step('Tab away from the button', async () => {
|
|
87
|
+
await userEvent.tab();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
await step('Check if button loses focus and text changes to "Blurred!"', async () => {
|
|
91
|
+
await waitFor(async () => expect(button).not.toHaveFocus());
|
|
92
|
+
await waitFor(async () => expect(button).toHaveTextContent('Blurred!'));
|
|
93
|
+
});
|
|
70
94
|
},
|
|
71
95
|
render: function Render(args) {
|
|
72
96
|
const [blurred, setBlurred] = useState(false);
|
|
@@ -80,11 +104,17 @@ export const BlurInteraction: Story = {
|
|
|
80
104
|
};
|
|
81
105
|
|
|
82
106
|
export const MouseEnterInteraction: Story = {
|
|
83
|
-
play: async ({ canvasElement }) => {
|
|
107
|
+
play: async ({ canvasElement, step }) => {
|
|
84
108
|
const canvas = within(canvasElement);
|
|
85
109
|
const button = canvas.getByRole('button');
|
|
86
|
-
|
|
87
|
-
await
|
|
110
|
+
|
|
111
|
+
await step('Hover over the button', async () => {
|
|
112
|
+
await userEvent.hover(button);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
await step('Check if button text changes to "Hovered!"', async () => {
|
|
116
|
+
await waitFor(async () => expect(button).toHaveTextContent('Hovered!'));
|
|
117
|
+
});
|
|
88
118
|
},
|
|
89
119
|
render: function Render(args) {
|
|
90
120
|
const [hovered, setHovered] = useState(false);
|
|
@@ -98,11 +128,21 @@ export const MouseEnterInteraction: Story = {
|
|
|
98
128
|
};
|
|
99
129
|
|
|
100
130
|
export const MouseLeaveInteraction: Story = {
|
|
101
|
-
play: async ({ canvasElement }) => {
|
|
131
|
+
play: async ({ canvasElement, step }) => {
|
|
102
132
|
const canvas = within(canvasElement);
|
|
103
133
|
const button = canvas.getByRole('button');
|
|
104
|
-
|
|
105
|
-
await
|
|
134
|
+
|
|
135
|
+
await step('Hover over the button', async () => {
|
|
136
|
+
await userEvent.hover(button);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
await step('Unhover the button', async () => {
|
|
140
|
+
await userEvent.unhover(button);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
await step('Check if button text changes to "Left!"', async () => {
|
|
144
|
+
await waitFor(async () => expect(button).toHaveTextContent('Left!'));
|
|
145
|
+
});
|
|
106
146
|
},
|
|
107
147
|
render: function Render(args) {
|
|
108
148
|
const [left, setLeft] = useState(false);
|
|
@@ -116,11 +156,17 @@ export const MouseLeaveInteraction: Story = {
|
|
|
116
156
|
};
|
|
117
157
|
|
|
118
158
|
export const KeyDownInteraction: Story = {
|
|
119
|
-
play: async ({ canvasElement }) => {
|
|
159
|
+
play: async ({ canvasElement, step }) => {
|
|
120
160
|
const canvas = within(canvasElement);
|
|
121
161
|
const button = canvas.getByRole('button');
|
|
122
|
-
|
|
123
|
-
await
|
|
162
|
+
|
|
163
|
+
await step('Press Enter key on the button', async () => {
|
|
164
|
+
await userEvent.type(button, '{enter}');
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
await step('Check if button text changes to "Key Pressed!"', async () => {
|
|
168
|
+
await waitFor(async () => expect(button).toHaveTextContent('Key Pressed!'));
|
|
169
|
+
});
|
|
124
170
|
},
|
|
125
171
|
render: function Render(args) {
|
|
126
172
|
const [keyPressed, setKeyPressed] = useState(false);
|
|
@@ -134,11 +180,17 @@ export const KeyDownInteraction: Story = {
|
|
|
134
180
|
};
|
|
135
181
|
|
|
136
182
|
export const DisabledClickInteraction: Story = {
|
|
137
|
-
play: async ({ canvasElement }) => {
|
|
183
|
+
play: async ({ canvasElement, step }) => {
|
|
138
184
|
const canvas = within(canvasElement);
|
|
139
185
|
const button = canvas.getByRole('button');
|
|
140
|
-
|
|
141
|
-
await
|
|
186
|
+
|
|
187
|
+
await step('Click the disabled button', async () => {
|
|
188
|
+
await userEvent.click(button);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
await step('Check if button text remains "Button text"', async () => {
|
|
192
|
+
await waitFor(async () => expect(button).toHaveTextContent('Button text'));
|
|
193
|
+
});
|
|
142
194
|
},
|
|
143
195
|
render: function Render(args) {
|
|
144
196
|
return (
|
|
@@ -150,11 +202,17 @@ export const DisabledClickInteraction: Story = {
|
|
|
150
202
|
};
|
|
151
203
|
|
|
152
204
|
export const DisabledFocusInteraction: Story = {
|
|
153
|
-
play: async ({ canvasElement }) => {
|
|
205
|
+
play: async ({ canvasElement, step }) => {
|
|
154
206
|
const canvas = within(canvasElement);
|
|
155
207
|
const button = canvas.getByRole('button');
|
|
156
|
-
|
|
157
|
-
await
|
|
208
|
+
|
|
209
|
+
await step('Tab to the disabled button', async () => {
|
|
210
|
+
await userEvent.tab();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
await step('Check if button does not have focus', async () => {
|
|
214
|
+
await waitFor(async () => expect(button).not.toHaveFocus());
|
|
215
|
+
});
|
|
158
216
|
},
|
|
159
217
|
render: function Render(args) {
|
|
160
218
|
return (
|
|
@@ -166,11 +224,17 @@ export const DisabledFocusInteraction: Story = {
|
|
|
166
224
|
};
|
|
167
225
|
|
|
168
226
|
export const DisabledBlurInteraction: Story = {
|
|
169
|
-
play: async ({ canvasElement }) => {
|
|
227
|
+
play: async ({ canvasElement, step }) => {
|
|
170
228
|
const canvas = within(canvasElement);
|
|
171
229
|
const button = canvas.getByRole('button');
|
|
172
|
-
|
|
173
|
-
await
|
|
230
|
+
|
|
231
|
+
await step('Tab to the disabled button', async () => {
|
|
232
|
+
await userEvent.tab();
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
await step('Check if button does not have focus', async () => {
|
|
236
|
+
await waitFor(async () => expect(button).not.toHaveFocus());
|
|
237
|
+
});
|
|
174
238
|
},
|
|
175
239
|
render: function Render(args) {
|
|
176
240
|
return (
|
|
@@ -182,11 +246,17 @@ export const DisabledBlurInteraction: Story = {
|
|
|
182
246
|
};
|
|
183
247
|
|
|
184
248
|
export const DisabledKeyDownInteraction: Story = {
|
|
185
|
-
play: async ({ canvasElement }) => {
|
|
249
|
+
play: async ({ canvasElement, step }) => {
|
|
186
250
|
const canvas = within(canvasElement);
|
|
187
251
|
const button = canvas.getByRole('button');
|
|
188
|
-
|
|
189
|
-
await
|
|
252
|
+
|
|
253
|
+
await step('Press Enter key on the disabled button', async () => {
|
|
254
|
+
await userEvent.type(button, '{enter}');
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
await step('Check if button text remains "Button text"', async () => {
|
|
258
|
+
await waitFor(async () => expect(button).toHaveTextContent('Button text'));
|
|
259
|
+
});
|
|
190
260
|
},
|
|
191
261
|
render: function Render(args) {
|
|
192
262
|
return (
|
|
@@ -198,11 +268,17 @@ export const DisabledKeyDownInteraction: Story = {
|
|
|
198
268
|
};
|
|
199
269
|
|
|
200
270
|
export const DisabledMouseEnterInteraction: Story = {
|
|
201
|
-
play: async ({ canvasElement }) => {
|
|
271
|
+
play: async ({ canvasElement, step }) => {
|
|
202
272
|
const canvas = within(canvasElement);
|
|
203
273
|
const button = canvas.getByRole('button');
|
|
204
|
-
|
|
205
|
-
await
|
|
274
|
+
|
|
275
|
+
await step('Hover over the disabled button', async () => {
|
|
276
|
+
await userEvent.hover(button);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
await step('Check if button text remains "Button text"', async () => {
|
|
280
|
+
await waitFor(async () => expect(button).toHaveTextContent('Button text'));
|
|
281
|
+
});
|
|
206
282
|
},
|
|
207
283
|
render: function Render(args) {
|
|
208
284
|
return (
|
|
@@ -214,11 +290,17 @@ export const DisabledMouseEnterInteraction: Story = {
|
|
|
214
290
|
};
|
|
215
291
|
|
|
216
292
|
export const DisabledMouseLeaveInteraction: Story = {
|
|
217
|
-
play: async ({ canvasElement }) => {
|
|
293
|
+
play: async ({ canvasElement, step }) => {
|
|
218
294
|
const canvas = within(canvasElement);
|
|
219
295
|
const button = canvas.getByRole('button');
|
|
220
|
-
|
|
221
|
-
await
|
|
296
|
+
|
|
297
|
+
await step('Unhover the disabled button', async () => {
|
|
298
|
+
await userEvent.unhover(button);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
await step('Check if button text remains "Button text"', async () => {
|
|
302
|
+
await waitFor(async () => expect(button).toHaveTextContent('Button text'));
|
|
303
|
+
});
|
|
222
304
|
},
|
|
223
305
|
render: function Render(args) {
|
|
224
306
|
return (
|