@aleph-alpha/ui-library 6.4.0 → 6.5.0
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/dist/system/components/UiFileItem/UiFileItem.vue.d.ts +10 -1
- package/dist/system/components/UiFileItem/index.d.ts +1 -1
- package/dist/system/components/UiFileItem/types.d.ts +81 -5
- package/dist/system/components/UiPopover/UiPopoverContent.vue.d.ts +1 -0
- package/dist/system/components/UiPopover/types.d.ts +6 -0
- package/dist/system/components/core/popover/PopoverContent.vue.d.ts +1 -0
- package/dist/system/lib.js +7294 -7198
- package/package.json +2 -2
- package/src/components/UiFileItem/UiFileItem.vue +111 -6
- package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +52 -0
- package/src/components/UiFileItem/index.ts +1 -0
- package/src/components/UiFileItem/types.ts +82 -5
- package/src/components/UiPopover/UiPopover.stories.ts +141 -0
- package/src/components/UiPopover/UiPopoverContent.vue +2 -0
- package/src/components/UiPopover/__tests__/UiPopover.test.ts +48 -0
- package/src/components/UiPopover/types.ts +7 -0
- package/src/components/core/popover/PopoverContent.vue +9 -3
- package/src/patterns/UiFileUpload/UiFileItem.stories.ts +808 -22
- package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +188 -6
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
-
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
2
|
+
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
|
|
3
3
|
import { UiFileItem } from '@/components/UiFileItem';
|
|
4
4
|
|
|
5
5
|
// `UiFileItem` emits `remove` with no payload and declares no handler prop, so
|
|
6
6
|
// the plays bind a module-level spy via `@remove` and clear it per story.
|
|
7
7
|
const onRemove = fn();
|
|
8
|
+
const onRemoveItem = fn();
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* `UiFileItem` is a single-row primitive that represents a file with
|
|
@@ -22,10 +23,16 @@ const meta: Meta<typeof UiFileItem> = {
|
|
|
22
23
|
sizeLabel: '1.2 MB',
|
|
23
24
|
progress: null,
|
|
24
25
|
error: '',
|
|
26
|
+
processing: false,
|
|
27
|
+
processingLabel: 'Processing…',
|
|
25
28
|
disabled: false,
|
|
26
29
|
removable: true,
|
|
27
30
|
removeLabel: 'Remove file',
|
|
28
31
|
progressLabel: undefined,
|
|
32
|
+
expandLabel: 'Show files',
|
|
33
|
+
listLabel: 'Attached files',
|
|
34
|
+
popoverSide: 'bottom',
|
|
35
|
+
popoverAlign: 'center',
|
|
29
36
|
size: 'default',
|
|
30
37
|
mediaTone: undefined,
|
|
31
38
|
mediaIcon: undefined,
|
|
@@ -37,6 +44,37 @@ const meta: Meta<typeof UiFileItem> = {
|
|
|
37
44
|
description:
|
|
38
45
|
'Error text. When non-empty the row enters the error state and replaces the type/size meta.',
|
|
39
46
|
},
|
|
47
|
+
processing: {
|
|
48
|
+
control: 'boolean',
|
|
49
|
+
description:
|
|
50
|
+
'Processing state. Shows `typeLabel | processingLabel` and a neutral file badge instead of a progress bar or the file size.',
|
|
51
|
+
},
|
|
52
|
+
processingLabel: {
|
|
53
|
+
control: 'text',
|
|
54
|
+
description:
|
|
55
|
+
'Visible processing status. Also announced, with the filename, from the status region — pass a translated string.',
|
|
56
|
+
},
|
|
57
|
+
items: {
|
|
58
|
+
control: 'object',
|
|
59
|
+
description:
|
|
60
|
+
'Files inside the multi variant. A non-empty list adds a chevron that opens them in a popover. Each entry uses the file-type icon for its extension.',
|
|
61
|
+
},
|
|
62
|
+
expandLabel: {
|
|
63
|
+
control: 'text',
|
|
64
|
+
description: 'Accessible name for the chevron that opens the file list.',
|
|
65
|
+
},
|
|
66
|
+
listLabel: {
|
|
67
|
+
control: 'text',
|
|
68
|
+
description: 'Accessible name for the list inside the popover.',
|
|
69
|
+
},
|
|
70
|
+
popoverSide: {
|
|
71
|
+
control: 'select',
|
|
72
|
+
options: ['top', 'right', 'bottom', 'left'],
|
|
73
|
+
},
|
|
74
|
+
popoverAlign: {
|
|
75
|
+
control: 'select',
|
|
76
|
+
options: ['start', 'center', 'end'],
|
|
77
|
+
},
|
|
40
78
|
removable: {
|
|
41
79
|
control: 'boolean',
|
|
42
80
|
description:
|
|
@@ -68,11 +106,12 @@ const meta: Meta<typeof UiFileItem> = {
|
|
|
68
106
|
},
|
|
69
107
|
},
|
|
70
108
|
decorators: [
|
|
71
|
-
//
|
|
72
|
-
// so it needs more room than the single-row stories.
|
|
109
|
+
// Side-by-side stories need more room than a single row.
|
|
73
110
|
(story, context) => ({
|
|
74
111
|
template: `<div class="p-4 ${
|
|
75
|
-
context.name === 'Accessibility'
|
|
112
|
+
context.name === 'Accessibility' || context.name === 'Multi'
|
|
113
|
+
? 'max-w-3xl'
|
|
114
|
+
: 'max-w-md'
|
|
76
115
|
}"><story /></div>`,
|
|
77
116
|
}),
|
|
78
117
|
],
|
|
@@ -236,6 +275,108 @@ const onRemove = () => undefined;
|
|
|
236
275
|
/>
|
|
237
276
|
</template>`;
|
|
238
277
|
|
|
278
|
+
const processingTemplateSource = `<script setup lang="ts">
|
|
279
|
+
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
280
|
+
|
|
281
|
+
const onRemove = () => undefined;
|
|
282
|
+
</script>
|
|
283
|
+
|
|
284
|
+
<template>
|
|
285
|
+
<UiFileItem
|
|
286
|
+
filename="Filename.pdf"
|
|
287
|
+
type-label="PDF"
|
|
288
|
+
processing
|
|
289
|
+
processing-label="Processing…"
|
|
290
|
+
@remove="onRemove"
|
|
291
|
+
/>
|
|
292
|
+
</template>`;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Default size · processing. Neutral file badge plus `PDF | Processing…`.
|
|
296
|
+
* The status text is a prop so it can be translated, and it is exposed as a
|
|
297
|
+
* status region named with the file.
|
|
298
|
+
*/
|
|
299
|
+
export const Processing: Story = {
|
|
300
|
+
args: {
|
|
301
|
+
filename: 'Filename.pdf',
|
|
302
|
+
typeLabel: 'PDF',
|
|
303
|
+
sizeLabel: '12 MB',
|
|
304
|
+
progress: 40,
|
|
305
|
+
error: '',
|
|
306
|
+
processing: true,
|
|
307
|
+
processingLabel: 'Processing…',
|
|
308
|
+
size: 'default',
|
|
309
|
+
},
|
|
310
|
+
render: renderArgs,
|
|
311
|
+
parameters: {
|
|
312
|
+
docs: { source: { code: processingTemplateSource } },
|
|
313
|
+
},
|
|
314
|
+
play: async ({ canvasElement, step }) => {
|
|
315
|
+
// Scenario (UiFileItem): a file has finished uploading and is being
|
|
316
|
+
// processed. The row must say so in text — the neutral badge is not enough —
|
|
317
|
+
// and must not keep showing a progress bar or a stale size.
|
|
318
|
+
const canvas = within(canvasElement);
|
|
319
|
+
|
|
320
|
+
await step(
|
|
321
|
+
'interaction: processing replaces the progress bar and the file size',
|
|
322
|
+
async () => {
|
|
323
|
+
await expect(canvas.getByText('Filename')).toBeVisible();
|
|
324
|
+
await expect(canvas.getByText('PDF')).toBeVisible();
|
|
325
|
+
await expect(canvas.getByText('Processing…')).toBeVisible();
|
|
326
|
+
await expect(canvas.queryByText('12 MB')).not.toBeInTheDocument();
|
|
327
|
+
await expect(canvas.queryByRole('progressbar')).not.toBeInTheDocument();
|
|
328
|
+
await expect(
|
|
329
|
+
canvasElement.querySelector('[data-slot="file-type"]'),
|
|
330
|
+
).toHaveAttribute('data-tone', 'default');
|
|
331
|
+
},
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
await step(
|
|
335
|
+
'screen-reader: the processing status names the file and the translated label (WCAG 4.1.3)',
|
|
336
|
+
async () => {
|
|
337
|
+
await expect(canvas.getByRole('status')).toHaveAccessibleName(
|
|
338
|
+
'Filename.pdf, PDF, Processing…',
|
|
339
|
+
);
|
|
340
|
+
},
|
|
341
|
+
);
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
const smallProcessingTemplateSource = `<script setup lang="ts">
|
|
346
|
+
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
347
|
+
|
|
348
|
+
const onRemove = () => undefined;
|
|
349
|
+
</script>
|
|
350
|
+
|
|
351
|
+
<template>
|
|
352
|
+
<UiFileItem
|
|
353
|
+
size="small"
|
|
354
|
+
filename="Filename.pdf"
|
|
355
|
+
type-label="PDF"
|
|
356
|
+
processing
|
|
357
|
+
processing-label="Processing…"
|
|
358
|
+
@remove="onRemove"
|
|
359
|
+
/>
|
|
360
|
+
</template>`;
|
|
361
|
+
|
|
362
|
+
/** Small size · processing. Same status line, tighter row. */
|
|
363
|
+
export const SmallProcessing: Story = {
|
|
364
|
+
args: {
|
|
365
|
+
filename: 'Filename.pdf',
|
|
366
|
+
typeLabel: 'PDF',
|
|
367
|
+
sizeLabel: undefined,
|
|
368
|
+
progress: null,
|
|
369
|
+
error: '',
|
|
370
|
+
processing: true,
|
|
371
|
+
processingLabel: 'Processing…',
|
|
372
|
+
size: 'small',
|
|
373
|
+
},
|
|
374
|
+
render: renderArgs,
|
|
375
|
+
parameters: {
|
|
376
|
+
docs: { source: { code: smallProcessingTemplateSource } },
|
|
377
|
+
},
|
|
378
|
+
};
|
|
379
|
+
|
|
239
380
|
/** Default size · error. CircleAlert media + destructive subtitle text. */
|
|
240
381
|
export const DefaultError: Story = {
|
|
241
382
|
args: {
|
|
@@ -472,6 +613,13 @@ const onRemove = () => undefined;
|
|
|
472
613
|
<div class="flex max-w-md flex-1 flex-col gap-3">
|
|
473
614
|
<p class="label-12-medium text-content-on-surface-muted">Default size</p>
|
|
474
615
|
<UiFileItem filename="Filename.pdf" :progress="30" @remove="onRemove" />
|
|
616
|
+
<UiFileItem
|
|
617
|
+
filename="Filename.pdf"
|
|
618
|
+
type-label="PDF"
|
|
619
|
+
processing
|
|
620
|
+
processing-label="Processing…"
|
|
621
|
+
@remove="onRemove"
|
|
622
|
+
/>
|
|
475
623
|
<UiFileItem
|
|
476
624
|
filename="Filename.pdf"
|
|
477
625
|
type-label="PDF"
|
|
@@ -483,6 +631,14 @@ const onRemove = () => undefined;
|
|
|
483
631
|
<div class="flex max-w-64 flex-1 flex-col gap-3">
|
|
484
632
|
<p class="label-12-medium text-content-on-surface-muted">Small size</p>
|
|
485
633
|
<UiFileItem size="small" filename="Filename.pdf" :progress="30" @remove="onRemove" />
|
|
634
|
+
<UiFileItem
|
|
635
|
+
size="small"
|
|
636
|
+
filename="Filename.pdf"
|
|
637
|
+
type-label="PDF"
|
|
638
|
+
processing
|
|
639
|
+
processing-label="Processing…"
|
|
640
|
+
@remove="onRemove"
|
|
641
|
+
/>
|
|
486
642
|
<UiFileItem
|
|
487
643
|
size="small"
|
|
488
644
|
filename="Filename.pdf"
|
|
@@ -593,6 +749,405 @@ export const AllFileTypes: Story = {
|
|
|
593
749
|
},
|
|
594
750
|
};
|
|
595
751
|
|
|
752
|
+
const multiItems = [
|
|
753
|
+
{
|
|
754
|
+
id: 'plan',
|
|
755
|
+
filename: '26_Business_Plan_2026.pdf',
|
|
756
|
+
typeLabel: 'PDF',
|
|
757
|
+
sizeLabel: '12 MB',
|
|
758
|
+
removeLabel: 'Remove 26_Business_Plan_2026.pdf',
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
id: 'notes',
|
|
762
|
+
filename: 'Last_weeks_memory.md',
|
|
763
|
+
typeLabel: 'MD',
|
|
764
|
+
sizeLabel: '12 KB',
|
|
765
|
+
removeLabel: 'Remove Last_weeks_memory.md',
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
id: 'sheet',
|
|
769
|
+
filename: 'Tabular_analysis.csv',
|
|
770
|
+
typeLabel: 'CSV',
|
|
771
|
+
sizeLabel: '12 MB',
|
|
772
|
+
removeLabel: 'Remove Tabular_analysis.csv',
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
id: 'clip',
|
|
776
|
+
filename: 'Product_tour.mp4',
|
|
777
|
+
typeLabel: 'MP4',
|
|
778
|
+
sizeLabel: '18 MB',
|
|
779
|
+
removeLabel: 'Remove Product_tour.mp4',
|
|
780
|
+
},
|
|
781
|
+
];
|
|
782
|
+
|
|
783
|
+
const multiTemplateSource = `<script setup lang="ts">
|
|
784
|
+
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
785
|
+
|
|
786
|
+
const onRemove = () => undefined;
|
|
787
|
+
const onRemoveItem = () => undefined;
|
|
788
|
+
|
|
789
|
+
const items = [
|
|
790
|
+
{ filename: '26_Business_Plan_2026.pdf', typeLabel: 'PDF', sizeLabel: '12 MB' },
|
|
791
|
+
{ filename: 'Last_weeks_memory.md', typeLabel: 'MD', sizeLabel: '12 KB' },
|
|
792
|
+
{ filename: 'Tabular_analysis.csv', typeLabel: 'CSV', sizeLabel: '12 MB' },
|
|
793
|
+
{ filename: 'Product_tour.mp4', typeLabel: 'MP4', sizeLabel: '18 MB' },
|
|
794
|
+
];
|
|
795
|
+
</script>
|
|
796
|
+
|
|
797
|
+
<template>
|
|
798
|
+
<div class="flex flex-wrap gap-8">
|
|
799
|
+
<div class="flex max-w-md flex-1 flex-col gap-3">
|
|
800
|
+
<p class="label-12-medium text-content-on-surface-muted">Default size</p>
|
|
801
|
+
<UiFileItem
|
|
802
|
+
filename="Attached documents"
|
|
803
|
+
type-label="4 files"
|
|
804
|
+
size-label="42 MB"
|
|
805
|
+
expand-label="Show attached documents"
|
|
806
|
+
list-label="Attached files"
|
|
807
|
+
:items="items"
|
|
808
|
+
@remove="onRemove"
|
|
809
|
+
@remove-item="onRemoveItem"
|
|
810
|
+
/>
|
|
811
|
+
</div>
|
|
812
|
+
<div class="flex max-w-64 flex-1 flex-col gap-3">
|
|
813
|
+
<p class="label-12-medium text-content-on-surface-muted">Small size</p>
|
|
814
|
+
<UiFileItem
|
|
815
|
+
size="small"
|
|
816
|
+
filename="Attached documents"
|
|
817
|
+
type-label="4 files"
|
|
818
|
+
size-label="42 MB"
|
|
819
|
+
expand-label="Show attached documents"
|
|
820
|
+
list-label="Attached files"
|
|
821
|
+
:items="items"
|
|
822
|
+
@remove="onRemove"
|
|
823
|
+
@remove-item="onRemoveItem"
|
|
824
|
+
/>
|
|
825
|
+
</div>
|
|
826
|
+
</div>
|
|
827
|
+
</template>`;
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Multi variant at both sizes. The row summarises the group and a chevron
|
|
831
|
+
* opens a popover of the files inside. Each file keeps the icon for its type:
|
|
832
|
+
* PDF, Markdown, CSV, and video.
|
|
833
|
+
*/
|
|
834
|
+
export const Multi: Story = {
|
|
835
|
+
parameters: {
|
|
836
|
+
docs: { source: { code: multiTemplateSource } },
|
|
837
|
+
},
|
|
838
|
+
render: () => ({
|
|
839
|
+
components: { UiFileItem },
|
|
840
|
+
setup() {
|
|
841
|
+
return { items: multiItems, onRemove, onRemoveItem };
|
|
842
|
+
},
|
|
843
|
+
template: `
|
|
844
|
+
<div class="flex flex-wrap gap-8">
|
|
845
|
+
<div class="flex max-w-md flex-1 flex-col gap-3">
|
|
846
|
+
<p class="label-12-medium text-content-on-surface-muted">Default size</p>
|
|
847
|
+
<UiFileItem
|
|
848
|
+
filename="Attached documents"
|
|
849
|
+
type-label="4 files"
|
|
850
|
+
size-label="42 MB"
|
|
851
|
+
expand-label="Show attached documents"
|
|
852
|
+
list-label="Attached files"
|
|
853
|
+
:items="items"
|
|
854
|
+
@remove="onRemove"
|
|
855
|
+
@remove-item="onRemoveItem"
|
|
856
|
+
/>
|
|
857
|
+
</div>
|
|
858
|
+
<div class="flex max-w-64 flex-1 flex-col gap-3">
|
|
859
|
+
<p class="label-12-medium text-content-on-surface-muted">Small size</p>
|
|
860
|
+
<UiFileItem
|
|
861
|
+
size="small"
|
|
862
|
+
filename="Attached documents"
|
|
863
|
+
type-label="4 files"
|
|
864
|
+
size-label="42 MB"
|
|
865
|
+
expand-label="Show attached documents"
|
|
866
|
+
list-label="Attached files"
|
|
867
|
+
:items="items"
|
|
868
|
+
@remove="onRemove"
|
|
869
|
+
@remove-item="onRemoveItem"
|
|
870
|
+
/>
|
|
871
|
+
</div>
|
|
872
|
+
</div>
|
|
873
|
+
`,
|
|
874
|
+
}),
|
|
875
|
+
play: async ({ canvasElement, step }) => {
|
|
876
|
+
// Scenario (UiFileItem): several attachments are collapsed into one row,
|
|
877
|
+
// at the default size and the compact size. The chevron is the disclosure;
|
|
878
|
+
// until it is opened the individual files stay out of the way.
|
|
879
|
+
const canvas = within(canvasElement);
|
|
880
|
+
|
|
881
|
+
await step(
|
|
882
|
+
'interaction: both sizes show a collapsed chevron and hide the files',
|
|
883
|
+
async () => {
|
|
884
|
+
const chevrons = canvas.getAllByRole('button', {
|
|
885
|
+
name: 'Show attached documents',
|
|
886
|
+
});
|
|
887
|
+
await expect(chevrons).toHaveLength(2);
|
|
888
|
+
for (const chevron of chevrons) {
|
|
889
|
+
await expect(chevron).toHaveAttribute('aria-expanded', 'false');
|
|
890
|
+
}
|
|
891
|
+
await expect(canvas.getAllByText('Attached documents')).toHaveLength(2);
|
|
892
|
+
await expect(canvas.getAllByText('4 files')).toHaveLength(2);
|
|
893
|
+
await expect(
|
|
894
|
+
canvas.queryByText('26_Business_Plan_2026'),
|
|
895
|
+
).not.toBeInTheDocument();
|
|
896
|
+
},
|
|
897
|
+
);
|
|
898
|
+
},
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
const multiAllFileTypesTemplateSource = `<script setup lang="ts">
|
|
902
|
+
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
903
|
+
|
|
904
|
+
const onRemove = () => undefined;
|
|
905
|
+
|
|
906
|
+
const files = [
|
|
907
|
+
{ filename: 'Filename.pdf', typeLabel: 'PDF' },
|
|
908
|
+
{ filename: 'Filename.md', typeLabel: 'MD' },
|
|
909
|
+
{ filename: 'Filename.csv', typeLabel: 'CSV' },
|
|
910
|
+
{ filename: 'Filename.mp4', typeLabel: 'MP4' },
|
|
911
|
+
{ filename: 'Filename.zip', typeLabel: 'ZIP' },
|
|
912
|
+
];
|
|
913
|
+
</script>
|
|
914
|
+
|
|
915
|
+
<template>
|
|
916
|
+
<div class="flex max-w-md flex-col gap-3">
|
|
917
|
+
<UiFileItem
|
|
918
|
+
v-for="file in files"
|
|
919
|
+
:key="file.filename"
|
|
920
|
+
:filename="file.filename"
|
|
921
|
+
:type-label="file.typeLabel"
|
|
922
|
+
size-label="12 MB"
|
|
923
|
+
:expand-label="'Show ' + file.filename"
|
|
924
|
+
:items="[{ filename: file.filename, typeLabel: file.typeLabel, sizeLabel: '12 MB' }]"
|
|
925
|
+
@remove="onRemove"
|
|
926
|
+
/>
|
|
927
|
+
</div>
|
|
928
|
+
</template>`;
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* One multi row per file-type group. The summary badge follows the filename:
|
|
932
|
+
* pink, soft, yellow, orange, and the neutral fallback for an unknown extension.
|
|
933
|
+
*/
|
|
934
|
+
export const MultiAllFileTypes: Story = {
|
|
935
|
+
parameters: {
|
|
936
|
+
controls: { disable: true },
|
|
937
|
+
docs: { source: { code: multiAllFileTypesTemplateSource } },
|
|
938
|
+
},
|
|
939
|
+
render: () => ({
|
|
940
|
+
components: { UiFileItem },
|
|
941
|
+
setup() {
|
|
942
|
+
const files = [
|
|
943
|
+
{ filename: 'Filename.pdf', typeLabel: 'PDF' },
|
|
944
|
+
{ filename: 'Filename.md', typeLabel: 'MD' },
|
|
945
|
+
{ filename: 'Filename.csv', typeLabel: 'CSV' },
|
|
946
|
+
{ filename: 'Filename.mp4', typeLabel: 'MP4' },
|
|
947
|
+
{ filename: 'Filename.zip', typeLabel: 'ZIP' },
|
|
948
|
+
];
|
|
949
|
+
return { files, onRemove };
|
|
950
|
+
},
|
|
951
|
+
template: `
|
|
952
|
+
<div class="flex max-w-md flex-col gap-3">
|
|
953
|
+
<UiFileItem
|
|
954
|
+
v-for="file in files"
|
|
955
|
+
:key="file.filename"
|
|
956
|
+
:filename="file.filename"
|
|
957
|
+
:type-label="file.typeLabel"
|
|
958
|
+
size-label="12 MB"
|
|
959
|
+
:expand-label="'Show ' + file.filename"
|
|
960
|
+
:items="[{ filename: file.filename, typeLabel: file.typeLabel, sizeLabel: '12 MB' }]"
|
|
961
|
+
@remove="onRemove"
|
|
962
|
+
/>
|
|
963
|
+
</div>
|
|
964
|
+
`,
|
|
965
|
+
}),
|
|
966
|
+
play: async ({ canvasElement, step }) => {
|
|
967
|
+
// Scenario (UiFileItem): each multi summary takes its icon from the
|
|
968
|
+
// filename alone, and the type is also written out because the badge is
|
|
969
|
+
// decorative.
|
|
970
|
+
const canvas = within(canvasElement);
|
|
971
|
+
|
|
972
|
+
await step(
|
|
973
|
+
'interaction: each multi row takes the icon group for its file type',
|
|
974
|
+
async () => {
|
|
975
|
+
const tones = Array.from(
|
|
976
|
+
canvasElement.querySelectorAll('[data-slot="file-type"]'),
|
|
977
|
+
).map((badge) => badge.getAttribute('data-tone'));
|
|
978
|
+
await expect(tones).toEqual([
|
|
979
|
+
'accent-pink',
|
|
980
|
+
'accent-soft',
|
|
981
|
+
'accent-yellow',
|
|
982
|
+
'accent-orange',
|
|
983
|
+
'default',
|
|
984
|
+
]);
|
|
985
|
+
},
|
|
986
|
+
);
|
|
987
|
+
|
|
988
|
+
await step(
|
|
989
|
+
'screen-reader: the type label carries the file family (WCAG 1.4.1)',
|
|
990
|
+
async () => {
|
|
991
|
+
for (const badge of canvasElement.querySelectorAll(
|
|
992
|
+
'[data-slot="file-type"]',
|
|
993
|
+
)) {
|
|
994
|
+
await expect(badge).toHaveAttribute('aria-hidden', 'true');
|
|
995
|
+
}
|
|
996
|
+
for (const label of ['PDF', 'MD', 'CSV', 'MP4', 'ZIP']) {
|
|
997
|
+
await expect(canvas.getByText(label)).toBeVisible();
|
|
998
|
+
}
|
|
999
|
+
},
|
|
1000
|
+
);
|
|
1001
|
+
},
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
const multiDisabledTemplateSource = `<script setup lang="ts">
|
|
1005
|
+
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
1006
|
+
|
|
1007
|
+
const onRemove = () => undefined;
|
|
1008
|
+
</script>
|
|
1009
|
+
|
|
1010
|
+
<template>
|
|
1011
|
+
<UiFileItem
|
|
1012
|
+
filename="locked.pdf"
|
|
1013
|
+
type-label="PDF"
|
|
1014
|
+
size-label="2 MB"
|
|
1015
|
+
expand-label="Show locked.pdf"
|
|
1016
|
+
disabled
|
|
1017
|
+
:items="[{ filename: 'locked.pdf', typeLabel: 'PDF', sizeLabel: '2 MB' }]"
|
|
1018
|
+
@remove="onRemove"
|
|
1019
|
+
/>
|
|
1020
|
+
</template>`;
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Disabled multi row. The chevron and the remove control are both inert, so
|
|
1024
|
+
* the file list cannot be opened and the group cannot be detached.
|
|
1025
|
+
*/
|
|
1026
|
+
export const MultiDisabled: Story = {
|
|
1027
|
+
render: () => ({
|
|
1028
|
+
components: { UiFileItem },
|
|
1029
|
+
setup() {
|
|
1030
|
+
return { onRemove };
|
|
1031
|
+
},
|
|
1032
|
+
template: `
|
|
1033
|
+
<UiFileItem
|
|
1034
|
+
filename="locked.pdf"
|
|
1035
|
+
type-label="PDF"
|
|
1036
|
+
size-label="2 MB"
|
|
1037
|
+
expand-label="Show locked.pdf"
|
|
1038
|
+
disabled
|
|
1039
|
+
:items="[{ filename: 'locked.pdf', typeLabel: 'PDF', sizeLabel: '2 MB' }]"
|
|
1040
|
+
@remove="onRemove"
|
|
1041
|
+
/>
|
|
1042
|
+
`,
|
|
1043
|
+
}),
|
|
1044
|
+
parameters: {
|
|
1045
|
+
docs: { source: { code: multiDisabledTemplateSource } },
|
|
1046
|
+
},
|
|
1047
|
+
play: async ({ canvasElement, step }) => {
|
|
1048
|
+
// Scenario (UiFileItem): a locked group must refuse both disclosure and
|
|
1049
|
+
// removal. The single-file Disabled story never renders the chevron.
|
|
1050
|
+
onRemove.mockClear();
|
|
1051
|
+
const canvas = within(canvasElement);
|
|
1052
|
+
|
|
1053
|
+
await step(
|
|
1054
|
+
'interaction: a disabled multi row refuses the chevron and remove (WCAG 4.1.2)',
|
|
1055
|
+
async () => {
|
|
1056
|
+
const chevron = canvas.getByRole('button', {
|
|
1057
|
+
name: 'Show locked.pdf',
|
|
1058
|
+
});
|
|
1059
|
+
const remove = canvas.getByRole('button', { name: 'Remove file' });
|
|
1060
|
+
await expect(chevron).toBeDisabled();
|
|
1061
|
+
await expect(remove).toBeDisabled();
|
|
1062
|
+
// A disabled UiButton sets `pointer-events: none`, which makes
|
|
1063
|
+
// `userEvent.click` throw instead of no-op; bypass the check so the
|
|
1064
|
+
// guard itself is what gets asserted.
|
|
1065
|
+
await userEvent.click(chevron, { pointerEventsCheck: 0 });
|
|
1066
|
+
await userEvent.click(remove, { pointerEventsCheck: 0 });
|
|
1067
|
+
await expect(chevron).toHaveAttribute('aria-expanded', 'false');
|
|
1068
|
+
await expect(onRemove).not.toHaveBeenCalled();
|
|
1069
|
+
},
|
|
1070
|
+
);
|
|
1071
|
+
},
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
const multiErrorTemplateSource = `<script setup lang="ts">
|
|
1075
|
+
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
1076
|
+
|
|
1077
|
+
const onRemove = () => undefined;
|
|
1078
|
+
|
|
1079
|
+
const items = [
|
|
1080
|
+
{ filename: 'Filename.pdf', typeLabel: 'PDF', sizeLabel: '12 MB' },
|
|
1081
|
+
{ filename: 'Filename.md', typeLabel: 'MD', sizeLabel: '12 KB' },
|
|
1082
|
+
];
|
|
1083
|
+
</script>
|
|
1084
|
+
|
|
1085
|
+
<template>
|
|
1086
|
+
<UiFileItem
|
|
1087
|
+
filename="Attached documents"
|
|
1088
|
+
error="2 uploads failed"
|
|
1089
|
+
expand-label="Show attached documents"
|
|
1090
|
+
:items="items"
|
|
1091
|
+
@remove="onRemove"
|
|
1092
|
+
/>
|
|
1093
|
+
</template>`;
|
|
1094
|
+
|
|
1095
|
+
/**
|
|
1096
|
+
* Error multi row. The failure replaces the type and size line, and the
|
|
1097
|
+
* chevron stays available so the failed files can still be opened.
|
|
1098
|
+
*/
|
|
1099
|
+
export const MultiError: Story = {
|
|
1100
|
+
render: () => ({
|
|
1101
|
+
components: { UiFileItem },
|
|
1102
|
+
setup() {
|
|
1103
|
+
const items = [
|
|
1104
|
+
{ filename: 'Filename.pdf', typeLabel: 'PDF', sizeLabel: '12 MB' },
|
|
1105
|
+
{ filename: 'Filename.md', typeLabel: 'MD', sizeLabel: '12 KB' },
|
|
1106
|
+
];
|
|
1107
|
+
return { items, onRemove };
|
|
1108
|
+
},
|
|
1109
|
+
template: `
|
|
1110
|
+
<UiFileItem
|
|
1111
|
+
filename="Attached documents"
|
|
1112
|
+
error="2 uploads failed"
|
|
1113
|
+
expand-label="Show attached documents"
|
|
1114
|
+
:items="items"
|
|
1115
|
+
@remove="onRemove"
|
|
1116
|
+
/>
|
|
1117
|
+
`,
|
|
1118
|
+
}),
|
|
1119
|
+
parameters: {
|
|
1120
|
+
docs: { source: { code: multiErrorTemplateSource } },
|
|
1121
|
+
},
|
|
1122
|
+
play: async ({ canvasElement, step }) => {
|
|
1123
|
+
// Scenario (UiFileItem): a failed group says why in the row itself. The
|
|
1124
|
+
// single-file error story has no chevron, so this one checks the
|
|
1125
|
+
// disclosure stays collapsed until the user opens it.
|
|
1126
|
+
const canvas = within(canvasElement);
|
|
1127
|
+
|
|
1128
|
+
await step(
|
|
1129
|
+
'interaction: the error row keeps a collapsed chevron and hides the file list',
|
|
1130
|
+
async () => {
|
|
1131
|
+
const chevron = canvas.getByRole('button', {
|
|
1132
|
+
name: 'Show attached documents',
|
|
1133
|
+
});
|
|
1134
|
+
await expect(chevron).toHaveAttribute('aria-expanded', 'false');
|
|
1135
|
+
await expect(canvas.queryByText('Filename')).not.toBeInTheDocument();
|
|
1136
|
+
await expect(canvas.queryByText('PDF')).not.toBeInTheDocument();
|
|
1137
|
+
},
|
|
1138
|
+
);
|
|
1139
|
+
|
|
1140
|
+
await step(
|
|
1141
|
+
'screen-reader: the failure reason is announced via an alert region (WCAG 4.1.3)',
|
|
1142
|
+
async () => {
|
|
1143
|
+
await expect(canvas.getByRole('alert')).toHaveTextContent(
|
|
1144
|
+
'2 uploads failed',
|
|
1145
|
+
);
|
|
1146
|
+
},
|
|
1147
|
+
);
|
|
1148
|
+
},
|
|
1149
|
+
};
|
|
1150
|
+
|
|
596
1151
|
/** All variants in one column for quick visual comparison. */
|
|
597
1152
|
export const AllVariants: Story = {
|
|
598
1153
|
parameters: {
|
|
@@ -614,6 +1169,13 @@ export const AllVariants: Story = {
|
|
|
614
1169
|
<div class="flex max-w-md flex-1 flex-col gap-3">
|
|
615
1170
|
<p class="label-12-medium text-content-on-surface-muted">Default size</p>
|
|
616
1171
|
<UiFileItem filename="Filename.pdf" :progress="30" @remove="onRemove" />
|
|
1172
|
+
<UiFileItem
|
|
1173
|
+
filename="Filename.pdf"
|
|
1174
|
+
type-label="PDF"
|
|
1175
|
+
processing
|
|
1176
|
+
processing-label="Processing…"
|
|
1177
|
+
@remove="onRemove"
|
|
1178
|
+
/>
|
|
617
1179
|
<UiFileItem
|
|
618
1180
|
filename="Filename.pdf"
|
|
619
1181
|
type-label="PDF"
|
|
@@ -625,6 +1187,14 @@ export const AllVariants: Story = {
|
|
|
625
1187
|
<div class="flex max-w-64 flex-1 flex-col gap-3">
|
|
626
1188
|
<p class="label-12-medium text-content-on-surface-muted">Small size</p>
|
|
627
1189
|
<UiFileItem size="small" filename="Filename.pdf" :progress="30" @remove="onRemove" />
|
|
1190
|
+
<UiFileItem
|
|
1191
|
+
size="small"
|
|
1192
|
+
filename="Filename.pdf"
|
|
1193
|
+
type-label="PDF"
|
|
1194
|
+
processing
|
|
1195
|
+
processing-label="Processing…"
|
|
1196
|
+
@remove="onRemove"
|
|
1197
|
+
/>
|
|
628
1198
|
<UiFileItem
|
|
629
1199
|
size="small"
|
|
630
1200
|
filename="Filename.pdf"
|
|
@@ -671,7 +1241,7 @@ export const Accessibility: Story = {
|
|
|
671
1241
|
Never rely on the media badge alone
|
|
672
1242
|
</h3>
|
|
673
1243
|
<p class="body-16-regular text-content-on-surface-primary">
|
|
674
|
-
The round media badge is decorative and hidden from assistive tech, so the file family must also be stated in text. In the accessibility theme the media badge for video resolves to the same yellow as tabular files, which is why every row keeps its type label and its own icon.
|
|
1244
|
+
The round media badge is decorative and hidden from assistive tech, so the file family must also be stated in text. In the accessibility theme the media badge for video resolves to the same yellow as tabular files, which is why every row keeps its type label and its own icon. Processing uses the same neutral badge as an upload in progress, so the status has to be the text “Processing…”, not the badge.
|
|
675
1245
|
</p>
|
|
676
1246
|
</div>
|
|
677
1247
|
</div>
|
|
@@ -786,6 +1356,16 @@ export const StatePrecedence: Story = {
|
|
|
786
1356
|
remove-label="Remove Notes.md"
|
|
787
1357
|
@remove="onRemove"
|
|
788
1358
|
/>
|
|
1359
|
+
<UiFileItem
|
|
1360
|
+
filename="Brief.docx"
|
|
1361
|
+
type-label="DOCX"
|
|
1362
|
+
size-label="9 MB"
|
|
1363
|
+
:progress="40"
|
|
1364
|
+
processing
|
|
1365
|
+
processing-label="Processing…"
|
|
1366
|
+
remove-label="Remove Brief.docx"
|
|
1367
|
+
@remove="onRemove"
|
|
1368
|
+
/>
|
|
789
1369
|
</div>
|
|
790
1370
|
`,
|
|
791
1371
|
}),
|
|
@@ -824,6 +1404,18 @@ export const StatePrecedence: Story = {
|
|
|
824
1404
|
await expect(canvas.getByText('4 KB')).toBeVisible();
|
|
825
1405
|
},
|
|
826
1406
|
);
|
|
1407
|
+
|
|
1408
|
+
await step(
|
|
1409
|
+
'interaction: a processing row replaces its progress bar and size with the status text',
|
|
1410
|
+
async () => {
|
|
1411
|
+
await expect(canvas.getByText('DOCX')).toBeVisible();
|
|
1412
|
+
await expect(canvas.getByText('Processing…')).toBeVisible();
|
|
1413
|
+
await expect(canvas.queryByText('9 MB')).not.toBeInTheDocument();
|
|
1414
|
+
await expect(
|
|
1415
|
+
canvas.queryByRole('progressbar', { name: 'Brief.docx' }),
|
|
1416
|
+
).not.toBeInTheDocument();
|
|
1417
|
+
},
|
|
1418
|
+
);
|
|
827
1419
|
},
|
|
828
1420
|
};
|
|
829
1421
|
|
|
@@ -931,6 +1523,14 @@ export const ScreenReader: Story = {
|
|
|
931
1523
|
remove-label="Dismiss Archive.zip"
|
|
932
1524
|
@remove="onRemove"
|
|
933
1525
|
/>
|
|
1526
|
+
<UiFileItem
|
|
1527
|
+
filename="Notes.docx"
|
|
1528
|
+
type-label="DOCX"
|
|
1529
|
+
processing
|
|
1530
|
+
processing-label="Processing document"
|
|
1531
|
+
remove-label="Remove Notes.docx"
|
|
1532
|
+
@remove="onRemove"
|
|
1533
|
+
/>
|
|
934
1534
|
</div>
|
|
935
1535
|
`,
|
|
936
1536
|
}),
|
|
@@ -992,6 +1592,15 @@ export const ScreenReader: Story = {
|
|
|
992
1592
|
);
|
|
993
1593
|
},
|
|
994
1594
|
);
|
|
1595
|
+
|
|
1596
|
+
await step(
|
|
1597
|
+
'screen-reader: processing is a status named with the file and the translated label (WCAG 4.1.3)',
|
|
1598
|
+
async () => {
|
|
1599
|
+
await expect(canvas.getByRole('status')).toHaveAccessibleName(
|
|
1600
|
+
'Notes.docx, DOCX, Processing document',
|
|
1601
|
+
);
|
|
1602
|
+
},
|
|
1603
|
+
);
|
|
995
1604
|
},
|
|
996
1605
|
};
|
|
997
1606
|
|
|
@@ -1018,21 +1627,38 @@ export const ZoomMagnification: Story = {
|
|
|
1018
1627
|
render: () => ({
|
|
1019
1628
|
components: { UiFileItem },
|
|
1020
1629
|
setup() {
|
|
1021
|
-
return { onRemove };
|
|
1630
|
+
return { onRemove, onRemoveItem, items: multiItems };
|
|
1022
1631
|
},
|
|
1023
1632
|
template: `
|
|
1024
|
-
<
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1633
|
+
<div class="flex flex-col gap-3">
|
|
1634
|
+
<UiFileItem
|
|
1635
|
+
filename="Filename.pdf"
|
|
1636
|
+
type-label="PDF"
|
|
1637
|
+
size-label="12 MB"
|
|
1638
|
+
@remove="onRemove"
|
|
1639
|
+
/>
|
|
1640
|
+
<UiFileItem
|
|
1641
|
+
filename="Brief.docx"
|
|
1642
|
+
type-label="DOCX"
|
|
1643
|
+
processing
|
|
1644
|
+
processing-label="Processing…"
|
|
1645
|
+
remove-label="Remove Brief.docx"
|
|
1646
|
+
@remove="onRemove"
|
|
1647
|
+
/>
|
|
1648
|
+
<UiFileItem
|
|
1649
|
+
filename="Attached documents"
|
|
1650
|
+
type-label="4 files"
|
|
1651
|
+
expand-label="Show attached documents"
|
|
1652
|
+
:items="items"
|
|
1653
|
+
:removable="false"
|
|
1654
|
+
@remove-item="onRemoveItem"
|
|
1655
|
+
/>
|
|
1656
|
+
</div>
|
|
1030
1657
|
`,
|
|
1031
1658
|
}),
|
|
1032
1659
|
play: async ({ canvasElement, step }) => {
|
|
1033
|
-
// Scenario (UiFileItem): at 200% page zoom
|
|
1034
|
-
//
|
|
1035
|
-
// manage attachments without horizontal scrolling.
|
|
1660
|
+
// Scenario (UiFileItem): at 200% page zoom a finished row, a processing
|
|
1661
|
+
// status, and the group chevron stay readable and operable.
|
|
1036
1662
|
onRemove.mockClear();
|
|
1037
1663
|
const canvas = within(canvasElement);
|
|
1038
1664
|
const remove = canvas.getByRole('button', { name: 'Remove file' });
|
|
@@ -1054,6 +1680,20 @@ export const ZoomMagnification: Story = {
|
|
|
1054
1680
|
await userEvent.click(remove);
|
|
1055
1681
|
await expect(onRemove).toHaveBeenCalledTimes(1);
|
|
1056
1682
|
});
|
|
1683
|
+
|
|
1684
|
+
await step('zoom: the processing status stays readable', async () => {
|
|
1685
|
+
await expect(canvas.getByRole('status')).toHaveAccessibleName(
|
|
1686
|
+
'Brief.docx, DOCX, Processing…',
|
|
1687
|
+
);
|
|
1688
|
+
});
|
|
1689
|
+
|
|
1690
|
+
await step('zoom: the group chevron remains operable', async () => {
|
|
1691
|
+
const chevron = canvas.getByRole('button', {
|
|
1692
|
+
name: 'Show attached documents',
|
|
1693
|
+
});
|
|
1694
|
+
await userEvent.click(chevron);
|
|
1695
|
+
await expect(chevron).toHaveAttribute('aria-expanded', 'true');
|
|
1696
|
+
});
|
|
1057
1697
|
},
|
|
1058
1698
|
};
|
|
1059
1699
|
|
|
@@ -1081,15 +1721,24 @@ export const MobileBreakpoint: Story = {
|
|
|
1081
1721
|
render: () => ({
|
|
1082
1722
|
components: { UiFileItem },
|
|
1083
1723
|
setup() {
|
|
1084
|
-
return { onRemove };
|
|
1724
|
+
return { onRemove, items: multiItems };
|
|
1085
1725
|
},
|
|
1086
1726
|
template: `
|
|
1087
|
-
<
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1727
|
+
<div class="flex flex-col gap-3">
|
|
1728
|
+
<UiFileItem
|
|
1729
|
+
filename="A rather long quarterly report filename.pdf"
|
|
1730
|
+
type-label="PDF"
|
|
1731
|
+
size-label="12 MB"
|
|
1732
|
+
@remove="onRemove"
|
|
1733
|
+
/>
|
|
1734
|
+
<UiFileItem
|
|
1735
|
+
filename="Attached documents"
|
|
1736
|
+
type-label="4 files"
|
|
1737
|
+
expand-label="Show attached documents"
|
|
1738
|
+
:items="items"
|
|
1739
|
+
:removable="false"
|
|
1740
|
+
/>
|
|
1741
|
+
</div>
|
|
1093
1742
|
`,
|
|
1094
1743
|
}),
|
|
1095
1744
|
play: async ({ canvasElement, step }) => {
|
|
@@ -1133,6 +1782,143 @@ export const MobileBreakpoint: Story = {
|
|
|
1133
1782
|
await expect(onRemove).toHaveBeenCalledTimes(1);
|
|
1134
1783
|
},
|
|
1135
1784
|
);
|
|
1785
|
+
|
|
1786
|
+
await step(
|
|
1787
|
+
'mobile: the group chevron meets the minimum touch-target size (WCAG 2.5.8)',
|
|
1788
|
+
async () => {
|
|
1789
|
+
const chevron = canvas.getByRole('button', {
|
|
1790
|
+
name: 'Show attached documents',
|
|
1791
|
+
});
|
|
1792
|
+
const { width, height, right } = chevron.getBoundingClientRect();
|
|
1793
|
+
await expect(width).toBeGreaterThanOrEqual(24);
|
|
1794
|
+
await expect(height).toBeGreaterThanOrEqual(24);
|
|
1795
|
+
await expect(right).toBeLessThanOrEqual(window.innerWidth);
|
|
1796
|
+
},
|
|
1797
|
+
);
|
|
1798
|
+
},
|
|
1799
|
+
};
|
|
1800
|
+
|
|
1801
|
+
/**
|
|
1802
|
+
* The multi row's chevron opens a popover list. Each file keeps the icon for
|
|
1803
|
+
* its type, keyboard opens and closes the list, and removing a row names that
|
|
1804
|
+
* file. Hidden test-only story.
|
|
1805
|
+
*/
|
|
1806
|
+
export const MultiDisclosure: Story = {
|
|
1807
|
+
name: 'test - Multi Disclosure',
|
|
1808
|
+
tags: ['!dev', '!autodocs'],
|
|
1809
|
+
parameters: {
|
|
1810
|
+
chromatic: { disableSnapshot: true },
|
|
1811
|
+
controls: { disable: true },
|
|
1812
|
+
docs: {
|
|
1813
|
+
description: {
|
|
1814
|
+
story:
|
|
1815
|
+
'Open the chevron to list the grouped files, then remove one from the popover.',
|
|
1816
|
+
},
|
|
1817
|
+
},
|
|
1818
|
+
},
|
|
1819
|
+
render: () => ({
|
|
1820
|
+
components: { UiFileItem },
|
|
1821
|
+
setup() {
|
|
1822
|
+
return { items: multiItems, onRemove, onRemoveItem };
|
|
1823
|
+
},
|
|
1824
|
+
template: `
|
|
1825
|
+
<UiFileItem
|
|
1826
|
+
filename="Attached documents"
|
|
1827
|
+
type-label="4 files"
|
|
1828
|
+
size-label="42 MB"
|
|
1829
|
+
expand-label="Show attached documents"
|
|
1830
|
+
list-label="Attached files"
|
|
1831
|
+
:items="items"
|
|
1832
|
+
@remove="onRemove"
|
|
1833
|
+
@remove-item="onRemoveItem"
|
|
1834
|
+
/>
|
|
1835
|
+
`,
|
|
1836
|
+
}),
|
|
1837
|
+
play: async ({ canvasElement, step }) => {
|
|
1838
|
+
// Scenario (UiFileItem): a keyboard user expands a group of mixed file
|
|
1839
|
+
// types, hears each file, and removes one without collapsing the summary.
|
|
1840
|
+
onRemoveItem.mockClear();
|
|
1841
|
+
const canvas = within(canvasElement);
|
|
1842
|
+
const body = within(document.body);
|
|
1843
|
+
const chevron = canvas.getByRole('button', {
|
|
1844
|
+
name: 'Show attached documents',
|
|
1845
|
+
});
|
|
1846
|
+
|
|
1847
|
+
await step(
|
|
1848
|
+
'keyboard: the chevron follows the remove control and opens with Enter (WCAG 2.1.1)',
|
|
1849
|
+
async () => {
|
|
1850
|
+
await userEvent.tab();
|
|
1851
|
+
await userEvent.tab();
|
|
1852
|
+
await expect(chevron).toHaveFocus();
|
|
1853
|
+
await userEvent.keyboard('{Enter}');
|
|
1854
|
+
await expect(chevron).toHaveAttribute('aria-expanded', 'true');
|
|
1855
|
+
},
|
|
1856
|
+
);
|
|
1857
|
+
|
|
1858
|
+
await step(
|
|
1859
|
+
'interaction: the popover lists each file with the icon for its type',
|
|
1860
|
+
async () => {
|
|
1861
|
+
const list = await body.findByRole('list', { name: 'Attached files' });
|
|
1862
|
+
// The panel fades and zooms in, so it is in the DOM a frame before it
|
|
1863
|
+
// is visible.
|
|
1864
|
+
await waitFor(async () => {
|
|
1865
|
+
await expect(list).toBeVisible();
|
|
1866
|
+
});
|
|
1867
|
+
const tones = Array.from(
|
|
1868
|
+
list.querySelectorAll('[data-slot="file-type"]'),
|
|
1869
|
+
).map((badge) => badge.getAttribute('data-tone'));
|
|
1870
|
+
await expect(tones).toEqual([
|
|
1871
|
+
'accent-pink',
|
|
1872
|
+
'accent-soft',
|
|
1873
|
+
'accent-yellow',
|
|
1874
|
+
'accent-orange',
|
|
1875
|
+
]);
|
|
1876
|
+
for (const label of ['PDF', 'MD', 'CSV', 'MP4']) {
|
|
1877
|
+
await waitFor(async () => {
|
|
1878
|
+
await expect(within(list).getByText(label)).toBeVisible();
|
|
1879
|
+
});
|
|
1880
|
+
}
|
|
1881
|
+
},
|
|
1882
|
+
);
|
|
1883
|
+
|
|
1884
|
+
await step(
|
|
1885
|
+
'screen-reader: each file in the list exposes its full filename (WCAG 4.1.2)',
|
|
1886
|
+
async () => {
|
|
1887
|
+
const list = body.getByRole('list', { name: 'Attached files' });
|
|
1888
|
+
await expect(
|
|
1889
|
+
within(list).getByLabelText('26_Business_Plan_2026.pdf'),
|
|
1890
|
+
).toHaveTextContent('26_Business_Plan_2026');
|
|
1891
|
+
await expect(
|
|
1892
|
+
within(list).getByRole('button', {
|
|
1893
|
+
name: 'Remove Last_weeks_memory.md',
|
|
1894
|
+
}),
|
|
1895
|
+
).toHaveAccessibleName('Remove Last_weeks_memory.md');
|
|
1896
|
+
},
|
|
1897
|
+
);
|
|
1898
|
+
|
|
1899
|
+
await step(
|
|
1900
|
+
'interaction: removing a file inside the list emits that file',
|
|
1901
|
+
async () => {
|
|
1902
|
+
await userEvent.click(
|
|
1903
|
+
body.getByRole('button', { name: 'Remove Tabular_analysis.csv' }),
|
|
1904
|
+
);
|
|
1905
|
+
await expect(onRemoveItem).toHaveBeenCalledTimes(1);
|
|
1906
|
+
await expect(onRemoveItem.mock.calls[0]?.[0]).toMatchObject({
|
|
1907
|
+
id: 'sheet',
|
|
1908
|
+
filename: 'Tabular_analysis.csv',
|
|
1909
|
+
});
|
|
1910
|
+
},
|
|
1911
|
+
);
|
|
1912
|
+
|
|
1913
|
+
await step('keyboard: Escape closes the file list', async () => {
|
|
1914
|
+
await userEvent.keyboard('{Escape}');
|
|
1915
|
+
await expect(chevron).toHaveAttribute('aria-expanded', 'false');
|
|
1916
|
+
await waitFor(async () => {
|
|
1917
|
+
await expect(
|
|
1918
|
+
body.queryByRole('list', { name: 'Attached files' }),
|
|
1919
|
+
).not.toBeInTheDocument();
|
|
1920
|
+
});
|
|
1921
|
+
});
|
|
1136
1922
|
},
|
|
1137
1923
|
};
|
|
1138
1924
|
|