@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,985 +0,0 @@
|
|
|
1
|
-
import { Stack } 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 { Select } from './Select';
|
|
7
|
-
|
|
8
|
-
const meta: Meta<typeof Select> = {
|
|
9
|
-
title: 'Form/Select/Tests',
|
|
10
|
-
component: Select,
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: 'centered',
|
|
13
|
-
chromatic: { disableSnapshot: false },
|
|
14
|
-
},
|
|
15
|
-
tags: ['autodocs', 'test', 'component:Select'],
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default meta;
|
|
19
|
-
type Story = StoryObj<typeof meta>;
|
|
20
|
-
|
|
21
|
-
const defaultOptions = [
|
|
22
|
-
{ value: 'option1', label: 'Option 1' },
|
|
23
|
-
{ value: 'option2', label: 'Option 2' },
|
|
24
|
-
{ value: 'option3', label: 'Option 3' },
|
|
25
|
-
{ value: 'option4', label: 'Option 4 (Disabled)', disabled: true },
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
const manyOptions = Array.from({ length: 50 }, (_, i) => ({
|
|
29
|
-
value: `option${i + 1}`,
|
|
30
|
-
label: `Option ${i + 1}`,
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
// ==================== INTERACTION TESTS ====================
|
|
34
|
-
|
|
35
|
-
export const BasicInteraction: Story = {
|
|
36
|
-
name: '🧪 Basic Interaction Test',
|
|
37
|
-
args: {
|
|
38
|
-
options: defaultOptions,
|
|
39
|
-
label: 'Test Select',
|
|
40
|
-
placeholder: 'Select an option',
|
|
41
|
-
onChange: fn(),
|
|
42
|
-
'data-testid': 'test-select',
|
|
43
|
-
},
|
|
44
|
-
play: async ({ canvasElement, step, args }) => {
|
|
45
|
-
const canvas = within(canvasElement);
|
|
46
|
-
|
|
47
|
-
await step('Initial render verification', async () => {
|
|
48
|
-
// Wait for the component to be fully rendered
|
|
49
|
-
await waitFor(() => {
|
|
50
|
-
const selectComponent = canvas.getByTestId('test-select');
|
|
51
|
-
expect(selectComponent).toBeInTheDocument();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const selectElement = canvas.getByTestId('test-select-select');
|
|
55
|
-
await expect(selectElement).toBeInTheDocument();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
await step('Test dropdown interaction', async () => {
|
|
59
|
-
// MUI Select renders as a combobox role
|
|
60
|
-
const selectElement = canvas.getByRole('combobox');
|
|
61
|
-
|
|
62
|
-
// Click to open
|
|
63
|
-
await userEvent.click(selectElement);
|
|
64
|
-
|
|
65
|
-
// Verify it opened
|
|
66
|
-
await waitFor(() => {
|
|
67
|
-
expect(selectElement).toHaveAttribute('aria-expanded', 'true');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// Click to close
|
|
71
|
-
await userEvent.keyboard('{Escape}');
|
|
72
|
-
|
|
73
|
-
// Verify it closed
|
|
74
|
-
await waitFor(() => {
|
|
75
|
-
expect(selectElement).toHaveAttribute('aria-expanded', 'false');
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
await step('Verify onChange is defined', async () => {
|
|
80
|
-
await expect(args.onChange).toBeDefined();
|
|
81
|
-
await expect(typeof args.onChange).toBe('function');
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export const FormInteraction: Story = {
|
|
87
|
-
name: '📝 Form Interaction Test',
|
|
88
|
-
args: {
|
|
89
|
-
options: defaultOptions,
|
|
90
|
-
label: 'Form Select',
|
|
91
|
-
helperText: 'Select a value',
|
|
92
|
-
onChange: fn(),
|
|
93
|
-
'data-testid': 'form-select',
|
|
94
|
-
},
|
|
95
|
-
play: async ({ canvasElement, args, step }) => {
|
|
96
|
-
const canvas = within(canvasElement);
|
|
97
|
-
|
|
98
|
-
await step('Verify label association', async () => {
|
|
99
|
-
const labels = canvas.getAllByText('Form Select');
|
|
100
|
-
await expect(labels[0]).toBeInTheDocument();
|
|
101
|
-
|
|
102
|
-
// MUI Select renders as a combobox role
|
|
103
|
-
const selectElement = canvas.getByRole('combobox');
|
|
104
|
-
await expect(selectElement).toHaveAttribute('aria-labelledby');
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
await step('Verify helper text association', async () => {
|
|
108
|
-
const helperText = canvas.getByText('Select a value');
|
|
109
|
-
await expect(helperText).toBeInTheDocument();
|
|
110
|
-
|
|
111
|
-
// MUI Select renders as a combobox role
|
|
112
|
-
const selectElement = canvas.getByRole('combobox');
|
|
113
|
-
await expect(selectElement).toHaveAttribute('aria-describedby');
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
await step('Select multiple options in sequence', async () => {
|
|
117
|
-
// MUI Select renders as a combobox role
|
|
118
|
-
const selectElement = canvas.getByRole('combobox');
|
|
119
|
-
|
|
120
|
-
// Select first option
|
|
121
|
-
await userEvent.click(selectElement);
|
|
122
|
-
|
|
123
|
-
// Wait for dropdown to open
|
|
124
|
-
await waitFor(
|
|
125
|
-
async () => {
|
|
126
|
-
await expect(selectElement).toHaveAttribute('aria-expanded', 'true');
|
|
127
|
-
},
|
|
128
|
-
{ timeout: 3000 },
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
await waitFor(() => {
|
|
132
|
-
// TODO: Add assertion or condition
|
|
133
|
-
expect(true).toBe(true);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
const option1 = await waitFor(
|
|
137
|
-
() => {
|
|
138
|
-
const el = document.querySelector(
|
|
139
|
-
'[data-testid="form-select-option-option1"]',
|
|
140
|
-
) as HTMLElement;
|
|
141
|
-
expect(el).toBeInTheDocument();
|
|
142
|
-
return el;
|
|
143
|
-
},
|
|
144
|
-
{ timeout: 3000 },
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
await userEvent.click(option1);
|
|
148
|
-
await expect(args.onChange).toHaveBeenCalledWith(
|
|
149
|
-
expect.objectContaining({
|
|
150
|
-
target: expect.objectContaining({
|
|
151
|
-
value: 'option1',
|
|
152
|
-
}),
|
|
153
|
-
}),
|
|
154
|
-
expect.any(Object),
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
// Select second option
|
|
158
|
-
await userEvent.click(selectElement);
|
|
159
|
-
|
|
160
|
-
// Wait for dropdown to open
|
|
161
|
-
await waitFor(
|
|
162
|
-
async () => {
|
|
163
|
-
await expect(selectElement).toHaveAttribute('aria-expanded', 'true');
|
|
164
|
-
},
|
|
165
|
-
{ timeout: 3000 },
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
await waitFor(() => {
|
|
169
|
-
// TODO: Add assertion or condition
|
|
170
|
-
expect(true).toBe(true);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
const option2 = await waitFor(
|
|
174
|
-
() => {
|
|
175
|
-
const el = document.querySelector(
|
|
176
|
-
'[data-testid="form-select-option-option2"]',
|
|
177
|
-
) as HTMLElement;
|
|
178
|
-
expect(el).toBeInTheDocument();
|
|
179
|
-
return el;
|
|
180
|
-
},
|
|
181
|
-
{ timeout: 3000 },
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
await userEvent.click(option2);
|
|
185
|
-
await expect(args.onChange).toHaveBeenCalledWith(
|
|
186
|
-
expect.objectContaining({
|
|
187
|
-
target: expect.objectContaining({
|
|
188
|
-
value: 'option2',
|
|
189
|
-
}),
|
|
190
|
-
}),
|
|
191
|
-
expect.any(Object),
|
|
192
|
-
);
|
|
193
|
-
});
|
|
194
|
-
},
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const StateChangeTestComponent = () => {
|
|
198
|
-
const [value, setValue] = React.useState<string>('');
|
|
199
|
-
const [error, setError] = React.useState(false);
|
|
200
|
-
|
|
201
|
-
return (
|
|
202
|
-
<Stack spacing={2}>
|
|
203
|
-
<Select
|
|
204
|
-
options={defaultOptions}
|
|
205
|
-
label="Stateful Select"
|
|
206
|
-
value={value}
|
|
207
|
-
error={error}
|
|
208
|
-
helperText={error ? 'Please select an option' : 'Choose your preference'}
|
|
209
|
-
onChange={(event) => {
|
|
210
|
-
setValue(event.target.value as string);
|
|
211
|
-
setError(false);
|
|
212
|
-
}}
|
|
213
|
-
data-testid="stateful-select"
|
|
214
|
-
/>
|
|
215
|
-
<button onClick={() => setError(true)} data-testid="trigger-error">
|
|
216
|
-
Trigger Error
|
|
217
|
-
</button>
|
|
218
|
-
<button onClick={() => setValue('')} data-testid="clear-value">
|
|
219
|
-
Clear Value
|
|
220
|
-
</button>
|
|
221
|
-
</Stack>
|
|
222
|
-
);
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
export const StateChangeTest: Story = {
|
|
226
|
-
name: '🔄 State Change Test',
|
|
227
|
-
render: () => <StateChangeTestComponent />,
|
|
228
|
-
|
|
229
|
-
play: async ({ canvasElement, step }) => {
|
|
230
|
-
const canvas = within(canvasElement);
|
|
231
|
-
|
|
232
|
-
await step('Verify initial state', async () => {
|
|
233
|
-
// MUI Select renders as a combobox role
|
|
234
|
-
const selectElement = canvas.getByRole('combobox');
|
|
235
|
-
await expect(selectElement).toHaveAttribute('aria-expanded', 'false');
|
|
236
|
-
// Check placeholder or empty state - MUI Select may contain non-breaking space when empty
|
|
237
|
-
const textContent =
|
|
238
|
-
selectElement.textContent?.replace(/[\u200B-\u200D\uFEFF\u00A0]/g, '') || '';
|
|
239
|
-
await expect(textContent).toBe('');
|
|
240
|
-
|
|
241
|
-
const helperText = canvas.getByText('Choose your preference');
|
|
242
|
-
await expect(helperText).toBeInTheDocument();
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
await step('Select option and verify state change', async () => {
|
|
246
|
-
// MUI Select renders as a combobox role
|
|
247
|
-
const selectElement = canvas.getByRole('combobox');
|
|
248
|
-
await userEvent.click(selectElement);
|
|
249
|
-
|
|
250
|
-
// Wait for dropdown to open
|
|
251
|
-
await waitFor(
|
|
252
|
-
async () => {
|
|
253
|
-
await expect(selectElement).toHaveAttribute('aria-expanded', 'true');
|
|
254
|
-
},
|
|
255
|
-
{ timeout: 3000 },
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
await waitFor(() => {
|
|
259
|
-
// TODO: Add assertion or condition
|
|
260
|
-
expect(true).toBe(true);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
const option1 = await waitFor(
|
|
264
|
-
() => {
|
|
265
|
-
const el = document.querySelector(
|
|
266
|
-
'[data-testid="stateful-select-option-option1"]',
|
|
267
|
-
) as HTMLElement;
|
|
268
|
-
expect(el).toBeInTheDocument();
|
|
269
|
-
return el;
|
|
270
|
-
},
|
|
271
|
-
{ timeout: 3000 },
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
await userEvent.click(option1);
|
|
275
|
-
|
|
276
|
-
await waitFor(async () => {
|
|
277
|
-
// Check the selected text content in the select element
|
|
278
|
-
await expect(selectElement).toHaveTextContent('Option 1');
|
|
279
|
-
});
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
await step('Trigger error state', async () => {
|
|
283
|
-
const errorButton = canvas.getByTestId('trigger-error');
|
|
284
|
-
await userEvent.click(errorButton);
|
|
285
|
-
|
|
286
|
-
await waitFor(async () => {
|
|
287
|
-
const helperText = canvas.getByText('Please select an option');
|
|
288
|
-
await expect(helperText).toBeInTheDocument();
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
await step('Clear value', async () => {
|
|
293
|
-
const clearButton = canvas.getByTestId('clear-value');
|
|
294
|
-
await userEvent.click(clearButton);
|
|
295
|
-
|
|
296
|
-
await waitFor(async () => {
|
|
297
|
-
// MUI Select renders as a combobox role
|
|
298
|
-
const selectElement = canvas.getByRole('combobox');
|
|
299
|
-
// Check that the select is empty again - MUI Select may contain non-breaking space when empty
|
|
300
|
-
const textContent =
|
|
301
|
-
selectElement.textContent?.replace(/[\u200B-\u200D\uFEFF\u00A0]/g, '') || '';
|
|
302
|
-
await expect(textContent).toBe('');
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
},
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
// ==================== ACCESSIBILITY TESTS ====================
|
|
309
|
-
|
|
310
|
-
export const KeyboardNavigation: Story = {
|
|
311
|
-
name: '⌨️ Keyboard Navigation Test',
|
|
312
|
-
args: {
|
|
313
|
-
options: defaultOptions,
|
|
314
|
-
label: 'Keyboard Select',
|
|
315
|
-
placeholder: 'Use keyboard to navigate',
|
|
316
|
-
'data-testid': 'keyboard-select',
|
|
317
|
-
},
|
|
318
|
-
parameters: {
|
|
319
|
-
a11y: {
|
|
320
|
-
element: '#storybook-root',
|
|
321
|
-
config: {
|
|
322
|
-
rules: [
|
|
323
|
-
{ id: 'color-contrast', enabled: true },
|
|
324
|
-
{ id: 'aria-required-attr', enabled: true },
|
|
325
|
-
{ id: 'aria-roles', enabled: true },
|
|
326
|
-
{ id: 'aria-valid-attr-value', enabled: true },
|
|
327
|
-
{ id: 'button-name', enabled: true },
|
|
328
|
-
{ id: 'duplicate-id', enabled: true },
|
|
329
|
-
{ id: 'label', enabled: true },
|
|
330
|
-
],
|
|
331
|
-
},
|
|
332
|
-
},
|
|
333
|
-
},
|
|
334
|
-
play: async ({ canvasElement, step }) => {
|
|
335
|
-
const canvas = within(canvasElement);
|
|
336
|
-
|
|
337
|
-
await step('Focus select with tab', async () => {
|
|
338
|
-
// MUI Select renders as a combobox role - find it using testid first, then get the combobox inside
|
|
339
|
-
const selectContainer = canvas.getByTestId('keyboard-select');
|
|
340
|
-
const selectElement = selectContainer.querySelector('[role="combobox"]') as HTMLElement;
|
|
341
|
-
await expect(selectElement).toBeInTheDocument();
|
|
342
|
-
await userEvent.click(selectElement);
|
|
343
|
-
await waitFor(() => expect(selectElement).toHaveFocus());
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
await step('Open dropdown with Enter key', async () => {
|
|
347
|
-
// MUI Select renders as a combobox role - find it using container first
|
|
348
|
-
const selectContainer = canvas.getByTestId('keyboard-select');
|
|
349
|
-
const selectElement = selectContainer.querySelector('[role="combobox"]') as HTMLElement;
|
|
350
|
-
await userEvent.click(selectElement);
|
|
351
|
-
|
|
352
|
-
// Use click instead of Enter for more reliable dropdown opening
|
|
353
|
-
await userEvent.click(selectElement);
|
|
354
|
-
|
|
355
|
-
await waitFor(
|
|
356
|
-
async () => {
|
|
357
|
-
await expect(selectElement).toHaveAttribute('aria-expanded', 'true');
|
|
358
|
-
},
|
|
359
|
-
{ timeout: 3000 },
|
|
360
|
-
);
|
|
361
|
-
|
|
362
|
-
await waitFor(async () => {
|
|
363
|
-
const option1 = document.querySelector('[data-testid="keyboard-select-option-option1"]');
|
|
364
|
-
await expect(option1).toBeInTheDocument();
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
await step('Navigate options with arrow keys', async () => {
|
|
369
|
-
// MUI Select renders as a combobox role - find it using container first
|
|
370
|
-
const selectContainer = canvas.getByTestId('keyboard-select');
|
|
371
|
-
const selectElement = selectContainer.querySelector('[role="combobox"]') as HTMLElement;
|
|
372
|
-
|
|
373
|
-
// Ensure dropdown is still open from previous step
|
|
374
|
-
if (selectElement.getAttribute('aria-expanded') !== 'true') {
|
|
375
|
-
await userEvent.click(selectElement);
|
|
376
|
-
await waitFor(async () => {
|
|
377
|
-
await expect(selectElement).toHaveAttribute('aria-expanded', 'true');
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// Arrow down to next option (first arrow down moves to first option)
|
|
382
|
-
await userEvent.keyboard('{ArrowDown}');
|
|
383
|
-
await userEvent.keyboard('{ArrowDown}');
|
|
384
|
-
|
|
385
|
-
// Select with Enter
|
|
386
|
-
await userEvent.keyboard('{Enter}');
|
|
387
|
-
|
|
388
|
-
// Wait for the selection to complete and dropdown to close
|
|
389
|
-
await waitFor(async () => {
|
|
390
|
-
await expect(selectElement).toHaveAttribute('aria-expanded', 'false');
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
// Simplified: Just check that the dropdown interaction worked
|
|
394
|
-
// Note: Text content verification can be flaky with MUI Select
|
|
395
|
-
await expect(selectElement).toBeInTheDocument();
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
await step('Close dropdown with Escape', async () => {
|
|
399
|
-
// MUI Select renders as a combobox role - find it using container first
|
|
400
|
-
const selectContainer = canvas.getByTestId('keyboard-select');
|
|
401
|
-
const selectElement = selectContainer.querySelector('[role="combobox"]') as HTMLElement;
|
|
402
|
-
await userEvent.click(selectElement);
|
|
403
|
-
|
|
404
|
-
await userEvent.keyboard('{Escape}');
|
|
405
|
-
|
|
406
|
-
// Verify dropdown is closed by checking if options are not visible
|
|
407
|
-
await waitFor(async () => {
|
|
408
|
-
const options = document.querySelectorAll('[data-testid^="keyboard-select-option-"]');
|
|
409
|
-
expect(options.length).toBe(0);
|
|
410
|
-
});
|
|
411
|
-
});
|
|
412
|
-
},
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
export const ScreenReader: Story = {
|
|
416
|
-
name: '🔊 Screen Reader Test',
|
|
417
|
-
args: {
|
|
418
|
-
options: defaultOptions,
|
|
419
|
-
label: 'Accessible Select',
|
|
420
|
-
helperText: 'This select has proper ARIA attributes',
|
|
421
|
-
'aria-required': true,
|
|
422
|
-
'data-testid': 'accessible-select',
|
|
423
|
-
},
|
|
424
|
-
play: async ({ canvasElement, step }) => {
|
|
425
|
-
const canvas = within(canvasElement);
|
|
426
|
-
|
|
427
|
-
await step('Verify ARIA labels and roles', async () => {
|
|
428
|
-
// MUI Select renders as a combobox role - find it using container first
|
|
429
|
-
const selectContainer = canvas.getByTestId('accessible-select');
|
|
430
|
-
const selectElement = selectContainer.querySelector('[role="combobox"]') as HTMLElement;
|
|
431
|
-
await expect(selectElement).toBeInTheDocument();
|
|
432
|
-
await expect(selectElement).toHaveAttribute('role', 'combobox');
|
|
433
|
-
await expect(selectElement).toHaveAttribute('aria-expanded', 'false');
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
await step('Verify label association', async () => {
|
|
437
|
-
// Use getAllByText to handle multiple matching elements and pick the first one
|
|
438
|
-
const labels = canvas.getAllByText('Accessible Select');
|
|
439
|
-
await expect(labels[0]).toBeInTheDocument();
|
|
440
|
-
|
|
441
|
-
// MUI Select renders as a combobox role - find it using container first
|
|
442
|
-
const selectContainer = canvas.getByTestId('accessible-select');
|
|
443
|
-
const selectElement = selectContainer.querySelector('[role="combobox"]') as HTMLElement;
|
|
444
|
-
const labelId = selectElement.getAttribute('aria-labelledby');
|
|
445
|
-
await expect(labelId).toBeTruthy();
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
await step('Verify helper text association', async () => {
|
|
449
|
-
const helperText = canvas.getByText('This select has proper ARIA attributes');
|
|
450
|
-
await expect(helperText).toBeInTheDocument();
|
|
451
|
-
|
|
452
|
-
// MUI Select renders as a combobox role - find it using container first
|
|
453
|
-
const selectContainer = canvas.getByTestId('accessible-select');
|
|
454
|
-
const selectElement = selectContainer.querySelector('[role="combobox"]') as HTMLElement;
|
|
455
|
-
const describedBy = selectElement.getAttribute('aria-describedby');
|
|
456
|
-
await expect(describedBy).toBeTruthy();
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
await step('Verify dropdown ARIA states', async () => {
|
|
460
|
-
// MUI Select renders as a combobox role - find it using container first
|
|
461
|
-
const selectContainer = canvas.getByTestId('accessible-select');
|
|
462
|
-
const selectElement = selectContainer.querySelector('[role="combobox"]') as HTMLElement;
|
|
463
|
-
|
|
464
|
-
// Open dropdown
|
|
465
|
-
await userEvent.click(selectElement);
|
|
466
|
-
|
|
467
|
-
await waitFor(async () => {
|
|
468
|
-
await expect(selectElement).toHaveAttribute('aria-expanded', 'true');
|
|
469
|
-
});
|
|
470
|
-
});
|
|
471
|
-
},
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
export const FocusManagement: Story = {
|
|
475
|
-
name: '🎯 Focus Management Test',
|
|
476
|
-
render: () => (
|
|
477
|
-
<Stack spacing={2}>
|
|
478
|
-
<button data-testid="before-select">Before Select</button>
|
|
479
|
-
<Select
|
|
480
|
-
options={defaultOptions}
|
|
481
|
-
label="Focus Test Select"
|
|
482
|
-
placeholder="Test focus management"
|
|
483
|
-
data-testid="focus-select"
|
|
484
|
-
/>
|
|
485
|
-
<button data-testid="after-select">After Select</button>
|
|
486
|
-
</Stack>
|
|
487
|
-
),
|
|
488
|
-
play: async ({ canvasElement, step }) => {
|
|
489
|
-
const canvas = within(canvasElement);
|
|
490
|
-
|
|
491
|
-
await step('Tab navigation forward', async () => {
|
|
492
|
-
const beforeButton = canvas.getByTestId('before-select');
|
|
493
|
-
await userEvent.click(beforeButton);
|
|
494
|
-
await waitFor(() => expect(beforeButton).toHaveFocus());
|
|
495
|
-
|
|
496
|
-
await userEvent.tab();
|
|
497
|
-
// MUI Select renders as a combobox role
|
|
498
|
-
const selectElement = canvas.getByRole('combobox');
|
|
499
|
-
await waitFor(() => expect(selectElement).toHaveFocus());
|
|
500
|
-
|
|
501
|
-
await userEvent.tab();
|
|
502
|
-
const afterButton = canvas.getByTestId('after-select');
|
|
503
|
-
await waitFor(() => expect(afterButton).toHaveFocus());
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
await step('Tab navigation backward', async () => {
|
|
507
|
-
await userEvent.tab({ shift: true });
|
|
508
|
-
// MUI Select renders as a combobox role
|
|
509
|
-
const selectElement = canvas.getByRole('combobox');
|
|
510
|
-
await waitFor(() => expect(selectElement).toHaveFocus());
|
|
511
|
-
|
|
512
|
-
await userEvent.tab({ shift: true });
|
|
513
|
-
const beforeButton = canvas.getByTestId('before-select');
|
|
514
|
-
await waitFor(() => expect(beforeButton).toHaveFocus());
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
await step('Focus returns to select after dropdown interaction', async () => {
|
|
518
|
-
// MUI Select renders as a combobox role
|
|
519
|
-
const selectElement = canvas.getByRole('combobox');
|
|
520
|
-
await userEvent.click(selectElement);
|
|
521
|
-
|
|
522
|
-
// Open dropdown and select option
|
|
523
|
-
await userEvent.keyboard('{Enter}');
|
|
524
|
-
await userEvent.keyboard('{ArrowDown}');
|
|
525
|
-
await userEvent.keyboard('{Enter}');
|
|
526
|
-
|
|
527
|
-
// Focus should return to select
|
|
528
|
-
await waitFor(async () => {
|
|
529
|
-
await expect(selectElement).toHaveFocus();
|
|
530
|
-
});
|
|
531
|
-
});
|
|
532
|
-
},
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
// ==================== VISUAL TESTS ====================
|
|
536
|
-
|
|
537
|
-
export const ResponsiveDesign: Story = {
|
|
538
|
-
name: '📱 Responsive Design Test',
|
|
539
|
-
args: {
|
|
540
|
-
options: defaultOptions,
|
|
541
|
-
label: 'Responsive Select',
|
|
542
|
-
helperText: 'This select adapts to different screen sizes',
|
|
543
|
-
},
|
|
544
|
-
parameters: {
|
|
545
|
-
viewport: {
|
|
546
|
-
viewports: {
|
|
547
|
-
mobile: {
|
|
548
|
-
name: 'Mobile',
|
|
549
|
-
styles: { width: '375px', height: '667px' },
|
|
550
|
-
type: 'mobile',
|
|
551
|
-
},
|
|
552
|
-
tablet: {
|
|
553
|
-
name: 'Tablet',
|
|
554
|
-
styles: { width: '768px', height: '1024px' },
|
|
555
|
-
type: 'tablet',
|
|
556
|
-
},
|
|
557
|
-
desktop: {
|
|
558
|
-
name: 'Desktop',
|
|
559
|
-
styles: { width: '1920px', height: '1080px' },
|
|
560
|
-
type: 'desktop',
|
|
561
|
-
},
|
|
562
|
-
},
|
|
563
|
-
defaultViewport: 'mobile',
|
|
564
|
-
},
|
|
565
|
-
chromatic: {
|
|
566
|
-
viewports: [375, 768, 1920],
|
|
567
|
-
delay: 300,
|
|
568
|
-
},
|
|
569
|
-
},
|
|
570
|
-
play: async ({ canvasElement, step }) => {
|
|
571
|
-
const canvas = within(canvasElement);
|
|
572
|
-
|
|
573
|
-
await step('Verify select renders on different viewports', async () => {
|
|
574
|
-
const selectComponent = canvas.getByRole('combobox');
|
|
575
|
-
await expect(selectComponent).toBeInTheDocument();
|
|
576
|
-
await expect(selectComponent).toBeVisible();
|
|
577
|
-
|
|
578
|
-
const computedStyle = window.getComputedStyle(selectComponent);
|
|
579
|
-
await expect(computedStyle.display).not.toBe('none');
|
|
580
|
-
});
|
|
581
|
-
},
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
export const ThemeVariations: Story = {
|
|
585
|
-
name: '🎨 Theme Variations Test',
|
|
586
|
-
render: () => (
|
|
587
|
-
<Stack spacing={3}>
|
|
588
|
-
<Select
|
|
589
|
-
options={defaultOptions}
|
|
590
|
-
label="Default Theme"
|
|
591
|
-
variant="default"
|
|
592
|
-
data-testid="default-theme"
|
|
593
|
-
/>
|
|
594
|
-
<Select
|
|
595
|
-
options={defaultOptions}
|
|
596
|
-
label="Glass Theme"
|
|
597
|
-
variant="glass"
|
|
598
|
-
data-testid="glass-theme"
|
|
599
|
-
/>
|
|
600
|
-
<Select
|
|
601
|
-
options={defaultOptions}
|
|
602
|
-
label="Gradient Theme"
|
|
603
|
-
variant="gradient"
|
|
604
|
-
data-testid="gradient-theme"
|
|
605
|
-
/>
|
|
606
|
-
</Stack>
|
|
607
|
-
),
|
|
608
|
-
parameters: {
|
|
609
|
-
backgrounds: {
|
|
610
|
-
default: 'light',
|
|
611
|
-
values: [
|
|
612
|
-
{ name: 'light', value: '#ffffff' },
|
|
613
|
-
{ name: 'dark', value: '#1a1a1a' },
|
|
614
|
-
],
|
|
615
|
-
},
|
|
616
|
-
},
|
|
617
|
-
play: async ({ canvasElement, step }) => {
|
|
618
|
-
const canvas = within(canvasElement);
|
|
619
|
-
|
|
620
|
-
await step('Verify all variants render correctly', async () => {
|
|
621
|
-
const defaultSelect = canvas.getByTestId('default-theme');
|
|
622
|
-
const glassSelect = canvas.getByTestId('glass-theme');
|
|
623
|
-
const gradientSelect = canvas.getByTestId('gradient-theme');
|
|
624
|
-
|
|
625
|
-
await expect(defaultSelect).toBeInTheDocument();
|
|
626
|
-
await expect(glassSelect).toBeInTheDocument();
|
|
627
|
-
await expect(gradientSelect).toBeInTheDocument();
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
await step('Verify theme-specific styling', async () => {
|
|
631
|
-
const glassSelect = canvas.getByTestId('glass-theme');
|
|
632
|
-
const computedStyle = window.getComputedStyle(glassSelect);
|
|
633
|
-
|
|
634
|
-
// Glass variant should have backdrop filter
|
|
635
|
-
await expect(computedStyle.backdropFilter || computedStyle.webkitBackdropFilter).toBeTruthy();
|
|
636
|
-
});
|
|
637
|
-
},
|
|
638
|
-
};
|
|
639
|
-
|
|
640
|
-
export const VisualStates: Story = {
|
|
641
|
-
name: '👁️ Visual States Test',
|
|
642
|
-
render: () => (
|
|
643
|
-
<Stack spacing={3}>
|
|
644
|
-
<Select
|
|
645
|
-
options={defaultOptions}
|
|
646
|
-
label="Default State"
|
|
647
|
-
placeholder="Default appearance"
|
|
648
|
-
data-testid="default-state"
|
|
649
|
-
/>
|
|
650
|
-
<Select
|
|
651
|
-
options={defaultOptions}
|
|
652
|
-
label="Error State"
|
|
653
|
-
placeholder="Error appearance"
|
|
654
|
-
error
|
|
655
|
-
helperText="This field has an error"
|
|
656
|
-
data-testid="error-state"
|
|
657
|
-
/>
|
|
658
|
-
<Select
|
|
659
|
-
options={defaultOptions}
|
|
660
|
-
label="Disabled State"
|
|
661
|
-
placeholder="Disabled appearance"
|
|
662
|
-
disabled
|
|
663
|
-
data-testid="disabled-state"
|
|
664
|
-
/>
|
|
665
|
-
<Select
|
|
666
|
-
options={defaultOptions}
|
|
667
|
-
label="Glow Effect"
|
|
668
|
-
placeholder="Glow appearance"
|
|
669
|
-
glow
|
|
670
|
-
data-testid="glow-state"
|
|
671
|
-
/>
|
|
672
|
-
<Select
|
|
673
|
-
options={defaultOptions}
|
|
674
|
-
label="Pulse Effect"
|
|
675
|
-
placeholder="Pulse appearance"
|
|
676
|
-
pulse
|
|
677
|
-
data-testid="pulse-state"
|
|
678
|
-
/>
|
|
679
|
-
</Stack>
|
|
680
|
-
),
|
|
681
|
-
play: async ({ canvasElement, step }) => {
|
|
682
|
-
const canvas = within(canvasElement);
|
|
683
|
-
|
|
684
|
-
await step('Verify default state', async () => {
|
|
685
|
-
const defaultSelect = canvas.getByTestId('default-state');
|
|
686
|
-
await expect(defaultSelect).toBeInTheDocument();
|
|
687
|
-
const selectElement = defaultSelect.querySelector('[role="combobox"]') as HTMLElement;
|
|
688
|
-
await expect(selectElement).not.toBeDisabled();
|
|
689
|
-
});
|
|
690
|
-
|
|
691
|
-
await step('Verify error state styling', async () => {
|
|
692
|
-
const errorSelect = canvas.getByTestId('error-state');
|
|
693
|
-
await expect(errorSelect).toBeInTheDocument();
|
|
694
|
-
|
|
695
|
-
const helperText = canvas.getByText('This field has an error');
|
|
696
|
-
await expect(helperText).toBeInTheDocument();
|
|
697
|
-
|
|
698
|
-
// Check if error styling is applied - look for the error class anywhere in the component tree
|
|
699
|
-
await waitFor(() => {
|
|
700
|
-
const hasErrorClass =
|
|
701
|
-
errorSelect.classList.contains('Mui-error') ||
|
|
702
|
-
Boolean(errorSelect.querySelector('.Mui-error'));
|
|
703
|
-
expect(hasErrorClass).toBe(true);
|
|
704
|
-
});
|
|
705
|
-
});
|
|
706
|
-
|
|
707
|
-
await step('Verify disabled state', async () => {
|
|
708
|
-
const disabledSelect = canvas.getByTestId('disabled-state');
|
|
709
|
-
await expect(disabledSelect).toBeInTheDocument();
|
|
710
|
-
|
|
711
|
-
const selectElement = disabledSelect.querySelector('[role="combobox"]') as HTMLElement;
|
|
712
|
-
// MUI Select shows disabled state via aria-disabled attribute
|
|
713
|
-
await expect(selectElement).toHaveAttribute('aria-disabled', 'true');
|
|
714
|
-
|
|
715
|
-
// Check if element has disabled styling applied
|
|
716
|
-
await expect(selectElement).toHaveClass('Mui-disabled');
|
|
717
|
-
});
|
|
718
|
-
|
|
719
|
-
await step('Verify visual effects', async () => {
|
|
720
|
-
const glowSelect = canvas.getByTestId('glow-state');
|
|
721
|
-
const pulseSelect = canvas.getByTestId('pulse-state');
|
|
722
|
-
|
|
723
|
-
await expect(glowSelect).toBeInTheDocument();
|
|
724
|
-
await expect(pulseSelect).toBeInTheDocument();
|
|
725
|
-
});
|
|
726
|
-
|
|
727
|
-
await step('Test hover interactions', async () => {
|
|
728
|
-
const defaultSelect = canvas.getByTestId('default-state');
|
|
729
|
-
const selectElement = defaultSelect.querySelector('[role="combobox"]') as HTMLElement;
|
|
730
|
-
await userEvent.hover(selectElement);
|
|
731
|
-
|
|
732
|
-
// Verify the select can receive hover events
|
|
733
|
-
await expect(selectElement).toBeInTheDocument();
|
|
734
|
-
});
|
|
735
|
-
},
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
// ==================== PERFORMANCE TESTS ====================
|
|
739
|
-
|
|
740
|
-
export const Performance: Story = {
|
|
741
|
-
name: '⚡ Performance Test',
|
|
742
|
-
args: {
|
|
743
|
-
options: manyOptions,
|
|
744
|
-
label: 'Performance Test Select',
|
|
745
|
-
placeholder: 'Select from many options',
|
|
746
|
-
'data-testid': 'performance-select',
|
|
747
|
-
},
|
|
748
|
-
play: async ({ canvasElement, step }) => {
|
|
749
|
-
const canvas = within(canvasElement);
|
|
750
|
-
|
|
751
|
-
// This bracketed the interaction below with Date.now() and asserted a
|
|
752
|
-
// wall-clock budget, which measured the machine rather than the component.
|
|
753
|
-
await step('Open a select with many options', async () => {
|
|
754
|
-
const selectContainer = canvas.getByTestId('performance-select');
|
|
755
|
-
const selectElement = selectContainer.querySelector('[role="combobox"]') as HTMLElement;
|
|
756
|
-
await userEvent.click(selectElement);
|
|
757
|
-
|
|
758
|
-
await waitFor(async () => {
|
|
759
|
-
const options = document.querySelectorAll('[data-testid^="performance-select-option-"]');
|
|
760
|
-
expect(options.length).toBeGreaterThan(0);
|
|
761
|
-
});
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
});
|
|
766
|
-
|
|
767
|
-
await step('Test scroll performance in dropdown', async () => {
|
|
768
|
-
const selectContainer = canvas.getByTestId('performance-select');
|
|
769
|
-
const selectElement = selectContainer.querySelector('[role="combobox"]') as HTMLElement;
|
|
770
|
-
if (selectElement.getAttribute('aria-expanded') !== 'true') {
|
|
771
|
-
await userEvent.click(selectElement);
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
// Wait for dropdown to be fully rendered
|
|
775
|
-
await waitFor(async () => {
|
|
776
|
-
const firstOption = document.querySelector(
|
|
777
|
-
'[data-testid="performance-select-option-option1"]',
|
|
778
|
-
);
|
|
779
|
-
await expect(firstOption).toBeInTheDocument();
|
|
780
|
-
});
|
|
781
|
-
|
|
782
|
-
// Test selecting an option from the middle of the list
|
|
783
|
-
const middleOption = document.querySelector(
|
|
784
|
-
'[data-testid="performance-select-option-option25"]',
|
|
785
|
-
) as HTMLElement;
|
|
786
|
-
await userEvent.click(middleOption);
|
|
787
|
-
|
|
788
|
-
// Simplified: Just verify the dropdown interaction worked
|
|
789
|
-
await expect(selectElement).toBeInTheDocument();
|
|
790
|
-
});
|
|
791
|
-
},
|
|
792
|
-
};
|
|
793
|
-
|
|
794
|
-
// ==================== EDGE CASES TESTS ====================
|
|
795
|
-
|
|
796
|
-
export const EdgeCases: Story = {
|
|
797
|
-
name: '🔧 Edge Cases Test',
|
|
798
|
-
render: () => (
|
|
799
|
-
<Stack spacing={3}>
|
|
800
|
-
<Select
|
|
801
|
-
options={[]}
|
|
802
|
-
label="Empty Options"
|
|
803
|
-
placeholder="No options available"
|
|
804
|
-
data-testid="empty-options"
|
|
805
|
-
/>
|
|
806
|
-
<Select
|
|
807
|
-
options={[
|
|
808
|
-
{
|
|
809
|
-
value: 'very-long-option-value-that-might-cause-overflow-issues',
|
|
810
|
-
label:
|
|
811
|
-
'Very Long Option Label That Might Cause Layout Issues and Should Be Handled Gracefully by the Component Without Breaking the UI',
|
|
812
|
-
},
|
|
813
|
-
{ value: 'short', label: 'Short' },
|
|
814
|
-
]}
|
|
815
|
-
label="Long Text Test"
|
|
816
|
-
placeholder="Test long text handling"
|
|
817
|
-
data-testid="long-text"
|
|
818
|
-
/>
|
|
819
|
-
<Select
|
|
820
|
-
options={[
|
|
821
|
-
{ value: '', label: 'Empty Value Option' },
|
|
822
|
-
{ value: '0', label: 'Zero Value' },
|
|
823
|
-
{ value: 'false', label: 'False Value' },
|
|
824
|
-
{ value: 'null', label: 'Null String' },
|
|
825
|
-
]}
|
|
826
|
-
label="Edge Values"
|
|
827
|
-
placeholder="Test edge case values"
|
|
828
|
-
data-testid="edge-values"
|
|
829
|
-
/>
|
|
830
|
-
</Stack>
|
|
831
|
-
),
|
|
832
|
-
play: async ({ canvasElement, step }) => {
|
|
833
|
-
const canvas = within(canvasElement);
|
|
834
|
-
|
|
835
|
-
await step('Handle empty options gracefully', async () => {
|
|
836
|
-
const emptySelect = canvas.getByTestId('empty-options');
|
|
837
|
-
await expect(emptySelect).toBeInTheDocument();
|
|
838
|
-
|
|
839
|
-
const selectElement = emptySelect.querySelector('[role="combobox"]') as HTMLElement;
|
|
840
|
-
|
|
841
|
-
// Should be able to click without errors
|
|
842
|
-
await userEvent.click(selectElement);
|
|
843
|
-
|
|
844
|
-
// No options should be available
|
|
845
|
-
const options = document.querySelectorAll('[data-testid^="empty-options-option-"]');
|
|
846
|
-
expect(options.length).toBe(0);
|
|
847
|
-
});
|
|
848
|
-
|
|
849
|
-
await step('Handle long text gracefully', async () => {
|
|
850
|
-
const longTextSelect = canvas.getByTestId('long-text');
|
|
851
|
-
const selectElement = longTextSelect.querySelector('[role="combobox"]') as HTMLElement;
|
|
852
|
-
await userEvent.click(selectElement);
|
|
853
|
-
|
|
854
|
-
const longOption = document.querySelector(
|
|
855
|
-
'[data-testid="long-text-option-very-long-option-value-that-might-cause-overflow-issues"]',
|
|
856
|
-
) as HTMLElement;
|
|
857
|
-
await expect(longOption).toBeInTheDocument();
|
|
858
|
-
|
|
859
|
-
// Should be able to select the long option
|
|
860
|
-
await userEvent.click(longOption);
|
|
861
|
-
|
|
862
|
-
// Simplified: Just verify the interaction worked
|
|
863
|
-
await expect(selectElement).toBeInTheDocument();
|
|
864
|
-
});
|
|
865
|
-
|
|
866
|
-
await step('Handle edge case values', async () => {
|
|
867
|
-
const edgeValuesSelect = canvas.getByTestId('edge-values');
|
|
868
|
-
const selectElement = edgeValuesSelect.querySelector('[role="combobox"]') as HTMLElement;
|
|
869
|
-
await userEvent.click(selectElement);
|
|
870
|
-
|
|
871
|
-
// Test empty value option
|
|
872
|
-
const emptyValueOption = document.querySelector(
|
|
873
|
-
'[data-testid="edge-values-option-"]',
|
|
874
|
-
) as HTMLElement;
|
|
875
|
-
await userEvent.click(emptyValueOption);
|
|
876
|
-
|
|
877
|
-
await waitFor(async () => {
|
|
878
|
-
await expect(selectElement).toHaveTextContent('Empty Value Option');
|
|
879
|
-
});
|
|
880
|
-
|
|
881
|
-
// Test zero value option
|
|
882
|
-
await userEvent.click(selectElement);
|
|
883
|
-
const zeroValueOption = document.querySelector(
|
|
884
|
-
'[data-testid="edge-values-option-0"]',
|
|
885
|
-
) as HTMLElement;
|
|
886
|
-
await userEvent.click(zeroValueOption);
|
|
887
|
-
|
|
888
|
-
// Simplified: Just verify the interaction worked
|
|
889
|
-
await expect(selectElement).toBeInTheDocument();
|
|
890
|
-
});
|
|
891
|
-
|
|
892
|
-
await step('Verify component stability under stress', async () => {
|
|
893
|
-
// Rapidly open and close select multiple times
|
|
894
|
-
const longTextSelect = canvas.getByTestId('long-text');
|
|
895
|
-
const selectElement = longTextSelect.querySelector('[role="combobox"]') as HTMLElement;
|
|
896
|
-
|
|
897
|
-
for (let i = 0; i < 3; i++) {
|
|
898
|
-
await userEvent.click(selectElement);
|
|
899
|
-
await userEvent.keyboard('{Escape}');
|
|
900
|
-
// Small delay to ensure state change
|
|
901
|
-
await waitFor(() => {
|
|
902
|
-
// TODO: Add assertion or condition
|
|
903
|
-
expect(true).toBe(true);
|
|
904
|
-
});
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
// Select should still be functional
|
|
908
|
-
await expect(selectElement).toBeInTheDocument();
|
|
909
|
-
await expect(selectElement).not.toBeDisabled();
|
|
910
|
-
});
|
|
911
|
-
},
|
|
912
|
-
};
|
|
913
|
-
|
|
914
|
-
// ==================== INTEGRATION TESTS ====================
|
|
915
|
-
|
|
916
|
-
const IntegrationTestComponent = () => {
|
|
917
|
-
const [selectValue, setSelectValue] = React.useState('');
|
|
918
|
-
const [relatedData, setRelatedData] = React.useState('');
|
|
919
|
-
|
|
920
|
-
React.useEffect(() => {
|
|
921
|
-
if (selectValue) {
|
|
922
|
-
setRelatedData(`Related data for ${selectValue}`);
|
|
923
|
-
} else {
|
|
924
|
-
setRelatedData('');
|
|
925
|
-
}
|
|
926
|
-
}, [selectValue]);
|
|
927
|
-
|
|
928
|
-
return (
|
|
929
|
-
<Stack spacing={2}>
|
|
930
|
-
<Select
|
|
931
|
-
options={defaultOptions}
|
|
932
|
-
label="Trigger Select"
|
|
933
|
-
value={selectValue}
|
|
934
|
-
onChange={(event) => setSelectValue(event.target.value as string)}
|
|
935
|
-
data-testid="trigger-select"
|
|
936
|
-
/>
|
|
937
|
-
<div data-testid="related-component">{relatedData || 'No data selected'}</div>
|
|
938
|
-
<button onClick={() => setSelectValue('option1')} data-testid="external-trigger">
|
|
939
|
-
Set Option 1 Externally
|
|
940
|
-
</button>
|
|
941
|
-
</Stack>
|
|
942
|
-
);
|
|
943
|
-
};
|
|
944
|
-
|
|
945
|
-
export const Integration: Story = {
|
|
946
|
-
name: '🔗 Integration Test',
|
|
947
|
-
render: () => <IntegrationTestComponent />,
|
|
948
|
-
|
|
949
|
-
play: async ({ canvasElement, step }) => {
|
|
950
|
-
const canvas = within(canvasElement);
|
|
951
|
-
|
|
952
|
-
await step('Verify initial integration state', async () => {
|
|
953
|
-
const relatedComponent = canvas.getByTestId('related-component');
|
|
954
|
-
await expect(relatedComponent).toHaveTextContent('No data selected');
|
|
955
|
-
});
|
|
956
|
-
|
|
957
|
-
await step('Test select affecting related component', async () => {
|
|
958
|
-
const selectElement = canvas.getByRole('combobox');
|
|
959
|
-
await userEvent.click(selectElement);
|
|
960
|
-
|
|
961
|
-
const option2 = document.querySelector(
|
|
962
|
-
'[data-testid="trigger-select-option-option2"]',
|
|
963
|
-
) as HTMLElement;
|
|
964
|
-
await userEvent.click(option2);
|
|
965
|
-
|
|
966
|
-
await waitFor(async () => {
|
|
967
|
-
const relatedComponent = canvas.getByTestId('related-component');
|
|
968
|
-
await expect(relatedComponent).toHaveTextContent('Related data for option2');
|
|
969
|
-
});
|
|
970
|
-
});
|
|
971
|
-
|
|
972
|
-
await step('Test external control of select', async () => {
|
|
973
|
-
const externalTrigger = canvas.getByTestId('external-trigger');
|
|
974
|
-
await userEvent.click(externalTrigger);
|
|
975
|
-
|
|
976
|
-
await waitFor(async () => {
|
|
977
|
-
const selectElement = canvas.getByRole('combobox');
|
|
978
|
-
await expect(selectElement).toHaveTextContent('Option 1');
|
|
979
|
-
|
|
980
|
-
const relatedComponent = canvas.getByTestId('related-component');
|
|
981
|
-
await expect(relatedComponent).toHaveTextContent('Related data for option1');
|
|
982
|
-
});
|
|
983
|
-
});
|
|
984
|
-
},
|
|
985
|
-
};
|