@12-apps/ui 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -9
- package/src/button/index.ts +1 -0
- package/src/social-login-button/index.ts +1 -0
- package/src/{social-login-button.tsx → social-login-button/social-login-button.tsx} +5 -5
- package/src/user-avatar/index.ts +1 -0
- package/src/{user-avatar.tsx → user-avatar/user-avatar.tsx} +4 -4
- package/eslint.config.js +0 -89
- package/src/__tests__/data-grid.test.tsx +0 -125
- package/src/__tests__/package-wiring.test.ts +0 -41
- package/src/__tests__/setup.ts +0 -1
- package/src/__tests__/social-login-button.test.tsx +0 -186
- package/src/__tests__/user-avatar.test.tsx +0 -195
- package/src/__tests__/viewport.test.ts +0 -50
- package/src/components/command/__tests__/command.test.tsx +0 -112
- package/src/components/data-display/Alert/Alert.stories.tsx +0 -559
- package/src/components/data-display/Alert/Alert.test.stories.tsx +0 -707
- package/src/components/data-display/AlertDialog/AlertDialog.stories.tsx +0 -362
- package/src/components/data-display/AlertDialog/AlertDialog.test.stories.tsx +0 -763
- package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.stories.tsx +0 -230
- package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.test.stories.tsx +0 -270
- package/src/components/data-display/Avatar/Avatar.stories.tsx +0 -721
- package/src/components/data-display/Avatar/Avatar.test.stories.tsx +0 -822
- package/src/components/data-display/Badge/Badge.stories.tsx +0 -1134
- package/src/components/data-display/Badge/Badge.test.stories.tsx +0 -1194
- package/src/components/data-display/Banner/Banner.stories.tsx +0 -528
- package/src/components/data-display/Banner/Banner.test.stories.tsx +0 -511
- package/src/components/data-display/Carousel/Carousel.stories.tsx +0 -607
- package/src/components/data-display/Carousel/Carousel.test.stories.tsx +0 -701
- package/src/components/data-display/Chart/Chart.stories.tsx +0 -568
- package/src/components/data-display/Chart/Chart.test.stories.tsx +0 -174
- package/src/components/data-display/Chart/SpecChart.stories.tsx +0 -150
- package/src/components/data-display/Chart/SpecChart.test.stories.tsx +0 -56
- package/src/components/data-display/Chart/__tests__/SpecChart.test.tsx +0 -60
- package/src/components/data-display/Chart/__tests__/chart-format.test.ts +0 -43
- package/src/components/data-display/Chart/__tests__/chart-spec.test.ts +0 -119
- package/src/components/data-display/Chip/Chip.stories.tsx +0 -252
- package/src/components/data-display/Chip/Chip.test.stories.tsx +0 -266
- package/src/components/data-display/DataGrid/DataGrid.stories.tsx +0 -515
- package/src/components/data-display/DataGrid/DataGrid.test.stories.tsx +0 -653
- package/src/components/data-display/DataViews/__tests__/DataViewsGrid.test.tsx +0 -271
- package/src/components/data-display/DataViews/__tests__/DataViewsTableBase.test.tsx +0 -134
- package/src/components/data-display/DataViews/__tests__/SaveViewModal.test.tsx +0 -83
- package/src/components/data-display/DataViews/__tests__/data-views-filter.test.ts +0 -115
- package/src/components/data-display/DataViews/__tests__/data-views-preview.test.ts +0 -53
- package/src/components/data-display/DataViews/__tests__/range-pill.test.tsx +0 -114
- package/src/components/data-display/DataViews/base-card.stories.tsx +0 -136
- package/src/components/data-display/DescriptionItem/DescriptionItem.stories.tsx +0 -254
- package/src/components/data-display/EmptyState/EmptyState.stories.tsx +0 -282
- package/src/components/data-display/EmptyState/EmptyState.test.stories.tsx +0 -441
- package/src/components/data-display/ErrorState/ErrorState.stories.tsx +0 -110
- package/src/components/data-display/ErrorState/ErrorState.test.stories.tsx +0 -133
- package/src/components/data-display/HoverCard/HoverCard.stories.tsx +0 -650
- package/src/components/data-display/HoverCard/HoverCard.test.stories.tsx +0 -929
- package/src/components/data-display/InteractiveTooltip/InteractiveTooltip.stories.tsx +0 -411
- package/src/components/data-display/LazyImage/LazyImage.stories.tsx +0 -387
- package/src/components/data-display/Lightbox/Lightbox.stories.tsx +0 -315
- package/src/components/data-display/Lightbox/Lightbox.test.stories.tsx +0 -598
- package/src/components/data-display/LoadingState/LoadingState.stories.tsx +0 -124
- package/src/components/data-display/LoadingState/LoadingState.test.stories.tsx +0 -99
- package/src/components/data-display/MapPreview/MapPreview.stories.tsx +0 -458
- package/src/components/data-display/MapPreview/MapPreview.test.stories.tsx +0 -394
- package/src/components/data-display/Popover/Popover.stories.tsx +0 -295
- package/src/components/data-display/Popover/Popover.test.stories.tsx +0 -1162
- package/src/components/data-display/Progress/Progress.stories.tsx +0 -481
- package/src/components/data-display/Progress/Progress.test.stories.tsx +0 -2070
- package/src/components/data-display/SectionOnboarding/SectionOnboarding.stories.tsx +0 -160
- package/src/components/data-display/SectionOnboarding/SectionOnboarding.test.stories.tsx +0 -190
- package/src/components/data-display/Sheet/Sheet.stories.tsx +0 -883
- package/src/components/data-display/Sheet/Sheet.test.stories.tsx +0 -1105
- package/src/components/data-display/StatCard/StatCard.stories.tsx +0 -167
- package/src/components/data-display/StatCard/StatCard.test.stories.tsx +0 -240
- package/src/components/data-display/Stepper/Stepper.stories.tsx +0 -540
- package/src/components/data-display/Stepper/Stepper.test.stories.tsx +0 -600
- package/src/components/data-display/Table/Table.stories.tsx +0 -803
- package/src/components/data-display/Table/Table.test.stories.tsx +0 -369
- package/src/components/data-display/Timeline/Timeline.stories.tsx +0 -442
- package/src/components/data-display/Timeline/Timeline.test.stories.tsx +0 -930
- package/src/components/data-display/TimingDiagram/TimingDiagram.stories.tsx +0 -475
- package/src/components/data-display/TimingDiagram/TimingDiagram.test.stories.tsx +0 -734
- package/src/components/data-display/Tooltip/Tooltip.stories.tsx +0 -468
- package/src/components/data-display/Tooltip/Tooltip.test.stories.tsx +0 -1154
- package/src/components/feedback/ConfirmAction/ConfirmAction.stories.tsx +0 -146
- package/src/components/feedback/ConfirmAction/ConfirmAction.test.stories.tsx +0 -114
- package/src/components/feedback/ConfirmAction/__tests__/confirm-action.test.tsx +0 -288
- package/src/components/feedback/Dialog/Dialog.stories.tsx +0 -833
- package/src/components/feedback/Dialog/Dialog.test.stories.tsx +0 -964
- package/src/components/feedback/Dialog/__tests__/dialog-content-spacing.test.tsx +0 -66
- package/src/components/feedback/Modal/Modal.stories.tsx +0 -765
- package/src/components/feedback/Modal/Modal.test.stories.tsx +0 -251
- package/src/components/feedback/Sonner/Sonner.stories.tsx +0 -698
- package/src/components/feedback/Sonner/Sonner.test.stories.tsx +0 -896
- package/src/components/feedback/StackedModal/StackedModal.stories.tsx +0 -1783
- package/src/components/feedback/StackedModal/StackedModal.test.stories.tsx +0 -973
- package/src/components/feedback/StackedModal/__tests__/stacked-modal-viewport.test.tsx +0 -104
- package/src/components/feedback/Toast/Toast.stories.tsx +0 -548
- package/src/components/feedback/Toast/Toast.test.stories.tsx +0 -834
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.stories.tsx +0 -691
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.test.stories.tsx +0 -634
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.stories.tsx +0 -665
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.test.stories.tsx +0 -727
- package/src/components/form/Autocomplete/Autocomplete.stories.tsx +0 -715
- package/src/components/form/Autocomplete/Autocomplete.test.stories.tsx +0 -825
- package/src/components/form/Button/Button.stories.tsx +0 -365
- package/src/components/form/Button/Button.test.stories.tsx +0 -607
- package/src/components/form/Calendar/Calendar.stories.tsx +0 -349
- package/src/components/form/Calendar/Calendar.test.stories.tsx +0 -464
- package/src/components/form/CepField/CepField.stories.tsx +0 -138
- package/src/components/form/CepField/CepField.test.stories.tsx +0 -281
- package/src/components/form/Checkbox/Checkbox.stories.tsx +0 -265
- package/src/components/form/Checkbox/Checkbox.test.stories.tsx +0 -181
- package/src/components/form/CodeEditor/CodeEditor.stories.tsx +0 -871
- package/src/components/form/CodeEditor/CodeEditor.test.stories.tsx +0 -574
- package/src/components/form/Command/Command.stories.tsx +0 -580
- package/src/components/form/Command/Command.test.stories.tsx +0 -215
- package/src/components/form/CreatableSelect/CreatableSelect.stories.tsx +0 -112
- package/src/components/form/CreatableSelect/CreatableSelect.test.stories.tsx +0 -134
- package/src/components/form/Form/Form.stories.tsx +0 -687
- package/src/components/form/Form/Form.test.stories.tsx +0 -601
- package/src/components/form/Input/Input.stories.tsx +0 -260
- package/src/components/form/Input/Input.test.stories.tsx +0 -1191
- package/src/components/form/InputOTP/InputOTP.stories.tsx +0 -774
- package/src/components/form/InputOTP/InputOTP.test.stories.tsx +0 -588
- package/src/components/form/Label/Label.stories.tsx +0 -473
- package/src/components/form/Label/Label.test.stories.tsx +0 -915
- package/src/components/form/Menubar/Menubar.stories.tsx +0 -472
- package/src/components/form/Menubar/Menubar.test.stories.tsx +0 -584
- package/src/components/form/PasswordStrength/PasswordStrength.stories.tsx +0 -562
- package/src/components/form/PasswordStrength/PasswordStrength.test.stories.tsx +0 -327
- package/src/components/form/PhoneInput/PhoneInput.stories.tsx +0 -495
- package/src/components/form/PhoneInput/PhoneInput.test.stories.tsx +0 -666
- package/src/components/form/RadioGroup/RadioGroup.stories.tsx +0 -518
- package/src/components/form/RadioGroup/RadioGroup.test.stories.tsx +0 -685
- package/src/components/form/RichTextEditor/RichTextEditor.stories.tsx +0 -261
- package/src/components/form/RichTextEditor/RichTextEditor.test.stories.tsx +0 -491
- package/src/components/form/SearchPalette/SearchPalette.stories.tsx +0 -135
- package/src/components/form/Select/Select.stories.tsx +0 -364
- package/src/components/form/Select/Select.test.stories.tsx +0 -985
- package/src/components/form/Slider/Slider.stories.tsx +0 -418
- package/src/components/form/Slider/Slider.test.stories.tsx +0 -1042
- package/src/components/form/Switch/Switch.stories.tsx +0 -697
- package/src/components/form/Switch/Switch.test.stories.tsx +0 -597
- package/src/components/form/Textarea/Textarea.stories.tsx +0 -473
- package/src/components/form/Textarea/Textarea.test.stories.tsx +0 -702
- package/src/components/form/Toggle/Toggle.stories.tsx +0 -638
- package/src/components/form/Toggle/Toggle.test.stories.tsx +0 -1159
- package/src/components/form/ToggleGroup/ToggleGroup.stories.tsx +0 -617
- package/src/components/form/ToggleGroup/ToggleGroup.test.stories.tsx +0 -915
- package/src/components/form/UploadButton/UploadButton.stories.tsx +0 -367
- package/src/components/form/UploadButton/UploadButton.test.stories.tsx +0 -573
- package/src/components/form/total-form/total-form.test.tsx +0 -214
- package/src/components/layout/Accordion/Accordion.stories.tsx +0 -694
- package/src/components/layout/Accordion/Accordion.test.stories.tsx +0 -1344
- package/src/components/layout/Card/Card.stories.tsx +0 -591
- package/src/components/layout/Card/Card.test.stories.tsx +0 -1134
- package/src/components/layout/CardGrid/__tests__/CardGrid.test.tsx +0 -92
- package/src/components/layout/Collapsible/Collapsible.stories.tsx +0 -180
- package/src/components/layout/Collapsible/Collapsible.test.stories.tsx +0 -308
- package/src/components/layout/Container/Container.stories.tsx +0 -557
- package/src/components/layout/Container/Container.test.stories.tsx +0 -745
- package/src/components/layout/ContentToolbar/ContentToolbar.stories.tsx +0 -129
- package/src/components/layout/ContentToolbar/ContentToolbar.test.stories.tsx +0 -251
- package/src/components/layout/ContentToolbar/__tests__/ColumnsMenu.test.tsx +0 -39
- package/src/components/layout/ContentToolbar/__tests__/MultiSelectDropdown.test.tsx +0 -131
- package/src/components/layout/ContentToolbar/__tests__/SavedViewsMenu.test.tsx +0 -99
- package/src/components/layout/Dashboard/Dashboard.stories.tsx +0 -104
- package/src/components/layout/Dashboard/Dashboard.test.stories.tsx +0 -190
- package/src/components/layout/Drawer/Drawer.stories.tsx +0 -658
- package/src/components/layout/Drawer/Drawer.test.stories.tsx +0 -1343
- package/src/components/layout/Resizable/Resizable.stories.tsx +0 -1039
- package/src/components/layout/Resizable/Resizable.test.stories.tsx +0 -754
- package/src/components/layout/ScrollArea/ScrollArea.stories.tsx +0 -651
- package/src/components/layout/ScrollArea/ScrollArea.test.stories.tsx +0 -619
- package/src/components/layout/Separator/Separator.stories.tsx +0 -563
- package/src/components/layout/Separator/Separator.test.stories.tsx +0 -518
- package/src/components/layout/SettingsLayout/SettingsLayout.stories.tsx +0 -192
- package/src/components/layout/SettingsLayout/SettingsLayout.test.stories.tsx +0 -175
- package/src/components/layout/Sidebar/Sidebar.stories.tsx +0 -609
- package/src/components/layout/Sidebar/Sidebar.test.stories.tsx +0 -1324
- package/src/components/layout/Skeleton/Skeleton.stories.tsx +0 -689
- package/src/components/layout/Skeleton/Skeleton.test.stories.tsx +0 -521
- package/src/components/layout/Spacer/Spacer.stories.tsx +0 -502
- package/src/components/layout/Spacer/Spacer.test.stories.tsx +0 -474
- package/src/components/layout/TableFilter/TableFilter.stories.tsx +0 -82
- package/src/components/layout/TableFilter/TableFilter.test.stories.tsx +0 -87
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.stories.tsx +0 -638
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.test.stories.tsx +0 -1008
- package/src/components/navigation/CommandPalette/CommandPalette.stories.tsx +0 -386
- package/src/components/navigation/CommandPalette/CommandPalette.test.stories.tsx +0 -435
- package/src/components/navigation/ContextMenu/ContextMenu.stories.tsx +0 -614
- package/src/components/navigation/ContextMenu/ContextMenu.test.stories.tsx +0 -845
- package/src/components/navigation/DropdownMenu/DropdownMenu.stories.tsx +0 -578
- package/src/components/navigation/DropdownMenu/DropdownMenu.test.stories.tsx +0 -660
- package/src/components/navigation/NavigationMenu/stories/NavigationMenu.stories.tsx +0 -516
- package/src/components/navigation/NavigationMenu/stories/NavigationMenu.test.stories.tsx +0 -935
- package/src/components/navigation/NavigationMenu/stories/NavigationMenuHorizontal.stories.tsx +0 -501
- package/src/components/navigation/NavigationMenu/stories/NavigationMenuVertical.stories.tsx +0 -453
- package/src/components/navigation/Pagination/Pagination.stories.tsx +0 -602
- package/src/components/navigation/Pagination/Pagination.test.stories.tsx +0 -520
- package/src/components/navigation/Tabs/Tabs.stories.tsx +0 -1004
- package/src/components/navigation/Tabs/Tabs.test.stories.tsx +0 -1225
- package/src/components/typography/Blockquote/Blockquote.stories.tsx +0 -359
- package/src/components/typography/Blockquote/Blockquote.test.stories.tsx +0 -432
- package/src/components/typography/Code/Code.stories.tsx +0 -686
- package/src/components/typography/Code/Code.test.stories.tsx +0 -703
- package/src/components/typography/Heading/Heading.stories.tsx +0 -451
- package/src/components/typography/Heading/Heading.test.stories.tsx +0 -830
- package/src/components/typography/Paragraph/Paragraph.stories.tsx +0 -280
- package/src/components/typography/Paragraph/Paragraph.test.stories.tsx +0 -231
- package/src/components/typography/Text/Text.stories.tsx +0 -359
- package/src/components/typography/Text/Text.test.stories.tsx +0 -759
- package/src/components/utility/AnimatedIcon/AnimatedIcon.stories.tsx +0 -945
- package/src/components/utility/AnimatedIcon/AnimatedIcon.test.stories.tsx +0 -603
- package/src/components/utility/AspectRatio/AspectRatio.stories.tsx +0 -414
- package/src/components/utility/AspectRatio/AspectRatio.test.stories.tsx +0 -859
- package/src/components/utility/InfiniteScroll/InfiniteScroll.stories.tsx +0 -620
- package/src/components/utility/InfiniteScroll/InfiniteScroll.test.stories.tsx +0 -361
- package/src/components/utility/InstallPrompt/InstallPrompt.stories.tsx +0 -118
- package/src/components/utility/InstallPrompt/InstallPrompt.test.stories.tsx +0 -83
- package/src/components/utility/InstallPrompt/__tests__/InstallPrompt.ios.test.tsx +0 -65
- package/src/components/utility/InstallPrompt/__tests__/usePwaInstall.test.tsx +0 -271
- package/src/components/utility/Portal/Portal.stories.tsx +0 -340
- package/src/components/utility/Portal/Portal.test.stories.tsx +0 -2086
- package/src/components/utility/Transition/Transition.stories.tsx +0 -493
- package/src/components/utility/Transition/Transition.test.stories.tsx +0 -854
- package/src/components/utility/VirtualList/VirtualList.stories.tsx +0 -1073
- package/src/components/utility/VirtualList/VirtualList.test.stories.tsx +0 -1085
- package/src/components/utility/WorkflowStep/WorkflowStep.stories.tsx +0 -431
- package/src/components/utility/WorkflowStep/WorkflowStep.test.stories.tsx +0 -364
- /package/src/{button.tsx → button/button.tsx} +0 -0
|
@@ -1,511 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
|
|
3
|
-
|
|
4
|
-
import { Banner } from './Banner';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Banner> = {
|
|
7
|
-
title: 'DataDisplay/Banner/Tests',
|
|
8
|
-
component: Banner,
|
|
9
|
-
parameters: {
|
|
10
|
-
layout: 'fullscreen',
|
|
11
|
-
chromatic: { disableSnapshot: false },
|
|
12
|
-
},
|
|
13
|
-
tags: ['autodocs', 'test', 'component:Banner'],
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default meta;
|
|
17
|
-
export type Story = StoryObj<typeof meta>;
|
|
18
|
-
|
|
19
|
-
// Basic Interaction Tests
|
|
20
|
-
export const BasicInteraction: Story = {
|
|
21
|
-
args: {
|
|
22
|
-
variant: 'info',
|
|
23
|
-
title: 'Test Banner',
|
|
24
|
-
description: 'Testing basic interaction functionality',
|
|
25
|
-
dismissible: true,
|
|
26
|
-
onDismiss: fn(),
|
|
27
|
-
},
|
|
28
|
-
play: async ({ canvasElement, args }) => {
|
|
29
|
-
const canvas = within(canvasElement);
|
|
30
|
-
|
|
31
|
-
// Verify banner is visible
|
|
32
|
-
await waitFor(() => {
|
|
33
|
-
const banner = canvas.getByRole('status');
|
|
34
|
-
expect(banner).toBeInTheDocument();
|
|
35
|
-
expect(banner).toBeVisible();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Verify content
|
|
39
|
-
expect(canvas.getByText('Test Banner')).toBeInTheDocument();
|
|
40
|
-
expect(canvas.getByText('Testing basic interaction functionality')).toBeInTheDocument();
|
|
41
|
-
|
|
42
|
-
// Verify dismiss button functionality
|
|
43
|
-
const dismissButton = canvas.getByRole('button', { name: /dismiss banner/i });
|
|
44
|
-
expect(dismissButton).toBeInTheDocument();
|
|
45
|
-
|
|
46
|
-
// Test dismiss functionality
|
|
47
|
-
await userEvent.click(dismissButton);
|
|
48
|
-
|
|
49
|
-
// Verify onDismiss callback was called
|
|
50
|
-
await waitFor(() => {
|
|
51
|
-
expect(args.onDismiss).toHaveBeenCalledTimes(1);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Verify banner is removed from DOM
|
|
55
|
-
await waitFor(() => {
|
|
56
|
-
expect(canvas.queryByRole('status')).not.toBeInTheDocument();
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// State Change Tests
|
|
62
|
-
export const StateChange: Story = {
|
|
63
|
-
args: {
|
|
64
|
-
variant: 'warning',
|
|
65
|
-
title: 'State Change Test',
|
|
66
|
-
description: 'Testing state changes and updates',
|
|
67
|
-
actions: [
|
|
68
|
-
{ label: 'Primary Action', onClick: fn(), variant: 'primary' },
|
|
69
|
-
{ label: 'Secondary Action', onClick: fn(), variant: 'secondary' },
|
|
70
|
-
],
|
|
71
|
-
dismissible: true,
|
|
72
|
-
},
|
|
73
|
-
play: async ({ canvasElement, args }) => {
|
|
74
|
-
const canvas = within(canvasElement);
|
|
75
|
-
|
|
76
|
-
// Verify initial state
|
|
77
|
-
await waitFor(() => {
|
|
78
|
-
const banner = canvas.getByRole('alert');
|
|
79
|
-
expect(banner).toBeInTheDocument();
|
|
80
|
-
expect(banner).toBeVisible();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// Test action button clicks
|
|
84
|
-
const primaryButton = canvas.getByRole('button', { name: 'Primary Action' });
|
|
85
|
-
const secondaryButton = canvas.getByRole('button', { name: 'Secondary Action' });
|
|
86
|
-
|
|
87
|
-
await userEvent.click(primaryButton);
|
|
88
|
-
expect(args.actions![0].onClick).toHaveBeenCalledTimes(1);
|
|
89
|
-
|
|
90
|
-
await userEvent.click(secondaryButton);
|
|
91
|
-
expect(args.actions![1].onClick).toHaveBeenCalledTimes(1);
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
// Keyboard Navigation Tests
|
|
96
|
-
export const KeyboardNavigation: Story = {
|
|
97
|
-
args: {
|
|
98
|
-
variant: 'success',
|
|
99
|
-
title: 'Keyboard Navigation Test',
|
|
100
|
-
description: 'Testing keyboard accessibility',
|
|
101
|
-
actions: [
|
|
102
|
-
{ label: 'Action 1', onClick: fn(), variant: 'primary' },
|
|
103
|
-
{ label: 'Action 2', onClick: fn(), variant: 'secondary' },
|
|
104
|
-
],
|
|
105
|
-
dismissible: true,
|
|
106
|
-
onDismiss: fn(),
|
|
107
|
-
},
|
|
108
|
-
play: async ({ canvasElement, args }) => {
|
|
109
|
-
const canvas = within(canvasElement);
|
|
110
|
-
|
|
111
|
-
// Wait for banner to be visible
|
|
112
|
-
await waitFor(() => {
|
|
113
|
-
const banner = canvas.getByRole('status');
|
|
114
|
-
expect(banner).toBeVisible();
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
// Focus the banner
|
|
118
|
-
const banner = canvas.getByRole('status');
|
|
119
|
-
await userEvent.click(banner);
|
|
120
|
-
await waitFor(() => expect(banner).toHaveFocus());
|
|
121
|
-
|
|
122
|
-
// Tab to first action button
|
|
123
|
-
await userEvent.tab();
|
|
124
|
-
const action1 = canvas.getByRole('button', { name: 'Action 1' });
|
|
125
|
-
await waitFor(() => expect(action1).toHaveFocus());
|
|
126
|
-
|
|
127
|
-
// Tab to second action button
|
|
128
|
-
await userEvent.tab();
|
|
129
|
-
const action2 = canvas.getByRole('button', { name: 'Action 2' });
|
|
130
|
-
await waitFor(() => expect(action2).toHaveFocus());
|
|
131
|
-
|
|
132
|
-
// Tab to dismiss button
|
|
133
|
-
await userEvent.tab();
|
|
134
|
-
const dismissButton = canvas.getByRole('button', { name: /dismiss banner/i });
|
|
135
|
-
await waitFor(() => expect(dismissButton).toHaveFocus());
|
|
136
|
-
|
|
137
|
-
// Test Enter key on action button. Focused directly rather than clicked:
|
|
138
|
-
// a click would fire the very handler the next line counts.
|
|
139
|
-
// eslint-disable-next-line test-flakiness/no-focus-check -- clicking would fire the handler under assertion
|
|
140
|
-
action1.focus();
|
|
141
|
-
await userEvent.keyboard('{Enter}');
|
|
142
|
-
expect(args.actions![0].onClick).toHaveBeenCalledTimes(1);
|
|
143
|
-
|
|
144
|
-
// Test Space key on dismiss button. Focused rather than clicked for the
|
|
145
|
-
// same reason: a click is itself a dismiss.
|
|
146
|
-
// eslint-disable-next-line test-flakiness/no-focus-check, test-flakiness/await-async-events -- clicking would perform the action under test
|
|
147
|
-
dismissButton.focus();
|
|
148
|
-
await userEvent.keyboard(' ');
|
|
149
|
-
|
|
150
|
-
// Verify onDismiss was called
|
|
151
|
-
await waitFor(() => {
|
|
152
|
-
expect(args.onDismiss).toHaveBeenCalledTimes(1);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// Verify banner is removed
|
|
156
|
-
await waitFor(() => {
|
|
157
|
-
expect(canvas.queryByRole('status')).not.toBeInTheDocument();
|
|
158
|
-
});
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
// Screen Reader Tests
|
|
163
|
-
export const ScreenReader: Story = {
|
|
164
|
-
args: {
|
|
165
|
-
variant: 'critical',
|
|
166
|
-
title: 'Screen Reader Test',
|
|
167
|
-
description: 'Testing screen reader accessibility',
|
|
168
|
-
dismissible: true,
|
|
169
|
-
},
|
|
170
|
-
play: async ({ canvasElement }) => {
|
|
171
|
-
const canvas = within(canvasElement);
|
|
172
|
-
|
|
173
|
-
// Verify ARIA attributes for critical variant
|
|
174
|
-
const banner = canvas.getByRole('alert');
|
|
175
|
-
expect(banner).toHaveAttribute('aria-live', 'assertive');
|
|
176
|
-
expect(banner).toHaveAttribute('aria-atomic', 'true');
|
|
177
|
-
|
|
178
|
-
// Verify dismiss button accessibility
|
|
179
|
-
const dismissButton = canvas.getByRole('button', { name: /dismiss banner/i });
|
|
180
|
-
expect(dismissButton).toHaveAttribute('aria-label', 'Dismiss banner');
|
|
181
|
-
|
|
182
|
-
// Verify content structure for screen readers
|
|
183
|
-
expect(canvas.getByText('Screen Reader Test')).toBeInTheDocument();
|
|
184
|
-
expect(canvas.getByText('Testing screen reader accessibility')).toBeInTheDocument();
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// Focus Management Tests
|
|
189
|
-
export const FocusManagement: Story = {
|
|
190
|
-
args: {
|
|
191
|
-
variant: 'info',
|
|
192
|
-
title: 'Focus Management Test',
|
|
193
|
-
description: 'Testing focus management and keyboard navigation',
|
|
194
|
-
actions: [{ label: 'Focus Test', onClick: fn(), variant: 'primary' }],
|
|
195
|
-
dismissible: true,
|
|
196
|
-
},
|
|
197
|
-
play: async ({ canvasElement }) => {
|
|
198
|
-
const canvas = within(canvasElement);
|
|
199
|
-
|
|
200
|
-
// Test initial focus state
|
|
201
|
-
const banner = canvas.getByRole('status');
|
|
202
|
-
expect(banner).toHaveAttribute('tabIndex', '0');
|
|
203
|
-
|
|
204
|
-
// Test focus visibility
|
|
205
|
-
await userEvent.click(banner);
|
|
206
|
-
await waitFor(() => expect(banner).toHaveFocus());
|
|
207
|
-
|
|
208
|
-
// Test that focus moves properly through interactive elements
|
|
209
|
-
await userEvent.tab();
|
|
210
|
-
const actionButton = canvas.getByRole('button', { name: 'Focus Test' });
|
|
211
|
-
await waitFor(() => expect(actionButton).toHaveFocus());
|
|
212
|
-
|
|
213
|
-
await userEvent.tab();
|
|
214
|
-
const dismissButton = canvas.getByRole('button', { name: /dismiss banner/i });
|
|
215
|
-
await waitFor(() => expect(dismissButton).toHaveFocus());
|
|
216
|
-
},
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
// Responsive Design Tests
|
|
220
|
-
export const ResponsiveDesign: Story = {
|
|
221
|
-
args: {
|
|
222
|
-
variant: 'warning',
|
|
223
|
-
title: 'Responsive Design Test',
|
|
224
|
-
description: 'Testing responsive layout behavior',
|
|
225
|
-
actions: [
|
|
226
|
-
{ label: 'Action 1', onClick: fn(), variant: 'primary' },
|
|
227
|
-
{ label: 'Action 2', onClick: fn(), variant: 'secondary' },
|
|
228
|
-
],
|
|
229
|
-
dismissible: true,
|
|
230
|
-
},
|
|
231
|
-
parameters: {
|
|
232
|
-
viewport: {
|
|
233
|
-
viewports: {
|
|
234
|
-
mobile: { name: 'Mobile', styles: { width: '375px', height: '667px' } },
|
|
235
|
-
tablet: { name: 'Tablet', styles: { width: '768px', height: '1024px' } },
|
|
236
|
-
desktop: { name: 'Desktop', styles: { width: '1024px', height: '768px' } },
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
play: async ({ canvasElement }) => {
|
|
241
|
-
const canvas = within(canvasElement);
|
|
242
|
-
|
|
243
|
-
// Wait for banner to be visible
|
|
244
|
-
await waitFor(() => {
|
|
245
|
-
const banner = canvas.getByRole('alert');
|
|
246
|
-
expect(banner).toBeInTheDocument();
|
|
247
|
-
expect(banner).toBeVisible();
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
// Verify all elements are present
|
|
251
|
-
expect(canvas.getByText('Responsive Design Test')).toBeInTheDocument();
|
|
252
|
-
expect(canvas.getByText('Testing responsive layout behavior')).toBeInTheDocument();
|
|
253
|
-
expect(canvas.getByRole('button', { name: 'Action 1' })).toBeInTheDocument();
|
|
254
|
-
expect(canvas.getByRole('button', { name: 'Action 2' })).toBeInTheDocument();
|
|
255
|
-
expect(canvas.getByRole('button', { name: /dismiss banner/i })).toBeInTheDocument();
|
|
256
|
-
|
|
257
|
-
// Verify layout adaptation (elements should be accessible regardless of viewport)
|
|
258
|
-
const banner = canvas.getByRole('alert');
|
|
259
|
-
const actionsContainer = banner.querySelector('.banner-actions');
|
|
260
|
-
expect(actionsContainer).toBeInTheDocument();
|
|
261
|
-
},
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
// Theme Variations Tests
|
|
265
|
-
export const ThemeVariations: Story = {
|
|
266
|
-
args: {
|
|
267
|
-
variant: 'success',
|
|
268
|
-
title: 'Theme Variations Test',
|
|
269
|
-
description: 'Testing different theme variations',
|
|
270
|
-
dismissible: true,
|
|
271
|
-
},
|
|
272
|
-
play: async ({ canvasElement }) => {
|
|
273
|
-
const canvas = within(canvasElement);
|
|
274
|
-
|
|
275
|
-
// Wait for banner to be visible
|
|
276
|
-
await waitFor(() => {
|
|
277
|
-
const banner = canvas.getByRole('status');
|
|
278
|
-
expect(banner).toBeInTheDocument();
|
|
279
|
-
expect(banner).toBeVisible();
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
// Verify banner has appropriate styling for success variant
|
|
283
|
-
const banner = canvas.getByRole('status');
|
|
284
|
-
|
|
285
|
-
// Verify icon is present (success variant should have CheckCircle icon)
|
|
286
|
-
const icon = banner.querySelector('.banner-icon');
|
|
287
|
-
expect(icon).toBeInTheDocument();
|
|
288
|
-
|
|
289
|
-
// Verify color scheme is applied
|
|
290
|
-
const computedStyle = window.getComputedStyle(banner);
|
|
291
|
-
expect(computedStyle.backgroundColor).toBeTruthy();
|
|
292
|
-
expect(computedStyle.borderColor).toBeTruthy();
|
|
293
|
-
},
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
// Visual States Tests
|
|
297
|
-
export const VisualStates: Story = {
|
|
298
|
-
render: () => (
|
|
299
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px', padding: '16px' }}>
|
|
300
|
-
<Banner variant="info" title="Info State" description="Information banner state" />
|
|
301
|
-
<Banner variant="success" title="Success State" description="Success banner state" />
|
|
302
|
-
<Banner variant="warning" title="Warning State" description="Warning banner state" />
|
|
303
|
-
<Banner variant="critical" title="Critical State" description="Critical error banner state" />
|
|
304
|
-
</div>
|
|
305
|
-
),
|
|
306
|
-
play: async ({ canvasElement }) => {
|
|
307
|
-
const canvas = within(canvasElement);
|
|
308
|
-
|
|
309
|
-
// Wait for all banners to be rendered
|
|
310
|
-
await waitFor(() => {
|
|
311
|
-
// We expect 2 status and 2 alert roles
|
|
312
|
-
const statusBanners = canvas.getAllByRole('status');
|
|
313
|
-
const alertBanners = canvas.getAllByRole('alert');
|
|
314
|
-
expect(statusBanners).toHaveLength(2); // info and success
|
|
315
|
-
expect(alertBanners).toHaveLength(2); // warning and critical
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
// Verify each variant has appropriate styling
|
|
319
|
-
const statusBanners = canvas.getAllByRole('status');
|
|
320
|
-
const alertBanners = canvas.getAllByRole('alert');
|
|
321
|
-
const allBanners = [...statusBanners, ...alertBanners];
|
|
322
|
-
|
|
323
|
-
allBanners.forEach((banner) => {
|
|
324
|
-
expect(banner).toBeInTheDocument();
|
|
325
|
-
const computedStyle = window.getComputedStyle(banner);
|
|
326
|
-
expect(computedStyle.backgroundColor).toBeTruthy();
|
|
327
|
-
expect(computedStyle.borderColor).toBeTruthy();
|
|
328
|
-
});
|
|
329
|
-
},
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
// Performance Tests
|
|
333
|
-
export const Performance: Story = {
|
|
334
|
-
render: () => (
|
|
335
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px', padding: '16px' }}>
|
|
336
|
-
{Array.from({ length: 10 }, (_, i) => (
|
|
337
|
-
<Banner
|
|
338
|
-
key={i}
|
|
339
|
-
variant={(['info', 'success', 'warning', 'critical'] as const)[i % 4]}
|
|
340
|
-
title={`Performance Test Banner ${i + 1}`}
|
|
341
|
-
description={`Testing performance with multiple banners - Instance ${i + 1}`}
|
|
342
|
-
dismissible={i % 2 === 0}
|
|
343
|
-
actions={
|
|
344
|
-
i % 3 === 0 ? [{ label: 'Action', onClick: fn(), variant: 'primary' }] : undefined
|
|
345
|
-
}
|
|
346
|
-
/>
|
|
347
|
-
))}
|
|
348
|
-
</div>
|
|
349
|
-
),
|
|
350
|
-
play: async ({ canvasElement }) => {
|
|
351
|
-
const canvas = within(canvasElement);
|
|
352
|
-
const startTime = window.performance.now();
|
|
353
|
-
|
|
354
|
-
// Wait for all banners to be rendered
|
|
355
|
-
await waitFor(() => {
|
|
356
|
-
// Get both status and alert roles
|
|
357
|
-
const statusBanners = canvas.getAllByRole('status');
|
|
358
|
-
const alertBanners = canvas.getAllByRole('alert');
|
|
359
|
-
const totalBanners = statusBanners.length + alertBanners.length;
|
|
360
|
-
expect(totalBanners).toBe(10);
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
// Verify performance is acceptable
|
|
364
|
-
const endTime = window.performance.now();
|
|
365
|
-
const renderTime = endTime - startTime;
|
|
366
|
-
expect(renderTime).toBeLessThan(500); // Should render in less than 500ms
|
|
367
|
-
|
|
368
|
-
// Test interaction performance - dismissible banners have dismiss buttons
|
|
369
|
-
const allDismissButtons = canvas.getAllByRole('button', { name: /dismiss banner/i });
|
|
370
|
-
|
|
371
|
-
// Click first 3 dismiss buttons
|
|
372
|
-
const dismissCount = Math.min(3, allDismissButtons.length);
|
|
373
|
-
for (let i = 0; i < dismissCount; i++) {
|
|
374
|
-
await userEvent.click(allDismissButtons[i]);
|
|
375
|
-
// The old wait here had an empty body, so it was a fixed delay with a
|
|
376
|
-
// waitFor's name on it. Waiting for the banner count to actually drop is
|
|
377
|
-
// both the real signal and the assertion.
|
|
378
|
-
const remaining = allDismissButtons.length - (i + 1);
|
|
379
|
-
await waitFor(() => {
|
|
380
|
-
expect(canvas.queryAllByRole('button', { name: /dismiss banner/i })).toHaveLength(
|
|
381
|
-
remaining,
|
|
382
|
-
);
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
},
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
// Edge Cases Tests
|
|
389
|
-
export const EdgeCases: Story = {
|
|
390
|
-
render: () => (
|
|
391
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px', padding: '16px' }}>
|
|
392
|
-
<Banner variant="info" title="" description="" />
|
|
393
|
-
<Banner variant="success" title="Only Title" />
|
|
394
|
-
<Banner variant="warning" description="Only description provided" />
|
|
395
|
-
<Banner
|
|
396
|
-
variant="critical"
|
|
397
|
-
title="Very Long Title That Should Handle Overflow Gracefully Without Breaking Layout"
|
|
398
|
-
description="This is a very long description that tests how the banner handles overflow content and ensures that the layout remains stable even with extensive text content that might wrap to multiple lines."
|
|
399
|
-
/>
|
|
400
|
-
<Banner
|
|
401
|
-
variant="info"
|
|
402
|
-
title="Many Actions Test"
|
|
403
|
-
actions={[
|
|
404
|
-
{ label: 'Action 1', onClick: fn(), variant: 'primary' },
|
|
405
|
-
{ label: 'Action 2', onClick: fn(), variant: 'secondary' },
|
|
406
|
-
{ label: 'Action 3', onClick: fn(), variant: 'primary' },
|
|
407
|
-
{ label: 'Action 4', onClick: fn(), variant: 'secondary' },
|
|
408
|
-
]}
|
|
409
|
-
/>
|
|
410
|
-
</div>
|
|
411
|
-
),
|
|
412
|
-
play: async ({ canvasElement }) => {
|
|
413
|
-
const canvas = within(canvasElement);
|
|
414
|
-
|
|
415
|
-
// Wait for all edge case banners to render
|
|
416
|
-
await waitFor(() => {
|
|
417
|
-
const statusBanners = canvas.getAllByRole('status');
|
|
418
|
-
const alertBanners = canvas.getAllByRole('alert');
|
|
419
|
-
const totalBanners = statusBanners.length + alertBanners.length;
|
|
420
|
-
expect(totalBanners).toBe(5);
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
// Get all banners
|
|
424
|
-
const statusBanners = canvas.getAllByRole('status');
|
|
425
|
-
const alertBanners = canvas.getAllByRole('alert');
|
|
426
|
-
const allBanners = [...statusBanners, ...alertBanners];
|
|
427
|
-
|
|
428
|
-
// Verify empty content banner renders (first one)
|
|
429
|
-
expect(allBanners[0]).toBeInTheDocument();
|
|
430
|
-
|
|
431
|
-
// Verify title-only banner
|
|
432
|
-
expect(canvas.getByText('Only Title')).toBeInTheDocument();
|
|
433
|
-
|
|
434
|
-
// Verify description-only banner
|
|
435
|
-
expect(canvas.getByText('Only description provided')).toBeInTheDocument();
|
|
436
|
-
|
|
437
|
-
// Verify long content banner
|
|
438
|
-
expect(canvas.getByText(/Very Long Title/)).toBeInTheDocument();
|
|
439
|
-
|
|
440
|
-
// Verify many actions banner - find it by its title
|
|
441
|
-
const manyActionsText = canvas.getByText('Many Actions Test');
|
|
442
|
-
const manyActionsBanner = manyActionsText.closest('[role="status"], [role="alert"]');
|
|
443
|
-
expect(manyActionsBanner).toBeInTheDocument();
|
|
444
|
-
|
|
445
|
-
if (manyActionsBanner) {
|
|
446
|
-
const actionButtons = within(manyActionsBanner).getAllByRole('button');
|
|
447
|
-
expect(actionButtons).toHaveLength(4);
|
|
448
|
-
}
|
|
449
|
-
},
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
// Integration Tests
|
|
453
|
-
export const Integration: Story = {
|
|
454
|
-
render: () => (
|
|
455
|
-
<div>
|
|
456
|
-
<Banner
|
|
457
|
-
variant="info"
|
|
458
|
-
title="Cookie Notice"
|
|
459
|
-
description="We use cookies to enhance your experience"
|
|
460
|
-
actions={[
|
|
461
|
-
{ label: 'Accept All', onClick: fn(), variant: 'primary' },
|
|
462
|
-
{ label: 'Manage Preferences', onClick: fn(), variant: 'secondary' },
|
|
463
|
-
]}
|
|
464
|
-
dismissible
|
|
465
|
-
/>
|
|
466
|
-
<div style={{ padding: '16px' }}>
|
|
467
|
-
<p>Page content below the banner</p>
|
|
468
|
-
<button>Page button</button>
|
|
469
|
-
</div>
|
|
470
|
-
<Banner
|
|
471
|
-
variant="warning"
|
|
472
|
-
title="Maintenance Notice"
|
|
473
|
-
description="Scheduled maintenance tonight from 2-4 AM"
|
|
474
|
-
sticky
|
|
475
|
-
fullWidth
|
|
476
|
-
dismissible
|
|
477
|
-
/>
|
|
478
|
-
</div>
|
|
479
|
-
),
|
|
480
|
-
play: async ({ canvasElement }) => {
|
|
481
|
-
const canvas = within(canvasElement);
|
|
482
|
-
|
|
483
|
-
// Wait for both banners to be present
|
|
484
|
-
await waitFor(() => {
|
|
485
|
-
const statusBanners = canvas.getAllByRole('status');
|
|
486
|
-
const alertBanners = canvas.getAllByRole('alert');
|
|
487
|
-
const totalBanners = statusBanners.length + alertBanners.length;
|
|
488
|
-
expect(totalBanners).toBe(2);
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
// Test integration with page content
|
|
492
|
-
expect(canvas.getByText('Page content below the banner')).toBeInTheDocument();
|
|
493
|
-
expect(canvas.getByRole('button', { name: 'Page button' })).toBeInTheDocument();
|
|
494
|
-
|
|
495
|
-
// Test banner interactions don't interfere with page
|
|
496
|
-
const acceptButton = canvas.getByRole('button', { name: 'Accept All' });
|
|
497
|
-
await userEvent.click(acceptButton);
|
|
498
|
-
|
|
499
|
-
// Verify page content is still accessible
|
|
500
|
-
const pageButton = canvas.getByRole('button', { name: 'Page button' });
|
|
501
|
-
await userEvent.click(pageButton);
|
|
502
|
-
|
|
503
|
-
// Test sticky banner functionality - find the warning banner (should be sticky)
|
|
504
|
-
const warningBanner = canvas.getByRole('alert');
|
|
505
|
-
expect(warningBanner).toBeInTheDocument();
|
|
506
|
-
|
|
507
|
-
// Verify sticky banner has correct styling
|
|
508
|
-
const computedStyle = window.getComputedStyle(warningBanner);
|
|
509
|
-
expect(computedStyle.position).toBe('sticky');
|
|
510
|
-
},
|
|
511
|
-
};
|