@aleph-alpha/ui-library 6.3.2 → 6.3.4

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.
Files changed (51) hide show
  1. package/config.js +2 -0
  2. package/dist/system/components/UiFileUploadBox/types.d.ts +8 -5
  3. package/dist/system/components/UiStepper/context.d.ts +8 -0
  4. package/dist/system/components/core/range-calendar/RangeCalendar.vue.d.ts +24 -24
  5. package/dist/system/icons/story-sidebar-icons.json +7 -0
  6. package/dist/system/lib.js +14776 -14598
  7. package/dist/system/patterns/UiLayout/layout-shell.d.ts +217 -5
  8. package/dist/system/patterns/UiTopBar/accessory-dropdown.d.ts +227 -0
  9. package/dist/system/story-sidebar-icons.json +7 -0
  10. package/package.json +1 -1
  11. package/src/components/UiAccordion/UiAccordion.stories.ts +1079 -0
  12. package/src/components/UiCalendar/UiCalendar.stories.ts +734 -0
  13. package/src/components/UiCalendar/__tests__/UiCalendar.test.ts +8 -5
  14. package/src/components/UiDropdownMenu/UiDropdownMenuTrigger.vue +3 -1
  15. package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +389 -3
  16. package/src/components/UiFileUploadBox/UiFileUploadBox.vue +55 -75
  17. package/src/components/UiFileUploadBox/__tests__/UiFileUploadBox.test.ts +44 -0
  18. package/src/components/UiFileUploadBox/types.ts +8 -5
  19. package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +723 -0
  20. package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +819 -7
  21. package/src/components/UiRangeCalendar/__tests__/UiRangeCalendar.test.ts +8 -3
  22. package/src/components/UiResizable/UiResizable.stories.ts +1215 -5
  23. package/src/components/UiSnackbar/UiSnackbar.stories.ts +1017 -4
  24. package/src/components/UiSnackbar/UiSnackbar.vue +3 -2
  25. package/src/components/UiSnackbar/UiSnackbarContent.vue +1 -1
  26. package/src/components/UiSnackbar/__tests__/UiSnackbar.test.ts +3 -1
  27. package/src/components/UiStepper/UiStepper.stories.ts +566 -2
  28. package/src/components/UiStepper/UiStepper.vue +14 -1
  29. package/src/components/UiStepper/UiStepperItem.vue +22 -4
  30. package/src/components/UiStepper/__tests__/UiStepper.test.ts +66 -0
  31. package/src/components/UiStepper/context.ts +10 -0
  32. package/src/components/core/calendar/Calendar.vue +234 -2
  33. package/src/components/core/calendar/CalendarCellTrigger.vue +1 -1
  34. package/src/components/core/navigation-menu/NavigationMenuList.vue +1 -1
  35. package/src/components/core/range-calendar/RangeCalendar.vue +254 -6
  36. package/src/components/core/range-calendar/RangeCalendarCellTrigger.vue +1 -1
  37. package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +846 -17
  38. package/src/patterns/UiDatePicker/UiDatePicker.vue +9 -0
  39. package/src/patterns/UiDatePicker/__tests__/UiDatePicker.test.ts +13 -8
  40. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +23 -17
  41. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +138 -113
  42. package/src/patterns/UiFileUpload/UiFileUpload.vue +1 -1
  43. package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +2 -2
  44. package/src/patterns/UiLayout/UiLayout.stories.ts +25 -0
  45. package/src/patterns/UiLayout/UiLayoutContent.stories.ts +359 -0
  46. package/src/patterns/UiLayout/UiLayoutContent.vue +45 -23
  47. package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +13 -0
  48. package/src/patterns/UiLayout/layout-shell.ts +159 -13
  49. package/src/patterns/UiTopBar/UiTopBar.stories.ts +245 -36
  50. package/src/patterns/UiTopBar/UiTopBar.vue +4 -2
  51. package/src/patterns/UiTopBar/accessory-dropdown.ts +97 -0
@@ -1,7 +1,13 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
- import { fn } from 'storybook/test';
3
- import { ref } from 'vue';
4
- import { showSnackbar, showSnackbarPromise, UiSnackbar } from './index';
2
+ import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
3
+ import { onUnmounted, ref } from 'vue';
4
+ import {
5
+ showSnackbar,
6
+ showSnackbarPromise,
7
+ toast,
8
+ UiSnackbar,
9
+ UiSnackbarContent,
10
+ } from './index';
5
11
  import { UiButton } from '../UiButton';
6
12
  import { UiDialog, UiDialogContent, UiDialogTrigger } from '../UiDialog';
7
13
 
@@ -55,6 +61,10 @@ const SNACKBAR_ACTION_TITLE = 'Event has been created';
55
61
  const SNACKBAR_DESCRIPTION = 'Sunday, December 03, 2023 at 9:00 AM';
56
62
  const SNACKBAR_ACTION_LABEL = 'Undo';
57
63
 
64
+ // Module-level spy shared by every story with a play function that asserts
65
+ // the action callback; each play clears it first so runs stay independent.
66
+ const onAction = fn();
67
+
58
68
  const defaultTemplateSource = `<script setup lang="ts">
59
69
  import { UiSnackbar, showSnackbar, UiButton } from '@aleph-alpha/ui-library'
60
70
  </script>
@@ -82,6 +92,10 @@ export const Default: Story = {
82
92
  render: (args) => ({
83
93
  components: { UiSnackbar, UiButton },
84
94
  setup() {
95
+ // The play leaves a toast mounted for the axe audit and the Chromatic
96
+ // snapshot (duration: Infinity keeps it deterministic); Sonner's
97
+ // module-level toast state is cleared again on story teardown.
98
+ onUnmounted(() => toast.dismiss());
85
99
  const toasterId = 'story-default';
86
100
  const show = () =>
87
101
  showSnackbar({
@@ -91,6 +105,7 @@ export const Default: Story = {
91
105
  actionMode: 'default',
92
106
  iconMode: 'info',
93
107
  onAction: fn(),
108
+ duration: Infinity,
94
109
  toasterId,
95
110
  });
96
111
  return { args, show, toasterId };
@@ -107,6 +122,51 @@ export const Default: Story = {
107
122
  source: { code: defaultTemplateSource },
108
123
  },
109
124
  },
125
+ play: async ({ canvasElement, step }) => {
126
+ // Scenario (UiSnackbar + showSnackbar): a pointer user triggers the
127
+ // full-featured snackbar, reads it, and dismisses it from its close
128
+ // control.
129
+ const canvas = within(canvasElement);
130
+
131
+ await step(
132
+ 'interaction: the snackbar appears with its message',
133
+ async () => {
134
+ await userEvent.click(
135
+ canvas.getByRole('button', { name: 'Show snackbar' }),
136
+ );
137
+ // The toast fades in, so wait for the entry transition before
138
+ // asserting visibility.
139
+ await waitFor(async () => {
140
+ await expect(canvas.getByText(SNACKBAR_ACTION_TITLE)).toBeVisible();
141
+ await expect(canvas.getByText(SNACKBAR_DESCRIPTION)).toBeVisible();
142
+ });
143
+ },
144
+ );
145
+
146
+ await step(
147
+ 'interaction: the dismiss control removes the snackbar',
148
+ async () => {
149
+ await userEvent.click(
150
+ canvas.getByRole('button', { name: 'Close toast' }),
151
+ );
152
+ await waitFor(async () => {
153
+ await expect(canvas.queryByText(SNACKBAR_ACTION_TITLE)).toBeNull();
154
+ });
155
+ },
156
+ );
157
+
158
+ await step(
159
+ 'interaction: the snackbar stays mounted for the accessibility audit',
160
+ async () => {
161
+ await userEvent.click(
162
+ canvas.getByRole('button', { name: 'Show snackbar' }),
163
+ );
164
+ await waitFor(async () => {
165
+ await expect(canvas.getByText(SNACKBAR_ACTION_TITLE)).toBeVisible();
166
+ });
167
+ },
168
+ );
169
+ },
110
170
  };
111
171
 
112
172
  const withDescriptionTemplateSource = `<script setup lang="ts">
@@ -133,11 +193,16 @@ export const WithDescription: Story = {
133
193
  render: (args) => ({
134
194
  components: { UiSnackbar, UiButton },
135
195
  setup() {
196
+ // The play leaves a toast mounted for the axe audit and the Chromatic
197
+ // snapshot (duration: Infinity keeps it deterministic); Sonner's
198
+ // module-level toast state is cleared again on story teardown.
199
+ onUnmounted(() => toast.dismiss());
136
200
  const toasterId = 'story-description';
137
201
  const show = () =>
138
202
  showSnackbar({
139
203
  title: 'Event has been created',
140
204
  description: 'Sunday, December 03, 2023 at 9:00 AM',
205
+ duration: Infinity,
141
206
  toasterId,
142
207
  });
143
208
  return { args, show, toasterId };
@@ -154,6 +219,57 @@ export const WithDescription: Story = {
154
219
  source: { code: withDescriptionTemplateSource },
155
220
  },
156
221
  },
222
+ play: async ({ canvasElement, step }) => {
223
+ // Scenario (UiSnackbar + showSnackbar): the text-only snackbar (Sonner's
224
+ // native rendering path) announces title and description, and dismisses
225
+ // from the native close control.
226
+ const canvas = within(canvasElement);
227
+
228
+ await step(
229
+ 'interaction: the snackbar appears with its title and description',
230
+ async () => {
231
+ await userEvent.click(
232
+ canvas.getByRole('button', { name: 'Show snackbar' }),
233
+ );
234
+ // The toast fades in, so wait for the entry transition before
235
+ // asserting visibility.
236
+ await waitFor(async () => {
237
+ await expect(
238
+ canvas.getByText('Event has been created'),
239
+ ).toBeVisible();
240
+ await expect(
241
+ canvas.getByText('Sunday, December 03, 2023 at 9:00 AM'),
242
+ ).toBeVisible();
243
+ });
244
+ },
245
+ );
246
+
247
+ await step(
248
+ 'interaction: the dismiss control removes the snackbar',
249
+ async () => {
250
+ await userEvent.click(
251
+ canvas.getByRole('button', { name: 'Close toast' }),
252
+ );
253
+ await waitFor(async () => {
254
+ await expect(canvas.queryByText('Event has been created')).toBeNull();
255
+ });
256
+ },
257
+ );
258
+
259
+ await step(
260
+ 'interaction: the snackbar stays mounted for the accessibility audit',
261
+ async () => {
262
+ await userEvent.click(
263
+ canvas.getByRole('button', { name: 'Show snackbar' }),
264
+ );
265
+ await waitFor(async () => {
266
+ await expect(
267
+ canvas.getByText('Event has been created'),
268
+ ).toBeVisible();
269
+ });
270
+ },
271
+ );
272
+ },
157
273
  };
158
274
 
159
275
  const withIconModesTemplateSource = `<script setup lang="ts">
@@ -227,6 +343,193 @@ export const IconModes: Story = {
227
343
  },
228
344
  };
229
345
 
346
+ type ShowSnackbarStoryOptions = Parameters<typeof showSnackbar>[0];
347
+
348
+ /**
349
+ * Builds the docs source for an individual state story: one trigger opening a
350
+ * single snackbar with the given options.
351
+ * @param optionsSource Extra `showSnackbar` option lines after the title.
352
+ * @param toasterAttrs Extra attributes rendered on the `UiSnackbar` toaster.
353
+ */
354
+ function stateTemplateSource(optionsSource = '', toasterAttrs = ''): string {
355
+ const optionBlock = optionsSource ? `\n ${optionsSource}` : '';
356
+ return `<script setup lang="ts">
357
+ import { UiSnackbar, showSnackbar, UiButton } from '@aleph-alpha/ui-library'
358
+ </script>
359
+
360
+ <template>
361
+ <UiButton
362
+ @click="showSnackbar({
363
+ title: 'Event has been created',${optionBlock}
364
+ })"
365
+ >
366
+ Show snackbar
367
+ </UiButton>
368
+ <UiSnackbar${toasterAttrs} />
369
+ </template>`;
370
+ }
371
+
372
+ /**
373
+ * Render factory for the individual state stories: one trigger that opens a
374
+ * single snackbar with the given options. The play leaves the toast mounted
375
+ * so Chromatic and the axe audit check the rendered state (`duration:
376
+ * Infinity` keeps it deterministic); Sonner's module-level toast state is
377
+ * cleared again on story teardown.
378
+ * @param toasterId Unique Sonner toaster id so stories do not share toasts.
379
+ * @param options `showSnackbar` options for the rendered state.
380
+ */
381
+ function renderStateSnackbar(
382
+ toasterId: string,
383
+ options: Omit<ShowSnackbarStoryOptions, 'toasterId' | 'duration'>,
384
+ ) {
385
+ return (args: Story['args']) => ({
386
+ components: { UiSnackbar, UiButton },
387
+ setup() {
388
+ onUnmounted(() => toast.dismiss());
389
+ const show = () =>
390
+ showSnackbar({ ...options, duration: Infinity, toasterId });
391
+ return { args, show, toasterId };
392
+ },
393
+ template: `
394
+ <div>
395
+ <UiButton @click="show">Show snackbar</UiButton>
396
+ <UiSnackbar v-bind="args" :id="toasterId" />
397
+ </div>
398
+ `,
399
+ });
400
+ }
401
+
402
+ /**
403
+ * Opens a state story's snackbar and waits for its message, leaving the toast
404
+ * mounted for the Chromatic snapshot and the axe audit.
405
+ * @param canvas Testing-library queries scoped to the story canvas.
406
+ */
407
+ async function openStateSnackbar(canvas: ReturnType<typeof within>) {
408
+ await userEvent.click(canvas.getByRole('button', { name: 'Show snackbar' }));
409
+ // The toast fades in, so wait for the entry transition.
410
+ await waitFor(async () => {
411
+ await expect(canvas.getByText(SNACKBAR_ACTION_TITLE)).toBeVisible();
412
+ });
413
+ }
414
+
415
+ /**
416
+ * Success state with its status icon, rendered mounted so visual and
417
+ * accessibility checks exercise it independently of the grouped `IconModes`
418
+ * demo.
419
+ */
420
+ export const Success: Story = {
421
+ render: renderStateSnackbar('story-success', {
422
+ title: SNACKBAR_ACTION_TITLE,
423
+ iconMode: 'success',
424
+ }),
425
+ parameters: {
426
+ docs: {
427
+ source: { code: stateTemplateSource(`iconMode: 'success',`) },
428
+ },
429
+ },
430
+ play: async ({ canvasElement, step }) => {
431
+ const canvas = within(canvasElement);
432
+ await step(
433
+ 'interaction: the success snackbar renders its labelled status icon',
434
+ async () => {
435
+ await openStateSnackbar(canvas);
436
+ await expect(
437
+ canvas.getByRole('img', { name: 'Success' }),
438
+ ).toHaveAttribute('data-mode', 'success');
439
+ },
440
+ );
441
+ },
442
+ };
443
+
444
+ /**
445
+ * Warning state with its status icon, rendered mounted so visual and
446
+ * accessibility checks exercise it independently of the grouped `IconModes`
447
+ * demo.
448
+ */
449
+ export const Warning: Story = {
450
+ render: renderStateSnackbar('story-warning', {
451
+ title: SNACKBAR_ACTION_TITLE,
452
+ iconMode: 'warning',
453
+ }),
454
+ parameters: {
455
+ docs: {
456
+ source: { code: stateTemplateSource(`iconMode: 'warning',`) },
457
+ },
458
+ },
459
+ play: async ({ canvasElement, step }) => {
460
+ const canvas = within(canvasElement);
461
+ await step(
462
+ 'interaction: the warning snackbar renders its labelled status icon',
463
+ async () => {
464
+ await openStateSnackbar(canvas);
465
+ await expect(
466
+ canvas.getByRole('img', { name: 'Warning' }),
467
+ ).toHaveAttribute('data-mode', 'warning');
468
+ },
469
+ );
470
+ },
471
+ };
472
+
473
+ /**
474
+ * Error state with its status icon, rendered mounted so visual and
475
+ * accessibility checks exercise it independently of the grouped `IconModes`
476
+ * demo.
477
+ */
478
+ export const ErrorState: Story = {
479
+ name: 'Error',
480
+ render: renderStateSnackbar('story-error', {
481
+ title: SNACKBAR_ACTION_TITLE,
482
+ iconMode: 'error',
483
+ }),
484
+ parameters: {
485
+ docs: {
486
+ source: { code: stateTemplateSource(`iconMode: 'error',`) },
487
+ },
488
+ },
489
+ play: async ({ canvasElement, step }) => {
490
+ const canvas = within(canvasElement);
491
+ await step(
492
+ 'interaction: the error snackbar renders its labelled status icon',
493
+ async () => {
494
+ await openStateSnackbar(canvas);
495
+ await expect(
496
+ canvas.getByRole('img', { name: 'Error' }),
497
+ ).toHaveAttribute('data-mode', 'error');
498
+ },
499
+ );
500
+ },
501
+ };
502
+
503
+ /**
504
+ * Loading state with its spinner, rendered mounted so visual and
505
+ * accessibility checks exercise it independently of the grouped `IconModes`
506
+ * and transient `Promise` demos. The spinner is a `status` role so assistive
507
+ * technology announces the ongoing operation.
508
+ */
509
+ export const Loading: Story = {
510
+ render: renderStateSnackbar('story-loading', {
511
+ title: SNACKBAR_ACTION_TITLE,
512
+ iconMode: 'loading',
513
+ }),
514
+ parameters: {
515
+ docs: {
516
+ source: { code: stateTemplateSource(`iconMode: 'loading',`) },
517
+ },
518
+ },
519
+ play: async ({ canvasElement, step }) => {
520
+ const canvas = within(canvasElement);
521
+ await step(
522
+ 'interaction: the loading snackbar renders its announced spinner',
523
+ async () => {
524
+ await openStateSnackbar(canvas);
525
+ await expect(
526
+ canvas.getByRole('status', { name: 'Loading' }),
527
+ ).toHaveAttribute('data-mode', 'loading');
528
+ },
529
+ );
530
+ },
531
+ };
532
+
230
533
  const withActionModesTemplateSource = `<script setup lang="ts">
231
534
  import { UiSnackbar, showSnackbar, UiButton } from '@aleph-alpha/ui-library'
232
535
  </script>
@@ -299,6 +602,46 @@ export const ActionModes: Story = {
299
602
  },
300
603
  };
301
604
 
605
+ /**
606
+ * Secondary action button mode, rendered mounted so visual and accessibility
607
+ * checks exercise it independently of the grouped `ActionModes` demo. For the
608
+ * default action mode see `WithAction`.
609
+ */
610
+ export const SecondaryAction: Story = {
611
+ render: renderStateSnackbar('story-secondary-action', {
612
+ title: SNACKBAR_ACTION_TITLE,
613
+ actionLabel: SNACKBAR_ACTION_LABEL,
614
+ actionMode: 'secondary',
615
+ onAction: () => onAction(),
616
+ }),
617
+ parameters: {
618
+ docs: {
619
+ source: {
620
+ code: stateTemplateSource(
621
+ `actionLabel: 'Undo',\n actionMode: 'secondary',\n onAction: () => {},`,
622
+ ),
623
+ },
624
+ },
625
+ },
626
+ play: async ({ canvasElement, step }) => {
627
+ onAction.mockClear();
628
+ const canvas = within(canvasElement);
629
+ await step(
630
+ 'interaction: the secondary action renders and invokes its handler',
631
+ async () => {
632
+ await openStateSnackbar(canvas);
633
+ const undo = canvas.getByRole('button', {
634
+ name: SNACKBAR_ACTION_LABEL,
635
+ });
636
+ await expect(undo).toBeVisible();
637
+ await userEvent.click(undo);
638
+ await expect(onAction).toHaveBeenCalledTimes(1);
639
+ await expect(canvas.getByText(SNACKBAR_ACTION_TITLE)).toBeVisible();
640
+ },
641
+ );
642
+ },
643
+ };
644
+
302
645
  const withActionTemplateSource = `<script setup lang="ts">
303
646
  import { UiSnackbar, showSnackbar, UiButton } from '@aleph-alpha/ui-library'
304
647
  </script>
@@ -325,13 +668,18 @@ export const WithAction: Story = {
325
668
  render: (args) => ({
326
669
  components: { UiSnackbar, UiButton },
327
670
  setup() {
671
+ // The play leaves a toast mounted for the axe audit and the Chromatic
672
+ // snapshot (duration: Infinity keeps it deterministic); Sonner's
673
+ // module-level toast state is cleared again on story teardown.
674
+ onUnmounted(() => toast.dismiss());
328
675
  const toasterId = 'story-action';
329
676
  const show = () =>
330
677
  showSnackbar({
331
678
  title: SNACKBAR_ACTION_TITLE,
332
679
  actionLabel: SNACKBAR_ACTION_LABEL,
333
680
  actionMode: 'default',
334
- onAction: fn(),
681
+ onAction: () => onAction(),
682
+ duration: Infinity,
335
683
  toasterId,
336
684
  });
337
685
  return { args, show, toasterId };
@@ -348,6 +696,88 @@ export const WithAction: Story = {
348
696
  source: { code: withActionTemplateSource },
349
697
  },
350
698
  },
699
+ play: async ({ canvasElement, step }) => {
700
+ // Scenario (UiSnackbar + showSnackbar + UiSnackbarContent): a pointer
701
+ // user triggers the action snackbar, invokes Undo, and dismisses the
702
+ // snackbar from its embedded close control.
703
+ onAction.mockClear();
704
+ const canvas = within(canvasElement);
705
+
706
+ await step(
707
+ 'interaction: the built-in action invokes its handler',
708
+ async () => {
709
+ await userEvent.click(
710
+ canvas.getByRole('button', { name: 'Show snackbar' }),
711
+ );
712
+ // The toast fades in, so wait for the entry transition before
713
+ // asserting visibility.
714
+ await waitFor(async () => {
715
+ await expect(canvas.getByText(SNACKBAR_ACTION_TITLE)).toBeVisible();
716
+ });
717
+
718
+ await userEvent.click(
719
+ canvas.getByRole('button', { name: SNACKBAR_ACTION_LABEL }),
720
+ );
721
+ await expect(onAction).toHaveBeenCalledTimes(1);
722
+ },
723
+ );
724
+
725
+ await step(
726
+ 'interaction: the action snackbar dismisses from its own close control',
727
+ async () => {
728
+ await userEvent.click(
729
+ canvas.getByRole('button', { name: 'Close toast' }),
730
+ );
731
+ await waitFor(async () => {
732
+ await expect(canvas.queryByText(SNACKBAR_ACTION_TITLE)).toBeNull();
733
+ });
734
+ },
735
+ );
736
+
737
+ await step(
738
+ 'interaction: the snackbar stays mounted for the accessibility audit',
739
+ async () => {
740
+ await userEvent.click(
741
+ canvas.getByRole('button', { name: 'Show snackbar' }),
742
+ );
743
+ await waitFor(async () => {
744
+ await expect(canvas.getByText(SNACKBAR_ACTION_TITLE)).toBeVisible();
745
+ });
746
+ },
747
+ );
748
+ },
749
+ };
750
+
751
+ /**
752
+ * Snackbar without a dismiss control (`closeButton: false`), rendered mounted
753
+ * so visual and accessibility checks exercise it independently. Reserve this
754
+ * for auto-dismissing confirmations; keep the close control whenever the
755
+ * message carries an action or stays longer.
756
+ */
757
+ export const WithoutCloseButton: Story = {
758
+ render: renderStateSnackbar('story-no-close', {
759
+ title: SNACKBAR_ACTION_TITLE,
760
+ closeButton: false,
761
+ }),
762
+ parameters: {
763
+ docs: {
764
+ source: {
765
+ code: stateTemplateSource(`closeButton: false,`),
766
+ },
767
+ },
768
+ },
769
+ play: async ({ canvasElement, step }) => {
770
+ const canvas = within(canvasElement);
771
+ await step(
772
+ 'interaction: the snackbar renders without a dismiss control',
773
+ async () => {
774
+ await openStateSnackbar(canvas);
775
+ await expect(
776
+ canvas.queryByRole('button', { name: 'Close toast' }),
777
+ ).toBeNull();
778
+ },
779
+ );
780
+ },
351
781
  };
352
782
 
353
783
  const promiseTemplateSource = `<script setup lang="ts">
@@ -532,3 +962,586 @@ export const WithDialog: Story = {
532
962
  },
533
963
  },
534
964
  };
965
+
966
+ /**
967
+ * Accessibility guidance for conveying outcomes without relying on colour,
968
+ * comfortable targets, generous timing, and the accessible theme.
969
+ */
970
+ export const Accessibility: Story = {
971
+ render: () => ({
972
+ components: { UiSnackbarContent },
973
+ setup() {
974
+ const noop = () => {};
975
+ return { noop };
976
+ },
977
+ template: `
978
+ <section class="flex w-full flex-col gap-6 p-4">
979
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
980
+ Accessibility
981
+ </h2>
982
+
983
+ <div class="flex flex-col gap-2">
984
+ <h3 class="body-16-medium text-content-on-surface-primary">
985
+ Requirements
986
+ </h3>
987
+ <ul class="body-16-regular flex list-disc flex-col gap-1 pl-6 text-content-on-surface-primary">
988
+ <li>The outcome is carried by the icon and the words, so colour is never the only signal</li>
989
+ <li>Success, error and warning are distinguishable by icon shape, not only by hue</li>
990
+ <li>Text holds contrast against the snackbar's own surface, which sits over arbitrary content</li>
991
+ <li>The action is a comfortable target and keeps a visible focus state</li>
992
+ <li>The snackbar stays long enough to be read unhurriedly, and longer when it carries an action</li>
993
+ <li>Anything important is also available in the interface, since a snackbar is easy to miss</li>
994
+ </ul>
995
+ </div>
996
+
997
+ <div class="flex flex-col gap-2">
998
+ <h3 class="body-16-medium text-content-on-surface-primary">
999
+ Enable accessibility theme
1000
+ </h3>
1001
+ <p class="body-16-regular text-content-on-surface-primary">
1002
+ When accessibility is required, enable our accessibility theme.
1003
+ This increases contrast and ensures there are no color contrast
1004
+ issues.
1005
+ </p>
1006
+ </div>
1007
+
1008
+ <div class="grid gap-4 md:grid-cols-2">
1009
+ <div class="flex flex-col gap-3">
1010
+ <h3 class="label-16-medium text-center text-content-on-surface-primary">
1011
+ Default
1012
+ </h3>
1013
+ <div class="flex justify-center border border-border-surface-default p-6">
1014
+ <div class="flex w-full max-w-sm items-center rounded border border-border-surface-default bg-background-surface-floating p-4 pl-5 shadow-[0px_4px_24px_0px_#00000033]">
1015
+ <UiSnackbarContent
1016
+ embedded
1017
+ title="Title Text"
1018
+ description="This is a toast description."
1019
+ icon-mode="success"
1020
+ action-label="Undo"
1021
+ :on-close-toast="noop"
1022
+ />
1023
+ </div>
1024
+ </div>
1025
+ </div>
1026
+
1027
+ <div class="accessible-theme flex flex-col gap-3">
1028
+ <h3 class="label-16-medium text-center text-content-on-surface-primary">
1029
+ Accessible
1030
+ </h3>
1031
+ <div class="flex justify-center border border-border-surface-default p-6">
1032
+ <div class="flex w-full max-w-sm items-center rounded border border-border-surface-default bg-background-surface-floating p-4 pl-5 shadow-[0px_4px_24px_0px_#00000033]">
1033
+ <UiSnackbarContent
1034
+ embedded
1035
+ title="Title Text"
1036
+ description="This is a toast description."
1037
+ icon-mode="success"
1038
+ action-label="Undo"
1039
+ :on-close-toast="noop"
1040
+ />
1041
+ </div>
1042
+ </div>
1043
+ </div>
1044
+ </div>
1045
+ </section>
1046
+ `,
1047
+ }),
1048
+ tags: ['!autodocs'],
1049
+ parameters: {
1050
+ a11y: { test: 'off' },
1051
+ chromatic: {
1052
+ disableSnapshot: true,
1053
+ },
1054
+ docs: {
1055
+ canvas: {
1056
+ sourceState: 'none',
1057
+ },
1058
+ },
1059
+ },
1060
+ };
1061
+
1062
+ /*
1063
+ * ─────────────────────────────────────────────────────────────────────────────
1064
+ * Interaction & accessibility tests (play functions)
1065
+ * ─────────────────────────────────────────────────────────────────────────────
1066
+ * The stories below are hidden from the sidebar and the docs page but still run
1067
+ * in the Storybook test-runner on every PR, alongside the axe audit. The
1068
+ * `interaction:` checks (message, dismissal, action callback, state rendering)
1069
+ * are co-located on the visible stories above, per TESTING.md; only the
1070
+ * keyboard, screen-reader, zoom, and mobile flows live here. The `step()`
1071
+ * prefix is parsed into the CI report, so keep it accurate:
1072
+ * • `interaction:` behaviour and guards (WCAG 4.1.2)
1073
+ * • `keyboard:` focus order and activation (WCAG 2.1.1, 2.4.3)
1074
+ * • `screen-reader:` names, roles and states (WCAG 4.1.2)
1075
+ * • `zoom:` operable when magnified (WCAG 1.4.4)
1076
+ * • `mobile:` 320px reflow and target size (WCAG 1.4.10, 2.5.8)
1077
+ * The Accessibility column is filled automatically by the axe audit — never add
1078
+ * an `a11y:` prefix.
1079
+ *
1080
+ * Snackbars are status messages: the toast region is a *polite* live region
1081
+ * (`aria-live="polite"`), so messages wait for the screen reader to finish
1082
+ * speaking. Assertive, interrupt-now messaging belongs to `UiAlert`
1083
+ * (`role="alert"`), which is why no story here asserts assertive semantics.
1084
+ * The test runner's `postVisit` hook runs the axe audit on whatever the play
1085
+ * leaves rendered, so every play ends by reopening both rendering paths
1086
+ * (Sonner's native toast and the custom `UiSnackbarContent`) after the
1087
+ * dismissal assertions — otherwise the audit would only ever see an empty
1088
+ * toaster. The fixture dismisses all toasts again on story teardown.
1089
+ */
1090
+
1091
+ /**
1092
+ * The fixture the test stories drive: one trigger for a text-only snackbar
1093
+ * (Sonner's native close control) and one for a custom snackbar with a status
1094
+ * icon and an Undo action (`UiSnackbarContent`'s embedded close control).
1095
+ * `duration: Infinity` keeps auto-dismiss out of the assertions — the plays
1096
+ * dismiss explicitly and leave reopened toasts mounted for the axe audit, so
1097
+ * the fixture clears Sonner's module-level toast state on story teardown to
1098
+ * keep stories independent.
1099
+ * @param toasterId Unique Sonner toaster id so stories do not share toasts.
1100
+ * @returns Vue component options for a story `render` function.
1101
+ */
1102
+ function renderTestSnackbar(toasterId: string) {
1103
+ return {
1104
+ components: { UiSnackbar, UiButton },
1105
+ setup() {
1106
+ // Teardown, not pre-audit cleanup: toasts stay mounted when the play
1107
+ // returns so the postVisit axe audit checks rendered snackbar content.
1108
+ onUnmounted(() => toast.dismiss());
1109
+ const showMessage = () =>
1110
+ showSnackbar({
1111
+ title: 'Draft saved',
1112
+ description: 'Stored in your workspace just now.',
1113
+ duration: Infinity,
1114
+ toasterId,
1115
+ });
1116
+ const showActionSnackbar = () =>
1117
+ showSnackbar({
1118
+ title: 'Event has been created',
1119
+ iconMode: 'success',
1120
+ actionLabel: 'Undo',
1121
+ onAction: () => onAction(),
1122
+ duration: Infinity,
1123
+ toasterId,
1124
+ });
1125
+ return { showMessage, showActionSnackbar, toasterId };
1126
+ },
1127
+ template: `
1128
+ <div class="flex flex-wrap items-center gap-2">
1129
+ <UiButton @click="showMessage">Show message</UiButton>
1130
+ <UiButton @click="showActionSnackbar">Show action snackbar</UiButton>
1131
+ <UiSnackbar :id="toasterId" />
1132
+ </div>
1133
+ `,
1134
+ };
1135
+ }
1136
+
1137
+ /**
1138
+ * Reopens both snackbar rendering paths — the native text-only toast and the
1139
+ * custom `UiSnackbarContent` with icon and action — and waits for them, so the
1140
+ * axe audit that the test runner's `postVisit` hook performs after the play
1141
+ * checks rendered snackbar content instead of an empty toaster. The fixture
1142
+ * dismisses them again on story teardown.
1143
+ * @param canvas Testing-library queries scoped to the story canvas.
1144
+ */
1145
+ async function leaveSnackbarsMountedForAudit(
1146
+ canvas: ReturnType<typeof within>,
1147
+ ) {
1148
+ await userEvent.click(canvas.getByRole('button', { name: 'Show message' }));
1149
+ await userEvent.click(
1150
+ canvas.getByRole('button', { name: 'Show action snackbar' }),
1151
+ );
1152
+ await waitFor(async () => {
1153
+ await expect(canvas.getByText('Draft saved')).toBeVisible();
1154
+ await expect(canvas.getByText('Event has been created')).toBeVisible();
1155
+ });
1156
+ }
1157
+
1158
+ /**
1159
+ * Presses Tab until the given element has focus, proving it is reachable from
1160
+ * the keyboard regardless of where Sonner restores focus after a dismissal.
1161
+ * @param element Element that must receive focus.
1162
+ * @param maxTabs Upper bound of Tab presses before failing.
1163
+ */
1164
+ async function tabTo(element: HTMLElement, maxTabs = 6) {
1165
+ for (let i = 0; i < maxTabs; i += 1) {
1166
+ await userEvent.tab();
1167
+ if (document.activeElement === element) return;
1168
+ }
1169
+ throw new Error('Element was not reached with Tab');
1170
+ }
1171
+
1172
+ /**
1173
+ * The dismiss control and the built-in action are reachable with Tab and
1174
+ * operable with Enter and Space. Hidden test-only story.
1175
+ */
1176
+ export const KeyboardNavigation: Story = {
1177
+ name: 'test - Keyboard Navigation',
1178
+ tags: ['!dev', '!autodocs'],
1179
+ parameters: {
1180
+ // Focus moves and toasts appear and disappear during the play function.
1181
+ chromatic: { disableSnapshot: true },
1182
+ docs: {
1183
+ description: {
1184
+ story:
1185
+ 'Press `Tab` to reach the snackbar and its dismiss control, then `Enter` or `Space` to activate it.',
1186
+ },
1187
+ },
1188
+ },
1189
+ render: () => renderTestSnackbar('test-keyboard'),
1190
+ play: async ({ canvasElement, step }) => {
1191
+ // Scenario (UiSnackbar + showSnackbar + UiSnackbarContent): a keyboard user
1192
+ // triggers a snackbar, tabs into it, dismisses it with Enter, and drives
1193
+ // the Undo action and the embedded close control of a second one.
1194
+ onAction.mockClear();
1195
+ const canvas = within(canvasElement);
1196
+
1197
+ await step(
1198
+ 'keyboard: Tab reaches the trigger and Enter shows the snackbar',
1199
+ async () => {
1200
+ await userEvent.tab();
1201
+ await expect(
1202
+ canvas.getByRole('button', { name: 'Show message' }),
1203
+ ).toHaveFocus();
1204
+ await userEvent.keyboard('{Enter}');
1205
+ await waitFor(async () => {
1206
+ await expect(canvas.getByText('Draft saved')).toBeVisible();
1207
+ });
1208
+ },
1209
+ );
1210
+
1211
+ await step(
1212
+ 'keyboard: the dismiss control is reachable with Tab (WCAG 2.1.1)',
1213
+ async () => {
1214
+ const close = canvas.getByRole('button', { name: 'Close toast' });
1215
+ await tabTo(close);
1216
+ await expect(close).toHaveFocus();
1217
+ },
1218
+ );
1219
+
1220
+ await step(
1221
+ 'keyboard: Enter on the dismiss control removes the snackbar',
1222
+ async () => {
1223
+ await userEvent.keyboard('{Enter}');
1224
+ await waitFor(async () => {
1225
+ await expect(canvas.queryByText('Draft saved')).toBeNull();
1226
+ });
1227
+ },
1228
+ );
1229
+
1230
+ await step(
1231
+ 'keyboard: the action snackbar opens and its action activates with Enter',
1232
+ async () => {
1233
+ const actionTrigger = canvas.getByRole('button', {
1234
+ name: 'Show action snackbar',
1235
+ });
1236
+ await tabTo(actionTrigger);
1237
+ await userEvent.keyboard(' ');
1238
+ await waitFor(async () => {
1239
+ await expect(
1240
+ canvas.getByText('Event has been created'),
1241
+ ).toBeVisible();
1242
+ });
1243
+
1244
+ const undo = canvas.getByRole('button', { name: 'Undo' });
1245
+ await tabTo(undo);
1246
+ await userEvent.keyboard('{Enter}');
1247
+ await expect(onAction).toHaveBeenCalled();
1248
+ },
1249
+ );
1250
+
1251
+ await step(
1252
+ 'keyboard: Space on the embedded dismiss control removes the snackbar',
1253
+ async () => {
1254
+ const close = canvas.getByRole('button', { name: 'Close toast' });
1255
+ await userEvent.tab();
1256
+ await expect(close).toHaveFocus();
1257
+ await userEvent.keyboard(' ');
1258
+ await userEvent.keyboard(' ');
1259
+ await waitFor(async () => {
1260
+ await expect(canvas.queryByText('Event has been created')).toBeNull();
1261
+ });
1262
+ },
1263
+ );
1264
+
1265
+ await step(
1266
+ 'interaction: both rendering paths stay mounted for the accessibility audit',
1267
+ async () => {
1268
+ await leaveSnackbarsMountedForAudit(canvas);
1269
+ },
1270
+ );
1271
+ },
1272
+ };
1273
+
1274
+ /**
1275
+ * Screen-reader semantics: a polite live region announcing messages as status
1276
+ * (not alert), a named dismiss control, and a status icon that keeps the
1277
+ * outcome off colour alone. Hidden test-only story.
1278
+ */
1279
+ export const ScreenReader: Story = {
1280
+ name: 'test - Screen Reader',
1281
+ tags: ['!dev', '!autodocs'],
1282
+ parameters: {
1283
+ // Toasts appear and disappear during the play function.
1284
+ chromatic: { disableSnapshot: true },
1285
+ docs: {
1286
+ description: {
1287
+ story:
1288
+ 'Verifies polite live-region semantics (status rather than alert), the named dismiss control, and the announced status icon.',
1289
+ },
1290
+ },
1291
+ },
1292
+ render: () => renderTestSnackbar('test-screen-reader'),
1293
+ play: async ({ canvasElement, step }) => {
1294
+ // Scenario (UiSnackbar + showSnackbar + UiSnackbarContent + UiSnackbarIcon):
1295
+ // assistive tech hears new snackbars politely once the current speech
1296
+ // finishes, finds a named dismiss control, and gets the outcome from the
1297
+ // labelled status icon as well as the words.
1298
+ const canvas = within(canvasElement);
1299
+ const region = canvas.getByLabelText(/Notifications/);
1300
+
1301
+ await step(
1302
+ 'screen-reader: the toast region is a polite live region — status, not alert (WCAG 4.1.3)',
1303
+ async () => {
1304
+ // Snackbars report outcomes that already happened, so they must not
1305
+ // interrupt. Assertive, interrupt-now messaging is UiAlert's job.
1306
+ await expect(region).toHaveAttribute('aria-live', 'polite');
1307
+ await expect(region).toHaveAttribute('aria-relevant', 'additions text');
1308
+ },
1309
+ );
1310
+
1311
+ await step(
1312
+ 'screen-reader: the message is announced from inside the live region',
1313
+ async () => {
1314
+ await userEvent.click(
1315
+ canvas.getByRole('button', { name: 'Show message' }),
1316
+ );
1317
+ const title = await canvas.findByText('Draft saved');
1318
+ await expect(region.contains(title)).toBe(true);
1319
+ await waitFor(async () => {
1320
+ await expect(
1321
+ canvas.getByText('Stored in your workspace just now.'),
1322
+ ).toBeVisible();
1323
+ });
1324
+ },
1325
+ );
1326
+
1327
+ await step(
1328
+ 'screen-reader: the dismiss control has an accessible name (WCAG 4.1.2)',
1329
+ async () => {
1330
+ const close = canvas.getByRole('button', { name: 'Close toast' });
1331
+ await expect(close).toBeVisible();
1332
+ await userEvent.click(close);
1333
+ await waitFor(async () => {
1334
+ await expect(canvas.queryByText('Draft saved')).toBeNull();
1335
+ });
1336
+ },
1337
+ );
1338
+
1339
+ await step(
1340
+ 'screen-reader: the status icon is announced, so the outcome is not colour-only (WCAG 1.4.1)',
1341
+ async () => {
1342
+ await userEvent.click(
1343
+ canvas.getByRole('button', { name: 'Show action snackbar' }),
1344
+ );
1345
+ await canvas.findByText('Event has been created');
1346
+ const icon = canvas.getByRole('img', { name: 'Success' });
1347
+ await expect(icon).toHaveAttribute('data-mode', 'success');
1348
+ await waitFor(async () => {
1349
+ await expect(
1350
+ canvas.getByRole('button', { name: 'Undo' }),
1351
+ ).toBeVisible();
1352
+ });
1353
+ },
1354
+ );
1355
+
1356
+ await step(
1357
+ 'screen-reader: dismissing removes the message from the live region',
1358
+ async () => {
1359
+ await userEvent.click(
1360
+ canvas.getByRole('button', { name: 'Close toast' }),
1361
+ );
1362
+ await waitFor(async () => {
1363
+ await expect(canvas.queryByText('Event has been created')).toBeNull();
1364
+ });
1365
+ },
1366
+ );
1367
+
1368
+ await step(
1369
+ 'interaction: both rendering paths stay mounted for the accessibility audit',
1370
+ async () => {
1371
+ await leaveSnackbarsMountedForAudit(canvas);
1372
+ },
1373
+ );
1374
+ },
1375
+ };
1376
+
1377
+ /**
1378
+ * Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
1379
+ * try 400% reflow (WCAG 1.4.10); the snackbar must stay readable and its
1380
+ * dismiss control operable. Hidden test-only story.
1381
+ */
1382
+ export const ZoomMagnification: Story = {
1383
+ name: 'test - Zoom Magnification',
1384
+ tags: ['!dev', '!autodocs'],
1385
+ globals: { zoom: '200' },
1386
+ parameters: {
1387
+ // Zoom changes the layout scale; the accessible-reflow Chromatic mode
1388
+ // already covers magnified snapshots, so skip this one.
1389
+ chromatic: { disableSnapshot: true },
1390
+ docs: {
1391
+ description: {
1392
+ story:
1393
+ 'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
1394
+ },
1395
+ },
1396
+ },
1397
+ render: () => renderTestSnackbar('test-zoom'),
1398
+ play: async ({ canvasElement, step }) => {
1399
+ // Scenario (UiSnackbar + showSnackbar): at 200% page zoom the snackbar
1400
+ // stays inside the viewport, its message stays readable, and the dismiss
1401
+ // control still works.
1402
+ const canvas = within(canvasElement);
1403
+
1404
+ await step(
1405
+ 'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
1406
+ async () => {
1407
+ await expect(document.documentElement.style.zoom).toBe('200%');
1408
+ },
1409
+ );
1410
+
1411
+ await step(
1412
+ 'zoom: the snackbar stays visible and inside the viewport',
1413
+ async () => {
1414
+ await userEvent.click(
1415
+ canvas.getByRole('button', { name: 'Show message' }),
1416
+ );
1417
+ await waitFor(async () => {
1418
+ await expect(canvas.getByText('Draft saved')).toBeVisible();
1419
+ });
1420
+
1421
+ const toast = canvasElement.querySelector('[data-sonner-toast]');
1422
+ await expect(toast).not.toBeNull();
1423
+ const { left, right } = (toast as HTMLElement).getBoundingClientRect();
1424
+ await expect(left).toBeGreaterThanOrEqual(0);
1425
+ await expect(right).toBeLessThanOrEqual(window.innerWidth + 1);
1426
+ },
1427
+ );
1428
+
1429
+ await step('zoom: the dismiss control remains operable', async () => {
1430
+ await userEvent.click(
1431
+ canvas.getByRole('button', { name: 'Close toast' }),
1432
+ );
1433
+ await waitFor(async () => {
1434
+ await expect(canvas.queryByText('Draft saved')).toBeNull();
1435
+ });
1436
+ });
1437
+
1438
+ await step(
1439
+ 'interaction: both rendering paths stay mounted for the accessibility audit',
1440
+ async () => {
1441
+ await leaveSnackbarsMountedForAudit(canvas);
1442
+ },
1443
+ );
1444
+ },
1445
+ };
1446
+
1447
+ /**
1448
+ * Rendered at the mobile (320px reflow) breakpoint via the Media breakpoint
1449
+ * toolbar. The snackbar fits the viewport and its dismiss and action controls
1450
+ * meet the minimum touch-target size (WCAG 2.5.8). Hidden test-only story.
1451
+ */
1452
+ export const MobileBreakpoint: Story = {
1453
+ name: 'test - Mobile Breakpoint',
1454
+ tags: ['!dev', '!autodocs'],
1455
+ globals: { mediaBreakpoint: 'reflow' },
1456
+ parameters: {
1457
+ // Reflow snapshots are already covered by the accessible-reflow mode.
1458
+ chromatic: { disableSnapshot: true },
1459
+ docs: {
1460
+ description: {
1461
+ story:
1462
+ 'Switch the Media breakpoint toolbar to Mobile to preview the 320px layout.',
1463
+ },
1464
+ },
1465
+ },
1466
+ render: () => renderTestSnackbar('test-mobile'),
1467
+ play: async ({ canvasElement, step }) => {
1468
+ // Scenario (UiSnackbar + showSnackbar + UiSnackbarContent): on a 320px
1469
+ // viewport the snackbar reflows inside the screen and both the Undo action
1470
+ // and the dismiss control are big enough to tap.
1471
+ const canvas = within(canvasElement);
1472
+
1473
+ await step(
1474
+ 'mobile: the snackbar fits the 320px viewport without sideways scrolling (WCAG 1.4.10 Reflow)',
1475
+ async () => {
1476
+ await userEvent.click(
1477
+ canvas.getByRole('button', { name: 'Show action snackbar' }),
1478
+ );
1479
+ await waitFor(async () => {
1480
+ await expect(
1481
+ canvas.getByText('Event has been created'),
1482
+ ).toBeVisible();
1483
+ });
1484
+
1485
+ const toast = canvasElement.querySelector('[data-sonner-toast]');
1486
+ await expect(toast).not.toBeNull();
1487
+ const { left, right } = (toast as HTMLElement).getBoundingClientRect();
1488
+ await expect(left).toBeGreaterThanOrEqual(0);
1489
+ await expect(right).toBeLessThanOrEqual(window.innerWidth + 1);
1490
+ },
1491
+ );
1492
+
1493
+ await step(
1494
+ 'mobile: dismiss and action meet the minimum touch-target size (WCAG 2.5.8)',
1495
+ async () => {
1496
+ // The close control measures exactly 24px (`size-6`), the 2.5.8 floor:
1497
+ // shrinking it again would drop the dismiss below conformance.
1498
+ for (const name of ['Close toast', 'Undo']) {
1499
+ const { width, height } = canvas
1500
+ .getByRole('button', { name })
1501
+ .getBoundingClientRect();
1502
+ await expect(width).toBeGreaterThanOrEqual(24);
1503
+ await expect(height).toBeGreaterThanOrEqual(24);
1504
+ }
1505
+ },
1506
+ );
1507
+
1508
+ await step(
1509
+ 'mobile: tapping the dismiss control removes the snackbar',
1510
+ async () => {
1511
+ await userEvent.click(
1512
+ canvas.getByRole('button', { name: 'Close toast' }),
1513
+ );
1514
+ await waitFor(async () => {
1515
+ await expect(canvas.queryByText('Event has been created')).toBeNull();
1516
+ });
1517
+ },
1518
+ );
1519
+
1520
+ await step(
1521
+ 'mobile: the native dismiss control is at least 24px and remains operable',
1522
+ async () => {
1523
+ await userEvent.click(
1524
+ canvas.getByRole('button', { name: 'Show message' }),
1525
+ );
1526
+ await waitFor(async () => {
1527
+ await expect(canvas.getByText('Draft saved')).toBeVisible();
1528
+ });
1529
+ const close = canvas.getByRole('button', { name: 'Close toast' });
1530
+ const { width, height } = close.getBoundingClientRect();
1531
+ await expect(width).toBeGreaterThanOrEqual(24);
1532
+ await expect(height).toBeGreaterThanOrEqual(24);
1533
+ await userEvent.click(close);
1534
+ await waitFor(async () => {
1535
+ await expect(canvas.queryByText('Draft saved')).toBeNull();
1536
+ });
1537
+ },
1538
+ );
1539
+
1540
+ await step(
1541
+ 'interaction: both rendering paths stay mounted for the accessibility audit',
1542
+ async () => {
1543
+ await leaveSnackbarsMountedForAudit(canvas);
1544
+ },
1545
+ );
1546
+ },
1547
+ };