@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,973 +0,0 @@
|
|
|
1
|
-
import { Box, Button, Paper,Stack, Typography } from '@mui/material';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { expect, fn,userEvent, waitFor, within } from 'storybook/test';
|
|
5
|
-
|
|
6
|
-
import { StackedModalActions, StackedModalContent, ModalStackProvider, StackedModal } from './StackedModal';
|
|
7
|
-
|
|
8
|
-
const meta: Meta<typeof StackedModal> = {
|
|
9
|
-
title: 'Enhanced/StackedModal/Tests',
|
|
10
|
-
component: StackedModal,
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: 'centered',
|
|
13
|
-
chromatic: { disableSnapshot: false },
|
|
14
|
-
},
|
|
15
|
-
tags: ['autodocs', 'test', 'component:StackedModal'],
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default meta;
|
|
19
|
-
type Story = StoryObj<typeof meta>;
|
|
20
|
-
|
|
21
|
-
// Test wrapper component
|
|
22
|
-
const TestWrapper = ({ children }: { children: React.ReactNode }) => (
|
|
23
|
-
<ModalStackProvider>{children}</ModalStackProvider>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
// Interaction Tests
|
|
27
|
-
export const BasicInteraction: Story = {
|
|
28
|
-
name: '🧪 Basic Interaction Test',
|
|
29
|
-
args: {
|
|
30
|
-
open: true,
|
|
31
|
-
onClose: fn(),
|
|
32
|
-
navigationTitle: 'Basic Modal',
|
|
33
|
-
modalId: 'test-modal-basic',
|
|
34
|
-
},
|
|
35
|
-
render: (args) => (
|
|
36
|
-
<TestWrapper>
|
|
37
|
-
<StackedModal {...args} data-testid="basic-modal">
|
|
38
|
-
<StackedModalContent>
|
|
39
|
-
<Typography variant="h6" data-testid="modal-content">
|
|
40
|
-
Basic Modal Content
|
|
41
|
-
</Typography>
|
|
42
|
-
<Typography variant="body2">This is a test modal for basic interactions.</Typography>
|
|
43
|
-
</StackedModalContent>
|
|
44
|
-
<StackedModalActions>
|
|
45
|
-
<Button data-testid="action-button" onClick={fn()}>
|
|
46
|
-
Test Action
|
|
47
|
-
</Button>
|
|
48
|
-
</StackedModalActions>
|
|
49
|
-
</StackedModal>
|
|
50
|
-
</TestWrapper>
|
|
51
|
-
),
|
|
52
|
-
play: async ({ step, args }) => {
|
|
53
|
-
// Use document.body for portal-rendered modals
|
|
54
|
-
const screen = within(document.body);
|
|
55
|
-
|
|
56
|
-
await step('Wait for modal to render', async () => {
|
|
57
|
-
await waitFor(
|
|
58
|
-
() => {
|
|
59
|
-
const modal = screen.getByRole('dialog');
|
|
60
|
-
expect(modal).toBeInTheDocument();
|
|
61
|
-
},
|
|
62
|
-
{ timeout: 5000 },
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
await step('Initial render verification', async () => {
|
|
67
|
-
const modal = screen.getByRole('dialog');
|
|
68
|
-
await expect(modal).toBeInTheDocument();
|
|
69
|
-
await expect(modal).toHaveAttribute('aria-labelledby');
|
|
70
|
-
await expect(modal).toHaveAttribute('aria-describedby');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
await step('Modal content visibility', async () => {
|
|
74
|
-
const content = screen.getByTestId('modal-content');
|
|
75
|
-
await expect(content).toBeInTheDocument();
|
|
76
|
-
await expect(content).toHaveTextContent('Basic Modal Content');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
await step('Close button interaction', async () => {
|
|
80
|
-
const closeButton = screen.getByLabelText('close');
|
|
81
|
-
await expect(closeButton).toBeInTheDocument();
|
|
82
|
-
await userEvent.click(closeButton);
|
|
83
|
-
await expect(args.onClose).toHaveBeenCalledTimes(1);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
await step('Action button interaction', async () => {
|
|
87
|
-
const actionButton = screen.getByTestId('action-button');
|
|
88
|
-
await expect(actionButton).toBeInTheDocument();
|
|
89
|
-
await userEvent.click(actionButton);
|
|
90
|
-
});
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export const StackingBehavior: Story = {
|
|
95
|
-
name: '📚 Stacking Behavior Test',
|
|
96
|
-
render: () => {
|
|
97
|
-
const [firstOpen, setFirstOpen] = React.useState(true);
|
|
98
|
-
const [secondOpen, setSecondOpen] = React.useState(false);
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<TestWrapper>
|
|
102
|
-
<StackedModal
|
|
103
|
-
open={firstOpen}
|
|
104
|
-
onClose={() => setFirstOpen(false)}
|
|
105
|
-
navigationTitle="First Modal"
|
|
106
|
-
modalId="first-modal"
|
|
107
|
-
data-testid="first-modal"
|
|
108
|
-
>
|
|
109
|
-
<StackedModalContent>
|
|
110
|
-
<Typography variant="h6">First Modal</Typography>
|
|
111
|
-
<Button data-testid="open-second" onClick={() => setSecondOpen(true)}>
|
|
112
|
-
Open Second Modal
|
|
113
|
-
</Button>
|
|
114
|
-
</StackedModalContent>
|
|
115
|
-
</StackedModal>
|
|
116
|
-
|
|
117
|
-
<StackedModal
|
|
118
|
-
open={secondOpen}
|
|
119
|
-
onClose={() => setSecondOpen(false)}
|
|
120
|
-
navigationTitle="Second Modal"
|
|
121
|
-
modalId="second-modal"
|
|
122
|
-
data-testid="second-modal"
|
|
123
|
-
>
|
|
124
|
-
<StackedModalContent>
|
|
125
|
-
<Typography variant="h6">Second Modal</Typography>
|
|
126
|
-
<Typography variant="body2">This is stacked on top</Typography>
|
|
127
|
-
</StackedModalContent>
|
|
128
|
-
</StackedModal>
|
|
129
|
-
</TestWrapper>
|
|
130
|
-
);
|
|
131
|
-
},
|
|
132
|
-
play: async ({ step }) => {
|
|
133
|
-
const screen = within(document.body);
|
|
134
|
-
|
|
135
|
-
await step('First modal opens', async () => {
|
|
136
|
-
await waitFor(() => {
|
|
137
|
-
const modal = screen.getByRole('dialog');
|
|
138
|
-
expect(modal).toBeInTheDocument();
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
await step('Open second modal', async () => {
|
|
143
|
-
const openSecondButton = screen.getByTestId('open-second');
|
|
144
|
-
await userEvent.click(openSecondButton);
|
|
145
|
-
|
|
146
|
-
// Wait for second modal to appear
|
|
147
|
-
await waitFor(() => {
|
|
148
|
-
const secondModalElements = screen.getAllByText('Second Modal');
|
|
149
|
-
expect(secondModalElements.length).toBeGreaterThan(0);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
await step('Verify stacking behavior', async () => {
|
|
154
|
-
// Both modal contents should be visible
|
|
155
|
-
const firstModalElements = screen.getAllByText('First Modal');
|
|
156
|
-
const secondModalElements = screen.getAllByText('Second Modal');
|
|
157
|
-
|
|
158
|
-
await expect(firstModalElements.length).toBeGreaterThan(0);
|
|
159
|
-
await expect(secondModalElements.length).toBeGreaterThan(0);
|
|
160
|
-
|
|
161
|
-
// Check stacking through z-index or modal count
|
|
162
|
-
const dialogs = screen.queryAllByRole('dialog');
|
|
163
|
-
await expect(dialogs.length).toBeGreaterThanOrEqual(1);
|
|
164
|
-
});
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
export const GlassEffect: Story = {
|
|
169
|
-
name: '✨ Glass Effect Test',
|
|
170
|
-
args: {
|
|
171
|
-
open: true,
|
|
172
|
-
onClose: fn(),
|
|
173
|
-
glass: true,
|
|
174
|
-
navigationTitle: 'Glass Modal',
|
|
175
|
-
modalId: 'glass-modal',
|
|
176
|
-
},
|
|
177
|
-
render: (args) => (
|
|
178
|
-
<TestWrapper>
|
|
179
|
-
<Box sx={{ p: 4, bgcolor: 'primary.main', minHeight: '200px' }}>
|
|
180
|
-
<Typography color="white">Background Content</Typography>
|
|
181
|
-
</Box>
|
|
182
|
-
<StackedModal {...args} data-testid="glass-modal">
|
|
183
|
-
<StackedModalContent>
|
|
184
|
-
<Typography variant="h6">Glass Effect Modal</Typography>
|
|
185
|
-
<Typography variant="body2">This modal has a glass morphism effect</Typography>
|
|
186
|
-
</StackedModalContent>
|
|
187
|
-
</StackedModal>
|
|
188
|
-
</TestWrapper>
|
|
189
|
-
),
|
|
190
|
-
play: async ({ step }) => {
|
|
191
|
-
const screen = within(document.body);
|
|
192
|
-
|
|
193
|
-
await step('Verify glass effect styles', async () => {
|
|
194
|
-
await waitFor(() => {
|
|
195
|
-
const modal = screen.getByRole('dialog');
|
|
196
|
-
expect(modal).toBeInTheDocument();
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
const modal = screen.getByRole('dialog');
|
|
200
|
-
const paperElement = modal.querySelector('.MuiDialog-paper');
|
|
201
|
-
if (paperElement) {
|
|
202
|
-
const styles = window.getComputedStyle(paperElement) as CSSStyleDeclaration & { webkitBackdropFilter?: string };
|
|
203
|
-
await expect(styles.backdropFilter || styles.webkitBackdropFilter).toContain('blur');
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
},
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
export const LoadingState: Story = {
|
|
210
|
-
name: '⏳ Loading State Test',
|
|
211
|
-
args: {
|
|
212
|
-
open: true,
|
|
213
|
-
onClose: fn(),
|
|
214
|
-
loading: true,
|
|
215
|
-
loadingText: 'Loading modal content...',
|
|
216
|
-
navigationTitle: 'Loading Modal',
|
|
217
|
-
modalId: 'loading-modal',
|
|
218
|
-
},
|
|
219
|
-
render: (args) => (
|
|
220
|
-
<TestWrapper>
|
|
221
|
-
<StackedModal {...args} data-testid="loading-modal">
|
|
222
|
-
<StackedModalContent>
|
|
223
|
-
<Typography variant="h6">This content is loading</Typography>
|
|
224
|
-
</StackedModalContent>
|
|
225
|
-
</StackedModal>
|
|
226
|
-
</TestWrapper>
|
|
227
|
-
),
|
|
228
|
-
play: async ({ step }) => {
|
|
229
|
-
const screen = within(document.body);
|
|
230
|
-
|
|
231
|
-
await step('Verify loading overlay', async () => {
|
|
232
|
-
await waitFor(() => {
|
|
233
|
-
const modal = screen.getByRole('dialog');
|
|
234
|
-
expect(modal).toBeInTheDocument();
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
const progressIndicator = screen.getByRole('progressbar');
|
|
238
|
-
await expect(progressIndicator).toBeInTheDocument();
|
|
239
|
-
|
|
240
|
-
const loadingText = screen.getByText('Loading modal content...');
|
|
241
|
-
await expect(loadingText).toBeInTheDocument();
|
|
242
|
-
});
|
|
243
|
-
},
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
export const ResponsiveDesign: Story = {
|
|
247
|
-
name: '📱 Responsive Design Test',
|
|
248
|
-
parameters: {
|
|
249
|
-
viewport: {
|
|
250
|
-
viewports: {
|
|
251
|
-
mobile: {
|
|
252
|
-
name: 'Mobile',
|
|
253
|
-
styles: { width: '375px', height: '667px' },
|
|
254
|
-
type: 'mobile',
|
|
255
|
-
},
|
|
256
|
-
tablet: {
|
|
257
|
-
name: 'Tablet',
|
|
258
|
-
styles: { width: '768px', height: '1024px' },
|
|
259
|
-
type: 'tablet',
|
|
260
|
-
},
|
|
261
|
-
desktop: {
|
|
262
|
-
name: 'Desktop',
|
|
263
|
-
styles: { width: '1920px', height: '1080px' },
|
|
264
|
-
type: 'desktop',
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
defaultViewport: 'mobile',
|
|
268
|
-
},
|
|
269
|
-
chromatic: {
|
|
270
|
-
viewports: [375, 768, 1920],
|
|
271
|
-
delay: 300,
|
|
272
|
-
},
|
|
273
|
-
},
|
|
274
|
-
args: {
|
|
275
|
-
open: true,
|
|
276
|
-
onClose: fn(),
|
|
277
|
-
navigationTitle: 'Responsive Modal',
|
|
278
|
-
modalId: 'responsive-modal',
|
|
279
|
-
},
|
|
280
|
-
render: (args) => (
|
|
281
|
-
<TestWrapper>
|
|
282
|
-
<StackedModal {...args} data-testid="responsive-modal">
|
|
283
|
-
<StackedModalContent>
|
|
284
|
-
<Typography variant="h6">Responsive Modal</Typography>
|
|
285
|
-
<Typography variant="body2">This modal adapts to different screen sizes</Typography>
|
|
286
|
-
</StackedModalContent>
|
|
287
|
-
<StackedModalActions>
|
|
288
|
-
<Button variant="contained">Action</Button>
|
|
289
|
-
</StackedModalActions>
|
|
290
|
-
</StackedModal>
|
|
291
|
-
</TestWrapper>
|
|
292
|
-
),
|
|
293
|
-
play: async ({ step }) => {
|
|
294
|
-
const screen = within(document.body);
|
|
295
|
-
|
|
296
|
-
await step('Verify modal responsiveness', async () => {
|
|
297
|
-
await waitFor(() => {
|
|
298
|
-
const modal = screen.getByRole('dialog');
|
|
299
|
-
expect(modal).toBeInTheDocument();
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
const modal = screen.getByRole('dialog');
|
|
303
|
-
await expect(modal).toBeInTheDocument();
|
|
304
|
-
|
|
305
|
-
// Check that modal adapts to viewport
|
|
306
|
-
const modalPaper =
|
|
307
|
-
modal.closest('.MuiDialog-paper') || modal.querySelector('.MuiDialog-paper');
|
|
308
|
-
if (modalPaper) {
|
|
309
|
-
await expect(modalPaper).toBeInTheDocument();
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
},
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
export const KeyboardNavigation: Story = {
|
|
316
|
-
name: '⌨️ Keyboard Navigation Test',
|
|
317
|
-
args: {
|
|
318
|
-
open: true,
|
|
319
|
-
onClose: fn(),
|
|
320
|
-
navigationTitle: 'Keyboard Modal',
|
|
321
|
-
modalId: 'keyboard-modal',
|
|
322
|
-
},
|
|
323
|
-
render: (args) => (
|
|
324
|
-
<TestWrapper>
|
|
325
|
-
<StackedModal {...args} data-testid="keyboard-modal">
|
|
326
|
-
<StackedModalContent>
|
|
327
|
-
<Typography variant="h6">Keyboard Navigation Test</Typography>
|
|
328
|
-
<Stack spacing={2} sx={{ mt: 2 }}>
|
|
329
|
-
<Button data-testid="first-button">First Button</Button>
|
|
330
|
-
<Button data-testid="second-button">Second Button</Button>
|
|
331
|
-
<Button data-testid="third-button">Third Button</Button>
|
|
332
|
-
</Stack>
|
|
333
|
-
</StackedModalContent>
|
|
334
|
-
</StackedModal>
|
|
335
|
-
</TestWrapper>
|
|
336
|
-
),
|
|
337
|
-
parameters: {
|
|
338
|
-
a11y: {
|
|
339
|
-
element: '#storybook-root',
|
|
340
|
-
config: {
|
|
341
|
-
rules: [
|
|
342
|
-
{ id: 'color-contrast', enabled: true },
|
|
343
|
-
{ id: 'aria-required-attr', enabled: true },
|
|
344
|
-
],
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
play: async ({ step, args }) => {
|
|
349
|
-
const screen = within(document.body);
|
|
350
|
-
|
|
351
|
-
await step('Wait for modal to render', async () => {
|
|
352
|
-
await waitFor(() => {
|
|
353
|
-
const modal = screen.getByRole('dialog');
|
|
354
|
-
expect(modal).toBeInTheDocument();
|
|
355
|
-
});
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
await step('Tab navigation through modal', async () => {
|
|
359
|
-
const firstButton = screen.getByTestId('first-button');
|
|
360
|
-
const secondButton = screen.getByTestId('second-button');
|
|
361
|
-
|
|
362
|
-
await userEvent.click(firstButton);
|
|
363
|
-
await waitFor(() => expect(firstButton).toHaveFocus());
|
|
364
|
-
|
|
365
|
-
await userEvent.tab();
|
|
366
|
-
await waitFor(() => expect(secondButton).toHaveFocus());
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
await step('Escape key closes modal', async () => {
|
|
370
|
-
await userEvent.keyboard('{Escape}');
|
|
371
|
-
await expect(args.onClose).toHaveBeenCalled();
|
|
372
|
-
});
|
|
373
|
-
},
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
export const ScreenReader: Story = {
|
|
377
|
-
name: '🔊 Screen Reader Test',
|
|
378
|
-
args: {
|
|
379
|
-
open: true,
|
|
380
|
-
onClose: fn(),
|
|
381
|
-
navigationTitle: 'Accessible Modal',
|
|
382
|
-
modalId: 'accessible-modal',
|
|
383
|
-
'aria-labelledby': 'modal-title',
|
|
384
|
-
'aria-describedby': 'modal-description',
|
|
385
|
-
},
|
|
386
|
-
render: (args) => (
|
|
387
|
-
<TestWrapper>
|
|
388
|
-
<StackedModal {...args} data-testid="accessible-modal">
|
|
389
|
-
<StackedModalContent>
|
|
390
|
-
<Typography variant="h6" id="modal-title">
|
|
391
|
-
Accessible Modal Title
|
|
392
|
-
</Typography>
|
|
393
|
-
<Typography variant="body2" id="modal-description">
|
|
394
|
-
This modal is properly configured for screen readers with ARIA attributes
|
|
395
|
-
</Typography>
|
|
396
|
-
</StackedModalContent>
|
|
397
|
-
</StackedModal>
|
|
398
|
-
</TestWrapper>
|
|
399
|
-
),
|
|
400
|
-
parameters: {
|
|
401
|
-
a11y: {
|
|
402
|
-
element: '#storybook-root',
|
|
403
|
-
config: {
|
|
404
|
-
rules: [
|
|
405
|
-
{ id: 'aria-required-attr', enabled: true },
|
|
406
|
-
{ id: 'aria-valid-attr', enabled: true },
|
|
407
|
-
{ id: 'button-name', enabled: true },
|
|
408
|
-
{ id: 'color-contrast', enabled: true },
|
|
409
|
-
],
|
|
410
|
-
},
|
|
411
|
-
},
|
|
412
|
-
},
|
|
413
|
-
play: async ({ step }) => {
|
|
414
|
-
const screen = within(document.body);
|
|
415
|
-
|
|
416
|
-
await step('Wait for modal to render', async () => {
|
|
417
|
-
await waitFor(() => {
|
|
418
|
-
const modal = screen.getByRole('dialog');
|
|
419
|
-
expect(modal).toBeInTheDocument();
|
|
420
|
-
});
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
await step('Verify ARIA attributes', async () => {
|
|
424
|
-
const modal = screen.getByRole('dialog');
|
|
425
|
-
await expect(modal).toHaveAttribute('aria-labelledby', 'modal-title');
|
|
426
|
-
await expect(modal).toHaveAttribute('aria-describedby', 'modal-description');
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
await step('Verify semantic structure', async () => {
|
|
430
|
-
const titles = screen.getAllByRole('heading');
|
|
431
|
-
// Find the title with our specific text
|
|
432
|
-
const modalTitle = titles.find((title) =>
|
|
433
|
-
title.textContent?.includes('Accessible Modal Title'),
|
|
434
|
-
);
|
|
435
|
-
await expect(modalTitle).toBeInTheDocument();
|
|
436
|
-
await expect(modalTitle).toHaveTextContent('Accessible Modal Title');
|
|
437
|
-
});
|
|
438
|
-
},
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
export const FocusManagement: Story = {
|
|
442
|
-
name: '🎯 Focus Management Test',
|
|
443
|
-
args: {
|
|
444
|
-
open: true,
|
|
445
|
-
onClose: fn(),
|
|
446
|
-
navigationTitle: 'Focus Modal',
|
|
447
|
-
modalId: 'focus-modal',
|
|
448
|
-
},
|
|
449
|
-
render: (args) => (
|
|
450
|
-
<TestWrapper>
|
|
451
|
-
<Button data-testid="external-button">External Button</Button>
|
|
452
|
-
<StackedModal {...args} data-testid="focus-modal">
|
|
453
|
-
<StackedModalContent>
|
|
454
|
-
<Typography variant="h6">Focus Management</Typography>
|
|
455
|
-
<Stack spacing={2} sx={{ mt: 2 }}>
|
|
456
|
-
<Button data-testid="modal-button-1">Button 1</Button>
|
|
457
|
-
<Button data-testid="modal-button-2">Button 2</Button>
|
|
458
|
-
</Stack>
|
|
459
|
-
</StackedModalContent>
|
|
460
|
-
</StackedModal>
|
|
461
|
-
</TestWrapper>
|
|
462
|
-
),
|
|
463
|
-
play: async ({ step }) => {
|
|
464
|
-
const screen = within(document.body);
|
|
465
|
-
|
|
466
|
-
await step('Wait for modal to render', async () => {
|
|
467
|
-
await waitFor(() => {
|
|
468
|
-
const modal = screen.getByRole('dialog');
|
|
469
|
-
expect(modal).toBeInTheDocument();
|
|
470
|
-
});
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
await step('Focus traps within modal', async () => {
|
|
474
|
-
const modalButton1 = screen.getByTestId('modal-button-1');
|
|
475
|
-
const modalButton2 = screen.getByTestId('modal-button-2');
|
|
476
|
-
|
|
477
|
-
await userEvent.click(modalButton1);
|
|
478
|
-
await waitFor(() => expect(modalButton1).toHaveFocus());
|
|
479
|
-
|
|
480
|
-
await userEvent.tab();
|
|
481
|
-
await waitFor(() => expect(modalButton2).toHaveFocus());
|
|
482
|
-
});
|
|
483
|
-
|
|
484
|
-
await step('Verify focus trap', async () => {
|
|
485
|
-
// Focus should remain within modal
|
|
486
|
-
const focusedElement = document.activeElement;
|
|
487
|
-
const modal = screen.getByRole('dialog');
|
|
488
|
-
await expect(modal.contains(focusedElement)).toBe(true);
|
|
489
|
-
});
|
|
490
|
-
},
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
export const RTLSupport: Story = {
|
|
494
|
-
name: '🔄 RTL Support Test',
|
|
495
|
-
args: {
|
|
496
|
-
open: true,
|
|
497
|
-
onClose: fn(),
|
|
498
|
-
navigationTitle: 'RTL Modal',
|
|
499
|
-
modalId: 'rtl-modal',
|
|
500
|
-
rtl: true,
|
|
501
|
-
},
|
|
502
|
-
render: (args) => (
|
|
503
|
-
<TestWrapper>
|
|
504
|
-
<StackedModal {...args} data-testid="rtl-modal">
|
|
505
|
-
<StackedModalContent>
|
|
506
|
-
<Typography variant="h6">مودال با پشتیبانی از راست به چپ</Typography>
|
|
507
|
-
<Typography variant="body2">این مودال از زبانهای راست به چپ پشتیبانی میکند</Typography>
|
|
508
|
-
</StackedModalContent>
|
|
509
|
-
</StackedModal>
|
|
510
|
-
</TestWrapper>
|
|
511
|
-
),
|
|
512
|
-
play: async ({ step }) => {
|
|
513
|
-
const screen = within(document.body);
|
|
514
|
-
|
|
515
|
-
await step('Wait for modal to render', async () => {
|
|
516
|
-
await waitFor(() => {
|
|
517
|
-
const modal = screen.getByRole('dialog');
|
|
518
|
-
expect(modal).toBeInTheDocument();
|
|
519
|
-
});
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
await step('Verify RTL direction', async () => {
|
|
523
|
-
const modal = screen.getByRole('dialog');
|
|
524
|
-
const styles = window.getComputedStyle(modal);
|
|
525
|
-
await expect(styles.direction).toBe('rtl');
|
|
526
|
-
});
|
|
527
|
-
|
|
528
|
-
await step('Verify back button rotation in RTL', async () => {
|
|
529
|
-
const backButton = screen.getByLabelText('close');
|
|
530
|
-
const styles = window.getComputedStyle(backButton);
|
|
531
|
-
// In RTL mode, back button should have transform
|
|
532
|
-
await expect(styles.transform).toBeTruthy();
|
|
533
|
-
});
|
|
534
|
-
},
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
export const VisualStates: Story = {
|
|
538
|
-
name: '👁️ Visual States Test',
|
|
539
|
-
render: () => (
|
|
540
|
-
<TestWrapper>
|
|
541
|
-
<Stack spacing={4}>
|
|
542
|
-
{/* Normal state */}
|
|
543
|
-
<StackedModal
|
|
544
|
-
open={true}
|
|
545
|
-
onClose={fn()}
|
|
546
|
-
navigationTitle="Normal State"
|
|
547
|
-
modalId="normal-modal"
|
|
548
|
-
data-testid="normal-modal"
|
|
549
|
-
>
|
|
550
|
-
<StackedModalContent>
|
|
551
|
-
<Typography>Normal modal state</Typography>
|
|
552
|
-
</StackedModalContent>
|
|
553
|
-
</StackedModal>
|
|
554
|
-
|
|
555
|
-
{/* Glass effect state */}
|
|
556
|
-
<StackedModal
|
|
557
|
-
open={true}
|
|
558
|
-
onClose={fn()}
|
|
559
|
-
glass={true}
|
|
560
|
-
navigationTitle="Glass Effect"
|
|
561
|
-
modalId="glass-state-modal"
|
|
562
|
-
data-testid="glass-state-modal"
|
|
563
|
-
>
|
|
564
|
-
<StackedModalContent>
|
|
565
|
-
<Typography>Glass effect modal</Typography>
|
|
566
|
-
</StackedModalContent>
|
|
567
|
-
</StackedModal>
|
|
568
|
-
</Stack>
|
|
569
|
-
</TestWrapper>
|
|
570
|
-
),
|
|
571
|
-
play: async ({ step }) => {
|
|
572
|
-
const screen = within(document.body);
|
|
573
|
-
|
|
574
|
-
await step('Wait for modals to render', async () => {
|
|
575
|
-
await waitFor(() => {
|
|
576
|
-
const modals = screen.getAllByRole('dialog');
|
|
577
|
-
expect(modals.length).toBeGreaterThan(0);
|
|
578
|
-
});
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
await step('Visual states verification', async () => {
|
|
582
|
-
const modals = screen.getAllByRole('dialog');
|
|
583
|
-
await expect(modals.length).toBeGreaterThan(0);
|
|
584
|
-
|
|
585
|
-
// Check glass effect on any modal with glass prop
|
|
586
|
-
modals.forEach((modal) => {
|
|
587
|
-
const paperElement = modal.querySelector('.MuiDialog-paper');
|
|
588
|
-
if (paperElement) {
|
|
589
|
-
const styles = window.getComputedStyle(paperElement) as CSSStyleDeclaration & { webkitBackdropFilter?: string };
|
|
590
|
-
// Glass modals should have backdrop filter
|
|
591
|
-
if (styles.backdropFilter || styles.webkitBackdropFilter) {
|
|
592
|
-
expect(styles.backdropFilter || styles.webkitBackdropFilter).toContain('blur');
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
});
|
|
596
|
-
});
|
|
597
|
-
},
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
export const Performance: Story = {
|
|
601
|
-
name: '⚡ Performance Test',
|
|
602
|
-
render: () => {
|
|
603
|
-
const modals = Array.from({ length: 5 }, (_, i) => ({
|
|
604
|
-
id: `perf-modal-${i}`,
|
|
605
|
-
title: `Modal ${i + 1}`,
|
|
606
|
-
open: i === 0, // Only first modal is open
|
|
607
|
-
}));
|
|
608
|
-
|
|
609
|
-
return (
|
|
610
|
-
<TestWrapper>
|
|
611
|
-
{modals.map((modal) => (
|
|
612
|
-
<StackedModal
|
|
613
|
-
key={modal.id}
|
|
614
|
-
open={modal.open}
|
|
615
|
-
onClose={fn()}
|
|
616
|
-
navigationTitle={modal.title}
|
|
617
|
-
modalId={modal.id}
|
|
618
|
-
data-testid={modal.id}
|
|
619
|
-
>
|
|
620
|
-
<StackedModalContent>
|
|
621
|
-
<Typography variant="h6">{modal.title}</Typography>
|
|
622
|
-
<Typography variant="body2">Performance test content</Typography>
|
|
623
|
-
</StackedModalContent>
|
|
624
|
-
</StackedModal>
|
|
625
|
-
))}
|
|
626
|
-
</TestWrapper>
|
|
627
|
-
);
|
|
628
|
-
},
|
|
629
|
-
play: async ({ step }) => {
|
|
630
|
-
const screen = within(document.body);
|
|
631
|
-
|
|
632
|
-
await step('Wait for modal to render', async () => {
|
|
633
|
-
await waitFor(() => {
|
|
634
|
-
const modal = screen.getByRole('dialog');
|
|
635
|
-
expect(modal).toBeInTheDocument();
|
|
636
|
-
});
|
|
637
|
-
});
|
|
638
|
-
|
|
639
|
-
// A wall-clock budget around an already-resolved waitFor measures the
|
|
640
|
-
// machine the story runs on, not the modal. That the dialog rendered at all
|
|
641
|
-
// is what the step above already establishes.
|
|
642
|
-
|
|
643
|
-
await step('Memory efficiency', async () => {
|
|
644
|
-
// Only one modal should be rendered at a time
|
|
645
|
-
const modals = screen.getAllByRole('dialog');
|
|
646
|
-
await expect(modals).toHaveLength(1);
|
|
647
|
-
});
|
|
648
|
-
},
|
|
649
|
-
};
|
|
650
|
-
|
|
651
|
-
export const EdgeCases: Story = {
|
|
652
|
-
name: '🔧 Edge Cases Test',
|
|
653
|
-
render: () => (
|
|
654
|
-
<TestWrapper>
|
|
655
|
-
<Stack spacing={2}>
|
|
656
|
-
{/* Modal with no content */}
|
|
657
|
-
<StackedModal
|
|
658
|
-
open={true}
|
|
659
|
-
onClose={fn()}
|
|
660
|
-
navigationTitle="Empty Modal"
|
|
661
|
-
modalId="empty-modal"
|
|
662
|
-
data-testid="empty-modal"
|
|
663
|
-
>
|
|
664
|
-
{/* No content */}
|
|
665
|
-
</StackedModal>
|
|
666
|
-
|
|
667
|
-
{/* Modal with very long title */}
|
|
668
|
-
<StackedModal
|
|
669
|
-
open={true}
|
|
670
|
-
onClose={fn()}
|
|
671
|
-
navigationTitle="This is a very long modal title that should be truncated with ellipsis when it exceeds the available space"
|
|
672
|
-
modalId="long-title-modal"
|
|
673
|
-
data-testid="long-title-modal"
|
|
674
|
-
>
|
|
675
|
-
<StackedModalContent>
|
|
676
|
-
<Typography>Long title test</Typography>
|
|
677
|
-
</StackedModalContent>
|
|
678
|
-
</StackedModal>
|
|
679
|
-
</Stack>
|
|
680
|
-
</TestWrapper>
|
|
681
|
-
),
|
|
682
|
-
play: async ({ step }) => {
|
|
683
|
-
const screen = within(document.body);
|
|
684
|
-
|
|
685
|
-
await step('Wait for modals to render', async () => {
|
|
686
|
-
await waitFor(() => {
|
|
687
|
-
const modals = screen.getAllByRole('dialog');
|
|
688
|
-
expect(modals.length).toBeGreaterThan(0);
|
|
689
|
-
});
|
|
690
|
-
});
|
|
691
|
-
|
|
692
|
-
await step('Edge cases handling', async () => {
|
|
693
|
-
const modals = screen.getAllByRole('dialog');
|
|
694
|
-
await expect(modals.length).toBeGreaterThan(0);
|
|
695
|
-
// Should not crash when content is empty
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
await step('Long title truncation', async () => {
|
|
699
|
-
const titleElements = screen.getAllByText(/This is a very long modal title/);
|
|
700
|
-
const titleElement = titleElements[0];
|
|
701
|
-
await expect(titleElement).toBeInTheDocument();
|
|
702
|
-
|
|
703
|
-
// Check if title has proper text truncation styles
|
|
704
|
-
const hasNoWrap = titleElement.classList.contains('MuiTypography-noWrap');
|
|
705
|
-
await expect(hasNoWrap).toBeTruthy();
|
|
706
|
-
});
|
|
707
|
-
},
|
|
708
|
-
};
|
|
709
|
-
|
|
710
|
-
export const Integration: Story = {
|
|
711
|
-
name: '🔗 Integration Test',
|
|
712
|
-
render: () => (
|
|
713
|
-
<TestWrapper>
|
|
714
|
-
<StackedModal
|
|
715
|
-
open={true}
|
|
716
|
-
onClose={fn()}
|
|
717
|
-
navigationTitle="Integration Test"
|
|
718
|
-
modalId="integration-modal"
|
|
719
|
-
data-testid="integration-modal"
|
|
720
|
-
>
|
|
721
|
-
<StackedModalContent>
|
|
722
|
-
<Typography variant="h6" gutterBottom>
|
|
723
|
-
Modal with Complex Content
|
|
724
|
-
</Typography>
|
|
725
|
-
<Paper elevation={1} sx={{ p: 2, mb: 2 }}>
|
|
726
|
-
<Typography variant="subtitle2">Nested Paper Component</Typography>
|
|
727
|
-
<Typography variant="body2">
|
|
728
|
-
Testing integration with other Material-UI components
|
|
729
|
-
</Typography>
|
|
730
|
-
</Paper>
|
|
731
|
-
<Stack spacing={2} direction="row">
|
|
732
|
-
<Button variant="outlined" data-testid="outlined-button">
|
|
733
|
-
Outlined
|
|
734
|
-
</Button>
|
|
735
|
-
<Button variant="contained" data-testid="contained-button">
|
|
736
|
-
Contained
|
|
737
|
-
</Button>
|
|
738
|
-
</Stack>
|
|
739
|
-
</StackedModalContent>
|
|
740
|
-
<StackedModalActions>
|
|
741
|
-
<Stack direction="row" spacing={1}>
|
|
742
|
-
<Button variant="outlined" size="small">
|
|
743
|
-
Cancel
|
|
744
|
-
</Button>
|
|
745
|
-
<Button variant="contained" size="small" data-testid="save-button">
|
|
746
|
-
Save
|
|
747
|
-
</Button>
|
|
748
|
-
</Stack>
|
|
749
|
-
</StackedModalActions>
|
|
750
|
-
</StackedModal>
|
|
751
|
-
</TestWrapper>
|
|
752
|
-
),
|
|
753
|
-
play: async ({ step }) => {
|
|
754
|
-
const screen = within(document.body);
|
|
755
|
-
|
|
756
|
-
await step('Wait for modal to render', async () => {
|
|
757
|
-
await waitFor(() => {
|
|
758
|
-
const modal = screen.getByRole('dialog');
|
|
759
|
-
expect(modal).toBeInTheDocument();
|
|
760
|
-
});
|
|
761
|
-
});
|
|
762
|
-
|
|
763
|
-
await step('Verify all integrated components', async () => {
|
|
764
|
-
const paper = screen.getByText('Nested Paper Component');
|
|
765
|
-
await expect(paper).toBeInTheDocument();
|
|
766
|
-
|
|
767
|
-
const outlinedButton = screen.getByTestId('outlined-button');
|
|
768
|
-
const containedButton = screen.getByTestId('contained-button');
|
|
769
|
-
await expect(outlinedButton).toBeInTheDocument();
|
|
770
|
-
await expect(containedButton).toBeInTheDocument();
|
|
771
|
-
});
|
|
772
|
-
|
|
773
|
-
await step('Test integrated interactions', async () => {
|
|
774
|
-
const saveButton = screen.getByTestId('save-button');
|
|
775
|
-
await userEvent.click(saveButton);
|
|
776
|
-
await expect(saveButton).toBeEnabled();
|
|
777
|
-
});
|
|
778
|
-
},
|
|
779
|
-
};
|
|
780
|
-
|
|
781
|
-
export const TestIds: Story = {
|
|
782
|
-
name: '🔍 Test IDs Verification',
|
|
783
|
-
args: {
|
|
784
|
-
open: true,
|
|
785
|
-
onClose: fn(),
|
|
786
|
-
navigationTitle: 'Test IDs Modal',
|
|
787
|
-
modalId: 'testid-modal',
|
|
788
|
-
dataTestId: 'modal-test',
|
|
789
|
-
loading: false,
|
|
790
|
-
},
|
|
791
|
-
render: (args) => (
|
|
792
|
-
<TestWrapper>
|
|
793
|
-
<StackedModal {...args}>
|
|
794
|
-
<StackedModalContent>
|
|
795
|
-
<Typography variant="h6">Testing Data Test IDs</Typography>
|
|
796
|
-
<Typography variant="body2">
|
|
797
|
-
This modal has data-testid attributes for all major elements
|
|
798
|
-
</Typography>
|
|
799
|
-
</StackedModalContent>
|
|
800
|
-
<StackedModalActions>
|
|
801
|
-
<Button variant="contained" size="small">
|
|
802
|
-
Action Button
|
|
803
|
-
</Button>
|
|
804
|
-
</StackedModalActions>
|
|
805
|
-
</StackedModal>
|
|
806
|
-
</TestWrapper>
|
|
807
|
-
),
|
|
808
|
-
play: async ({ step }) => {
|
|
809
|
-
const screen = within(document.body);
|
|
810
|
-
|
|
811
|
-
await step('Wait for modal to render', async () => {
|
|
812
|
-
await waitFor(() => {
|
|
813
|
-
const modal = screen.getByRole('dialog');
|
|
814
|
-
expect(modal).toBeInTheDocument();
|
|
815
|
-
});
|
|
816
|
-
});
|
|
817
|
-
|
|
818
|
-
await step('Verify modal container testId', async () => {
|
|
819
|
-
const modal = screen.getByTestId('modal-test');
|
|
820
|
-
await expect(modal).toBeInTheDocument();
|
|
821
|
-
});
|
|
822
|
-
|
|
823
|
-
await step('Verify header testIds', async () => {
|
|
824
|
-
const header = screen.getByTestId('modal-test-header');
|
|
825
|
-
await expect(header).toBeInTheDocument();
|
|
826
|
-
|
|
827
|
-
const title = screen.getByTestId('modal-test-title');
|
|
828
|
-
await expect(title).toBeInTheDocument();
|
|
829
|
-
await expect(title).toHaveTextContent('Test IDs Modal');
|
|
830
|
-
|
|
831
|
-
const closeButton = screen.getByTestId('modal-test-close-button');
|
|
832
|
-
await expect(closeButton).toBeInTheDocument();
|
|
833
|
-
|
|
834
|
-
const headerActions = screen.getByTestId('modal-test-header-actions');
|
|
835
|
-
await expect(headerActions).toBeInTheDocument();
|
|
836
|
-
});
|
|
837
|
-
|
|
838
|
-
await step('Verify content testId', async () => {
|
|
839
|
-
const content = screen.getByTestId('modal-test-content');
|
|
840
|
-
await expect(content).toBeInTheDocument();
|
|
841
|
-
await expect(content).toHaveTextContent('Testing Data Test IDs');
|
|
842
|
-
});
|
|
843
|
-
|
|
844
|
-
await step('Test close button interaction', async () => {
|
|
845
|
-
const closeButton = screen.getByTestId('modal-test-close-button');
|
|
846
|
-
await userEvent.click(closeButton);
|
|
847
|
-
// Verify onClose was called
|
|
848
|
-
});
|
|
849
|
-
},
|
|
850
|
-
};
|
|
851
|
-
|
|
852
|
-
export const TestIdsWithLoading: Story = {
|
|
853
|
-
name: '🔍 Test IDs with Loading State',
|
|
854
|
-
args: {
|
|
855
|
-
open: true,
|
|
856
|
-
onClose: fn(),
|
|
857
|
-
navigationTitle: 'Loading Modal',
|
|
858
|
-
modalId: 'loading-testid-modal',
|
|
859
|
-
dataTestId: 'modal-loading-test',
|
|
860
|
-
loading: true,
|
|
861
|
-
loadingText: 'Loading content...',
|
|
862
|
-
},
|
|
863
|
-
render: (args) => (
|
|
864
|
-
<TestWrapper>
|
|
865
|
-
<StackedModal {...args}>
|
|
866
|
-
<StackedModalContent>
|
|
867
|
-
<Typography variant="h6">Content that will be hidden by loading</Typography>
|
|
868
|
-
</StackedModalContent>
|
|
869
|
-
</StackedModal>
|
|
870
|
-
</TestWrapper>
|
|
871
|
-
),
|
|
872
|
-
play: async ({ step }) => {
|
|
873
|
-
const screen = within(document.body);
|
|
874
|
-
|
|
875
|
-
await step('Wait for modal to render', async () => {
|
|
876
|
-
await waitFor(() => {
|
|
877
|
-
const modal = screen.getByRole('dialog');
|
|
878
|
-
expect(modal).toBeInTheDocument();
|
|
879
|
-
});
|
|
880
|
-
});
|
|
881
|
-
|
|
882
|
-
await step('Verify loading overlay testIds', async () => {
|
|
883
|
-
const loadingOverlay = screen.getByTestId('modal-loading-test-loading-overlay');
|
|
884
|
-
await expect(loadingOverlay).toBeInTheDocument();
|
|
885
|
-
|
|
886
|
-
const loadingSpinner = screen.getByTestId('modal-loading-test-loading-spinner');
|
|
887
|
-
await expect(loadingSpinner).toBeInTheDocument();
|
|
888
|
-
|
|
889
|
-
const loadingText = screen.getByTestId('modal-loading-test-loading-text');
|
|
890
|
-
await expect(loadingText).toBeInTheDocument();
|
|
891
|
-
await expect(loadingText).toHaveTextContent('Loading content...');
|
|
892
|
-
});
|
|
893
|
-
},
|
|
894
|
-
};
|
|
895
|
-
|
|
896
|
-
export const TestIdsWithStacking: Story = {
|
|
897
|
-
name: '🔍 Test IDs with Stacked Modals',
|
|
898
|
-
render: () => {
|
|
899
|
-
const [firstOpen, setFirstOpen] = React.useState(true);
|
|
900
|
-
const [secondOpen, setSecondOpen] = React.useState(false);
|
|
901
|
-
|
|
902
|
-
return (
|
|
903
|
-
<TestWrapper>
|
|
904
|
-
<StackedModal
|
|
905
|
-
open={firstOpen}
|
|
906
|
-
onClose={() => setFirstOpen(false)}
|
|
907
|
-
navigationTitle="First Modal"
|
|
908
|
-
modalId="first-testid-modal"
|
|
909
|
-
dataTestId="stacked-first"
|
|
910
|
-
>
|
|
911
|
-
<StackedModalContent>
|
|
912
|
-
<Typography variant="h6">First Modal</Typography>
|
|
913
|
-
<Button data-testid="open-second-modal" onClick={() => setSecondOpen(true)}>
|
|
914
|
-
Open Second Modal
|
|
915
|
-
</Button>
|
|
916
|
-
</StackedModalContent>
|
|
917
|
-
</StackedModal>
|
|
918
|
-
|
|
919
|
-
<StackedModal
|
|
920
|
-
open={secondOpen}
|
|
921
|
-
onClose={() => setSecondOpen(false)}
|
|
922
|
-
navigationTitle="Second Modal"
|
|
923
|
-
modalId="second-testid-modal"
|
|
924
|
-
dataTestId="stacked-second"
|
|
925
|
-
>
|
|
926
|
-
<StackedModalContent>
|
|
927
|
-
<Typography variant="h6">Second Modal</Typography>
|
|
928
|
-
<Typography variant="body2">This is stacked on top</Typography>
|
|
929
|
-
</StackedModalContent>
|
|
930
|
-
</StackedModal>
|
|
931
|
-
</TestWrapper>
|
|
932
|
-
);
|
|
933
|
-
},
|
|
934
|
-
play: async ({ step }) => {
|
|
935
|
-
const screen = within(document.body);
|
|
936
|
-
|
|
937
|
-
await step('Verify first modal testIds', async () => {
|
|
938
|
-
await waitFor(() => {
|
|
939
|
-
const firstModal = screen.getByTestId('stacked-first');
|
|
940
|
-
expect(firstModal).toBeInTheDocument();
|
|
941
|
-
});
|
|
942
|
-
|
|
943
|
-
const firstHeader = screen.getByTestId('stacked-first-header');
|
|
944
|
-
await expect(firstHeader).toBeInTheDocument();
|
|
945
|
-
|
|
946
|
-
const firstContent = screen.getByTestId('stacked-first-content');
|
|
947
|
-
await expect(firstContent).toBeInTheDocument();
|
|
948
|
-
|
|
949
|
-
const firstCloseButton = screen.getByTestId('stacked-first-close-button');
|
|
950
|
-
await expect(firstCloseButton).toBeInTheDocument();
|
|
951
|
-
});
|
|
952
|
-
|
|
953
|
-
await step('Open second modal and verify testIds', async () => {
|
|
954
|
-
const openButton = screen.getByTestId('open-second-modal');
|
|
955
|
-
await userEvent.click(openButton);
|
|
956
|
-
|
|
957
|
-
await waitFor(() => {
|
|
958
|
-
const secondModal = screen.getByTestId('stacked-second');
|
|
959
|
-
expect(secondModal).toBeInTheDocument();
|
|
960
|
-
});
|
|
961
|
-
|
|
962
|
-
const secondHeader = screen.getByTestId('stacked-second-header');
|
|
963
|
-
await expect(secondHeader).toBeInTheDocument();
|
|
964
|
-
|
|
965
|
-
const secondContent = screen.getByTestId('stacked-second-content');
|
|
966
|
-
await expect(secondContent).toBeInTheDocument();
|
|
967
|
-
|
|
968
|
-
// Second modal should have a back button since there are stacked modals
|
|
969
|
-
const backButton = screen.getByTestId('stacked-second-back-button');
|
|
970
|
-
await expect(backButton).toBeInTheDocument();
|
|
971
|
-
});
|
|
972
|
-
},
|
|
973
|
-
};
|