@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,601 +0,0 @@
|
|
|
1
|
-
import { Button, TextField,Typography } from '@mui/material';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { expect, fn, userEvent, waitFor,within } from 'storybook/test';
|
|
4
|
-
|
|
5
|
-
import { Form, FormField } from './Form';
|
|
6
|
-
|
|
7
|
-
const meta: Meta<typeof Form> = {
|
|
8
|
-
title: 'Form/Form/Tests',
|
|
9
|
-
component: Form,
|
|
10
|
-
parameters: {
|
|
11
|
-
layout: 'centered',
|
|
12
|
-
chromatic: { disableSnapshot: false },
|
|
13
|
-
docs: {
|
|
14
|
-
description: {
|
|
15
|
-
component:
|
|
16
|
-
'Comprehensive test stories for Form component covering interaction, accessibility, visual, performance, and edge case testing.',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
tags: ['autodocs', 'test', 'component:Form'],
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default meta;
|
|
24
|
-
type Story = StoryObj<typeof meta>;
|
|
25
|
-
|
|
26
|
-
// Test 1: Basic Interaction Test
|
|
27
|
-
export const BasicInteraction: Story = {
|
|
28
|
-
args: {
|
|
29
|
-
variant: 'vertical',
|
|
30
|
-
maxWidth: 'sm',
|
|
31
|
-
spacing: 'md',
|
|
32
|
-
onSubmit: fn(),
|
|
33
|
-
dataTestId: 'login-form',
|
|
34
|
-
children: (
|
|
35
|
-
<>
|
|
36
|
-
<FormField name="email" label="Email" required dataTestId="email-field">
|
|
37
|
-
<TextField
|
|
38
|
-
type="email"
|
|
39
|
-
placeholder="Enter your email"
|
|
40
|
-
fullWidth
|
|
41
|
-
defaultValue=""
|
|
42
|
-
inputProps={{ 'data-testid': 'email-input' }}
|
|
43
|
-
/>
|
|
44
|
-
</FormField>
|
|
45
|
-
<FormField name="password" label="Password" required dataTestId="password-field">
|
|
46
|
-
<TextField
|
|
47
|
-
type="password"
|
|
48
|
-
placeholder="Enter your password"
|
|
49
|
-
fullWidth
|
|
50
|
-
defaultValue=""
|
|
51
|
-
inputProps={{ 'data-testid': 'password-input' }}
|
|
52
|
-
/>
|
|
53
|
-
</FormField>
|
|
54
|
-
<Button variant="contained" type="submit" fullWidth data-testid="submit-button">
|
|
55
|
-
Submit
|
|
56
|
-
</Button>
|
|
57
|
-
</>
|
|
58
|
-
),
|
|
59
|
-
},
|
|
60
|
-
play: async ({ canvasElement }) => {
|
|
61
|
-
const canvas = within(canvasElement);
|
|
62
|
-
|
|
63
|
-
// Verify form testId
|
|
64
|
-
const form = canvas.getByTestId('login-form');
|
|
65
|
-
expect(form).toBeInTheDocument();
|
|
66
|
-
expect(form).toHaveAttribute('role', 'form');
|
|
67
|
-
|
|
68
|
-
// Verify FormField testIds
|
|
69
|
-
const emailField = canvas.getByTestId('email-field');
|
|
70
|
-
const passwordField = canvas.getByTestId('password-field');
|
|
71
|
-
expect(emailField).toBeInTheDocument();
|
|
72
|
-
expect(passwordField).toBeInTheDocument();
|
|
73
|
-
|
|
74
|
-
// Verify nested testIds (label, control)
|
|
75
|
-
const emailLabel = canvas.getByTestId('email-field-label');
|
|
76
|
-
const emailControl = canvas.getByTestId('email-field-control');
|
|
77
|
-
const passwordLabel = canvas.getByTestId('password-field-label');
|
|
78
|
-
const passwordControl = canvas.getByTestId('password-field-control');
|
|
79
|
-
|
|
80
|
-
expect(emailLabel).toBeInTheDocument();
|
|
81
|
-
expect(emailControl).toBeInTheDocument();
|
|
82
|
-
expect(passwordLabel).toBeInTheDocument();
|
|
83
|
-
expect(passwordControl).toBeInTheDocument();
|
|
84
|
-
|
|
85
|
-
// Find form elements - use the input elements directly
|
|
86
|
-
const emailInput = canvas.getByTestId('email-input') as HTMLInputElement;
|
|
87
|
-
const passwordInput = canvas.getByTestId('password-input') as HTMLInputElement;
|
|
88
|
-
const submitButton = canvas.getByTestId('submit-button');
|
|
89
|
-
|
|
90
|
-
expect(emailInput).toBeInTheDocument();
|
|
91
|
-
expect(passwordInput).toBeInTheDocument();
|
|
92
|
-
expect(submitButton).toBeInTheDocument();
|
|
93
|
-
|
|
94
|
-
// Clear inputs first
|
|
95
|
-
await userEvent.clear(emailInput);
|
|
96
|
-
await userEvent.clear(passwordInput);
|
|
97
|
-
|
|
98
|
-
// Test basic interactions
|
|
99
|
-
await userEvent.type(emailInput, 'test@example.com');
|
|
100
|
-
await userEvent.type(passwordInput, 'password123');
|
|
101
|
-
|
|
102
|
-
// Wait for the values to be updated
|
|
103
|
-
await waitFor(() => {
|
|
104
|
-
expect(emailInput).toHaveValue('test@example.com');
|
|
105
|
-
expect(passwordInput).toHaveValue('password123');
|
|
106
|
-
});
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// Test 2: Keyboard Navigation Test
|
|
111
|
-
export const KeyboardNavigation: Story = {
|
|
112
|
-
args: {
|
|
113
|
-
variant: 'vertical',
|
|
114
|
-
maxWidth: 'sm',
|
|
115
|
-
spacing: 'md',
|
|
116
|
-
children: (
|
|
117
|
-
<>
|
|
118
|
-
<FormField name="field1" label="First Field" required>
|
|
119
|
-
<TextField
|
|
120
|
-
placeholder="First field"
|
|
121
|
-
fullWidth
|
|
122
|
-
inputProps={{ 'data-testid': 'first-field' }}
|
|
123
|
-
/>
|
|
124
|
-
</FormField>
|
|
125
|
-
<FormField name="field2" label="Second Field" required>
|
|
126
|
-
<TextField
|
|
127
|
-
placeholder="Second field"
|
|
128
|
-
fullWidth
|
|
129
|
-
inputProps={{ 'data-testid': 'second-field' }}
|
|
130
|
-
/>
|
|
131
|
-
</FormField>
|
|
132
|
-
<Button variant="contained" type="submit" data-testid="submit-btn" fullWidth>
|
|
133
|
-
Submit
|
|
134
|
-
</Button>
|
|
135
|
-
</>
|
|
136
|
-
),
|
|
137
|
-
},
|
|
138
|
-
play: async ({ canvasElement }) => {
|
|
139
|
-
const canvas = within(canvasElement);
|
|
140
|
-
|
|
141
|
-
const firstField = canvas.getByTestId('first-field');
|
|
142
|
-
const secondField = canvas.getByTestId('second-field');
|
|
143
|
-
const submitButton = canvas.getByTestId('submit-btn');
|
|
144
|
-
|
|
145
|
-
// Focus first field
|
|
146
|
-
await userEvent.click(firstField);
|
|
147
|
-
await waitFor(() => {
|
|
148
|
-
expect(firstField).toHaveFocus();
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
// Tab to second field
|
|
152
|
-
await userEvent.tab();
|
|
153
|
-
await waitFor(() => {
|
|
154
|
-
expect(secondField).toHaveFocus();
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
// Tab to submit button
|
|
158
|
-
await userEvent.tab();
|
|
159
|
-
await waitFor(() => {
|
|
160
|
-
expect(submitButton).toHaveFocus();
|
|
161
|
-
});
|
|
162
|
-
},
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// Test 3: Responsive Design Test
|
|
166
|
-
export const ResponsiveDesign: Story = {
|
|
167
|
-
args: {
|
|
168
|
-
variant: 'vertical',
|
|
169
|
-
maxWidth: 'full',
|
|
170
|
-
spacing: 'md',
|
|
171
|
-
children: (
|
|
172
|
-
<>
|
|
173
|
-
<Typography variant="h6" mb={2}>
|
|
174
|
-
Responsive Form Layout
|
|
175
|
-
</Typography>
|
|
176
|
-
<div data-testid="responsive-container">
|
|
177
|
-
<FormField name="firstName" label="First Name" required>
|
|
178
|
-
<TextField
|
|
179
|
-
placeholder="First name"
|
|
180
|
-
fullWidth
|
|
181
|
-
inputProps={{ 'data-testid': 'first-name' }}
|
|
182
|
-
/>
|
|
183
|
-
</FormField>
|
|
184
|
-
<FormField name="lastName" label="Last Name" required>
|
|
185
|
-
<TextField
|
|
186
|
-
placeholder="Last name"
|
|
187
|
-
fullWidth
|
|
188
|
-
inputProps={{ 'data-testid': 'last-name' }}
|
|
189
|
-
/>
|
|
190
|
-
</FormField>
|
|
191
|
-
</div>
|
|
192
|
-
</>
|
|
193
|
-
),
|
|
194
|
-
},
|
|
195
|
-
parameters: {
|
|
196
|
-
viewport: {
|
|
197
|
-
viewports: {
|
|
198
|
-
mobile: {
|
|
199
|
-
name: 'Mobile',
|
|
200
|
-
styles: { width: '375px', height: '667px' },
|
|
201
|
-
type: 'mobile',
|
|
202
|
-
},
|
|
203
|
-
tablet: {
|
|
204
|
-
name: 'Tablet',
|
|
205
|
-
styles: { width: '768px', height: '1024px' },
|
|
206
|
-
type: 'tablet',
|
|
207
|
-
},
|
|
208
|
-
desktop: {
|
|
209
|
-
name: 'Desktop',
|
|
210
|
-
styles: { width: '1920px', height: '1080px' },
|
|
211
|
-
type: 'desktop',
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
defaultViewport: 'mobile',
|
|
215
|
-
},
|
|
216
|
-
chromatic: {
|
|
217
|
-
viewports: [375, 768, 1920],
|
|
218
|
-
delay: 300,
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
play: async ({ canvasElement }) => {
|
|
222
|
-
const canvas = within(canvasElement);
|
|
223
|
-
|
|
224
|
-
const container = canvas.getByTestId('responsive-container');
|
|
225
|
-
expect(container).toBeInTheDocument();
|
|
226
|
-
|
|
227
|
-
const firstName = canvas.getByTestId('first-name');
|
|
228
|
-
const lastName = canvas.getByTestId('last-name');
|
|
229
|
-
|
|
230
|
-
expect(firstName).toBeInTheDocument();
|
|
231
|
-
expect(lastName).toBeInTheDocument();
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
// Test 4: Visual States Test
|
|
236
|
-
export const VisualStates: Story = {
|
|
237
|
-
args: {
|
|
238
|
-
variant: 'vertical',
|
|
239
|
-
maxWidth: 'sm',
|
|
240
|
-
spacing: 'md',
|
|
241
|
-
children: (
|
|
242
|
-
<>
|
|
243
|
-
<Typography variant="h6" mb={2} data-testid="form-title">
|
|
244
|
-
Visual States Demo
|
|
245
|
-
</Typography>
|
|
246
|
-
|
|
247
|
-
<FormField name="normal" label="Normal State">
|
|
248
|
-
<TextField
|
|
249
|
-
placeholder="Normal input"
|
|
250
|
-
fullWidth
|
|
251
|
-
inputProps={{ 'data-testid': 'normal-input' }}
|
|
252
|
-
/>
|
|
253
|
-
</FormField>
|
|
254
|
-
|
|
255
|
-
<FormField name="required" label="Required Field" required>
|
|
256
|
-
<TextField
|
|
257
|
-
placeholder="Required input"
|
|
258
|
-
fullWidth
|
|
259
|
-
inputProps={{ 'data-testid': 'required-input' }}
|
|
260
|
-
/>
|
|
261
|
-
</FormField>
|
|
262
|
-
|
|
263
|
-
<Button variant="contained" data-testid="submit-button" fullWidth>
|
|
264
|
-
Submit
|
|
265
|
-
</Button>
|
|
266
|
-
</>
|
|
267
|
-
),
|
|
268
|
-
},
|
|
269
|
-
play: async ({ canvasElement }) => {
|
|
270
|
-
const canvas = within(canvasElement);
|
|
271
|
-
|
|
272
|
-
const title = canvas.getByTestId('form-title');
|
|
273
|
-
expect(title).toBeInTheDocument();
|
|
274
|
-
expect(title).toBeVisible();
|
|
275
|
-
|
|
276
|
-
const normalInput = canvas.getByTestId('normal-input');
|
|
277
|
-
expect(normalInput).toBeInTheDocument();
|
|
278
|
-
|
|
279
|
-
const submitButton = canvas.getByTestId('submit-button');
|
|
280
|
-
expect(submitButton).toBeInTheDocument();
|
|
281
|
-
},
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
// Test 5: Edge Cases Test
|
|
285
|
-
export const EdgeCases: Story = {
|
|
286
|
-
args: {
|
|
287
|
-
variant: 'vertical',
|
|
288
|
-
maxWidth: 'sm',
|
|
289
|
-
spacing: 'md',
|
|
290
|
-
children: (
|
|
291
|
-
<>
|
|
292
|
-
<Typography variant="h6" mb={2}>
|
|
293
|
-
Edge Cases Testing
|
|
294
|
-
</Typography>
|
|
295
|
-
|
|
296
|
-
<FormField name="empty" label="Empty Field">
|
|
297
|
-
<div
|
|
298
|
-
data-testid="empty-field"
|
|
299
|
-
style={{ minHeight: '40px', border: '1px dashed #ccc', padding: '8px' }}
|
|
300
|
-
>
|
|
301
|
-
Empty field placeholder
|
|
302
|
-
</div>
|
|
303
|
-
</FormField>
|
|
304
|
-
|
|
305
|
-
<FormField name="longText" label="Very Long Label That Should Handle Overflow Gracefully">
|
|
306
|
-
<TextField
|
|
307
|
-
placeholder="Long text input"
|
|
308
|
-
fullWidth
|
|
309
|
-
inputProps={{ 'data-testid': 'long-text-input' }}
|
|
310
|
-
/>
|
|
311
|
-
</FormField>
|
|
312
|
-
|
|
313
|
-
<Button variant="contained" type="submit" fullWidth data-testid="edge-submit">
|
|
314
|
-
Submit Edge Cases
|
|
315
|
-
</Button>
|
|
316
|
-
</>
|
|
317
|
-
),
|
|
318
|
-
},
|
|
319
|
-
play: async ({ canvasElement }) => {
|
|
320
|
-
const canvas = within(canvasElement);
|
|
321
|
-
|
|
322
|
-
const emptyField = canvas.getByTestId('empty-field');
|
|
323
|
-
expect(emptyField).toBeInTheDocument();
|
|
324
|
-
expect(emptyField).toHaveTextContent('Empty field placeholder');
|
|
325
|
-
|
|
326
|
-
const longTextInput = canvas.getByTestId('long-text-input');
|
|
327
|
-
expect(longTextInput).toBeInTheDocument();
|
|
328
|
-
|
|
329
|
-
const submitButton = canvas.getByTestId('edge-submit');
|
|
330
|
-
expect(submitButton).toBeInTheDocument();
|
|
331
|
-
},
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
// Test 6: Screen Reader Test
|
|
335
|
-
export const ScreenReader: Story = {
|
|
336
|
-
args: {
|
|
337
|
-
variant: 'vertical',
|
|
338
|
-
maxWidth: 'sm',
|
|
339
|
-
spacing: 'md',
|
|
340
|
-
children: (
|
|
341
|
-
<>
|
|
342
|
-
<FormField name="accessible" label="Accessible Field" required>
|
|
343
|
-
<TextField
|
|
344
|
-
placeholder="Accessible input"
|
|
345
|
-
fullWidth
|
|
346
|
-
inputProps={{
|
|
347
|
-
'data-testid': 'accessible-input',
|
|
348
|
-
'aria-label': 'Accessible Field',
|
|
349
|
-
'aria-required': 'true',
|
|
350
|
-
}}
|
|
351
|
-
/>
|
|
352
|
-
</FormField>
|
|
353
|
-
<Button variant="contained" type="submit" fullWidth aria-label="Submit form">
|
|
354
|
-
Submit
|
|
355
|
-
</Button>
|
|
356
|
-
</>
|
|
357
|
-
),
|
|
358
|
-
},
|
|
359
|
-
play: async ({ canvasElement }) => {
|
|
360
|
-
const canvas = within(canvasElement);
|
|
361
|
-
|
|
362
|
-
const accessibleInput = canvas.getByTestId('accessible-input');
|
|
363
|
-
expect(accessibleInput).toHaveAttribute('aria-label', 'Accessible Field');
|
|
364
|
-
expect(accessibleInput).toHaveAttribute('aria-required', 'true');
|
|
365
|
-
|
|
366
|
-
const submitButton = canvas.getByRole('button', { name: 'Submit form' });
|
|
367
|
-
expect(submitButton).toBeInTheDocument();
|
|
368
|
-
},
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
// Test 7: Focus Management Test
|
|
372
|
-
export const FocusManagement: Story = {
|
|
373
|
-
args: {
|
|
374
|
-
variant: 'vertical',
|
|
375
|
-
maxWidth: 'sm',
|
|
376
|
-
spacing: 'md',
|
|
377
|
-
onFocus: fn(),
|
|
378
|
-
onBlur: fn(),
|
|
379
|
-
children: (
|
|
380
|
-
<>
|
|
381
|
-
<FormField name="focusTest" label="Focus Test Field">
|
|
382
|
-
<TextField
|
|
383
|
-
placeholder="Focus test"
|
|
384
|
-
fullWidth
|
|
385
|
-
inputProps={{ 'data-testid': 'focus-input' }}
|
|
386
|
-
onFocus={fn()}
|
|
387
|
-
onBlur={fn()}
|
|
388
|
-
/>
|
|
389
|
-
</FormField>
|
|
390
|
-
</>
|
|
391
|
-
),
|
|
392
|
-
},
|
|
393
|
-
play: async ({ canvasElement }) => {
|
|
394
|
-
const canvas = within(canvasElement);
|
|
395
|
-
|
|
396
|
-
const focusInput = canvas.getByTestId('focus-input');
|
|
397
|
-
|
|
398
|
-
// Test focus
|
|
399
|
-
await userEvent.click(focusInput);
|
|
400
|
-
await waitFor(() => {
|
|
401
|
-
expect(focusInput).toHaveFocus();
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
// Test blur
|
|
405
|
-
await userEvent.tab();
|
|
406
|
-
await waitFor(() => {
|
|
407
|
-
expect(focusInput).not.toHaveFocus();
|
|
408
|
-
});
|
|
409
|
-
},
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
// Test 8: Theme Variations Test
|
|
413
|
-
export const ThemeVariations: Story = {
|
|
414
|
-
args: {
|
|
415
|
-
variant: 'vertical',
|
|
416
|
-
maxWidth: 'sm',
|
|
417
|
-
spacing: 'md',
|
|
418
|
-
children: (
|
|
419
|
-
<>
|
|
420
|
-
<Typography variant="h6" mb={2}>
|
|
421
|
-
Theme Variations
|
|
422
|
-
</Typography>
|
|
423
|
-
<FormField name="themed" label="Themed Field">
|
|
424
|
-
<TextField
|
|
425
|
-
placeholder="Themed input"
|
|
426
|
-
fullWidth
|
|
427
|
-
inputProps={{ 'data-testid': 'themed-input' }}
|
|
428
|
-
/>
|
|
429
|
-
</FormField>
|
|
430
|
-
</>
|
|
431
|
-
),
|
|
432
|
-
},
|
|
433
|
-
parameters: {
|
|
434
|
-
backgrounds: {
|
|
435
|
-
default: 'dark',
|
|
436
|
-
},
|
|
437
|
-
},
|
|
438
|
-
play: async ({ canvasElement }) => {
|
|
439
|
-
const canvas = within(canvasElement);
|
|
440
|
-
|
|
441
|
-
const themedInput = canvas.getByTestId('themed-input');
|
|
442
|
-
expect(themedInput).toBeInTheDocument();
|
|
443
|
-
},
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
// Test 9: Performance Test
|
|
447
|
-
export const Performance: Story = {
|
|
448
|
-
args: {
|
|
449
|
-
variant: 'vertical',
|
|
450
|
-
maxWidth: 'lg',
|
|
451
|
-
spacing: 'sm',
|
|
452
|
-
children: (
|
|
453
|
-
<>
|
|
454
|
-
<Typography variant="h6" mb={2}>
|
|
455
|
-
Performance Test - Many Fields
|
|
456
|
-
</Typography>
|
|
457
|
-
{Array.from({ length: 10 }, (_, i) => (
|
|
458
|
-
<FormField key={i} name={`field${i}`} label={`Field ${i + 1}`}>
|
|
459
|
-
<TextField
|
|
460
|
-
placeholder={`Field ${i + 1}`}
|
|
461
|
-
fullWidth
|
|
462
|
-
inputProps={{ 'data-testid': `field-${i}` }}
|
|
463
|
-
/>
|
|
464
|
-
</FormField>
|
|
465
|
-
))}
|
|
466
|
-
</>
|
|
467
|
-
),
|
|
468
|
-
},
|
|
469
|
-
play: async ({ canvasElement }) => {
|
|
470
|
-
const canvas = within(canvasElement);
|
|
471
|
-
|
|
472
|
-
// Check that all fields are rendered
|
|
473
|
-
for (let i = 0; i < 10; i++) {
|
|
474
|
-
const field = canvas.getByTestId(`field-${i}`);
|
|
475
|
-
expect(field).toBeInTheDocument();
|
|
476
|
-
}
|
|
477
|
-
},
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
// Test 10: TestId Verification for Error Messages
|
|
481
|
-
export const ErrorMessageTestIds: Story = {
|
|
482
|
-
args: {
|
|
483
|
-
variant: 'vertical',
|
|
484
|
-
maxWidth: 'sm',
|
|
485
|
-
spacing: 'md',
|
|
486
|
-
dataTestId: 'error-form',
|
|
487
|
-
children: (
|
|
488
|
-
<>
|
|
489
|
-
<Typography variant="h6" mb={2}>
|
|
490
|
-
Error Message TestIds
|
|
491
|
-
</Typography>
|
|
492
|
-
<FormField name="email" label="Email" required error="Invalid email address" dataTestId="email-field-with-error">
|
|
493
|
-
<TextField
|
|
494
|
-
type="email"
|
|
495
|
-
placeholder="Enter email"
|
|
496
|
-
fullWidth
|
|
497
|
-
error
|
|
498
|
-
inputProps={{ 'data-testid': 'email-input-error' }}
|
|
499
|
-
/>
|
|
500
|
-
</FormField>
|
|
501
|
-
<FormField name="username" label="Username" helperText="Choose a unique username" dataTestId="username-field-with-helper">
|
|
502
|
-
<TextField
|
|
503
|
-
placeholder="Enter username"
|
|
504
|
-
fullWidth
|
|
505
|
-
inputProps={{ 'data-testid': 'username-input-helper' }}
|
|
506
|
-
/>
|
|
507
|
-
</FormField>
|
|
508
|
-
</>
|
|
509
|
-
),
|
|
510
|
-
},
|
|
511
|
-
play: async ({ canvasElement }) => {
|
|
512
|
-
const canvas = within(canvasElement);
|
|
513
|
-
|
|
514
|
-
// Verify form testId
|
|
515
|
-
const form = canvas.getByTestId('error-form');
|
|
516
|
-
expect(form).toBeInTheDocument();
|
|
517
|
-
|
|
518
|
-
// Verify error message testId
|
|
519
|
-
const errorField = canvas.getByTestId('email-field-with-error');
|
|
520
|
-
expect(errorField).toBeInTheDocument();
|
|
521
|
-
|
|
522
|
-
const errorMessage = canvas.getByTestId('email-field-with-error-message');
|
|
523
|
-
expect(errorMessage).toBeInTheDocument();
|
|
524
|
-
expect(errorMessage).toHaveTextContent('Invalid email address');
|
|
525
|
-
|
|
526
|
-
// Verify helper text testId
|
|
527
|
-
const helperField = canvas.getByTestId('username-field-with-helper');
|
|
528
|
-
expect(helperField).toBeInTheDocument();
|
|
529
|
-
|
|
530
|
-
const helperMessage = canvas.getByTestId('username-field-with-helper-message');
|
|
531
|
-
expect(helperMessage).toBeInTheDocument();
|
|
532
|
-
expect(helperMessage).toHaveTextContent('Choose a unique username');
|
|
533
|
-
},
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
// Test 11: Integration Test
|
|
537
|
-
export const Integration: Story = {
|
|
538
|
-
args: {
|
|
539
|
-
variant: 'vertical',
|
|
540
|
-
maxWidth: 'md',
|
|
541
|
-
spacing: 'md',
|
|
542
|
-
onSubmit: fn(),
|
|
543
|
-
children: (
|
|
544
|
-
<>
|
|
545
|
-
<Typography variant="h6" mb={2}>
|
|
546
|
-
Complete Form Integration
|
|
547
|
-
</Typography>
|
|
548
|
-
<FormField name="username" label="Username" required>
|
|
549
|
-
<TextField
|
|
550
|
-
placeholder="Enter username"
|
|
551
|
-
fullWidth
|
|
552
|
-
inputProps={{ 'data-testid': 'username' }}
|
|
553
|
-
/>
|
|
554
|
-
</FormField>
|
|
555
|
-
<FormField name="email" label="Email" required>
|
|
556
|
-
<TextField
|
|
557
|
-
type="email"
|
|
558
|
-
placeholder="Enter email"
|
|
559
|
-
fullWidth
|
|
560
|
-
inputProps={{ 'data-testid': 'email' }}
|
|
561
|
-
/>
|
|
562
|
-
</FormField>
|
|
563
|
-
<FormField name="bio" label="Bio">
|
|
564
|
-
<TextField
|
|
565
|
-
multiline
|
|
566
|
-
rows={4}
|
|
567
|
-
placeholder="Tell us about yourself"
|
|
568
|
-
fullWidth
|
|
569
|
-
inputProps={{ 'data-testid': 'bio' }}
|
|
570
|
-
/>
|
|
571
|
-
</FormField>
|
|
572
|
-
<Button variant="contained" type="submit" fullWidth data-testid="submit">
|
|
573
|
-
Submit Form
|
|
574
|
-
</Button>
|
|
575
|
-
</>
|
|
576
|
-
),
|
|
577
|
-
},
|
|
578
|
-
play: async ({ canvasElement }) => {
|
|
579
|
-
const canvas = within(canvasElement);
|
|
580
|
-
|
|
581
|
-
// Fill out the form
|
|
582
|
-
const username = canvas.getByTestId('username');
|
|
583
|
-
const email = canvas.getByTestId('email');
|
|
584
|
-
const bio = canvas.getByTestId('bio');
|
|
585
|
-
const submit = canvas.getByTestId('submit');
|
|
586
|
-
|
|
587
|
-
await userEvent.type(username, 'testuser');
|
|
588
|
-
await userEvent.type(email, 'test@example.com');
|
|
589
|
-
await userEvent.type(bio, 'This is my bio');
|
|
590
|
-
|
|
591
|
-
// Verify values
|
|
592
|
-
await waitFor(() => {
|
|
593
|
-
expect(username).toHaveValue('testuser');
|
|
594
|
-
expect(email).toHaveValue('test@example.com');
|
|
595
|
-
expect(bio).toHaveValue('This is my bio');
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
// Submit button should be enabled
|
|
599
|
-
expect(submit).toBeEnabled();
|
|
600
|
-
},
|
|
601
|
-
};
|