@12-apps/ui 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +16 -8
- 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,1134 +0,0 @@
|
|
|
1
|
-
import Favorite from '@mui/icons-material/Favorite';
|
|
2
|
-
import MoreVert from '@mui/icons-material/MoreVert';
|
|
3
|
-
import Share from '@mui/icons-material/Share';
|
|
4
|
-
import { Avatar, Box,Button, Chip, IconButton, Stack, Typography } from '@mui/material';
|
|
5
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
6
|
-
import { expect, fn,userEvent, waitFor, within } from 'storybook/test';
|
|
7
|
-
|
|
8
|
-
import { Card, CardActions, CardContent, CardHeader, CardMedia } from './Card';
|
|
9
|
-
|
|
10
|
-
const meta: Meta<typeof Card> = {
|
|
11
|
-
title: 'Layout/Card/Tests',
|
|
12
|
-
component: Card,
|
|
13
|
-
parameters: {
|
|
14
|
-
layout: 'centered',
|
|
15
|
-
chromatic: { disableSnapshot: false },
|
|
16
|
-
},
|
|
17
|
-
tags: ['autodocs', 'test', 'component:Card'],
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default meta;
|
|
21
|
-
type Story = StoryObj<typeof meta>;
|
|
22
|
-
|
|
23
|
-
// Interaction Tests
|
|
24
|
-
export const BasicInteraction: Story = {
|
|
25
|
-
name: '🧪 Basic Interaction Test',
|
|
26
|
-
args: {
|
|
27
|
-
interactive: true,
|
|
28
|
-
onClick: fn(),
|
|
29
|
-
onFocus: fn(),
|
|
30
|
-
onBlur: fn(),
|
|
31
|
-
},
|
|
32
|
-
render: (args) => (
|
|
33
|
-
<Card {...args} data-testid="interactive-card" tabIndex={0} sx={{ width: 300 }}>
|
|
34
|
-
<CardContent>
|
|
35
|
-
<Typography variant="h6">Interactive Card</Typography>
|
|
36
|
-
<Typography variant="body2">Click or hover to interact</Typography>
|
|
37
|
-
</CardContent>
|
|
38
|
-
</Card>
|
|
39
|
-
),
|
|
40
|
-
play: async ({ canvasElement, step, args }) => {
|
|
41
|
-
const canvas = within(canvasElement);
|
|
42
|
-
|
|
43
|
-
await step('Initial render verification', async () => {
|
|
44
|
-
const card = canvas.getByTestId('interactive-card');
|
|
45
|
-
await expect(card).toBeInTheDocument();
|
|
46
|
-
await expect(card).toHaveStyle({ cursor: 'pointer' });
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
await step('Click interaction', async () => {
|
|
50
|
-
const card = canvas.getByTestId('interactive-card');
|
|
51
|
-
await userEvent.click(card);
|
|
52
|
-
await expect(args.onClick).toHaveBeenCalledTimes(1);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
await step('Keyboard interaction', async () => {
|
|
56
|
-
const card = canvas.getByTestId('interactive-card');
|
|
57
|
-
// Verify the card has tabIndex for keyboard accessibility
|
|
58
|
-
await expect(card).toHaveAttribute('tabIndex', '0');
|
|
59
|
-
|
|
60
|
-
// Verify the card can receive keyboard events
|
|
61
|
-
await userEvent.type(card, '{space}');
|
|
62
|
-
// The card should still be in the document after keyboard interaction
|
|
63
|
-
await expect(card).toBeInTheDocument();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
await step('Hover interaction', async () => {
|
|
67
|
-
const card = canvas.getByTestId('interactive-card');
|
|
68
|
-
await userEvent.hover(card);
|
|
69
|
-
// Interactive cards should have hover effects
|
|
70
|
-
// We'll verify the card is still interactive and responding
|
|
71
|
-
await expect(card).toHaveStyle({ cursor: 'pointer' });
|
|
72
|
-
// The hover state is applied via CSS, which may not be immediately detectable in tests
|
|
73
|
-
// We verify the card maintains its interactive state
|
|
74
|
-
await expect(card).toBeInTheDocument();
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const VariantStatesTest: Story = {
|
|
80
|
-
name: '🎨 Variant States Test',
|
|
81
|
-
render: () => (
|
|
82
|
-
<Stack spacing={2} direction="row" flexWrap="wrap">
|
|
83
|
-
<Card variant="elevated" data-testid="elevated-card" sx={{ width: 200 }}>
|
|
84
|
-
<CardContent>
|
|
85
|
-
<Typography>Elevated</Typography>
|
|
86
|
-
</CardContent>
|
|
87
|
-
</Card>
|
|
88
|
-
<Card variant="outlined" data-testid="outlined-card" sx={{ width: 200 }}>
|
|
89
|
-
<CardContent>
|
|
90
|
-
<Typography>Outlined</Typography>
|
|
91
|
-
</CardContent>
|
|
92
|
-
</Card>
|
|
93
|
-
<Card variant="glass" data-testid="glass-card" sx={{ width: 200 }}>
|
|
94
|
-
<CardContent>
|
|
95
|
-
<Typography>Glass</Typography>
|
|
96
|
-
</CardContent>
|
|
97
|
-
</Card>
|
|
98
|
-
<Card variant="gradient" data-testid="gradient-card" sx={{ width: 200 }}>
|
|
99
|
-
<CardContent>
|
|
100
|
-
<Typography>Gradient</Typography>
|
|
101
|
-
</CardContent>
|
|
102
|
-
</Card>
|
|
103
|
-
<Card variant="neumorphic" data-testid="neumorphic-card" sx={{ width: 200 }}>
|
|
104
|
-
<CardContent>
|
|
105
|
-
<Typography>Neumorphic</Typography>
|
|
106
|
-
</CardContent>
|
|
107
|
-
</Card>
|
|
108
|
-
</Stack>
|
|
109
|
-
),
|
|
110
|
-
play: async ({ canvasElement, step }) => {
|
|
111
|
-
const canvas = within(canvasElement);
|
|
112
|
-
|
|
113
|
-
await step('Verify elevated variant', async () => {
|
|
114
|
-
const card = canvas.getByTestId('elevated-card');
|
|
115
|
-
await expect(card).toBeInTheDocument();
|
|
116
|
-
const styles = window.getComputedStyle(card);
|
|
117
|
-
// Elevated cards should have box-shadow
|
|
118
|
-
await expect(styles.boxShadow).not.toBe('none');
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
await step('Verify outlined variant', async () => {
|
|
122
|
-
const card = canvas.getByTestId('outlined-card');
|
|
123
|
-
await expect(card).toBeInTheDocument();
|
|
124
|
-
const styles = window.getComputedStyle(card);
|
|
125
|
-
// Outlined cards should have border
|
|
126
|
-
await expect(styles.borderWidth).not.toBe('0px');
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
await step('Verify glass variant', async () => {
|
|
130
|
-
const card = canvas.getByTestId('glass-card');
|
|
131
|
-
await expect(card).toBeInTheDocument();
|
|
132
|
-
const styles = window.getComputedStyle(card);
|
|
133
|
-
// Glass cards should have backdrop filter
|
|
134
|
-
await expect(styles.backdropFilter || styles.webkitBackdropFilter).toContain('blur');
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
await step('Verify gradient variant', async () => {
|
|
138
|
-
const card = canvas.getByTestId('gradient-card');
|
|
139
|
-
await expect(card).toBeInTheDocument();
|
|
140
|
-
const styles = window.getComputedStyle(card);
|
|
141
|
-
// Gradient cards should have background-image or background
|
|
142
|
-
await expect(styles.background || styles.backgroundImage).toContain('gradient');
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
await step('Verify neumorphic variant', async () => {
|
|
146
|
-
const card = canvas.getByTestId('neumorphic-card');
|
|
147
|
-
await expect(card).toBeInTheDocument();
|
|
148
|
-
const styles = window.getComputedStyle(card);
|
|
149
|
-
// Neumorphic cards should have multiple shadows
|
|
150
|
-
await expect(styles.boxShadow).toContain(',');
|
|
151
|
-
});
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export const BorderRadiusTest: Story = {
|
|
156
|
-
name: '📐 Border Radius Test',
|
|
157
|
-
render: () => (
|
|
158
|
-
<Stack spacing={2} direction="row" flexWrap="wrap">
|
|
159
|
-
<Card borderRadius="none" data-testid="radius-none" sx={{ width: 150, height: 100 }}>
|
|
160
|
-
<CardContent>
|
|
161
|
-
<Typography variant="body2">None</Typography>
|
|
162
|
-
</CardContent>
|
|
163
|
-
</Card>
|
|
164
|
-
<Card borderRadius="sm" data-testid="radius-sm" sx={{ width: 150, height: 100 }}>
|
|
165
|
-
<CardContent>
|
|
166
|
-
<Typography variant="body2">Small</Typography>
|
|
167
|
-
</CardContent>
|
|
168
|
-
</Card>
|
|
169
|
-
<Card borderRadius="md" data-testid="radius-md" sx={{ width: 150, height: 100 }}>
|
|
170
|
-
<CardContent>
|
|
171
|
-
<Typography variant="body2">Medium</Typography>
|
|
172
|
-
</CardContent>
|
|
173
|
-
</Card>
|
|
174
|
-
<Card borderRadius="lg" data-testid="radius-lg" sx={{ width: 150, height: 100 }}>
|
|
175
|
-
<CardContent>
|
|
176
|
-
<Typography variant="body2">Large</Typography>
|
|
177
|
-
</CardContent>
|
|
178
|
-
</Card>
|
|
179
|
-
<Card borderRadius="xl" data-testid="radius-xl" sx={{ width: 150, height: 100 }}>
|
|
180
|
-
<CardContent>
|
|
181
|
-
<Typography variant="body2">Extra Large</Typography>
|
|
182
|
-
</CardContent>
|
|
183
|
-
</Card>
|
|
184
|
-
</Stack>
|
|
185
|
-
),
|
|
186
|
-
play: async ({ canvasElement, step }) => {
|
|
187
|
-
const canvas = within(canvasElement);
|
|
188
|
-
|
|
189
|
-
await step('Verify no border radius', async () => {
|
|
190
|
-
const card = canvas.getByTestId('radius-none');
|
|
191
|
-
const styles = window.getComputedStyle(card);
|
|
192
|
-
await expect(styles.borderRadius).toBe('0px');
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
await step('Verify small border radius', async () => {
|
|
196
|
-
const card = canvas.getByTestId('radius-sm');
|
|
197
|
-
const styles = window.getComputedStyle(card);
|
|
198
|
-
await expect(parseInt(styles.borderRadius)).toBeGreaterThan(0);
|
|
199
|
-
await expect(parseInt(styles.borderRadius)).toBeLessThanOrEqual(4);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
await step('Verify medium border radius', async () => {
|
|
203
|
-
const card = canvas.getByTestId('radius-md');
|
|
204
|
-
const styles = window.getComputedStyle(card);
|
|
205
|
-
await expect(parseInt(styles.borderRadius)).toBeGreaterThan(4);
|
|
206
|
-
await expect(parseInt(styles.borderRadius)).toBeLessThanOrEqual(8);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
await step('Verify large border radius', async () => {
|
|
210
|
-
const card = canvas.getByTestId('radius-lg');
|
|
211
|
-
const styles = window.getComputedStyle(card);
|
|
212
|
-
await expect(parseInt(styles.borderRadius)).toBeGreaterThan(8);
|
|
213
|
-
await expect(parseInt(styles.borderRadius)).toBeLessThanOrEqual(16);
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
await step('Verify extra large border radius', async () => {
|
|
217
|
-
const card = canvas.getByTestId('radius-xl');
|
|
218
|
-
const styles = window.getComputedStyle(card);
|
|
219
|
-
await expect(parseInt(styles.borderRadius)).toBeGreaterThan(16);
|
|
220
|
-
});
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
export const LoadingStateTest: Story = {
|
|
225
|
-
name: '⏳ Loading State Test',
|
|
226
|
-
args: {
|
|
227
|
-
loading: true,
|
|
228
|
-
},
|
|
229
|
-
render: (args) => (
|
|
230
|
-
<Card {...args} data-testid="loading-card" sx={{ width: 300, height: 200 }}>
|
|
231
|
-
<CardContent>
|
|
232
|
-
<Typography variant="h6">Loading Card</Typography>
|
|
233
|
-
<Typography variant="body2">Content should be dimmed</Typography>
|
|
234
|
-
</CardContent>
|
|
235
|
-
</Card>
|
|
236
|
-
),
|
|
237
|
-
play: async ({ canvasElement, step }) => {
|
|
238
|
-
const canvas = within(canvasElement);
|
|
239
|
-
|
|
240
|
-
await step('Verify loading state', async () => {
|
|
241
|
-
const card = canvas.getByTestId('loading-card');
|
|
242
|
-
await expect(card).toBeInTheDocument();
|
|
243
|
-
|
|
244
|
-
// Check for reduced opacity
|
|
245
|
-
const styles = window.getComputedStyle(card);
|
|
246
|
-
await expect(parseFloat(styles.opacity)).toBeLessThan(1);
|
|
247
|
-
|
|
248
|
-
// Check for disabled pointer events
|
|
249
|
-
await expect(styles.pointerEvents).toBe('none');
|
|
250
|
-
|
|
251
|
-
// Check for loading indicator
|
|
252
|
-
const progressIndicator = canvas.getByRole('progressbar');
|
|
253
|
-
await expect(progressIndicator).toBeInTheDocument();
|
|
254
|
-
});
|
|
255
|
-
},
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
export const GlowEffectTest: Story = {
|
|
259
|
-
name: '✨ Glow Effect Test',
|
|
260
|
-
args: {
|
|
261
|
-
glow: true,
|
|
262
|
-
},
|
|
263
|
-
render: (args) => (
|
|
264
|
-
<Card {...args} data-testid="glow-card" sx={{ width: 300 }}>
|
|
265
|
-
<CardContent>
|
|
266
|
-
<Typography variant="h6">Glowing Card</Typography>
|
|
267
|
-
<Typography variant="body2">This card has a glow effect</Typography>
|
|
268
|
-
</CardContent>
|
|
269
|
-
</Card>
|
|
270
|
-
),
|
|
271
|
-
play: async ({ canvasElement, step }) => {
|
|
272
|
-
const canvas = within(canvasElement);
|
|
273
|
-
|
|
274
|
-
await step('Verify glow effect', async () => {
|
|
275
|
-
const card = canvas.getByTestId('glow-card');
|
|
276
|
-
await expect(card).toBeInTheDocument();
|
|
277
|
-
|
|
278
|
-
const styles = window.getComputedStyle(card);
|
|
279
|
-
// Glow effect should add box-shadow with rgba
|
|
280
|
-
await expect(styles.boxShadow).toContain('rgba');
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
await step('Verify glow on hover', async () => {
|
|
284
|
-
const card = canvas.getByTestId('glow-card');
|
|
285
|
-
await userEvent.hover(card);
|
|
286
|
-
|
|
287
|
-
await waitFor(() => {
|
|
288
|
-
const styles = window.getComputedStyle(card);
|
|
289
|
-
// Box shadow should change on hover
|
|
290
|
-
expect(styles.boxShadow).toContain('rgba');
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
},
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
export const PulseAnimationTest: Story = {
|
|
297
|
-
name: '🔄 Pulse Animation Test',
|
|
298
|
-
args: {
|
|
299
|
-
pulse: true,
|
|
300
|
-
},
|
|
301
|
-
render: (args) => (
|
|
302
|
-
<Card {...args} data-testid="pulse-card" sx={{ width: 300 }}>
|
|
303
|
-
<CardContent>
|
|
304
|
-
<Typography variant="h6">Pulsing Card</Typography>
|
|
305
|
-
<Typography variant="body2">This card has a pulse animation</Typography>
|
|
306
|
-
</CardContent>
|
|
307
|
-
</Card>
|
|
308
|
-
),
|
|
309
|
-
play: async ({ canvasElement, step }) => {
|
|
310
|
-
const canvas = within(canvasElement);
|
|
311
|
-
|
|
312
|
-
await step('Verify pulse animation', async () => {
|
|
313
|
-
const card = canvas.getByTestId('pulse-card');
|
|
314
|
-
await expect(card).toBeInTheDocument();
|
|
315
|
-
|
|
316
|
-
// Check for ::after pseudo-element animation
|
|
317
|
-
const styles = window.getComputedStyle(card, '::after');
|
|
318
|
-
await expect(styles.animation || styles.animationName).toBeTruthy();
|
|
319
|
-
});
|
|
320
|
-
},
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
// Sub-component Tests
|
|
324
|
-
export const CardHeaderTest: Story = {
|
|
325
|
-
name: '📋 Card Header Test',
|
|
326
|
-
render: () => (
|
|
327
|
-
<Card sx={{ width: 400 }}>
|
|
328
|
-
<CardHeader
|
|
329
|
-
avatar={<Avatar data-testid="avatar">U</Avatar>}
|
|
330
|
-
action={
|
|
331
|
-
<IconButton data-testid="action-button">
|
|
332
|
-
<MoreVert />
|
|
333
|
-
</IconButton>
|
|
334
|
-
}
|
|
335
|
-
title="Card Header Title"
|
|
336
|
-
subtitle="Card Header Subtitle"
|
|
337
|
-
/>
|
|
338
|
-
<CardContent>
|
|
339
|
-
<Typography>Card content</Typography>
|
|
340
|
-
</CardContent>
|
|
341
|
-
</Card>
|
|
342
|
-
),
|
|
343
|
-
play: async ({ canvasElement, step }) => {
|
|
344
|
-
const canvas = within(canvasElement);
|
|
345
|
-
|
|
346
|
-
await step('Verify header components', async () => {
|
|
347
|
-
// Check avatar
|
|
348
|
-
const avatar = canvas.getByTestId('avatar');
|
|
349
|
-
await expect(avatar).toBeInTheDocument();
|
|
350
|
-
|
|
351
|
-
// Check action button
|
|
352
|
-
const actionButton = canvas.getByTestId('action-button');
|
|
353
|
-
await expect(actionButton).toBeInTheDocument();
|
|
354
|
-
|
|
355
|
-
// Check title text
|
|
356
|
-
const title = canvas.getByText('Card Header Title');
|
|
357
|
-
await expect(title).toBeInTheDocument();
|
|
358
|
-
|
|
359
|
-
// Check subtitle text
|
|
360
|
-
const subtitle = canvas.getByText('Card Header Subtitle');
|
|
361
|
-
await expect(subtitle).toBeInTheDocument();
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
await step('Test action button interaction', async () => {
|
|
365
|
-
const actionButton = canvas.getByTestId('action-button');
|
|
366
|
-
await userEvent.click(actionButton);
|
|
367
|
-
// Button should be clickable
|
|
368
|
-
await expect(actionButton).toBeEnabled();
|
|
369
|
-
});
|
|
370
|
-
},
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
export const CardContentTest: Story = {
|
|
374
|
-
name: '📄 Card Content Test',
|
|
375
|
-
render: () => (
|
|
376
|
-
<Stack spacing={2}>
|
|
377
|
-
<Card sx={{ width: 300 }}>
|
|
378
|
-
<CardContent data-testid="normal-content">
|
|
379
|
-
<Typography>Normal padding content</Typography>
|
|
380
|
-
</CardContent>
|
|
381
|
-
</Card>
|
|
382
|
-
<Card sx={{ width: 300 }}>
|
|
383
|
-
<CardContent dense data-testid="dense-content">
|
|
384
|
-
<Typography>Dense padding content</Typography>
|
|
385
|
-
</CardContent>
|
|
386
|
-
</Card>
|
|
387
|
-
</Stack>
|
|
388
|
-
),
|
|
389
|
-
play: async ({ canvasElement, step }) => {
|
|
390
|
-
const canvas = within(canvasElement);
|
|
391
|
-
|
|
392
|
-
await step('Verify normal content padding', async () => {
|
|
393
|
-
const content = canvas.getByTestId('normal-content');
|
|
394
|
-
const styles = window.getComputedStyle(content);
|
|
395
|
-
// Normal padding should be 16px (theme.spacing(2))
|
|
396
|
-
await expect(parseInt(styles.padding)).toBeGreaterThan(8);
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
await step('Verify dense content padding', async () => {
|
|
400
|
-
const content = canvas.getByTestId('dense-content');
|
|
401
|
-
const styles = window.getComputedStyle(content);
|
|
402
|
-
// Dense padding should be 8px (theme.spacing(1))
|
|
403
|
-
await expect(parseInt(styles.padding)).toBeLessThanOrEqual(8);
|
|
404
|
-
});
|
|
405
|
-
},
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
export const CardActionsTest: Story = {
|
|
409
|
-
name: '🎬 Card Actions Test',
|
|
410
|
-
render: () => (
|
|
411
|
-
<Stack spacing={2}>
|
|
412
|
-
<Card sx={{ width: 350 }}>
|
|
413
|
-
<CardContent>
|
|
414
|
-
<Typography>Left aligned actions</Typography>
|
|
415
|
-
</CardContent>
|
|
416
|
-
<CardActions alignment="left" data-testid="left-actions">
|
|
417
|
-
<Button size="small">Action 1</Button>
|
|
418
|
-
<Button size="small">Action 2</Button>
|
|
419
|
-
</CardActions>
|
|
420
|
-
</Card>
|
|
421
|
-
<Card sx={{ width: 350 }}>
|
|
422
|
-
<CardContent>
|
|
423
|
-
<Typography>Center aligned actions</Typography>
|
|
424
|
-
</CardContent>
|
|
425
|
-
<CardActions alignment="center" data-testid="center-actions">
|
|
426
|
-
<Button size="small">Action 1</Button>
|
|
427
|
-
<Button size="small">Action 2</Button>
|
|
428
|
-
</CardActions>
|
|
429
|
-
</Card>
|
|
430
|
-
<Card sx={{ width: 350 }}>
|
|
431
|
-
<CardContent>
|
|
432
|
-
<Typography>Right aligned actions</Typography>
|
|
433
|
-
</CardContent>
|
|
434
|
-
<CardActions alignment="right" data-testid="right-actions">
|
|
435
|
-
<Button size="small">Action 1</Button>
|
|
436
|
-
<Button size="small">Action 2</Button>
|
|
437
|
-
</CardActions>
|
|
438
|
-
</Card>
|
|
439
|
-
<Card sx={{ width: 350 }}>
|
|
440
|
-
<CardContent>
|
|
441
|
-
<Typography>Space between actions</Typography>
|
|
442
|
-
</CardContent>
|
|
443
|
-
<CardActions alignment="space-between" data-testid="space-between-actions">
|
|
444
|
-
<Button size="small">Left</Button>
|
|
445
|
-
<Button size="small">Right</Button>
|
|
446
|
-
</CardActions>
|
|
447
|
-
</Card>
|
|
448
|
-
</Stack>
|
|
449
|
-
),
|
|
450
|
-
play: async ({ canvasElement, step }) => {
|
|
451
|
-
const canvas = within(canvasElement);
|
|
452
|
-
|
|
453
|
-
await step('Verify left alignment', async () => {
|
|
454
|
-
const actions = canvas.getByTestId('left-actions');
|
|
455
|
-
const styles = window.getComputedStyle(actions);
|
|
456
|
-
await expect(styles.justifyContent).toBe('flex-start');
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
await step('Verify center alignment', async () => {
|
|
460
|
-
const actions = canvas.getByTestId('center-actions');
|
|
461
|
-
const styles = window.getComputedStyle(actions);
|
|
462
|
-
await expect(styles.justifyContent).toBe('center');
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
await step('Verify right alignment', async () => {
|
|
466
|
-
const actions = canvas.getByTestId('right-actions');
|
|
467
|
-
const styles = window.getComputedStyle(actions);
|
|
468
|
-
await expect(styles.justifyContent).toBe('flex-end');
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
await step('Verify space-between alignment', async () => {
|
|
472
|
-
const actions = canvas.getByTestId('space-between-actions');
|
|
473
|
-
const styles = window.getComputedStyle(actions);
|
|
474
|
-
await expect(styles.justifyContent).toBe('space-between');
|
|
475
|
-
});
|
|
476
|
-
},
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
export const CardMediaTest: Story = {
|
|
480
|
-
name: '🖼️ Card Media Test',
|
|
481
|
-
render: () => (
|
|
482
|
-
<Card sx={{ width: 350 }}>
|
|
483
|
-
<CardMedia
|
|
484
|
-
component="img"
|
|
485
|
-
height="200"
|
|
486
|
-
image="https://via.placeholder.com/350x200"
|
|
487
|
-
title="Test Image"
|
|
488
|
-
data-testid="card-media"
|
|
489
|
-
/>
|
|
490
|
-
<CardContent>
|
|
491
|
-
<Typography>Card with media</Typography>
|
|
492
|
-
</CardContent>
|
|
493
|
-
</Card>
|
|
494
|
-
),
|
|
495
|
-
play: async ({ canvasElement, step }) => {
|
|
496
|
-
const canvas = within(canvasElement);
|
|
497
|
-
|
|
498
|
-
await step('Verify media element', async () => {
|
|
499
|
-
const media = canvas.getByTestId('card-media');
|
|
500
|
-
await expect(media).toBeInTheDocument();
|
|
501
|
-
await expect(media.tagName.toLowerCase()).toBe('img');
|
|
502
|
-
await expect(media).toHaveAttribute('height', '200');
|
|
503
|
-
await expect(media).toHaveAttribute('title', 'Test Image');
|
|
504
|
-
});
|
|
505
|
-
},
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
// Accessibility Tests
|
|
509
|
-
export const KeyboardNavigationTest: Story = {
|
|
510
|
-
name: '⌨️ Keyboard Navigation Test',
|
|
511
|
-
render: () => (
|
|
512
|
-
<Stack spacing={2}>
|
|
513
|
-
<Card interactive onClick={fn()} data-testid="interactive-card-1" tabIndex={0}>
|
|
514
|
-
<CardContent>
|
|
515
|
-
<Typography>First Interactive Card</Typography>
|
|
516
|
-
</CardContent>
|
|
517
|
-
</Card>
|
|
518
|
-
<Card interactive onClick={fn()} data-testid="interactive-card-2" tabIndex={0}>
|
|
519
|
-
<CardContent>
|
|
520
|
-
<Typography>Second Interactive Card</Typography>
|
|
521
|
-
</CardContent>
|
|
522
|
-
</Card>
|
|
523
|
-
</Stack>
|
|
524
|
-
),
|
|
525
|
-
parameters: {
|
|
526
|
-
a11y: {
|
|
527
|
-
element: '#storybook-root',
|
|
528
|
-
config: {
|
|
529
|
-
rules: [
|
|
530
|
-
{ id: 'color-contrast', enabled: true },
|
|
531
|
-
{ id: 'aria-required-attr', enabled: true },
|
|
532
|
-
],
|
|
533
|
-
},
|
|
534
|
-
},
|
|
535
|
-
},
|
|
536
|
-
play: async ({ canvasElement, step }) => {
|
|
537
|
-
const canvas = within(canvasElement);
|
|
538
|
-
|
|
539
|
-
await step('Tab navigation forward', async () => {
|
|
540
|
-
const firstCard = canvas.getByTestId('interactive-card-1');
|
|
541
|
-
const secondCard = canvas.getByTestId('interactive-card-2');
|
|
542
|
-
|
|
543
|
-
// Tab in from the body rather than calling .focus() — that made the first
|
|
544
|
-
// assertion a tautology about the DOM honouring focus(), not about this
|
|
545
|
-
// card being the first tab stop.
|
|
546
|
-
await userEvent.tab();
|
|
547
|
-
await waitFor(() => expect(firstCard).toHaveFocus());
|
|
548
|
-
|
|
549
|
-
// Tab to next card
|
|
550
|
-
await userEvent.tab();
|
|
551
|
-
await waitFor(() => expect(secondCard).toHaveFocus());
|
|
552
|
-
});
|
|
553
|
-
|
|
554
|
-
await step('Tab navigation backward', async () => {
|
|
555
|
-
await userEvent.tab({ shift: true });
|
|
556
|
-
const firstCard = canvas.getByTestId('interactive-card-1');
|
|
557
|
-
await waitFor(() => expect(firstCard).toHaveFocus());
|
|
558
|
-
});
|
|
559
|
-
},
|
|
560
|
-
};
|
|
561
|
-
|
|
562
|
-
// Visual States Test
|
|
563
|
-
export const VisualStatesTest: Story = {
|
|
564
|
-
name: '👁️ Visual States Test',
|
|
565
|
-
render: () => (
|
|
566
|
-
<Stack spacing={2}>
|
|
567
|
-
<Card data-testid="normal-card" sx={{ width: 300 }}>
|
|
568
|
-
<CardContent>
|
|
569
|
-
<Typography>Normal State</Typography>
|
|
570
|
-
</CardContent>
|
|
571
|
-
</Card>
|
|
572
|
-
<Card interactive data-testid="hover-card" sx={{ width: 300 }}>
|
|
573
|
-
<CardContent>
|
|
574
|
-
<Typography>Hover State (interactive)</Typography>
|
|
575
|
-
</CardContent>
|
|
576
|
-
</Card>
|
|
577
|
-
<Card data-testid="disabled-card" sx={{ width: 300, opacity: 0.5, pointerEvents: 'none' }}>
|
|
578
|
-
<CardContent>
|
|
579
|
-
<Typography>Disabled State</Typography>
|
|
580
|
-
</CardContent>
|
|
581
|
-
</Card>
|
|
582
|
-
<Card loading data-testid="loading-state-card" sx={{ width: 300 }}>
|
|
583
|
-
<CardContent>
|
|
584
|
-
<Typography>Loading State</Typography>
|
|
585
|
-
</CardContent>
|
|
586
|
-
</Card>
|
|
587
|
-
</Stack>
|
|
588
|
-
),
|
|
589
|
-
play: async ({ canvasElement, step }) => {
|
|
590
|
-
const canvas = within(canvasElement);
|
|
591
|
-
|
|
592
|
-
await step('Default state', async () => {
|
|
593
|
-
const card = canvas.getByTestId('normal-card');
|
|
594
|
-
await expect(card).toHaveStyle({ opacity: '1' });
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
await step('Hover state', async () => {
|
|
598
|
-
const card = canvas.getByTestId('hover-card');
|
|
599
|
-
await userEvent.hover(card);
|
|
600
|
-
// Verify the card maintains its interactive styling
|
|
601
|
-
await expect(card).toHaveStyle({ cursor: 'pointer' });
|
|
602
|
-
await expect(card).toBeInTheDocument();
|
|
603
|
-
});
|
|
604
|
-
|
|
605
|
-
await step('Disabled state', async () => {
|
|
606
|
-
const card = canvas.getByTestId('disabled-card');
|
|
607
|
-
await expect(card).toHaveStyle({ opacity: '0.5' });
|
|
608
|
-
await expect(card).toHaveStyle({ pointerEvents: 'none' });
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
await step('Loading state', async () => {
|
|
612
|
-
const card = canvas.getByTestId('loading-state-card');
|
|
613
|
-
const styles = window.getComputedStyle(card);
|
|
614
|
-
await expect(parseFloat(styles.opacity)).toBeLessThan(1);
|
|
615
|
-
await expect(styles.pointerEvents).toBe('none');
|
|
616
|
-
});
|
|
617
|
-
},
|
|
618
|
-
};
|
|
619
|
-
|
|
620
|
-
// Responsive Design Test
|
|
621
|
-
export const ResponsiveDesignTest: Story = {
|
|
622
|
-
name: '📱 Responsive Design Test',
|
|
623
|
-
parameters: {
|
|
624
|
-
viewport: {
|
|
625
|
-
viewports: {
|
|
626
|
-
mobile: {
|
|
627
|
-
name: 'Mobile',
|
|
628
|
-
styles: { width: '375px', height: '667px' },
|
|
629
|
-
type: 'mobile',
|
|
630
|
-
},
|
|
631
|
-
tablet: {
|
|
632
|
-
name: 'Tablet',
|
|
633
|
-
styles: { width: '768px', height: '1024px' },
|
|
634
|
-
type: 'tablet',
|
|
635
|
-
},
|
|
636
|
-
desktop: {
|
|
637
|
-
name: 'Desktop',
|
|
638
|
-
styles: { width: '1920px', height: '1080px' },
|
|
639
|
-
type: 'desktop',
|
|
640
|
-
},
|
|
641
|
-
},
|
|
642
|
-
defaultViewport: 'mobile',
|
|
643
|
-
},
|
|
644
|
-
chromatic: {
|
|
645
|
-
viewports: [375, 768, 1920],
|
|
646
|
-
delay: 300,
|
|
647
|
-
},
|
|
648
|
-
},
|
|
649
|
-
render: () => (
|
|
650
|
-
<Box
|
|
651
|
-
data-testid="responsive-container"
|
|
652
|
-
sx={{
|
|
653
|
-
display: 'grid',
|
|
654
|
-
gridTemplateColumns: {
|
|
655
|
-
xs: '1fr',
|
|
656
|
-
sm: 'repeat(2, 1fr)',
|
|
657
|
-
md: 'repeat(3, 1fr)',
|
|
658
|
-
},
|
|
659
|
-
gap: 2,
|
|
660
|
-
}}
|
|
661
|
-
>
|
|
662
|
-
<Card>
|
|
663
|
-
<CardContent>
|
|
664
|
-
<Typography>Card 1</Typography>
|
|
665
|
-
</CardContent>
|
|
666
|
-
</Card>
|
|
667
|
-
<Card>
|
|
668
|
-
<CardContent>
|
|
669
|
-
<Typography>Card 2</Typography>
|
|
670
|
-
</CardContent>
|
|
671
|
-
</Card>
|
|
672
|
-
<Card>
|
|
673
|
-
<CardContent>
|
|
674
|
-
<Typography>Card 3</Typography>
|
|
675
|
-
</CardContent>
|
|
676
|
-
</Card>
|
|
677
|
-
</Box>
|
|
678
|
-
),
|
|
679
|
-
play: async ({ canvasElement, step }) => {
|
|
680
|
-
const canvas = within(canvasElement);
|
|
681
|
-
|
|
682
|
-
await step('Verify responsive grid', async () => {
|
|
683
|
-
const container = canvas.getByTestId('responsive-container');
|
|
684
|
-
const computedStyle = window.getComputedStyle(container);
|
|
685
|
-
|
|
686
|
-
// Check grid template columns based on viewport
|
|
687
|
-
const columns = computedStyle.gridTemplateColumns;
|
|
688
|
-
await expect(columns).toBeTruthy();
|
|
689
|
-
});
|
|
690
|
-
},
|
|
691
|
-
};
|
|
692
|
-
|
|
693
|
-
// Edge Cases Test
|
|
694
|
-
export const EdgeCasesTest: Story = {
|
|
695
|
-
name: '🔧 Edge Cases Test',
|
|
696
|
-
render: () => (
|
|
697
|
-
<Stack spacing={2}>
|
|
698
|
-
<Card data-testid="empty-card" sx={{ width: 300, minHeight: 100 }}>
|
|
699
|
-
{/* Empty card */}
|
|
700
|
-
</Card>
|
|
701
|
-
<Card data-testid="overflow-card" sx={{ width: 200, height: 100, overflow: 'hidden' }}>
|
|
702
|
-
<CardContent>
|
|
703
|
-
<Typography data-testid="long-text" noWrap>
|
|
704
|
-
This is a very long text that should be truncated with ellipsis when it overflows the
|
|
705
|
-
card boundaries
|
|
706
|
-
</Typography>
|
|
707
|
-
</CardContent>
|
|
708
|
-
</Card>
|
|
709
|
-
<Card data-testid="nested-card" sx={{ width: 350 }}>
|
|
710
|
-
<CardContent>
|
|
711
|
-
<Typography>Parent Card</Typography>
|
|
712
|
-
<Card sx={{ mt: 2 }}>
|
|
713
|
-
<CardContent>
|
|
714
|
-
<Typography variant="body2">Nested Card</Typography>
|
|
715
|
-
</CardContent>
|
|
716
|
-
</Card>
|
|
717
|
-
</CardContent>
|
|
718
|
-
</Card>
|
|
719
|
-
</Stack>
|
|
720
|
-
),
|
|
721
|
-
play: async ({ canvasElement, step }) => {
|
|
722
|
-
const canvas = within(canvasElement);
|
|
723
|
-
|
|
724
|
-
await step('Empty card handling', async () => {
|
|
725
|
-
const emptyCard = canvas.getByTestId('empty-card');
|
|
726
|
-
await expect(emptyCard).toBeInTheDocument();
|
|
727
|
-
await expect(emptyCard.children.length).toBeGreaterThanOrEqual(0);
|
|
728
|
-
});
|
|
729
|
-
|
|
730
|
-
await step('Long text overflow', async () => {
|
|
731
|
-
const textElement = canvas.getByTestId('long-text');
|
|
732
|
-
const computedStyle = window.getComputedStyle(textElement);
|
|
733
|
-
await expect(computedStyle.textOverflow).toBe('ellipsis');
|
|
734
|
-
await expect(computedStyle.overflow).toBe('hidden');
|
|
735
|
-
});
|
|
736
|
-
|
|
737
|
-
await step('Nested cards', async () => {
|
|
738
|
-
const nestedCard = canvas.getByTestId('nested-card');
|
|
739
|
-
const innerCards = within(nestedCard).getAllByText(/Card/);
|
|
740
|
-
await expect(innerCards.length).toBeGreaterThan(1);
|
|
741
|
-
});
|
|
742
|
-
},
|
|
743
|
-
};
|
|
744
|
-
|
|
745
|
-
// Screen Reader Test
|
|
746
|
-
export const ScreenReaderTest: Story = {
|
|
747
|
-
name: '🔊 Screen Reader Test',
|
|
748
|
-
render: () => (
|
|
749
|
-
<Stack spacing={2}>
|
|
750
|
-
<Card
|
|
751
|
-
interactive
|
|
752
|
-
onClick={fn()}
|
|
753
|
-
data-testid="accessible-card"
|
|
754
|
-
role="button"
|
|
755
|
-
aria-label="Interactive card with important information"
|
|
756
|
-
tabIndex={0}
|
|
757
|
-
>
|
|
758
|
-
<CardContent>
|
|
759
|
-
<Typography variant="h6" id="card-title">
|
|
760
|
-
Important Announcement
|
|
761
|
-
</Typography>
|
|
762
|
-
<Typography variant="body2" aria-describedby="card-title">
|
|
763
|
-
This card contains accessible content for screen readers
|
|
764
|
-
</Typography>
|
|
765
|
-
</CardContent>
|
|
766
|
-
</Card>
|
|
767
|
-
<Card data-testid="semantic-card">
|
|
768
|
-
<CardHeader
|
|
769
|
-
title={
|
|
770
|
-
<span role="heading" aria-level={3}>
|
|
771
|
-
Card Title
|
|
772
|
-
</span>
|
|
773
|
-
}
|
|
774
|
-
subtitle="Card Subtitle"
|
|
775
|
-
/>
|
|
776
|
-
<CardContent>
|
|
777
|
-
<Typography component="p">Semantic HTML structure for screen readers</Typography>
|
|
778
|
-
</CardContent>
|
|
779
|
-
<CardActions>
|
|
780
|
-
<Button aria-label="Like this card">Like</Button>
|
|
781
|
-
<Button aria-label="Share this card">Share</Button>
|
|
782
|
-
</CardActions>
|
|
783
|
-
</Card>
|
|
784
|
-
</Stack>
|
|
785
|
-
),
|
|
786
|
-
parameters: {
|
|
787
|
-
a11y: {
|
|
788
|
-
element: '#storybook-root',
|
|
789
|
-
config: {
|
|
790
|
-
rules: [
|
|
791
|
-
{ id: 'aria-required-attr', enabled: true },
|
|
792
|
-
{ id: 'aria-valid-attr', enabled: true },
|
|
793
|
-
{ id: 'button-name', enabled: true },
|
|
794
|
-
{ id: 'color-contrast', enabled: true },
|
|
795
|
-
{ id: 'label', enabled: true },
|
|
796
|
-
],
|
|
797
|
-
},
|
|
798
|
-
},
|
|
799
|
-
},
|
|
800
|
-
play: async ({ canvasElement, step }) => {
|
|
801
|
-
const canvas = within(canvasElement);
|
|
802
|
-
|
|
803
|
-
await step('Verify ARIA attributes', async () => {
|
|
804
|
-
const accessibleCard = canvas.getByTestId('accessible-card');
|
|
805
|
-
await expect(accessibleCard).toHaveAttribute('role', 'button');
|
|
806
|
-
await expect(accessibleCard).toHaveAttribute('aria-label');
|
|
807
|
-
await expect(accessibleCard).toHaveAttribute('tabIndex', '0');
|
|
808
|
-
});
|
|
809
|
-
|
|
810
|
-
await step('Verify semantic HTML', async () => {
|
|
811
|
-
const heading = canvas.getByRole('heading', { level: 3 });
|
|
812
|
-
await expect(heading).toBeInTheDocument();
|
|
813
|
-
|
|
814
|
-
const buttons = canvas.getAllByRole('button', { name: /Like|Share/ });
|
|
815
|
-
await expect(buttons).toHaveLength(2);
|
|
816
|
-
});
|
|
817
|
-
|
|
818
|
-
await step('Keyboard activation', async () => {
|
|
819
|
-
const accessibleCard = canvas.getByTestId('accessible-card');
|
|
820
|
-
|
|
821
|
-
// Tab in rather than calling .focus(), so this covers the card actually
|
|
822
|
-
// being reachable by keyboard, and assert focus survives Enter — pressing
|
|
823
|
-
// Enter on a card must not send focus somewhere else.
|
|
824
|
-
await userEvent.tab();
|
|
825
|
-
await waitFor(() => expect(accessibleCard).toHaveFocus());
|
|
826
|
-
|
|
827
|
-
await userEvent.keyboard('{Enter}');
|
|
828
|
-
await waitFor(() => expect(accessibleCard).toHaveFocus());
|
|
829
|
-
});
|
|
830
|
-
},
|
|
831
|
-
};
|
|
832
|
-
|
|
833
|
-
// Focus Management Test
|
|
834
|
-
export const FocusManagementTest: Story = {
|
|
835
|
-
name: '🎯 Focus Management Test',
|
|
836
|
-
render: () => (
|
|
837
|
-
<Stack spacing={2}>
|
|
838
|
-
<Card interactive data-testid="focus-card-1" tabIndex={0} onFocus={fn()} onBlur={fn()}>
|
|
839
|
-
<CardContent>
|
|
840
|
-
<Typography>Focus Card 1</Typography>
|
|
841
|
-
<Button data-testid="inner-button-1">Inner Button</Button>
|
|
842
|
-
</CardContent>
|
|
843
|
-
</Card>
|
|
844
|
-
<Card interactive data-testid="focus-card-2" tabIndex={0}>
|
|
845
|
-
<CardContent>
|
|
846
|
-
<Typography>Focus Card 2</Typography>
|
|
847
|
-
<Button data-testid="inner-button-2">Inner Button</Button>
|
|
848
|
-
</CardContent>
|
|
849
|
-
</Card>
|
|
850
|
-
</Stack>
|
|
851
|
-
),
|
|
852
|
-
play: async ({ canvasElement, step }) => {
|
|
853
|
-
const canvas = within(canvasElement);
|
|
854
|
-
|
|
855
|
-
await step('Focus trap within card', async () => {
|
|
856
|
-
const card1 = canvas.getByTestId('focus-card-1');
|
|
857
|
-
const innerButton1 = canvas.getByTestId('inner-button-1');
|
|
858
|
-
|
|
859
|
-
// Tab in from the body. contains() is true for the node itself, so this
|
|
860
|
-
// holds whether the card is its own tab stop or focus goes straight to the
|
|
861
|
-
// button inside it.
|
|
862
|
-
await userEvent.tab();
|
|
863
|
-
await waitFor(() => expect(card1.contains(document.activeElement)).toBeTruthy());
|
|
864
|
-
|
|
865
|
-
// Whether the card is a tab stop of its own is a Card implementation
|
|
866
|
-
// detail, so step forward only if focus is not already on the button. The
|
|
867
|
-
// previous version wrapped the assertion itself in that condition, which
|
|
868
|
-
// meant one of its two paths asserted nothing at all.
|
|
869
|
-
if (document.activeElement !== innerButton1) {
|
|
870
|
-
await userEvent.tab();
|
|
871
|
-
}
|
|
872
|
-
await waitFor(() => expect(innerButton1).toHaveFocus());
|
|
873
|
-
});
|
|
874
|
-
|
|
875
|
-
await step('Focus visibility', async () => {
|
|
876
|
-
const card1 = canvas.getByTestId('focus-card-1');
|
|
877
|
-
// Focus is already inside card 1 from the previous step.
|
|
878
|
-
await waitFor(() => expect(card1.contains(document.activeElement)).toBeTruthy());
|
|
879
|
-
|
|
880
|
-
// Check for focus ring (outline)
|
|
881
|
-
const styles = window.getComputedStyle(card1);
|
|
882
|
-
await expect(styles.outline || styles.outlineWidth).toBeTruthy();
|
|
883
|
-
});
|
|
884
|
-
|
|
885
|
-
await step('Focus restoration', async () => {
|
|
886
|
-
const card1 = canvas.getByTestId('focus-card-1');
|
|
887
|
-
const card2 = canvas.getByTestId('focus-card-2');
|
|
888
|
-
|
|
889
|
-
// Continue the journey forward out of card 1 and into card 2...
|
|
890
|
-
await userEvent.tab();
|
|
891
|
-
await waitFor(() => expect(card2.contains(document.activeElement)).toBeTruthy());
|
|
892
|
-
|
|
893
|
-
// ...then shift-tab back, which is the restoration this step is named for.
|
|
894
|
-
// Calling .focus() on each card in turn only proved that focus() works.
|
|
895
|
-
await userEvent.tab({ shift: true });
|
|
896
|
-
await waitFor(() => expect(card1.contains(document.activeElement)).toBeTruthy());
|
|
897
|
-
});
|
|
898
|
-
},
|
|
899
|
-
};
|
|
900
|
-
|
|
901
|
-
// Theme Variations Test
|
|
902
|
-
export const ThemeVariationsTest: Story = {
|
|
903
|
-
name: '🎨 Theme Variations Test',
|
|
904
|
-
render: () => (
|
|
905
|
-
<Stack spacing={2}>
|
|
906
|
-
<Box sx={{ p: 2, backgroundColor: 'background.default' }}>
|
|
907
|
-
<Typography variant="h6" gutterBottom>
|
|
908
|
-
Light Theme
|
|
909
|
-
</Typography>
|
|
910
|
-
<Stack direction="row" spacing={2}>
|
|
911
|
-
<Card variant="elevated" data-testid="light-elevated">
|
|
912
|
-
<CardContent>
|
|
913
|
-
<Typography>Elevated</Typography>
|
|
914
|
-
</CardContent>
|
|
915
|
-
</Card>
|
|
916
|
-
<Card variant="outlined" data-testid="light-outlined">
|
|
917
|
-
<CardContent>
|
|
918
|
-
<Typography>Outlined</Typography>
|
|
919
|
-
</CardContent>
|
|
920
|
-
</Card>
|
|
921
|
-
<Card variant="glass" data-testid="light-glass">
|
|
922
|
-
<CardContent>
|
|
923
|
-
<Typography>Glass</Typography>
|
|
924
|
-
</CardContent>
|
|
925
|
-
</Card>
|
|
926
|
-
</Stack>
|
|
927
|
-
</Box>
|
|
928
|
-
<Box sx={{ p: 2, backgroundColor: 'grey.900', color: 'white' }}>
|
|
929
|
-
<Typography variant="h6" gutterBottom>
|
|
930
|
-
Dark Theme Simulation
|
|
931
|
-
</Typography>
|
|
932
|
-
<Stack direction="row" spacing={2}>
|
|
933
|
-
<Card variant="elevated" data-testid="dark-elevated">
|
|
934
|
-
<CardContent>
|
|
935
|
-
<Typography>Elevated</Typography>
|
|
936
|
-
</CardContent>
|
|
937
|
-
</Card>
|
|
938
|
-
<Card variant="outlined" data-testid="dark-outlined">
|
|
939
|
-
<CardContent>
|
|
940
|
-
<Typography>Outlined</Typography>
|
|
941
|
-
</CardContent>
|
|
942
|
-
</Card>
|
|
943
|
-
<Card variant="neumorphic" data-testid="dark-neumorphic">
|
|
944
|
-
<CardContent>
|
|
945
|
-
<Typography>Neumorphic</Typography>
|
|
946
|
-
</CardContent>
|
|
947
|
-
</Card>
|
|
948
|
-
</Stack>
|
|
949
|
-
</Box>
|
|
950
|
-
</Stack>
|
|
951
|
-
),
|
|
952
|
-
play: async ({ canvasElement, step }) => {
|
|
953
|
-
const canvas = within(canvasElement);
|
|
954
|
-
|
|
955
|
-
await step('Light theme variants', async () => {
|
|
956
|
-
const lightElevated = canvas.getByTestId('light-elevated');
|
|
957
|
-
const lightOutlined = canvas.getByTestId('light-outlined');
|
|
958
|
-
const lightGlass = canvas.getByTestId('light-glass');
|
|
959
|
-
|
|
960
|
-
await expect(lightElevated).toBeInTheDocument();
|
|
961
|
-
await expect(lightOutlined).toBeInTheDocument();
|
|
962
|
-
await expect(lightGlass).toBeInTheDocument();
|
|
963
|
-
});
|
|
964
|
-
|
|
965
|
-
await step('Dark theme variants', async () => {
|
|
966
|
-
const darkElevated = canvas.getByTestId('dark-elevated');
|
|
967
|
-
const darkOutlined = canvas.getByTestId('dark-outlined');
|
|
968
|
-
const darkNeumorphic = canvas.getByTestId('dark-neumorphic');
|
|
969
|
-
|
|
970
|
-
await expect(darkElevated).toBeInTheDocument();
|
|
971
|
-
await expect(darkOutlined).toBeInTheDocument();
|
|
972
|
-
await expect(darkNeumorphic).toBeInTheDocument();
|
|
973
|
-
|
|
974
|
-
// Neumorphic should have special shadow treatment
|
|
975
|
-
const neumorphicStyles = window.getComputedStyle(darkNeumorphic);
|
|
976
|
-
await expect(neumorphicStyles.boxShadow).toContain(',');
|
|
977
|
-
});
|
|
978
|
-
},
|
|
979
|
-
};
|
|
980
|
-
|
|
981
|
-
// Performance Test
|
|
982
|
-
export const PerformanceTest: Story = {
|
|
983
|
-
name: '⚡ Performance Test',
|
|
984
|
-
render: () => {
|
|
985
|
-
const cards = Array.from({ length: 50 }, (_, i) => ({
|
|
986
|
-
id: i,
|
|
987
|
-
title: `Card ${i + 1}`,
|
|
988
|
-
content: `Content for card ${i + 1}`,
|
|
989
|
-
}));
|
|
990
|
-
|
|
991
|
-
return (
|
|
992
|
-
<Box
|
|
993
|
-
data-testid="performance-container"
|
|
994
|
-
sx={{
|
|
995
|
-
display: 'grid',
|
|
996
|
-
gridTemplateColumns: 'repeat(auto-fill, minmax(200px, 1fr))',
|
|
997
|
-
gap: 2,
|
|
998
|
-
maxHeight: '600px',
|
|
999
|
-
overflow: 'auto',
|
|
1000
|
-
}}
|
|
1001
|
-
>
|
|
1002
|
-
{cards.map((card) => (
|
|
1003
|
-
<Card
|
|
1004
|
-
key={card.id}
|
|
1005
|
-
data-testid={`perf-card-${card.id}`}
|
|
1006
|
-
variant={card.id % 2 === 0 ? 'elevated' : 'outlined'}
|
|
1007
|
-
interactive={card.id % 3 === 0}
|
|
1008
|
-
>
|
|
1009
|
-
<CardContent>
|
|
1010
|
-
<Typography variant="h6">{card.title}</Typography>
|
|
1011
|
-
<Typography variant="body2">{card.content}</Typography>
|
|
1012
|
-
</CardContent>
|
|
1013
|
-
</Card>
|
|
1014
|
-
))}
|
|
1015
|
-
</Box>
|
|
1016
|
-
);
|
|
1017
|
-
},
|
|
1018
|
-
play: async ({ canvasElement, step }) => {
|
|
1019
|
-
const canvas = within(canvasElement);
|
|
1020
|
-
|
|
1021
|
-
await step('Render performance', async () => {
|
|
1022
|
-
const container = canvas.getByTestId('performance-container');
|
|
1023
|
-
await expect(container).toBeInTheDocument();
|
|
1024
|
-
|
|
1025
|
-
// Check that all cards rendered
|
|
1026
|
-
const cards = canvas.getAllByTestId(/^perf-card-/);
|
|
1027
|
-
await expect(cards).toHaveLength(50);
|
|
1028
|
-
|
|
1029
|
-
// No wall-clock budget here: the queries above run against DOM that has
|
|
1030
|
-
// already rendered, so a duration around them measures query time, and any
|
|
1031
|
-
// millisecond threshold is really a bet on how loaded the CI runner is.
|
|
1032
|
-
});
|
|
1033
|
-
|
|
1034
|
-
await step('Interaction performance', async () => {
|
|
1035
|
-
const interactiveCard = canvas.getByTestId('perf-card-0');
|
|
1036
|
-
|
|
1037
|
-
await userEvent.hover(interactiveCard);
|
|
1038
|
-
await userEvent.unhover(interactiveCard);
|
|
1039
|
-
|
|
1040
|
-
// The card survives a hover/unhover cycle. Timing it was a runner-speed
|
|
1041
|
-
// assertion, not a component one.
|
|
1042
|
-
await expect(interactiveCard).toBeInTheDocument();
|
|
1043
|
-
});
|
|
1044
|
-
|
|
1045
|
-
await step('Memory efficiency', async () => {
|
|
1046
|
-
// Check that components are properly garbage collected
|
|
1047
|
-
const cards = canvas.getAllByTestId(/^perf-card-/);
|
|
1048
|
-
|
|
1049
|
-
// Each card should be a unique DOM element
|
|
1050
|
-
const uniqueElements = new Set(cards);
|
|
1051
|
-
await expect(uniqueElements.size).toBe(50);
|
|
1052
|
-
});
|
|
1053
|
-
},
|
|
1054
|
-
};
|
|
1055
|
-
|
|
1056
|
-
// Integration Test
|
|
1057
|
-
export const IntegrationWithOtherComponentsTest: Story = {
|
|
1058
|
-
name: '🔗 Integration Test',
|
|
1059
|
-
render: () => (
|
|
1060
|
-
<Card sx={{ width: 400 }}>
|
|
1061
|
-
<CardHeader
|
|
1062
|
-
avatar={<Avatar>JD</Avatar>}
|
|
1063
|
-
action={
|
|
1064
|
-
<IconButton>
|
|
1065
|
-
<MoreVert />
|
|
1066
|
-
</IconButton>
|
|
1067
|
-
}
|
|
1068
|
-
title="John Doe"
|
|
1069
|
-
subtitle="Software Engineer"
|
|
1070
|
-
/>
|
|
1071
|
-
<CardMedia
|
|
1072
|
-
component="img"
|
|
1073
|
-
height="200"
|
|
1074
|
-
image="https://via.placeholder.com/400x200"
|
|
1075
|
-
title="Profile Banner"
|
|
1076
|
-
/>
|
|
1077
|
-
<CardContent>
|
|
1078
|
-
<Stack spacing={1}>
|
|
1079
|
-
<Typography variant="body1">Full-stack developer with 5 years of experience</Typography>
|
|
1080
|
-
<Stack direction="row" spacing={1}>
|
|
1081
|
-
<Chip label="React" size="small" />
|
|
1082
|
-
<Chip label="TypeScript" size="small" />
|
|
1083
|
-
<Chip label="Node.js" size="small" />
|
|
1084
|
-
</Stack>
|
|
1085
|
-
</Stack>
|
|
1086
|
-
</CardContent>
|
|
1087
|
-
<CardActions alignment="space-between">
|
|
1088
|
-
<Stack direction="row" spacing={1}>
|
|
1089
|
-
<IconButton size="small">
|
|
1090
|
-
<Favorite />
|
|
1091
|
-
</IconButton>
|
|
1092
|
-
<IconButton size="small">
|
|
1093
|
-
<Share />
|
|
1094
|
-
</IconButton>
|
|
1095
|
-
</Stack>
|
|
1096
|
-
<Button variant="contained" size="small">
|
|
1097
|
-
Contact
|
|
1098
|
-
</Button>
|
|
1099
|
-
</CardActions>
|
|
1100
|
-
</Card>
|
|
1101
|
-
),
|
|
1102
|
-
play: async ({ canvasElement, step }) => {
|
|
1103
|
-
const canvas = within(canvasElement);
|
|
1104
|
-
|
|
1105
|
-
await step('Verify all card sections', async () => {
|
|
1106
|
-
// Header
|
|
1107
|
-
const title = canvas.getByText('John Doe');
|
|
1108
|
-
await expect(title).toBeInTheDocument();
|
|
1109
|
-
|
|
1110
|
-
// Media
|
|
1111
|
-
const media = canvas.getByTitle('Profile Banner');
|
|
1112
|
-
await expect(media).toBeInTheDocument();
|
|
1113
|
-
|
|
1114
|
-
// Content with chips
|
|
1115
|
-
// Chips might be rendered as buttons or divs depending on MUI version
|
|
1116
|
-
const reactChip = canvas.getByText('React');
|
|
1117
|
-
const tsChip = canvas.getByText('TypeScript');
|
|
1118
|
-
const nodeChip = canvas.getByText('Node.js');
|
|
1119
|
-
await expect(reactChip).toBeInTheDocument();
|
|
1120
|
-
await expect(tsChip).toBeInTheDocument();
|
|
1121
|
-
await expect(nodeChip).toBeInTheDocument();
|
|
1122
|
-
|
|
1123
|
-
// Actions
|
|
1124
|
-
const contactButton = canvas.getByRole('button', { name: /Contact/i });
|
|
1125
|
-
await expect(contactButton).toBeInTheDocument();
|
|
1126
|
-
});
|
|
1127
|
-
|
|
1128
|
-
await step('Test integrated interactions', async () => {
|
|
1129
|
-
const contactButton = canvas.getByRole('button', { name: /Contact/i });
|
|
1130
|
-
await userEvent.click(contactButton);
|
|
1131
|
-
await expect(contactButton).toBeEnabled();
|
|
1132
|
-
});
|
|
1133
|
-
},
|
|
1134
|
-
};
|