@transferwise/components 46.83.3 → 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/build/common/closeButton/CloseButton.js.map +1 -1
- package/build/common/closeButton/CloseButton.mjs.map +1 -1
- package/build/flowNavigation/FlowNavigation.js +8 -3
- package/build/flowNavigation/FlowNavigation.js.map +1 -1
- package/build/flowNavigation/FlowNavigation.mjs +8 -3
- package/build/flowNavigation/FlowNavigation.mjs.map +1 -1
- package/build/i18n/de.json +5 -0
- package/build/i18n/de.json.js +5 -0
- package/build/i18n/de.json.js.map +1 -1
- package/build/i18n/de.json.mjs +5 -0
- package/build/i18n/de.json.mjs.map +1 -1
- package/build/iconButton/IconButton.js +41 -0
- package/build/iconButton/IconButton.js.map +1 -0
- package/build/iconButton/IconButton.mjs +39 -0
- package/build/iconButton/IconButton.mjs.map +1 -0
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -0
- package/build/index.mjs.map +1 -1
- package/build/main.css +86 -32
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +83 -0
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -0
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +81 -0
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -0
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +90 -0
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -0
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +88 -0
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -0
- package/build/styles/iconButton/IconButton.css +82 -0
- package/build/styles/main.css +86 -32
- package/build/styles/summary/Summary.css +4 -0
- package/build/summary/Summary.js +3 -3
- package/build/summary/Summary.js.map +1 -1
- package/build/summary/Summary.mjs +3 -3
- package/build/summary/Summary.mjs.map +1 -1
- package/build/types/common/closeButton/CloseButton.d.ts +3 -0
- package/build/types/common/closeButton/CloseButton.d.ts.map +1 -1
- package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
- package/build/types/iconButton/IconButton.d.ts +15 -0
- package/build/types/iconButton/IconButton.d.ts.map +1 -0
- package/build/types/iconButton/index.d.ts +3 -0
- package/build/types/iconButton/index.d.ts.map +1 -0
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/summary/Summary.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/common/closeButton/CloseButton.tsx +3 -0
- package/src/flowNavigation/FlowNavigation.spec.js +7 -8
- package/src/flowNavigation/FlowNavigation.tsx +11 -2
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +27 -3
- package/src/i18n/de.json +5 -0
- package/src/iconButton/IconButton.css +82 -0
- package/src/iconButton/IconButton.less +55 -0
- package/src/iconButton/IconButton.story.tsx +107 -0
- package/src/iconButton/IconButton.tsx +51 -0
- package/src/iconButton/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/inputs/SelectInput.story.tsx +68 -24
- package/src/main.css +86 -32
- package/src/main.less +1 -1
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.tests.story.tsx +81 -32
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.tests.story.tsx +124 -42
- package/src/summary/Summary.css +4 -0
- package/src/summary/Summary.less +3 -0
- package/src/summary/Summary.story.tsx +13 -3
- package/src/summary/Summary.tsx +13 -11
- package/build/flowNavigation/backButton/BackButton.js +0 -30
- package/build/flowNavigation/backButton/BackButton.js.map +0 -1
- package/build/flowNavigation/backButton/BackButton.mjs +0 -28
- package/build/flowNavigation/backButton/BackButton.mjs.map +0 -1
- package/build/styles/flowNavigation/backButton/BackButton.css +0 -32
- package/build/types/flowNavigation/backButton/BackButton.d.ts +0 -7
- package/build/types/flowNavigation/backButton/BackButton.d.ts.map +0 -1
- package/build/types/flowNavigation/backButton/index.d.ts +0 -3
- package/build/types/flowNavigation/backButton/index.d.ts.map +0 -1
- package/src/flowNavigation/backButton/BackButton.css +0 -32
- package/src/flowNavigation/backButton/BackButton.less +0 -36
- package/src/flowNavigation/backButton/BackButton.tsx +0 -29
- package/src/flowNavigation/backButton/index.ts +0 -2
|
@@ -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
|
|
package/src/main.css
CHANGED
|
@@ -535,6 +535,88 @@ div.critical-comms .critical-comms-body {
|
|
|
535
535
|
.np-avatar-layout-horizontal-child {
|
|
536
536
|
margin-left: calc(var(--np-avatar-offset) * -1);
|
|
537
537
|
}
|
|
538
|
+
.np-icon-button {
|
|
539
|
+
border: none;
|
|
540
|
+
}
|
|
541
|
+
.np-icon-button-tertiary-default {
|
|
542
|
+
color: var(--color-interactive-primary);
|
|
543
|
+
background-color: rgba(134,167,189,0.10196);
|
|
544
|
+
background-color: var(--color-background-neutral);
|
|
545
|
+
}
|
|
546
|
+
.np-icon-button-tertiary-default:not(.disabled):not(:disabled):hover {
|
|
547
|
+
background-color: var(--color-background-neutral-hover);
|
|
548
|
+
}
|
|
549
|
+
.np-icon-button-tertiary-default:not(.disabled):not(:disabled):active {
|
|
550
|
+
background-color: var(--color-background-neutral-active);
|
|
551
|
+
}
|
|
552
|
+
.np-icon-button-primary-default {
|
|
553
|
+
color: var(--color-interactive-control);
|
|
554
|
+
background-color: #00a2dd;
|
|
555
|
+
background-color: var(--color-interactive-accent);
|
|
556
|
+
}
|
|
557
|
+
.np-icon-button-primary-default:not(.disabled):not(:disabled):hover {
|
|
558
|
+
background-color: #008fc9;
|
|
559
|
+
background-color: var(--color-interactive-accent-hover);
|
|
560
|
+
}
|
|
561
|
+
.np-icon-button-primary-default:not(.disabled):not(:disabled):active {
|
|
562
|
+
background-color: #0081ba;
|
|
563
|
+
background-color: var(--color-interactive-accent-active);
|
|
564
|
+
}
|
|
565
|
+
.np-icon-button-primary-negative {
|
|
566
|
+
color: var(--color-contrast-overlay);
|
|
567
|
+
background-color: var(--color-sentiment-negative-primary);
|
|
568
|
+
}
|
|
569
|
+
.np-icon-button-primary-negative:not(.disabled):not(:disabled):hover {
|
|
570
|
+
background-color: var(--color-sentiment-negative-primary-hover);
|
|
571
|
+
}
|
|
572
|
+
.np-icon-button-primary-negative:not(.disabled):not(:disabled):active {
|
|
573
|
+
background-color: var(--color-sentiment-negative-primary-active);
|
|
574
|
+
}
|
|
575
|
+
.np-theme-personal--bright-green .np-icon-button-primary-negative {
|
|
576
|
+
color: var(--color-white);
|
|
577
|
+
}
|
|
578
|
+
.np-icon-button-minimal-default {
|
|
579
|
+
color: var(--color-interactive-primary);
|
|
580
|
+
background-color: #ffffff;
|
|
581
|
+
background-color: var(--color-background-screen);
|
|
582
|
+
background-color: transparent;
|
|
583
|
+
}
|
|
584
|
+
.np-icon-button-minimal-default:not(.disabled):not(:disabled):hover {
|
|
585
|
+
background-color: var(--color-background-screen-hover);
|
|
586
|
+
}
|
|
587
|
+
.np-icon-button-minimal-default:not(.disabled):not(:disabled):active {
|
|
588
|
+
background-color: var(--color-background-screen-active);
|
|
589
|
+
}
|
|
590
|
+
.np-icon-button-secondary-default {
|
|
591
|
+
color: var(--color-interactive-primary);
|
|
592
|
+
background-color: var(--color-interactive-neutral);
|
|
593
|
+
}
|
|
594
|
+
.np-icon-button-secondary-default:not(.disabled):not(:disabled):hover {
|
|
595
|
+
background-color: var(--color-interactive-neutral-hover);
|
|
596
|
+
}
|
|
597
|
+
.np-icon-button-secondary-default:not(.disabled):not(:disabled):active {
|
|
598
|
+
background-color: var(--color-interactive-neutral-active);
|
|
599
|
+
}
|
|
600
|
+
.np-theme-personal--bright-green .np-icon-button-secondary-default,
|
|
601
|
+
.np-theme-personal--forest-green .np-icon-button-secondary-default {
|
|
602
|
+
color: var(--color-interactive-control);
|
|
603
|
+
}
|
|
604
|
+
.np-icon-button-secondary-negative {
|
|
605
|
+
color: var(--color-sentiment-negative-primary);
|
|
606
|
+
background-color: var(--color-sentiment-negative-secondary);
|
|
607
|
+
}
|
|
608
|
+
.np-icon-button-secondary-negative:not(.disabled):not(:disabled):hover {
|
|
609
|
+
background-color: var(--color-sentiment-negative-secondary-hover);
|
|
610
|
+
}
|
|
611
|
+
.np-icon-button-secondary-negative:not(.disabled):not(:disabled):active {
|
|
612
|
+
background-color: var(--color-sentiment-negative-secondary-active);
|
|
613
|
+
}
|
|
614
|
+
.np-theme-personal--bright-green .np-icon-button-secondary-negative {
|
|
615
|
+
color: var(--color-white);
|
|
616
|
+
}
|
|
617
|
+
.np-theme-personal--forest-green .np-icon-button-secondary-negative {
|
|
618
|
+
color: var(--color-contrast-overlay);
|
|
619
|
+
}
|
|
538
620
|
.tw-badge {
|
|
539
621
|
position: relative;
|
|
540
622
|
display: inline-block;
|
|
@@ -2201,38 +2283,6 @@ button.np-option {
|
|
|
2201
2283
|
outline: var(--ring-outline-color) solid var(--ring-outline-width);
|
|
2202
2284
|
outline-offset: var(--ring-outline-offset);
|
|
2203
2285
|
}
|
|
2204
|
-
.np-back-button {
|
|
2205
|
-
color: #00a2dd;
|
|
2206
|
-
color: var(--color-interactive-accent);
|
|
2207
|
-
display: flex !important;
|
|
2208
|
-
}
|
|
2209
|
-
.np-back-button:hover {
|
|
2210
|
-
color: #008fc9;
|
|
2211
|
-
color: var(--color-interactive-accent-hover);
|
|
2212
|
-
}
|
|
2213
|
-
.np-back-button:active {
|
|
2214
|
-
color: #0081ba;
|
|
2215
|
-
color: var(--color-interactive-accent-active);
|
|
2216
|
-
}
|
|
2217
|
-
.np-theme-personal .np-back-button {
|
|
2218
|
-
color: #37517e;
|
|
2219
|
-
color: var(--color-content-primary);
|
|
2220
|
-
}
|
|
2221
|
-
.np-theme-personal .np-back-button:hover {
|
|
2222
|
-
color: var(--color-content-primary-hover);
|
|
2223
|
-
}
|
|
2224
|
-
.np-theme-personal .np-back-button:active {
|
|
2225
|
-
color: var(--color-content-primary-active);
|
|
2226
|
-
}
|
|
2227
|
-
.np-theme-personal .np-back-button .tw-icon {
|
|
2228
|
-
color: var(--color-interactive-primary);
|
|
2229
|
-
}
|
|
2230
|
-
.np-theme-personal .np-back-button .tw-icon:hover {
|
|
2231
|
-
color: var(--color-interactive-primary-hover);
|
|
2232
|
-
}
|
|
2233
|
-
.np-theme-personal .np-back-button .tw-icon:active {
|
|
2234
|
-
color: var(--color-interactive-primary-active);
|
|
2235
|
-
}
|
|
2236
2286
|
.np-flow-navigation {
|
|
2237
2287
|
width: 100%;
|
|
2238
2288
|
min-height: 97px;
|
|
@@ -4950,6 +5000,10 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
4950
5000
|
padding-left: calc(var(--size-24) + var(--size-8));
|
|
4951
5001
|
padding-right: 0;
|
|
4952
5002
|
}
|
|
5003
|
+
.np-summary__description-icon {
|
|
5004
|
+
margin-top: 4px;
|
|
5005
|
+
margin-top: var(--size-4);
|
|
5006
|
+
}
|
|
4953
5007
|
.np-summary__action {
|
|
4954
5008
|
margin-top: 4px;
|
|
4955
5009
|
margin-top: var(--size-4);
|
package/src/main.less
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
@import "./avatar/Avatar.less";
|
|
6
6
|
@import "./avatarView/AvatarView.less";
|
|
7
7
|
@import "./avatarLayout/AvatarLayout.less";
|
|
8
|
+
@import "./iconButton/IconButton.less";
|
|
8
9
|
@import "./badge/Badge.less";
|
|
9
10
|
@import "./button/Button.less";
|
|
10
11
|
@import "./card/Card.less";
|
|
@@ -30,7 +31,6 @@
|
|
|
30
31
|
@import "./dropFade/DropFade.less";
|
|
31
32
|
@import "./emphasis/Emphasis.less";
|
|
32
33
|
@import "./flowNavigation/animatedLabel/AnimatedLabel.less";
|
|
33
|
-
@import "./flowNavigation/backButton/BackButton.less";
|
|
34
34
|
@import "./flowNavigation/FlowNavigation.less";
|
|
35
35
|
@import "./header/Header.less";
|
|
36
36
|
@import "./image/Image.less";
|
|
@@ -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 (
|