@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,597 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { Moon, Sun, Volume2, VolumeX } from 'lucide-react';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
|
|
5
|
-
|
|
6
|
-
import { Switch } from './Switch';
|
|
7
|
-
|
|
8
|
-
const meta: Meta<typeof Switch> = {
|
|
9
|
-
title: 'Form/Switch/Tests',
|
|
10
|
-
component: Switch,
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: 'centered',
|
|
13
|
-
chromatic: { disableSnapshot: false },
|
|
14
|
-
},
|
|
15
|
-
tags: ['autodocs', 'test', 'component:Switch'],
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default meta;
|
|
19
|
-
type Story = StoryObj<typeof meta>;
|
|
20
|
-
|
|
21
|
-
// ===== INTERACTION TESTS =====
|
|
22
|
-
|
|
23
|
-
export const BasicInteraction: Story = {
|
|
24
|
-
name: '🧪 Basic Interaction Test',
|
|
25
|
-
args: {
|
|
26
|
-
'data-testid': 'basic-switch',
|
|
27
|
-
onChange: fn(),
|
|
28
|
-
onClick: fn(),
|
|
29
|
-
onFocus: fn(),
|
|
30
|
-
onBlur: fn(),
|
|
31
|
-
},
|
|
32
|
-
play: async ({ canvasElement, step, args }) => {
|
|
33
|
-
const canvas = within(canvasElement);
|
|
34
|
-
|
|
35
|
-
await step('Initial render verification', async () => {
|
|
36
|
-
const switchElement = canvas.getByRole('checkbox');
|
|
37
|
-
await expect(switchElement).toBeInTheDocument();
|
|
38
|
-
await expect(switchElement).not.toBeChecked();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
await step('Click interaction', async () => {
|
|
42
|
-
const switchElement = canvas.getByRole('checkbox');
|
|
43
|
-
await userEvent.click(switchElement);
|
|
44
|
-
await expect(args.onChange).toHaveBeenCalledTimes(1);
|
|
45
|
-
await expect(switchElement).toBeChecked();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
await step('Second click to toggle off', async () => {
|
|
49
|
-
const switchElement = canvas.getByRole('checkbox');
|
|
50
|
-
await userEvent.click(switchElement);
|
|
51
|
-
await expect(args.onChange).toHaveBeenCalledTimes(2);
|
|
52
|
-
await expect(switchElement).not.toBeChecked();
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const KeyboardInteraction: Story = {
|
|
58
|
-
name: '⌨️ Keyboard Interaction Test',
|
|
59
|
-
args: {
|
|
60
|
-
'data-testid': 'keyboard-switch',
|
|
61
|
-
label: 'Keyboard accessible switch',
|
|
62
|
-
onChange: fn(),
|
|
63
|
-
onFocus: fn(),
|
|
64
|
-
onBlur: fn(),
|
|
65
|
-
onClick: fn(),
|
|
66
|
-
},
|
|
67
|
-
play: async ({ canvasElement, step, args }) => {
|
|
68
|
-
const canvas = within(canvasElement);
|
|
69
|
-
|
|
70
|
-
await step('Focus with Tab key', async () => {
|
|
71
|
-
const switchElement = canvas.getByRole('checkbox');
|
|
72
|
-
await userEvent.tab();
|
|
73
|
-
await waitFor(() => expect(switchElement).toHaveFocus());
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
await step('Toggle with Space key', async () => {
|
|
77
|
-
const switchElement = canvas.getByRole('checkbox');
|
|
78
|
-
await userEvent.keyboard(' ');
|
|
79
|
-
await expect(args.onChange).toHaveBeenCalledTimes(1);
|
|
80
|
-
await expect(switchElement).toBeChecked();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
await step('Toggle again with Space key', async () => {
|
|
84
|
-
const switchElement = canvas.getByRole('checkbox');
|
|
85
|
-
await userEvent.keyboard(' ');
|
|
86
|
-
await expect(args.onChange).toHaveBeenCalledTimes(2);
|
|
87
|
-
await expect(switchElement).not.toBeChecked();
|
|
88
|
-
});
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const StateChangeComponent = () => {
|
|
93
|
-
const [checked, setChecked] = React.useState(false);
|
|
94
|
-
return (
|
|
95
|
-
<Switch
|
|
96
|
-
data-testid="stateful-switch"
|
|
97
|
-
label="Stateful switch"
|
|
98
|
-
checked={checked}
|
|
99
|
-
onChange={(e) => setChecked(e.target.checked)}
|
|
100
|
-
/>
|
|
101
|
-
);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export const StateChangeTest: Story = {
|
|
105
|
-
name: '🔄 State Change Test',
|
|
106
|
-
render: () => <StateChangeComponent />,
|
|
107
|
-
play: async ({ canvasElement, step }) => {
|
|
108
|
-
const canvas = within(canvasElement);
|
|
109
|
-
|
|
110
|
-
await step('Verify initial unchecked state', async () => {
|
|
111
|
-
const switchElement = canvas.getByRole('checkbox');
|
|
112
|
-
await expect(switchElement).not.toBeChecked();
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
await step('Toggle to checked state', async () => {
|
|
116
|
-
const switchElement = canvas.getByRole('checkbox');
|
|
117
|
-
await userEvent.click(switchElement);
|
|
118
|
-
await waitFor(() => {
|
|
119
|
-
expect(switchElement).toBeChecked();
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
await step('Toggle back to unchecked state', async () => {
|
|
124
|
-
const switchElement = canvas.getByRole('checkbox');
|
|
125
|
-
await userEvent.click(switchElement);
|
|
126
|
-
await waitFor(() => {
|
|
127
|
-
expect(switchElement).not.toBeChecked();
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// ===== ACCESSIBILITY TESTS =====
|
|
134
|
-
|
|
135
|
-
export const AccessibilityTest: Story = {
|
|
136
|
-
name: '♿ Accessibility Test',
|
|
137
|
-
args: {
|
|
138
|
-
'data-testid': 'accessible-switch',
|
|
139
|
-
label: 'Accessible switch',
|
|
140
|
-
description: 'This switch has proper accessibility attributes',
|
|
141
|
-
'aria-label': 'Toggle notifications',
|
|
142
|
-
'aria-describedby': 'switch-description',
|
|
143
|
-
onChange: fn(),
|
|
144
|
-
onFocus: fn(),
|
|
145
|
-
onBlur: fn(),
|
|
146
|
-
onClick: fn(),
|
|
147
|
-
},
|
|
148
|
-
parameters: {
|
|
149
|
-
a11y: {
|
|
150
|
-
element: '#storybook-root',
|
|
151
|
-
config: {
|
|
152
|
-
rules: [
|
|
153
|
-
{ id: 'color-contrast', enabled: true },
|
|
154
|
-
{ id: 'aria-required-attr', enabled: true },
|
|
155
|
-
{ id: 'aria-roles', enabled: true },
|
|
156
|
-
{ id: 'aria-valid-attr-value', enabled: true },
|
|
157
|
-
{ id: 'button-name', enabled: true },
|
|
158
|
-
{ id: 'duplicate-id', enabled: true },
|
|
159
|
-
{ id: 'label', enabled: true },
|
|
160
|
-
],
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
play: async ({ canvasElement, step }) => {
|
|
165
|
-
const canvas = within(canvasElement);
|
|
166
|
-
|
|
167
|
-
await step('Verify ARIA attributes', async () => {
|
|
168
|
-
const switchElement = canvas.getByRole('checkbox');
|
|
169
|
-
await expect(switchElement).toBeInTheDocument();
|
|
170
|
-
await expect(switchElement).toHaveAttribute('aria-label', 'Toggle notifications');
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
await step('Verify role attributes', async () => {
|
|
174
|
-
const switchElement = canvas.getByRole('checkbox');
|
|
175
|
-
await expect(switchElement).toHaveAttribute('type', 'checkbox');
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
await step('Verify label association', async () => {
|
|
179
|
-
// Since the label is rendered as text, not a proper label element,
|
|
180
|
-
// we verify the label text is present alongside the switch
|
|
181
|
-
const labelText = canvas.getByText('Accessible switch');
|
|
182
|
-
await expect(labelText).toBeInTheDocument();
|
|
183
|
-
|
|
184
|
-
// Verify the switch is in the same container
|
|
185
|
-
const switchElement = canvas.getByRole('checkbox');
|
|
186
|
-
await expect(switchElement).toBeInTheDocument();
|
|
187
|
-
});
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
export const FocusManagement: Story = {
|
|
192
|
-
name: '🎯 Focus Management Test',
|
|
193
|
-
render: () => (
|
|
194
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
|
|
195
|
-
<Switch data-testid="first-switch" label="First switch" />
|
|
196
|
-
<Switch data-testid="second-switch" label="Second switch" />
|
|
197
|
-
<Switch data-testid="third-switch" label="Third switch" />
|
|
198
|
-
</div>
|
|
199
|
-
),
|
|
200
|
-
play: async ({ canvasElement, step }) => {
|
|
201
|
-
const canvas = within(canvasElement);
|
|
202
|
-
|
|
203
|
-
await step('Tab through switches', async () => {
|
|
204
|
-
const firstSwitch = canvas
|
|
205
|
-
.getByTestId('first-switch')
|
|
206
|
-
.querySelector('input[type="checkbox"]');
|
|
207
|
-
const secondSwitch = canvas
|
|
208
|
-
.getByTestId('second-switch')
|
|
209
|
-
.querySelector('input[type="checkbox"]');
|
|
210
|
-
const thirdSwitch = canvas
|
|
211
|
-
.getByTestId('third-switch')
|
|
212
|
-
.querySelector('input[type="checkbox"]');
|
|
213
|
-
|
|
214
|
-
// Focus first switch
|
|
215
|
-
await userEvent.tab();
|
|
216
|
-
await waitFor(() => expect(firstSwitch).toHaveFocus());
|
|
217
|
-
|
|
218
|
-
// Tab to second switch
|
|
219
|
-
await userEvent.tab();
|
|
220
|
-
await waitFor(() => expect(secondSwitch).toHaveFocus());
|
|
221
|
-
|
|
222
|
-
// Tab to third switch
|
|
223
|
-
await userEvent.tab();
|
|
224
|
-
await waitFor(() => expect(thirdSwitch).toHaveFocus());
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
await step('Tab navigation backward', async () => {
|
|
228
|
-
const secondSwitch = canvas
|
|
229
|
-
.getByTestId('second-switch')
|
|
230
|
-
.querySelector('input[type="checkbox"]');
|
|
231
|
-
|
|
232
|
-
await userEvent.tab({ shift: true });
|
|
233
|
-
await waitFor(() => expect(secondSwitch).toHaveFocus());
|
|
234
|
-
});
|
|
235
|
-
},
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
// ===== VISUAL TESTS =====
|
|
239
|
-
|
|
240
|
-
export const VisualStates: Story = {
|
|
241
|
-
name: '👁️ Visual States Test',
|
|
242
|
-
render: () => (
|
|
243
|
-
<div
|
|
244
|
-
style={{
|
|
245
|
-
display: 'grid',
|
|
246
|
-
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
247
|
-
gap: '24px',
|
|
248
|
-
padding: '16px',
|
|
249
|
-
}}
|
|
250
|
-
>
|
|
251
|
-
<Switch data-testid="default-switch" label="Default state" checked={false} />
|
|
252
|
-
<Switch data-testid="checked-switch" label="Checked state" checked={true} />
|
|
253
|
-
<Switch data-testid="disabled-switch" label="Disabled state" disabled />
|
|
254
|
-
<Switch data-testid="error-switch" label="Error state" error helperText="This is required" />
|
|
255
|
-
<Switch data-testid="loading-switch" label="Loading state" loading checked={true} />
|
|
256
|
-
<Switch data-testid="glow-switch" label="Glow effect" glow checked={true} />
|
|
257
|
-
</div>
|
|
258
|
-
),
|
|
259
|
-
play: async ({ canvasElement, step }) => {
|
|
260
|
-
const canvas = within(canvasElement);
|
|
261
|
-
|
|
262
|
-
await step('Verify default state appearance', async () => {
|
|
263
|
-
const switchElement = canvas
|
|
264
|
-
.getByTestId('default-switch')
|
|
265
|
-
.querySelector('input[type="checkbox"]');
|
|
266
|
-
await expect(switchElement).not.toBeChecked();
|
|
267
|
-
await expect(switchElement).not.toBeDisabled();
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
await step('Verify disabled state', async () => {
|
|
271
|
-
const switchElement = canvas
|
|
272
|
-
.getByTestId('disabled-switch')
|
|
273
|
-
.querySelector('input[type="checkbox"]');
|
|
274
|
-
await expect(switchElement).toBeDisabled();
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
await step('Verify error state display', async () => {
|
|
278
|
-
const errorText = canvas.getByText('This is required');
|
|
279
|
-
await expect(errorText).toBeInTheDocument();
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
await step('Verify loading state (disabled interaction)', async () => {
|
|
283
|
-
const switchElement = canvas
|
|
284
|
-
.getByTestId('loading-switch')
|
|
285
|
-
.querySelector('input[type="checkbox"]');
|
|
286
|
-
await expect(switchElement).toBeDisabled();
|
|
287
|
-
});
|
|
288
|
-
},
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
export const ResponsiveDesign: Story = {
|
|
292
|
-
name: '📱 Responsive Design Test',
|
|
293
|
-
args: {
|
|
294
|
-
label: 'Responsive switch',
|
|
295
|
-
description: 'This switch adapts to different screen sizes',
|
|
296
|
-
onChange: fn(),
|
|
297
|
-
onFocus: fn(),
|
|
298
|
-
onBlur: fn(),
|
|
299
|
-
onClick: fn(),
|
|
300
|
-
},
|
|
301
|
-
parameters: {
|
|
302
|
-
viewport: {
|
|
303
|
-
viewports: {
|
|
304
|
-
mobile: {
|
|
305
|
-
name: 'Mobile',
|
|
306
|
-
styles: { width: '375px', height: '667px' },
|
|
307
|
-
type: 'mobile',
|
|
308
|
-
},
|
|
309
|
-
tablet: {
|
|
310
|
-
name: 'Tablet',
|
|
311
|
-
styles: { width: '768px', height: '1024px' },
|
|
312
|
-
type: 'tablet',
|
|
313
|
-
},
|
|
314
|
-
desktop: {
|
|
315
|
-
name: 'Desktop',
|
|
316
|
-
styles: { width: '1920px', height: '1080px' },
|
|
317
|
-
type: 'desktop',
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
defaultViewport: 'mobile',
|
|
321
|
-
},
|
|
322
|
-
chromatic: {
|
|
323
|
-
viewports: [375, 768, 1920],
|
|
324
|
-
delay: 300,
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
play: async ({ canvasElement, step }) => {
|
|
328
|
-
const canvas = within(canvasElement);
|
|
329
|
-
|
|
330
|
-
await step('Verify responsive layout', async () => {
|
|
331
|
-
const switchElement = canvas.getByRole('checkbox');
|
|
332
|
-
await expect(switchElement).toBeInTheDocument();
|
|
333
|
-
|
|
334
|
-
// Component should be visible and functional at all sizes
|
|
335
|
-
await userEvent.click(switchElement);
|
|
336
|
-
await expect(switchElement).toBeChecked();
|
|
337
|
-
});
|
|
338
|
-
},
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
// ===== VARIANT TESTS =====
|
|
342
|
-
|
|
343
|
-
export const VariantTests: Story = {
|
|
344
|
-
name: '🎨 Variant Tests',
|
|
345
|
-
render: () => (
|
|
346
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: '24px' }}>
|
|
347
|
-
{(['default', 'ios', 'android', 'material', 'label'] as const).map((variant) => (
|
|
348
|
-
<div key={variant}>
|
|
349
|
-
<h6 style={{ margin: '0 0 8px 0', fontSize: '14px', fontWeight: 600 }}>
|
|
350
|
-
{variant.charAt(0).toUpperCase() + variant.slice(1)} Variant
|
|
351
|
-
</h6>
|
|
352
|
-
<Switch
|
|
353
|
-
data-testid={`${variant}-variant`}
|
|
354
|
-
variant={variant}
|
|
355
|
-
label={`${variant} style`}
|
|
356
|
-
onText={variant === 'label' ? 'ON' : undefined}
|
|
357
|
-
offText={variant === 'label' ? 'OFF' : undefined}
|
|
358
|
-
defaultChecked={true}
|
|
359
|
-
/>
|
|
360
|
-
</div>
|
|
361
|
-
))}
|
|
362
|
-
</div>
|
|
363
|
-
),
|
|
364
|
-
play: async ({ canvasElement, step }) => {
|
|
365
|
-
const canvas = within(canvasElement);
|
|
366
|
-
|
|
367
|
-
await step('Verify all variants render', async () => {
|
|
368
|
-
const variants = ['default', 'ios', 'android', 'material', 'label'] as const;
|
|
369
|
-
for (const variant of variants) {
|
|
370
|
-
const switchElement = canvas
|
|
371
|
-
.getByTestId(`${variant}-variant`)
|
|
372
|
-
.querySelector('input[type="checkbox"]');
|
|
373
|
-
await expect(switchElement).toBeInTheDocument();
|
|
374
|
-
await expect(switchElement).toBeChecked();
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
await step('Test interaction with each variant', async () => {
|
|
379
|
-
const variants = ['default', 'ios', 'android', 'material', 'label'] as const;
|
|
380
|
-
for (const variant of variants) {
|
|
381
|
-
const switchElement = canvas
|
|
382
|
-
.getByTestId(`${variant}-variant`)
|
|
383
|
-
.querySelector('input[type="checkbox"]');
|
|
384
|
-
await userEvent.click(switchElement);
|
|
385
|
-
await expect(switchElement).not.toBeChecked();
|
|
386
|
-
await userEvent.click(switchElement);
|
|
387
|
-
await expect(switchElement).toBeChecked();
|
|
388
|
-
}
|
|
389
|
-
});
|
|
390
|
-
},
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
// ===== EDGE CASES TESTS =====
|
|
394
|
-
|
|
395
|
-
export const EdgeCases: Story = {
|
|
396
|
-
name: '🔧 Edge Cases Test',
|
|
397
|
-
render: () => (
|
|
398
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: '24px' }}>
|
|
399
|
-
<Switch
|
|
400
|
-
data-testid="very-long-label"
|
|
401
|
-
label="This is an extremely long label that should wrap properly and not break the layout even when the text becomes very lengthy and extends beyond normal boundaries"
|
|
402
|
-
description="This is also a very long description that tests how the component handles extensive text content and maintains proper spacing and alignment"
|
|
403
|
-
/>
|
|
404
|
-
<Switch data-testid="no-label" checked={true} />
|
|
405
|
-
<Switch
|
|
406
|
-
data-testid="custom-size"
|
|
407
|
-
label="Custom dimensions"
|
|
408
|
-
trackWidth={100}
|
|
409
|
-
trackHeight={50}
|
|
410
|
-
/>
|
|
411
|
-
<Switch
|
|
412
|
-
data-testid="with-icons"
|
|
413
|
-
label="With icons"
|
|
414
|
-
onIcon={<Sun size={16} />}
|
|
415
|
-
offIcon={<Moon size={16} />}
|
|
416
|
-
checked={true}
|
|
417
|
-
/>
|
|
418
|
-
</div>
|
|
419
|
-
),
|
|
420
|
-
play: async ({ canvasElement, step }) => {
|
|
421
|
-
const canvas = within(canvasElement);
|
|
422
|
-
|
|
423
|
-
await step('Verify long text handling', async () => {
|
|
424
|
-
const longLabelSwitch = canvas.getByTestId('very-long-label');
|
|
425
|
-
await expect(longLabelSwitch).toBeInTheDocument();
|
|
426
|
-
|
|
427
|
-
const switchInput = longLabelSwitch.querySelector('input[type="checkbox"]');
|
|
428
|
-
await userEvent.click(switchInput);
|
|
429
|
-
await expect(switchInput).toBeChecked();
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
await step('Verify switch without label', async () => {
|
|
433
|
-
const noLabelSwitch = canvas.getByTestId('no-label').querySelector('input[type="checkbox"]');
|
|
434
|
-
await expect(noLabelSwitch).toBeInTheDocument();
|
|
435
|
-
await expect(noLabelSwitch).toBeChecked();
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
await step('Verify custom size switch', async () => {
|
|
439
|
-
const customSizeSwitch = canvas
|
|
440
|
-
.getByTestId('custom-size')
|
|
441
|
-
.querySelector('input[type="checkbox"]');
|
|
442
|
-
await expect(customSizeSwitch).toBeInTheDocument();
|
|
443
|
-
await userEvent.click(customSizeSwitch);
|
|
444
|
-
await expect(customSizeSwitch).toBeChecked();
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
await step('Verify switch with icons', async () => {
|
|
448
|
-
const iconSwitch = canvas.getByTestId('with-icons').querySelector('input[type="checkbox"]');
|
|
449
|
-
await expect(iconSwitch).toBeInTheDocument();
|
|
450
|
-
await expect(iconSwitch).toBeChecked();
|
|
451
|
-
});
|
|
452
|
-
},
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
// ===== PERFORMANCE TEST =====
|
|
456
|
-
|
|
457
|
-
export const PerformanceTest: Story = {
|
|
458
|
-
name: '⚡ Performance Test',
|
|
459
|
-
render: () => (
|
|
460
|
-
<div
|
|
461
|
-
style={{
|
|
462
|
-
display: 'grid',
|
|
463
|
-
gridTemplateColumns: 'repeat(10, 1fr)',
|
|
464
|
-
gap: '8px',
|
|
465
|
-
padding: '16px',
|
|
466
|
-
}}
|
|
467
|
-
>
|
|
468
|
-
{Array.from({ length: 100 }, (_, i) => (
|
|
469
|
-
<Switch key={i} data-testid={`perf-switch-${i}`} size="sm" checked={i % 2 === 0} />
|
|
470
|
-
))}
|
|
471
|
-
</div>
|
|
472
|
-
),
|
|
473
|
-
play: async ({ canvasElement, step }) => {
|
|
474
|
-
const canvas = within(canvasElement);
|
|
475
|
-
|
|
476
|
-
await step('Measure render time for multiple switches', async () => {
|
|
477
|
-
const startTime = window.performance.now();
|
|
478
|
-
const switches = canvas.getAllByRole('checkbox');
|
|
479
|
-
const endTime = window.performance.now();
|
|
480
|
-
|
|
481
|
-
const renderTime = endTime - startTime;
|
|
482
|
-
// Use expect for assertions rather than console.log
|
|
483
|
-
await expect(switches).toHaveLength(100);
|
|
484
|
-
await expect(renderTime).toBeLessThan(1000);
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
await step('Test rapid interactions', async () => {
|
|
488
|
-
const firstSwitch = canvas
|
|
489
|
-
.getByTestId('perf-switch-0')
|
|
490
|
-
.querySelector('input[type="checkbox"]');
|
|
491
|
-
|
|
492
|
-
// Rapid clicking should not cause issues
|
|
493
|
-
for (let i = 0; i < 5; i++) {
|
|
494
|
-
await userEvent.click(firstSwitch);
|
|
495
|
-
await new Promise((resolve) => window.setTimeout(resolve, 10));
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
await expect(firstSwitch).toBeChecked();
|
|
499
|
-
});
|
|
500
|
-
},
|
|
501
|
-
};
|
|
502
|
-
|
|
503
|
-
// ===== INTEGRATION TEST =====
|
|
504
|
-
|
|
505
|
-
const IntegrationTestComponent = () => {
|
|
506
|
-
const [settings, setSettings] = React.useState({
|
|
507
|
-
notifications: true,
|
|
508
|
-
darkMode: false,
|
|
509
|
-
soundEnabled: true,
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
return (
|
|
513
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
|
|
514
|
-
<h6 style={{ margin: 0, fontSize: '18px', fontWeight: 600 }}>Settings Panel</h6>
|
|
515
|
-
<Switch
|
|
516
|
-
data-testid="notifications-switch"
|
|
517
|
-
label="Enable Notifications"
|
|
518
|
-
description={`Notifications are currently ${settings.notifications ? 'enabled' : 'disabled'}`}
|
|
519
|
-
checked={settings.notifications}
|
|
520
|
-
onChange={(e) => setSettings((prev) => ({ ...prev, notifications: e.target.checked }))}
|
|
521
|
-
onIcon={<Volume2 size={14} />}
|
|
522
|
-
offIcon={<VolumeX size={14} />}
|
|
523
|
-
/>
|
|
524
|
-
<Switch
|
|
525
|
-
data-testid="darkmode-switch"
|
|
526
|
-
label="Dark Mode"
|
|
527
|
-
description={`Theme: ${settings.darkMode ? 'Dark' : 'Light'}`}
|
|
528
|
-
checked={settings.darkMode}
|
|
529
|
-
onChange={(e) => setSettings((prev) => ({ ...prev, darkMode: e.target.checked }))}
|
|
530
|
-
onIcon={<Moon size={14} />}
|
|
531
|
-
offIcon={<Sun size={14} />}
|
|
532
|
-
variant="ios"
|
|
533
|
-
/>
|
|
534
|
-
<Switch
|
|
535
|
-
data-testid="sound-switch"
|
|
536
|
-
label="Sound Effects"
|
|
537
|
-
disabled={!settings.notifications}
|
|
538
|
-
description={
|
|
539
|
-
settings.notifications ? 'Sound effects for notifications' : 'Enable notifications first'
|
|
540
|
-
}
|
|
541
|
-
checked={settings.soundEnabled}
|
|
542
|
-
onChange={(e) => setSettings((prev) => ({ ...prev, soundEnabled: e.target.checked }))}
|
|
543
|
-
/>
|
|
544
|
-
<p style={{ margin: 0, fontSize: '14px', color: '#666' }}>
|
|
545
|
-
Settings: Notifications: {settings.notifications ? 'ON' : 'OFF'}, Dark Mode:{' '}
|
|
546
|
-
{settings.darkMode ? 'ON' : 'OFF'}, Sound: {settings.soundEnabled ? 'ON' : 'OFF'}
|
|
547
|
-
</p>
|
|
548
|
-
</div>
|
|
549
|
-
);
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
export const IntegrationTest: Story = {
|
|
553
|
-
name: '🔗 Integration Test',
|
|
554
|
-
render: () => <IntegrationTestComponent />,
|
|
555
|
-
play: async ({ canvasElement, step }) => {
|
|
556
|
-
const canvas = within(canvasElement);
|
|
557
|
-
|
|
558
|
-
await step('Test interdependent switches', async () => {
|
|
559
|
-
const notificationsSwitch = canvas
|
|
560
|
-
.getByTestId('notifications-switch')
|
|
561
|
-
.querySelector('input[type="checkbox"]');
|
|
562
|
-
const soundSwitch = canvas
|
|
563
|
-
.getByTestId('sound-switch')
|
|
564
|
-
.querySelector('input[type="checkbox"]');
|
|
565
|
-
|
|
566
|
-
// Initially notifications should be enabled and sound switch available
|
|
567
|
-
await expect(notificationsSwitch).toBeChecked();
|
|
568
|
-
await expect(soundSwitch).not.toBeDisabled();
|
|
569
|
-
|
|
570
|
-
// Disable notifications
|
|
571
|
-
await userEvent.click(notificationsSwitch);
|
|
572
|
-
await waitFor(() => {
|
|
573
|
-
expect(soundSwitch).toBeDisabled();
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
// Re-enable notifications
|
|
577
|
-
await userEvent.click(notificationsSwitch);
|
|
578
|
-
await waitFor(() => {
|
|
579
|
-
expect(soundSwitch).not.toBeDisabled();
|
|
580
|
-
});
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
await step('Test dark mode toggle', async () => {
|
|
584
|
-
const darkModeSwitch = canvas
|
|
585
|
-
.getByTestId('darkmode-switch')
|
|
586
|
-
.querySelector('input[type="checkbox"]');
|
|
587
|
-
const statusText = canvas.getByText(/Theme:/);
|
|
588
|
-
|
|
589
|
-
await expect(statusText).toHaveTextContent('Theme: Light');
|
|
590
|
-
|
|
591
|
-
await userEvent.click(darkModeSwitch);
|
|
592
|
-
await waitFor(() => {
|
|
593
|
-
expect(statusText).toHaveTextContent('Theme: Dark');
|
|
594
|
-
});
|
|
595
|
-
});
|
|
596
|
-
},
|
|
597
|
-
};
|