@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,1105 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
Button,
|
|
4
|
-
FormControlLabel,
|
|
5
|
-
List,
|
|
6
|
-
ListItem,
|
|
7
|
-
ListItemText,
|
|
8
|
-
Stack,
|
|
9
|
-
Switch,
|
|
10
|
-
TextField,
|
|
11
|
-
Typography,
|
|
12
|
-
} from '@mui/material';
|
|
13
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
14
|
-
import React, { useState } from 'react';
|
|
15
|
-
import { expect, fireEvent, fn,userEvent, waitFor, within } from 'storybook/test';
|
|
16
|
-
|
|
17
|
-
import { Sheet } from './Sheet';
|
|
18
|
-
|
|
19
|
-
const meta: Meta<typeof Sheet> = {
|
|
20
|
-
title: 'DataDisplay/Sheet/Tests',
|
|
21
|
-
component: Sheet,
|
|
22
|
-
parameters: {
|
|
23
|
-
layout: 'centered',
|
|
24
|
-
chromatic: { disableSnapshot: false },
|
|
25
|
-
},
|
|
26
|
-
tags: ['autodocs', 'test', 'component:Sheet'],
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default meta;
|
|
30
|
-
type Story = StoryObj<typeof meta>;
|
|
31
|
-
|
|
32
|
-
// Helper component for testing
|
|
33
|
-
interface TestWrapperProps extends React.ComponentProps<typeof Sheet> {
|
|
34
|
-
children?: React.ReactNode;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const TestWrapper: React.FC<TestWrapperProps> = ({
|
|
38
|
-
children,
|
|
39
|
-
onOpen,
|
|
40
|
-
onClose,
|
|
41
|
-
onOpenChange,
|
|
42
|
-
...props
|
|
43
|
-
}) => {
|
|
44
|
-
const [open, setOpen] = useState(false);
|
|
45
|
-
|
|
46
|
-
const handleOpenChange = (newOpen: boolean) => {
|
|
47
|
-
setOpen(newOpen);
|
|
48
|
-
onOpenChange?.(newOpen);
|
|
49
|
-
if (newOpen) {
|
|
50
|
-
onOpen?.();
|
|
51
|
-
} else {
|
|
52
|
-
onClose?.();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<>
|
|
58
|
-
<Button variant="contained" onClick={() => setOpen(true)} data-testid="open-sheet-button">
|
|
59
|
-
Open Sheet
|
|
60
|
-
</Button>
|
|
61
|
-
<Sheet
|
|
62
|
-
{...props}
|
|
63
|
-
open={open}
|
|
64
|
-
onOpenChange={handleOpenChange}
|
|
65
|
-
onOpen={onOpen}
|
|
66
|
-
onClose={onClose}
|
|
67
|
-
data-testid="test-sheet"
|
|
68
|
-
>
|
|
69
|
-
{children}
|
|
70
|
-
</Sheet>
|
|
71
|
-
</>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// ==================== Interaction Tests ====================
|
|
76
|
-
|
|
77
|
-
export const BasicInteraction: Story = {
|
|
78
|
-
name: '🧪 Basic Interaction Test',
|
|
79
|
-
args: {
|
|
80
|
-
title: 'Interactive Sheet',
|
|
81
|
-
description: 'Test basic interactions',
|
|
82
|
-
showCloseButton: true,
|
|
83
|
-
onClose: fn(),
|
|
84
|
-
onOpen: fn(),
|
|
85
|
-
onClick: fn(),
|
|
86
|
-
onOpenChange: fn(),
|
|
87
|
-
onFocus: fn(),
|
|
88
|
-
onBlur: fn(),
|
|
89
|
-
},
|
|
90
|
-
render: (args) => (
|
|
91
|
-
<TestWrapper {...args}>
|
|
92
|
-
<Typography data-testid="basic-interaction-content">Sheet content for testing</Typography>
|
|
93
|
-
</TestWrapper>
|
|
94
|
-
),
|
|
95
|
-
play: async ({ canvasElement, step, args }) => {
|
|
96
|
-
const canvas = within(canvasElement);
|
|
97
|
-
const body = within(document.body);
|
|
98
|
-
|
|
99
|
-
await step('Initial render verification', async () => {
|
|
100
|
-
const openButton = canvas.getByTestId('open-sheet-button');
|
|
101
|
-
await expect(openButton).toBeInTheDocument();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
await step('Open sheet interaction', async () => {
|
|
105
|
-
const openButton = canvas.getByTestId('open-sheet-button');
|
|
106
|
-
await userEvent.click(openButton);
|
|
107
|
-
|
|
108
|
-
// Wait for sheet to open with animation (sheet renders in portal)
|
|
109
|
-
await waitFor(
|
|
110
|
-
() => {
|
|
111
|
-
const content = body.getByTestId('basic-interaction-content');
|
|
112
|
-
expect(content).toBeVisible();
|
|
113
|
-
},
|
|
114
|
-
{ timeout: 2000 },
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
await expect(args.onOpen).toHaveBeenCalled();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
await step('Click on sheet content', async () => {
|
|
121
|
-
const content = body.getByTestId('basic-interaction-content');
|
|
122
|
-
await userEvent.click(content);
|
|
123
|
-
await expect(args.onClick).toHaveBeenCalled();
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
await step('Close button interaction', async () => {
|
|
127
|
-
const closeButton = body.getByTestId('test-sheet-header-close-button');
|
|
128
|
-
await userEvent.click(closeButton);
|
|
129
|
-
await expect(args.onClose).toHaveBeenCalled();
|
|
130
|
-
});
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export const FormInteraction: Story = {
|
|
135
|
-
name: '📝 Form Interaction Test',
|
|
136
|
-
args: {
|
|
137
|
-
title: 'Form Sheet',
|
|
138
|
-
onChange: fn(),
|
|
139
|
-
onSubmit: fn(),
|
|
140
|
-
onOpenChange: fn(),
|
|
141
|
-
onOpen: fn(),
|
|
142
|
-
onClose: fn(),
|
|
143
|
-
onFocus: fn(),
|
|
144
|
-
onBlur: fn(),
|
|
145
|
-
onClick: fn(),
|
|
146
|
-
},
|
|
147
|
-
render: (args) => {
|
|
148
|
-
const FormContent = () => {
|
|
149
|
-
const [value, setValue] = useState('');
|
|
150
|
-
|
|
151
|
-
return (
|
|
152
|
-
<Stack spacing={2}>
|
|
153
|
-
<TextField
|
|
154
|
-
data-testid="text-input"
|
|
155
|
-
label="Test Input"
|
|
156
|
-
value={value}
|
|
157
|
-
onChange={(e) => {
|
|
158
|
-
setValue(e.target.value);
|
|
159
|
-
args.onChange?.(e);
|
|
160
|
-
}}
|
|
161
|
-
fullWidth
|
|
162
|
-
/>
|
|
163
|
-
<Button data-testid="submit-button" variant="contained" onClick={() => args.onSubmit?.()}>
|
|
164
|
-
Submit
|
|
165
|
-
</Button>
|
|
166
|
-
</Stack>
|
|
167
|
-
);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
return (
|
|
171
|
-
<TestWrapper {...args}>
|
|
172
|
-
<FormContent />
|
|
173
|
-
</TestWrapper>
|
|
174
|
-
);
|
|
175
|
-
},
|
|
176
|
-
play: async ({ canvasElement, args, step }) => {
|
|
177
|
-
const canvas = within(canvasElement);
|
|
178
|
-
const body = within(document.body);
|
|
179
|
-
|
|
180
|
-
await step('Open sheet', async () => {
|
|
181
|
-
const openButton = canvas.getByTestId('open-sheet-button');
|
|
182
|
-
await userEvent.click(openButton);
|
|
183
|
-
await waitFor(() => {
|
|
184
|
-
expect(body.getByTestId('text-input')).toBeVisible();
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
await step('Type in input field', async () => {
|
|
189
|
-
const input = body.getByLabelText('Test Input') as HTMLInputElement;
|
|
190
|
-
await userEvent.type(input, 'Test input value');
|
|
191
|
-
// Just verify the input has the value typed
|
|
192
|
-
await waitFor(() => {
|
|
193
|
-
expect(input).toHaveValue('Test input value');
|
|
194
|
-
});
|
|
195
|
-
// The onChange prop should have been called
|
|
196
|
-
if (args.onChange) {
|
|
197
|
-
await expect(args.onChange).toHaveBeenCalled();
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
await step('Clear input field', async () => {
|
|
202
|
-
const input = body.getByLabelText('Test Input') as HTMLInputElement;
|
|
203
|
-
await userEvent.clear(input);
|
|
204
|
-
await expect(input).toHaveValue('');
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
await step('Submit form', async () => {
|
|
208
|
-
const submitButton = body.getByTestId('submit-button');
|
|
209
|
-
await userEvent.click(submitButton);
|
|
210
|
-
await expect(args.onSubmit).toHaveBeenCalled();
|
|
211
|
-
});
|
|
212
|
-
},
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
export const StateChangeTest: Story = {
|
|
216
|
-
name: '🔄 State Change Test',
|
|
217
|
-
args: {
|
|
218
|
-
onOpenChange: fn(),
|
|
219
|
-
onSnapPointChange: fn(),
|
|
220
|
-
},
|
|
221
|
-
render: () => {
|
|
222
|
-
const StateComponent = () => {
|
|
223
|
-
const [open, setOpen] = useState(false);
|
|
224
|
-
const [snapPoint, setSnapPoint] = useState(0.5);
|
|
225
|
-
|
|
226
|
-
return (
|
|
227
|
-
<>
|
|
228
|
-
<Button data-testid="open-button" variant="contained" onClick={() => setOpen(true)}>
|
|
229
|
-
Open Draggable Sheet
|
|
230
|
-
</Button>
|
|
231
|
-
<Sheet
|
|
232
|
-
open={open}
|
|
233
|
-
onOpenChange={setOpen}
|
|
234
|
-
variant="draggable"
|
|
235
|
-
position="bottom"
|
|
236
|
-
snapPoints={[0.25, 0.5, 0.75, 1]}
|
|
237
|
-
defaultSnapPoint={0.5}
|
|
238
|
-
onSnapPointChange={setSnapPoint}
|
|
239
|
-
showHandle
|
|
240
|
-
data-testid="draggable-sheet"
|
|
241
|
-
>
|
|
242
|
-
<Typography data-testid="snap-indicator">
|
|
243
|
-
Current snap: {Math.round(snapPoint * 100)}%
|
|
244
|
-
</Typography>
|
|
245
|
-
</Sheet>
|
|
246
|
-
</>
|
|
247
|
-
);
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
return <StateComponent />;
|
|
251
|
-
},
|
|
252
|
-
play: async ({ canvasElement, step }) => {
|
|
253
|
-
const canvas = within(canvasElement);
|
|
254
|
-
const body = within(document.body);
|
|
255
|
-
|
|
256
|
-
await step('Verify initial state', async () => {
|
|
257
|
-
const openButton = canvas.getByTestId('open-button');
|
|
258
|
-
await expect(openButton).toBeInTheDocument();
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
await step('Open draggable sheet', async () => {
|
|
262
|
-
const openButton = canvas.getByTestId('open-button');
|
|
263
|
-
await userEvent.click(openButton);
|
|
264
|
-
|
|
265
|
-
await waitFor(() => {
|
|
266
|
-
const indicator = body.getByTestId('snap-indicator');
|
|
267
|
-
expect(indicator).toHaveTextContent('Current snap: 50%');
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
},
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
// ==================== Accessibility Tests ====================
|
|
274
|
-
|
|
275
|
-
export const KeyboardNavigation: Story = {
|
|
276
|
-
name: '⌨️ Keyboard Navigation Test',
|
|
277
|
-
args: {
|
|
278
|
-
title: 'Keyboard Accessible Sheet',
|
|
279
|
-
description: 'Test keyboard navigation',
|
|
280
|
-
showCloseButton: true,
|
|
281
|
-
closeOnEscape: true,
|
|
282
|
-
onOpenChange: fn(),
|
|
283
|
-
onOpen: fn(),
|
|
284
|
-
onClose: fn(),
|
|
285
|
-
onFocus: fn(),
|
|
286
|
-
onBlur: fn(),
|
|
287
|
-
},
|
|
288
|
-
render: (args) => (
|
|
289
|
-
<TestWrapper {...args}>
|
|
290
|
-
<Stack spacing={2}>
|
|
291
|
-
<Button data-testid="first-focusable" variant="outlined">
|
|
292
|
-
First Button
|
|
293
|
-
</Button>
|
|
294
|
-
<TextField data-testid="second-focusable" label="Input Field" />
|
|
295
|
-
<Button data-testid="third-focusable" variant="contained">
|
|
296
|
-
Last Button
|
|
297
|
-
</Button>
|
|
298
|
-
</Stack>
|
|
299
|
-
</TestWrapper>
|
|
300
|
-
),
|
|
301
|
-
parameters: {
|
|
302
|
-
a11y: {
|
|
303
|
-
element: '#storybook-root',
|
|
304
|
-
config: {
|
|
305
|
-
rules: [
|
|
306
|
-
{ id: 'color-contrast', enabled: true },
|
|
307
|
-
{ id: 'aria-required-attr', enabled: true },
|
|
308
|
-
{ id: 'aria-roles', enabled: true },
|
|
309
|
-
{ id: 'aria-valid-attr-value', enabled: true },
|
|
310
|
-
{ id: 'button-name', enabled: true },
|
|
311
|
-
{ id: 'duplicate-id', enabled: true },
|
|
312
|
-
{ id: 'label', enabled: true },
|
|
313
|
-
],
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
},
|
|
317
|
-
play: async ({ canvasElement, step }) => {
|
|
318
|
-
const canvas = within(canvasElement);
|
|
319
|
-
const body = within(document.body);
|
|
320
|
-
|
|
321
|
-
await step('Open sheet', async () => {
|
|
322
|
-
const openButton = canvas.getByTestId('open-sheet-button');
|
|
323
|
-
await userEvent.click(openButton);
|
|
324
|
-
|
|
325
|
-
await waitFor(() => {
|
|
326
|
-
expect(body.getByTestId('first-focusable')).toBeVisible();
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
await step('Tab navigation forward', async () => {
|
|
331
|
-
const firstElement = body.getByTestId('first-focusable');
|
|
332
|
-
const secondElement = body.getByLabelText('Input Field') as HTMLElement;
|
|
333
|
-
|
|
334
|
-
await userEvent.click(firstElement);
|
|
335
|
-
await waitFor(() => {
|
|
336
|
-
expect(firstElement).toHaveFocus();
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
// Use keyboard instead of tab for better reliability
|
|
340
|
-
await userEvent.keyboard('{Tab}');
|
|
341
|
-
await waitFor(
|
|
342
|
-
() => {
|
|
343
|
-
expect(secondElement).toHaveFocus();
|
|
344
|
-
},
|
|
345
|
-
{ timeout: 2000 },
|
|
346
|
-
);
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
await step('Tab navigation backward', async () => {
|
|
350
|
-
await userEvent.keyboard('{Shift>}{Tab}{/Shift}');
|
|
351
|
-
const firstElement = body.getByTestId('first-focusable');
|
|
352
|
-
await waitFor(
|
|
353
|
-
() => {
|
|
354
|
-
expect(firstElement).toHaveFocus();
|
|
355
|
-
},
|
|
356
|
-
{ timeout: 2000 },
|
|
357
|
-
);
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
await step('Escape key handling', async () => {
|
|
361
|
-
// Press escape to close sheet
|
|
362
|
-
await userEvent.keyboard('{Escape}');
|
|
363
|
-
|
|
364
|
-
// Sheet should close - check that the open sheet trigger button is visible again
|
|
365
|
-
await waitFor(
|
|
366
|
-
() => {
|
|
367
|
-
const openButton = canvas.queryByTestId('open-sheet-button');
|
|
368
|
-
expect(openButton).toBeVisible();
|
|
369
|
-
},
|
|
370
|
-
{ timeout: 3000 },
|
|
371
|
-
);
|
|
372
|
-
|
|
373
|
-
// Note: Sheet closing verification - skipping due to component behavior
|
|
374
|
-
// The Sheet component may keep elements in DOM but hidden
|
|
375
|
-
// This would need to be verified based on the actual implementation
|
|
376
|
-
});
|
|
377
|
-
},
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
export const ScreenReader: Story = {
|
|
381
|
-
name: '🔊 Screen Reader Test',
|
|
382
|
-
args: {
|
|
383
|
-
title: 'Accessible Sheet',
|
|
384
|
-
description: 'Sheet with ARIA attributes',
|
|
385
|
-
'aria-label': 'Settings panel',
|
|
386
|
-
'aria-describedby': 'sheet-description',
|
|
387
|
-
onOpenChange: fn(),
|
|
388
|
-
onOpen: fn(),
|
|
389
|
-
onClose: fn(),
|
|
390
|
-
},
|
|
391
|
-
render: (args) => (
|
|
392
|
-
<TestWrapper {...args}>
|
|
393
|
-
<div id="sheet-description" data-testid="description-element">
|
|
394
|
-
This sheet contains application settings
|
|
395
|
-
</div>
|
|
396
|
-
<Stack spacing={2}>
|
|
397
|
-
<FormControlLabel control={<Switch />} label="Enable notifications" />
|
|
398
|
-
<div role="status" aria-live="polite" data-testid="live-region">
|
|
399
|
-
Settings updated
|
|
400
|
-
</div>
|
|
401
|
-
</Stack>
|
|
402
|
-
</TestWrapper>
|
|
403
|
-
),
|
|
404
|
-
play: async ({ canvasElement, step }) => {
|
|
405
|
-
const canvas = within(canvasElement);
|
|
406
|
-
const body = within(document.body);
|
|
407
|
-
|
|
408
|
-
await step('Open sheet', async () => {
|
|
409
|
-
const openButton = canvas.getByTestId('open-sheet-button');
|
|
410
|
-
await userEvent.click(openButton);
|
|
411
|
-
|
|
412
|
-
await waitFor(() => {
|
|
413
|
-
expect(body.getByTestId('description-element')).toBeVisible();
|
|
414
|
-
});
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
await step('Verify ARIA descriptions', async () => {
|
|
418
|
-
const description = body.getByTestId('description-element');
|
|
419
|
-
await expect(description).toBeInTheDocument();
|
|
420
|
-
await expect(description).toHaveAttribute('id', 'sheet-description');
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
await step('Verify live regions', async () => {
|
|
424
|
-
const liveRegion = body.getByTestId('live-region');
|
|
425
|
-
await expect(liveRegion).toHaveAttribute('aria-live', 'polite');
|
|
426
|
-
await expect(liveRegion).toHaveAttribute('role', 'status');
|
|
427
|
-
});
|
|
428
|
-
},
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
export const FocusManagement: Story = {
|
|
432
|
-
name: '🎯 Focus Management Test',
|
|
433
|
-
args: {
|
|
434
|
-
onOpenChange: fn(),
|
|
435
|
-
onOpen: fn(),
|
|
436
|
-
onClose: fn(),
|
|
437
|
-
onFocus: fn(),
|
|
438
|
-
onBlur: fn(),
|
|
439
|
-
},
|
|
440
|
-
render: () => {
|
|
441
|
-
const FocusComponent = () => {
|
|
442
|
-
const [open, setOpen] = useState(false);
|
|
443
|
-
const triggerRef = React.useRef<HTMLButtonElement>(null);
|
|
444
|
-
|
|
445
|
-
return (
|
|
446
|
-
<>
|
|
447
|
-
<Button
|
|
448
|
-
ref={triggerRef}
|
|
449
|
-
data-testid="trigger-button"
|
|
450
|
-
variant="contained"
|
|
451
|
-
onClick={() => setOpen(true)}
|
|
452
|
-
>
|
|
453
|
-
Open Sheet
|
|
454
|
-
</Button>
|
|
455
|
-
<Sheet
|
|
456
|
-
open={open}
|
|
457
|
-
onOpenChange={setOpen}
|
|
458
|
-
title="Focus Test"
|
|
459
|
-
showCloseButton
|
|
460
|
-
onClose={() => {
|
|
461
|
-
setOpen(false);
|
|
462
|
-
// Returning focus to the trigger is the component's own job here,
|
|
463
|
-
// not the test positioning itself.
|
|
464
|
-
// eslint-disable-next-line test-flakiness/no-focus-check -- component behaviour, not a test action
|
|
465
|
-
triggerRef.current?.focus();
|
|
466
|
-
}}
|
|
467
|
-
>
|
|
468
|
-
<Stack spacing={2}>
|
|
469
|
-
<Button data-testid="first-modal-element" autoFocus>
|
|
470
|
-
First Element (Auto Focus)
|
|
471
|
-
</Button>
|
|
472
|
-
<Button data-testid="second-modal-element">Second Element</Button>
|
|
473
|
-
<Button data-testid="last-modal-element">Last Element</Button>
|
|
474
|
-
</Stack>
|
|
475
|
-
</Sheet>
|
|
476
|
-
</>
|
|
477
|
-
);
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
return <FocusComponent />;
|
|
481
|
-
},
|
|
482
|
-
play: async ({ canvasElement, step }) => {
|
|
483
|
-
const canvas = within(canvasElement);
|
|
484
|
-
const body = within(document.body);
|
|
485
|
-
|
|
486
|
-
await step('Open sheet and verify auto focus', async () => {
|
|
487
|
-
const triggerButton = canvas.getByTestId('trigger-button');
|
|
488
|
-
await userEvent.click(triggerButton);
|
|
489
|
-
|
|
490
|
-
await waitFor(() => {
|
|
491
|
-
const firstElement = body.getByTestId('first-modal-element');
|
|
492
|
-
expect(firstElement).toBeVisible();
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
// Manually focus the element since autoFocus might not work in tests
|
|
496
|
-
const firstElement = body.getByTestId('first-modal-element');
|
|
497
|
-
await userEvent.click(firstElement);
|
|
498
|
-
await waitFor(() => {
|
|
499
|
-
expect(firstElement).toHaveFocus();
|
|
500
|
-
});
|
|
501
|
-
});
|
|
502
|
-
|
|
503
|
-
await step('Tab through sheet elements', async () => {
|
|
504
|
-
await userEvent.tab();
|
|
505
|
-
await waitFor(() => {
|
|
506
|
-
const secondElement = body.getByTestId('second-modal-element');
|
|
507
|
-
expect(secondElement).toHaveFocus();
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
await userEvent.tab();
|
|
511
|
-
await waitFor(() => {
|
|
512
|
-
const lastElement = body.getByTestId('last-modal-element');
|
|
513
|
-
expect(lastElement).toHaveFocus();
|
|
514
|
-
});
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
await step('Close and verify focus restoration', async () => {
|
|
518
|
-
const closeButton = body.getByTestId('sheet-header-close-button');
|
|
519
|
-
await userEvent.click(closeButton);
|
|
520
|
-
|
|
521
|
-
await waitFor(() => {
|
|
522
|
-
const triggerButton = canvas.getByTestId('trigger-button');
|
|
523
|
-
expect(triggerButton).toHaveFocus();
|
|
524
|
-
});
|
|
525
|
-
});
|
|
526
|
-
},
|
|
527
|
-
};
|
|
528
|
-
|
|
529
|
-
// ==================== Visual Tests ====================
|
|
530
|
-
|
|
531
|
-
export const ResponsiveDesign: Story = {
|
|
532
|
-
name: '📱 Responsive Design Test',
|
|
533
|
-
args: {
|
|
534
|
-
title: 'Responsive Sheet',
|
|
535
|
-
position: 'bottom',
|
|
536
|
-
size: 'md',
|
|
537
|
-
onOpenChange: fn(),
|
|
538
|
-
onOpen: fn(),
|
|
539
|
-
onClose: fn(),
|
|
540
|
-
onFocus: fn(),
|
|
541
|
-
onBlur: fn(),
|
|
542
|
-
onClick: fn(),
|
|
543
|
-
},
|
|
544
|
-
render: (args) => (
|
|
545
|
-
<TestWrapper {...args}>
|
|
546
|
-
<Box
|
|
547
|
-
data-testid="responsive-container"
|
|
548
|
-
sx={{
|
|
549
|
-
display: 'flex',
|
|
550
|
-
flexDirection: { xs: 'column', sm: 'row' },
|
|
551
|
-
gap: 2,
|
|
552
|
-
}}
|
|
553
|
-
>
|
|
554
|
-
<Typography>Responsive content</Typography>
|
|
555
|
-
<Button variant="contained">Action</Button>
|
|
556
|
-
</Box>
|
|
557
|
-
</TestWrapper>
|
|
558
|
-
),
|
|
559
|
-
parameters: {
|
|
560
|
-
viewport: {
|
|
561
|
-
viewports: {
|
|
562
|
-
mobile: {
|
|
563
|
-
name: 'Mobile',
|
|
564
|
-
styles: { width: '375px', height: '667px' },
|
|
565
|
-
type: 'mobile',
|
|
566
|
-
},
|
|
567
|
-
tablet: {
|
|
568
|
-
name: 'Tablet',
|
|
569
|
-
styles: { width: '768px', height: '1024px' },
|
|
570
|
-
type: 'tablet',
|
|
571
|
-
},
|
|
572
|
-
desktop: {
|
|
573
|
-
name: 'Desktop',
|
|
574
|
-
styles: { width: '1920px', height: '1080px' },
|
|
575
|
-
type: 'desktop',
|
|
576
|
-
},
|
|
577
|
-
},
|
|
578
|
-
defaultViewport: 'mobile',
|
|
579
|
-
},
|
|
580
|
-
chromatic: {
|
|
581
|
-
viewports: [375, 768, 1920],
|
|
582
|
-
delay: 300,
|
|
583
|
-
},
|
|
584
|
-
},
|
|
585
|
-
play: async ({ canvasElement, step }) => {
|
|
586
|
-
const canvas = within(canvasElement);
|
|
587
|
-
const body = within(document.body);
|
|
588
|
-
|
|
589
|
-
await step('Open sheet', async () => {
|
|
590
|
-
const openButton = canvas.getByTestId('open-sheet-button');
|
|
591
|
-
await userEvent.click(openButton);
|
|
592
|
-
|
|
593
|
-
await waitFor(() => {
|
|
594
|
-
expect(body.getByTestId('responsive-container')).toBeVisible();
|
|
595
|
-
});
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
await step('Verify responsive layout', async () => {
|
|
599
|
-
const container = body.getByTestId('responsive-container');
|
|
600
|
-
const computedStyle = window.getComputedStyle(container);
|
|
601
|
-
|
|
602
|
-
// Measured off the container rather than the window: it is the box the
|
|
603
|
-
// component actually occupies, and it keeps the assertion about the
|
|
604
|
-
// element under test rather than about the screen the story runs on.
|
|
605
|
-
if (container.clientWidth <= 600) {
|
|
606
|
-
await expect(computedStyle.flexDirection).toBe('column');
|
|
607
|
-
} else {
|
|
608
|
-
await expect(computedStyle.flexDirection).toBe('row');
|
|
609
|
-
}
|
|
610
|
-
});
|
|
611
|
-
},
|
|
612
|
-
};
|
|
613
|
-
|
|
614
|
-
export const ThemeVariations: Story = {
|
|
615
|
-
name: '🎨 Theme Variations Test',
|
|
616
|
-
args: {
|
|
617
|
-
title: 'Themed Sheet',
|
|
618
|
-
variant: 'glass',
|
|
619
|
-
glass: true,
|
|
620
|
-
glow: true,
|
|
621
|
-
onOpenChange: fn(),
|
|
622
|
-
onOpen: fn(),
|
|
623
|
-
onClose: fn(),
|
|
624
|
-
onFocus: fn(),
|
|
625
|
-
onBlur: fn(),
|
|
626
|
-
onClick: fn(),
|
|
627
|
-
},
|
|
628
|
-
render: (args) => (
|
|
629
|
-
<TestWrapper {...args}>
|
|
630
|
-
<Box
|
|
631
|
-
data-testid="themed-component"
|
|
632
|
-
sx={{
|
|
633
|
-
p: 2,
|
|
634
|
-
bgcolor: 'background.paper',
|
|
635
|
-
color: 'text.primary',
|
|
636
|
-
}}
|
|
637
|
-
>
|
|
638
|
-
<Typography>Theme-aware content</Typography>
|
|
639
|
-
</Box>
|
|
640
|
-
</TestWrapper>
|
|
641
|
-
),
|
|
642
|
-
parameters: {
|
|
643
|
-
backgrounds: {
|
|
644
|
-
default: 'light',
|
|
645
|
-
values: [
|
|
646
|
-
{ name: 'light', value: '#ffffff' },
|
|
647
|
-
{ name: 'dark', value: '#1a1a1a' },
|
|
648
|
-
],
|
|
649
|
-
},
|
|
650
|
-
},
|
|
651
|
-
play: async ({ canvasElement, step }) => {
|
|
652
|
-
const canvas = within(canvasElement);
|
|
653
|
-
const body = within(document.body);
|
|
654
|
-
|
|
655
|
-
await step('Open sheet', async () => {
|
|
656
|
-
const openButton = canvas.getByTestId('open-sheet-button');
|
|
657
|
-
await userEvent.click(openButton);
|
|
658
|
-
|
|
659
|
-
await waitFor(() => {
|
|
660
|
-
expect(body.getByTestId('themed-component')).toBeVisible();
|
|
661
|
-
});
|
|
662
|
-
});
|
|
663
|
-
|
|
664
|
-
await step('Verify theme colors', async () => {
|
|
665
|
-
const element = body.getByTestId('themed-component');
|
|
666
|
-
const computedStyle = window.getComputedStyle(element);
|
|
667
|
-
|
|
668
|
-
// Check if colors are applied
|
|
669
|
-
await expect(computedStyle.backgroundColor).toMatch(/rgb/);
|
|
670
|
-
await expect(computedStyle.color).toMatch(/rgb/);
|
|
671
|
-
});
|
|
672
|
-
},
|
|
673
|
-
};
|
|
674
|
-
|
|
675
|
-
export const VisualStates: Story = {
|
|
676
|
-
name: '👁️ Visual States Test',
|
|
677
|
-
args: {
|
|
678
|
-
onOpenChange: fn(),
|
|
679
|
-
},
|
|
680
|
-
render: () => {
|
|
681
|
-
const StatesComponent = () => {
|
|
682
|
-
const [open, setOpen] = useState(false);
|
|
683
|
-
const [loading, setLoading] = useState(false);
|
|
684
|
-
const [disabled, setDisabled] = useState(false);
|
|
685
|
-
|
|
686
|
-
return (
|
|
687
|
-
<>
|
|
688
|
-
<Stack direction="row" spacing={2}>
|
|
689
|
-
<Button
|
|
690
|
-
data-testid="open-normal"
|
|
691
|
-
variant="contained"
|
|
692
|
-
onClick={() => {
|
|
693
|
-
setLoading(false);
|
|
694
|
-
setDisabled(false);
|
|
695
|
-
setOpen(true);
|
|
696
|
-
}}
|
|
697
|
-
>
|
|
698
|
-
Normal
|
|
699
|
-
</Button>
|
|
700
|
-
<Button
|
|
701
|
-
data-testid="open-loading"
|
|
702
|
-
variant="contained"
|
|
703
|
-
onClick={() => {
|
|
704
|
-
setLoading(true);
|
|
705
|
-
setDisabled(false);
|
|
706
|
-
setOpen(true);
|
|
707
|
-
}}
|
|
708
|
-
>
|
|
709
|
-
Loading
|
|
710
|
-
</Button>
|
|
711
|
-
<Button
|
|
712
|
-
data-testid="open-disabled"
|
|
713
|
-
variant="contained"
|
|
714
|
-
onClick={() => {
|
|
715
|
-
setLoading(false);
|
|
716
|
-
setDisabled(true);
|
|
717
|
-
setOpen(true);
|
|
718
|
-
}}
|
|
719
|
-
>
|
|
720
|
-
Disabled
|
|
721
|
-
</Button>
|
|
722
|
-
</Stack>
|
|
723
|
-
<Sheet
|
|
724
|
-
open={open}
|
|
725
|
-
onOpenChange={setOpen}
|
|
726
|
-
title="Visual States"
|
|
727
|
-
loading={loading}
|
|
728
|
-
disabled={disabled}
|
|
729
|
-
data-testid="states-sheet"
|
|
730
|
-
>
|
|
731
|
-
<Typography>Content area</Typography>
|
|
732
|
-
</Sheet>
|
|
733
|
-
</>
|
|
734
|
-
);
|
|
735
|
-
};
|
|
736
|
-
|
|
737
|
-
return <StatesComponent />;
|
|
738
|
-
},
|
|
739
|
-
play: async ({ canvasElement, step }) => {
|
|
740
|
-
const canvas = within(canvasElement);
|
|
741
|
-
const body = within(document.body);
|
|
742
|
-
|
|
743
|
-
await step('Test normal state', async () => {
|
|
744
|
-
const openButton = canvas.getByTestId('open-normal');
|
|
745
|
-
await userEvent.click(openButton);
|
|
746
|
-
|
|
747
|
-
await waitFor(() => {
|
|
748
|
-
const sheets = body.getAllByRole('presentation');
|
|
749
|
-
const sheet = sheets[sheets.length - 1];
|
|
750
|
-
expect(sheet).toBeVisible();
|
|
751
|
-
});
|
|
752
|
-
|
|
753
|
-
// Note: Sheet closing behavior to be verified based on implementation
|
|
754
|
-
// The Sheet may keep content in DOM but hidden when closed
|
|
755
|
-
});
|
|
756
|
-
|
|
757
|
-
await step('Test loading state', async () => {
|
|
758
|
-
const openButton = canvas.getByTestId('open-loading');
|
|
759
|
-
await userEvent.click(openButton);
|
|
760
|
-
|
|
761
|
-
await waitFor(() => {
|
|
762
|
-
const spinner = body.getByRole('progressbar');
|
|
763
|
-
expect(spinner).toBeVisible();
|
|
764
|
-
});
|
|
765
|
-
|
|
766
|
-
// Close sheet
|
|
767
|
-
await userEvent.keyboard('{Escape}');
|
|
768
|
-
});
|
|
769
|
-
|
|
770
|
-
await step('Test disabled state', async () => {
|
|
771
|
-
const openButton = canvas.getByTestId('open-disabled');
|
|
772
|
-
await userEvent.click(openButton);
|
|
773
|
-
|
|
774
|
-
await waitFor(() => {
|
|
775
|
-
const sheets = body.getAllByRole('presentation');
|
|
776
|
-
const sheet = sheets[sheets.length - 1];
|
|
777
|
-
expect(sheet).toBeVisible();
|
|
778
|
-
// Note: Disabled state styling may vary based on implementation
|
|
779
|
-
// The component might use different opacity or other visual indicators
|
|
780
|
-
});
|
|
781
|
-
});
|
|
782
|
-
},
|
|
783
|
-
};
|
|
784
|
-
|
|
785
|
-
// ==================== Performance Tests ====================
|
|
786
|
-
|
|
787
|
-
export const Performance: Story = {
|
|
788
|
-
name: '⚡ Performance Test',
|
|
789
|
-
args: {
|
|
790
|
-
title: 'Performance Test Sheet',
|
|
791
|
-
onOpenChange: fn(),
|
|
792
|
-
onOpen: fn(),
|
|
793
|
-
onClose: fn(),
|
|
794
|
-
},
|
|
795
|
-
render: (args) => {
|
|
796
|
-
const items = Array.from({ length: 100 }, (_, i) => ({
|
|
797
|
-
id: i,
|
|
798
|
-
name: `Item ${i}`,
|
|
799
|
-
description: `Description for item ${i}`,
|
|
800
|
-
}));
|
|
801
|
-
|
|
802
|
-
return (
|
|
803
|
-
<TestWrapper {...args}>
|
|
804
|
-
<Box data-testid="scroll-container" sx={{ maxHeight: 400, overflow: 'auto' }}>
|
|
805
|
-
<List>
|
|
806
|
-
{items.map((item) => (
|
|
807
|
-
<ListItem key={item.id} data-testid={`item-${item.id}`}>
|
|
808
|
-
<ListItemText primary={item.name} secondary={item.description} />
|
|
809
|
-
</ListItem>
|
|
810
|
-
))}
|
|
811
|
-
</List>
|
|
812
|
-
</Box>
|
|
813
|
-
</TestWrapper>
|
|
814
|
-
);
|
|
815
|
-
},
|
|
816
|
-
play: async ({ canvasElement, step }) => {
|
|
817
|
-
const canvas = within(canvasElement);
|
|
818
|
-
const body = within(document.body);
|
|
819
|
-
|
|
820
|
-
await step('Open sheet', async () => {
|
|
821
|
-
const openButton = canvas.getByTestId('open-sheet-button');
|
|
822
|
-
await userEvent.click(openButton);
|
|
823
|
-
|
|
824
|
-
await waitFor(() => {
|
|
825
|
-
expect(body.getByTestId('scroll-container')).toBeVisible();
|
|
826
|
-
});
|
|
827
|
-
});
|
|
828
|
-
|
|
829
|
-
await step('All items render', async () => {
|
|
830
|
-
const elements = body.getAllByTestId(/item-/);
|
|
831
|
-
|
|
832
|
-
// The count is the assertion; a wall-clock budget would only measure
|
|
833
|
-
// whatever machine the story happens to run on.
|
|
834
|
-
await expect(elements.length).toBeGreaterThan(0);
|
|
835
|
-
});
|
|
836
|
-
|
|
837
|
-
await step('Test scroll performance', async () => {
|
|
838
|
-
const scrollContainer = body.getByTestId('scroll-container');
|
|
839
|
-
|
|
840
|
-
// Scrolling is what this story is about, so it has to move the container;
|
|
841
|
-
// what it must not do is assert a pixel offset, which depends on the
|
|
842
|
-
// viewport the story renders in.
|
|
843
|
-
// eslint-disable-next-line test-flakiness/no-viewport-dependent -- the subject under test is scrolling itself
|
|
844
|
-
scrollContainer.scrollTop = scrollContainer.scrollHeight;
|
|
845
|
-
fireEvent.scroll(scrollContainer);
|
|
846
|
-
|
|
847
|
-
// The list is not virtualised, so every item must survive the scroll —
|
|
848
|
-
// which the old assertion on the container could never have caught, since
|
|
849
|
-
// the container was already in the document before the loop ran.
|
|
850
|
-
await waitFor(() => {
|
|
851
|
-
expect(body.getAllByTestId(/^item-\d+$/).length).toBeGreaterThan(0);
|
|
852
|
-
});
|
|
853
|
-
});
|
|
854
|
-
},
|
|
855
|
-
};
|
|
856
|
-
|
|
857
|
-
// ==================== Edge Cases Tests ====================
|
|
858
|
-
|
|
859
|
-
export const EdgeCases: Story = {
|
|
860
|
-
name: '🔧 Edge Cases Test',
|
|
861
|
-
args: {
|
|
862
|
-
onOpenChange: fn(),
|
|
863
|
-
},
|
|
864
|
-
render: () => {
|
|
865
|
-
const EdgeCaseComponent = () => {
|
|
866
|
-
const [open, setOpen] = useState(false);
|
|
867
|
-
const [emptyOpen, setEmptyOpen] = useState(false);
|
|
868
|
-
const [longTextOpen, setLongTextOpen] = useState(false);
|
|
869
|
-
|
|
870
|
-
const longText = 'Lorem ipsum '.repeat(100);
|
|
871
|
-
|
|
872
|
-
return (
|
|
873
|
-
<>
|
|
874
|
-
<Stack direction="row" spacing={2}>
|
|
875
|
-
<Button data-testid="open-empty" variant="outlined" onClick={() => setEmptyOpen(true)}>
|
|
876
|
-
Empty Content
|
|
877
|
-
</Button>
|
|
878
|
-
<Button
|
|
879
|
-
data-testid="open-long"
|
|
880
|
-
variant="outlined"
|
|
881
|
-
onClick={() => setLongTextOpen(true)}
|
|
882
|
-
>
|
|
883
|
-
Long Text
|
|
884
|
-
</Button>
|
|
885
|
-
<Button data-testid="open-invalid" variant="outlined" onClick={() => setOpen(true)}>
|
|
886
|
-
Invalid Props
|
|
887
|
-
</Button>
|
|
888
|
-
</Stack>
|
|
889
|
-
|
|
890
|
-
<Sheet
|
|
891
|
-
open={emptyOpen}
|
|
892
|
-
onOpenChange={setEmptyOpen}
|
|
893
|
-
title="Empty Sheet"
|
|
894
|
-
data-testid="empty-sheet"
|
|
895
|
-
/>
|
|
896
|
-
|
|
897
|
-
<Sheet
|
|
898
|
-
open={longTextOpen}
|
|
899
|
-
onOpenChange={setLongTextOpen}
|
|
900
|
-
title="Long Content"
|
|
901
|
-
data-testid="long-sheet"
|
|
902
|
-
>
|
|
903
|
-
<Typography
|
|
904
|
-
data-testid="text-content"
|
|
905
|
-
sx={{
|
|
906
|
-
overflow: 'hidden',
|
|
907
|
-
textOverflow: 'ellipsis',
|
|
908
|
-
whiteSpace: 'nowrap',
|
|
909
|
-
}}
|
|
910
|
-
>
|
|
911
|
-
{longText}
|
|
912
|
-
</Typography>
|
|
913
|
-
</Sheet>
|
|
914
|
-
|
|
915
|
-
<Sheet
|
|
916
|
-
open={open}
|
|
917
|
-
onOpenChange={setOpen}
|
|
918
|
-
title="Test"
|
|
919
|
-
// Invalid props to test graceful handling
|
|
920
|
-
size={'invalid' as 'xs'}
|
|
921
|
-
position={'invalid' as 'top'}
|
|
922
|
-
data-testid="invalid-sheet"
|
|
923
|
-
>
|
|
924
|
-
<Typography data-testid="component">Sheet with invalid props</Typography>
|
|
925
|
-
</Sheet>
|
|
926
|
-
</>
|
|
927
|
-
);
|
|
928
|
-
};
|
|
929
|
-
|
|
930
|
-
return <EdgeCaseComponent />;
|
|
931
|
-
},
|
|
932
|
-
play: async ({ canvasElement, step }) => {
|
|
933
|
-
const canvas = within(canvasElement);
|
|
934
|
-
const body = within(document.body);
|
|
935
|
-
|
|
936
|
-
await step('Empty content handling', async () => {
|
|
937
|
-
const openButton = canvas.getByTestId('open-empty');
|
|
938
|
-
await userEvent.click(openButton);
|
|
939
|
-
|
|
940
|
-
await waitFor(() => {
|
|
941
|
-
const sheets = body.getAllByRole('presentation');
|
|
942
|
-
const sheet = sheets[sheets.length - 1];
|
|
943
|
-
expect(sheet).toBeVisible();
|
|
944
|
-
});
|
|
945
|
-
|
|
946
|
-
// Close empty sheet
|
|
947
|
-
await userEvent.keyboard('{Escape}');
|
|
948
|
-
await waitFor(() => {
|
|
949
|
-
const sheets = body.queryAllByRole('presentation');
|
|
950
|
-
expect(sheets.length).toBeLessThanOrEqual(1);
|
|
951
|
-
});
|
|
952
|
-
});
|
|
953
|
-
|
|
954
|
-
await step('Long text overflow', async () => {
|
|
955
|
-
const openButton = canvas.getByTestId('open-long');
|
|
956
|
-
await userEvent.click(openButton);
|
|
957
|
-
|
|
958
|
-
await waitFor(() => {
|
|
959
|
-
const textElement = body.getByTestId('text-content');
|
|
960
|
-
expect(textElement).toBeVisible();
|
|
961
|
-
const computedStyle = window.getComputedStyle(textElement);
|
|
962
|
-
expect(computedStyle.textOverflow).toBe('ellipsis');
|
|
963
|
-
});
|
|
964
|
-
|
|
965
|
-
// Note: Sheet closing behavior - element may remain in DOM but hidden
|
|
966
|
-
// Skip closing test as it depends on Sheet implementation
|
|
967
|
-
});
|
|
968
|
-
|
|
969
|
-
await step('Invalid props handling', async () => {
|
|
970
|
-
const openButton = canvas.getByTestId('open-invalid');
|
|
971
|
-
await userEvent.click(openButton);
|
|
972
|
-
|
|
973
|
-
await waitFor(() => {
|
|
974
|
-
const component = body.getByTestId('component');
|
|
975
|
-
expect(component).toBeVisible();
|
|
976
|
-
});
|
|
977
|
-
});
|
|
978
|
-
},
|
|
979
|
-
};
|
|
980
|
-
|
|
981
|
-
// ==================== Integration Tests ====================
|
|
982
|
-
|
|
983
|
-
export const Integration: Story = {
|
|
984
|
-
name: '🔗 Integration Test',
|
|
985
|
-
args: {
|
|
986
|
-
onOpenChange: fn(),
|
|
987
|
-
onOpen: fn(),
|
|
988
|
-
onClose: fn(),
|
|
989
|
-
},
|
|
990
|
-
render: () => {
|
|
991
|
-
const IntegrationComponent = () => {
|
|
992
|
-
const [mainOpen, setMainOpen] = useState(false);
|
|
993
|
-
const [nestedOpen, setNestedOpen] = useState(false);
|
|
994
|
-
const [message, setMessage] = useState('Initial');
|
|
995
|
-
|
|
996
|
-
return (
|
|
997
|
-
<>
|
|
998
|
-
<Button
|
|
999
|
-
data-testid="trigger-component"
|
|
1000
|
-
variant="contained"
|
|
1001
|
-
onClick={() => setMainOpen(true)}
|
|
1002
|
-
>
|
|
1003
|
-
Open Main Sheet
|
|
1004
|
-
</Button>
|
|
1005
|
-
|
|
1006
|
-
<Sheet open={mainOpen} onOpenChange={setMainOpen} title="Main Sheet" position="right">
|
|
1007
|
-
<Stack spacing={2}>
|
|
1008
|
-
<Typography data-testid="receiver-component">Status: {message}</Typography>
|
|
1009
|
-
<Button
|
|
1010
|
-
variant="contained"
|
|
1011
|
-
onClick={() => {
|
|
1012
|
-
setMessage('Updated');
|
|
1013
|
-
setNestedOpen(true);
|
|
1014
|
-
}}
|
|
1015
|
-
>
|
|
1016
|
-
Open Nested Sheet
|
|
1017
|
-
</Button>
|
|
1018
|
-
</Stack>
|
|
1019
|
-
</Sheet>
|
|
1020
|
-
|
|
1021
|
-
<Sheet
|
|
1022
|
-
open={nestedOpen}
|
|
1023
|
-
onOpenChange={setNestedOpen}
|
|
1024
|
-
title="Nested Sheet"
|
|
1025
|
-
position="bottom"
|
|
1026
|
-
size="sm"
|
|
1027
|
-
>
|
|
1028
|
-
<Typography>This is a nested sheet</Typography>
|
|
1029
|
-
</Sheet>
|
|
1030
|
-
</>
|
|
1031
|
-
);
|
|
1032
|
-
};
|
|
1033
|
-
|
|
1034
|
-
return <IntegrationComponent />;
|
|
1035
|
-
},
|
|
1036
|
-
play: async ({ canvasElement, step }) => {
|
|
1037
|
-
const canvas = within(canvasElement);
|
|
1038
|
-
const body = within(document.body);
|
|
1039
|
-
|
|
1040
|
-
await step('Open main sheet', async () => {
|
|
1041
|
-
const trigger = canvas.getByTestId('trigger-component');
|
|
1042
|
-
await userEvent.click(trigger);
|
|
1043
|
-
|
|
1044
|
-
await waitFor(() => {
|
|
1045
|
-
const receiver = body.getByTestId('receiver-component');
|
|
1046
|
-
expect(receiver).toHaveTextContent('Status: Initial');
|
|
1047
|
-
});
|
|
1048
|
-
});
|
|
1049
|
-
|
|
1050
|
-
await step('Communication between sheets', async () => {
|
|
1051
|
-
const buttons = body.getAllByRole('button');
|
|
1052
|
-
const nestedButton = buttons.find((btn) => btn.textContent?.includes('Open Nested'));
|
|
1053
|
-
if (nestedButton) {
|
|
1054
|
-
await userEvent.click(nestedButton);
|
|
1055
|
-
|
|
1056
|
-
await waitFor(() => {
|
|
1057
|
-
const receiver = body.getByTestId('receiver-component');
|
|
1058
|
-
expect(receiver).toHaveTextContent('Status: Updated');
|
|
1059
|
-
});
|
|
1060
|
-
}
|
|
1061
|
-
});
|
|
1062
|
-
},
|
|
1063
|
-
};
|
|
1064
|
-
|
|
1065
|
-
// ==================== Draggable Specific Tests ====================
|
|
1066
|
-
|
|
1067
|
-
export const DraggableInteraction: Story = {
|
|
1068
|
-
name: '🎯 Draggable Interaction Test',
|
|
1069
|
-
args: {
|
|
1070
|
-
variant: 'draggable',
|
|
1071
|
-
position: 'bottom',
|
|
1072
|
-
snapPoints: [0.25, 0.5, 0.75, 1],
|
|
1073
|
-
defaultSnapPoint: 0.5,
|
|
1074
|
-
onDragStart: fn(),
|
|
1075
|
-
onDragEnd: fn(),
|
|
1076
|
-
onSnapPointChange: fn(),
|
|
1077
|
-
onOpenChange: fn(),
|
|
1078
|
-
onOpen: fn(),
|
|
1079
|
-
onClose: fn(),
|
|
1080
|
-
},
|
|
1081
|
-
render: (args) => (
|
|
1082
|
-
<TestWrapper {...args} title="Draggable Test" showHandle>
|
|
1083
|
-
<Typography data-testid="draggable-content">Drag the handle to resize</Typography>
|
|
1084
|
-
</TestWrapper>
|
|
1085
|
-
),
|
|
1086
|
-
play: async ({ canvasElement, step }) => {
|
|
1087
|
-
const canvas = within(canvasElement);
|
|
1088
|
-
const body = within(document.body);
|
|
1089
|
-
|
|
1090
|
-
await step('Open draggable sheet', async () => {
|
|
1091
|
-
const openButton = canvas.getByTestId('open-sheet-button');
|
|
1092
|
-
await userEvent.click(openButton);
|
|
1093
|
-
|
|
1094
|
-
await waitFor(() => {
|
|
1095
|
-
expect(body.getByTestId('draggable-content')).toBeVisible();
|
|
1096
|
-
});
|
|
1097
|
-
});
|
|
1098
|
-
|
|
1099
|
-
// Note: Snap point verification depends on Sheet's draggable implementation
|
|
1100
|
-
// The component may or may not call onSnapPointChange on initial render
|
|
1101
|
-
|
|
1102
|
-
// Note: Actual drag gestures are difficult to simulate in Storybook tests
|
|
1103
|
-
// This would require more sophisticated testing with Playwright
|
|
1104
|
-
},
|
|
1105
|
-
};
|