@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,830 +0,0 @@
|
|
|
1
|
-
import { Box, createTheme, Paper, Stack, ThemeProvider } from '@mui/material';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { expect, userEvent, waitFor, within } from 'storybook/test';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
|
|
6
|
-
import { Heading } from './Heading';
|
|
7
|
-
|
|
8
|
-
const meta: Meta<typeof Heading> = {
|
|
9
|
-
title: 'Typography/Heading/Tests',
|
|
10
|
-
component: Heading,
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: 'centered',
|
|
13
|
-
chromatic: { disableSnapshot: false },
|
|
14
|
-
docs: {
|
|
15
|
-
description: {
|
|
16
|
-
component:
|
|
17
|
-
'Comprehensive test stories for the Heading component covering interaction, accessibility, visual states, performance, and edge cases.',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
tags: ['autodocs', 'test', 'component:Heading'],
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default meta;
|
|
25
|
-
type Story = StoryObj<typeof meta>;
|
|
26
|
-
|
|
27
|
-
// Basic Interaction Test Component
|
|
28
|
-
const BasicInteractionComponent = () => {
|
|
29
|
-
const [clickCount, setClickCount] = React.useState(0);
|
|
30
|
-
const handleClick = () => setClickCount((prev) => prev + 1);
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<Stack spacing={2} data-testid="basic-interaction-container">
|
|
34
|
-
<Heading level="h1" onClick={handleClick} data-testid="clickable-heading">
|
|
35
|
-
Click me! (Clicked: {clickCount})
|
|
36
|
-
</Heading>
|
|
37
|
-
<Heading level="h2" color="primary">
|
|
38
|
-
Static Heading
|
|
39
|
-
</Heading>
|
|
40
|
-
<div data-testid="click-count">{clickCount}</div>
|
|
41
|
-
</Stack>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// Keyboard Navigation Test Component
|
|
46
|
-
const KeyboardNavigationComponent = () => {
|
|
47
|
-
const [focusedId, setFocusedId] = React.useState<string>('');
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<Stack spacing={2} data-testid="keyboard-container">
|
|
51
|
-
<div data-testid="focused-element">Focused: {focusedId}</div>
|
|
52
|
-
<Heading
|
|
53
|
-
level="h1"
|
|
54
|
-
tabIndex={0}
|
|
55
|
-
onFocus={() => setFocusedId('h1')}
|
|
56
|
-
onBlur={() => setFocusedId('')}
|
|
57
|
-
data-testid="heading-h1"
|
|
58
|
-
>
|
|
59
|
-
Focusable H1 Heading
|
|
60
|
-
</Heading>
|
|
61
|
-
<Heading
|
|
62
|
-
level="h2"
|
|
63
|
-
tabIndex={0}
|
|
64
|
-
onFocus={() => setFocusedId('h2')}
|
|
65
|
-
onBlur={() => setFocusedId('')}
|
|
66
|
-
data-testid="heading-h2"
|
|
67
|
-
>
|
|
68
|
-
Focusable H2 Heading
|
|
69
|
-
</Heading>
|
|
70
|
-
<Heading
|
|
71
|
-
level="h3"
|
|
72
|
-
tabIndex={0}
|
|
73
|
-
onFocus={() => setFocusedId('h3')}
|
|
74
|
-
onBlur={() => setFocusedId('')}
|
|
75
|
-
data-testid="heading-h3"
|
|
76
|
-
>
|
|
77
|
-
Focusable H3 Heading
|
|
78
|
-
</Heading>
|
|
79
|
-
</Stack>
|
|
80
|
-
);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// Focus Management Test Component
|
|
84
|
-
const FocusManagementComponent = () => {
|
|
85
|
-
const [activeHeading, setActiveHeading] = React.useState<string>('');
|
|
86
|
-
const headingRefs = {
|
|
87
|
-
h1: React.useRef<globalThis.HTMLHeadingElement>(null),
|
|
88
|
-
h2: React.useRef<globalThis.HTMLHeadingElement>(null),
|
|
89
|
-
h3: React.useRef<globalThis.HTMLHeadingElement>(null),
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const focusHeading = async (level: string) => {
|
|
93
|
-
const ref = headingRefs[level as keyof typeof headingRefs];
|
|
94
|
-
if (ref.current) {
|
|
95
|
-
await userEvent.click(ref.current);
|
|
96
|
-
setActiveHeading(level);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<Stack spacing={2} data-testid="focus-management-container">
|
|
102
|
-
<Box>
|
|
103
|
-
<button onClick={() => focusHeading('h1')} data-testid="focus-h1-btn">
|
|
104
|
-
Focus H1
|
|
105
|
-
</button>
|
|
106
|
-
<button onClick={() => focusHeading('h2')} data-testid="focus-h2-btn">
|
|
107
|
-
Focus H2
|
|
108
|
-
</button>
|
|
109
|
-
<button onClick={() => focusHeading('h3')} data-testid="focus-h3-btn">
|
|
110
|
-
Focus H3
|
|
111
|
-
</button>
|
|
112
|
-
</Box>
|
|
113
|
-
<div data-testid="active-heading">Active: {activeHeading}</div>
|
|
114
|
-
|
|
115
|
-
<Heading
|
|
116
|
-
level="h1"
|
|
117
|
-
ref={headingRefs.h1}
|
|
118
|
-
tabIndex={-1}
|
|
119
|
-
onFocus={() => setActiveHeading('h1')}
|
|
120
|
-
data-testid="managed-h1"
|
|
121
|
-
>
|
|
122
|
-
Programmatically Focusable H1
|
|
123
|
-
</Heading>
|
|
124
|
-
|
|
125
|
-
<Heading
|
|
126
|
-
level="h2"
|
|
127
|
-
ref={headingRefs.h2}
|
|
128
|
-
tabIndex={-1}
|
|
129
|
-
onFocus={() => setActiveHeading('h2')}
|
|
130
|
-
data-testid="managed-h2"
|
|
131
|
-
>
|
|
132
|
-
Programmatically Focusable H2
|
|
133
|
-
</Heading>
|
|
134
|
-
|
|
135
|
-
<Heading
|
|
136
|
-
level="h3"
|
|
137
|
-
ref={headingRefs.h3}
|
|
138
|
-
tabIndex={-1}
|
|
139
|
-
onFocus={() => setActiveHeading('h3')}
|
|
140
|
-
data-testid="managed-h3"
|
|
141
|
-
>
|
|
142
|
-
Programmatically Focusable H3
|
|
143
|
-
</Heading>
|
|
144
|
-
</Stack>
|
|
145
|
-
);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
// Performance Test Component
|
|
149
|
-
const PerformanceTestComponent = () => {
|
|
150
|
-
const startTime = React.useRef(globalThis.performance.now());
|
|
151
|
-
const [renderTime, setRenderTime] = React.useState<number>(0);
|
|
152
|
-
|
|
153
|
-
React.useEffect(() => {
|
|
154
|
-
setRenderTime(globalThis.performance.now() - startTime.current);
|
|
155
|
-
}, []);
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<Stack spacing={1} data-testid="performance-container">
|
|
159
|
-
<div data-testid="render-time">Render time: {renderTime.toFixed(2)}ms</div>
|
|
160
|
-
{Array.from({ length: 50 }, (_, index) => (
|
|
161
|
-
<Heading
|
|
162
|
-
key={index}
|
|
163
|
-
level={(['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const)[index % 6]}
|
|
164
|
-
color={
|
|
165
|
-
(['primary', 'secondary', 'success', 'warning', 'danger', 'neutral'] as const)[
|
|
166
|
-
index % 6
|
|
167
|
-
]
|
|
168
|
-
}
|
|
169
|
-
weight={(['light', 'normal', 'medium', 'semibold', 'bold'] as const)[index % 5]}
|
|
170
|
-
data-testid={`perf-heading-${index}`}
|
|
171
|
-
>
|
|
172
|
-
Performance Test Heading {index + 1}
|
|
173
|
-
</Heading>
|
|
174
|
-
))}
|
|
175
|
-
</Stack>
|
|
176
|
-
);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// Integration Test Component
|
|
180
|
-
const IntegrationTestComponent = () => {
|
|
181
|
-
const [selectedTab, setSelectedTab] = React.useState(0);
|
|
182
|
-
const tabs = ['Tab 1', 'Tab 2', 'Tab 3'];
|
|
183
|
-
|
|
184
|
-
return (
|
|
185
|
-
<Stack spacing={3} data-testid="integration-container">
|
|
186
|
-
<Heading level="h1" data-testid="page-title">
|
|
187
|
-
Integration Testing Page
|
|
188
|
-
</Heading>
|
|
189
|
-
|
|
190
|
-
<Paper sx={{ p: 3 }}>
|
|
191
|
-
<Heading level="h2" color="primary" data-testid="section-title">
|
|
192
|
-
Content Section
|
|
193
|
-
</Heading>
|
|
194
|
-
|
|
195
|
-
<Box sx={{ borderBottom: 1, borderColor: 'divider', mb: 2 }}>
|
|
196
|
-
{tabs.map((tab, index) => (
|
|
197
|
-
<button
|
|
198
|
-
key={tab}
|
|
199
|
-
onClick={() => setSelectedTab(index)}
|
|
200
|
-
style={{
|
|
201
|
-
padding: '8px 16px',
|
|
202
|
-
marginRight: '8px',
|
|
203
|
-
backgroundColor: selectedTab === index ? '#1976d2' : 'transparent',
|
|
204
|
-
color: selectedTab === index ? 'white' : 'inherit',
|
|
205
|
-
border: '1px solid #ccc',
|
|
206
|
-
cursor: 'pointer',
|
|
207
|
-
}}
|
|
208
|
-
data-testid={`tab-${index}`}
|
|
209
|
-
>
|
|
210
|
-
{tab}
|
|
211
|
-
</button>
|
|
212
|
-
))}
|
|
213
|
-
</Box>
|
|
214
|
-
|
|
215
|
-
<Box data-testid="tab-content">
|
|
216
|
-
<Heading level="h3" data-testid="tab-heading">
|
|
217
|
-
{tabs[selectedTab]} Content
|
|
218
|
-
</Heading>
|
|
219
|
-
<Heading level="h4" weight="normal" data-testid="tab-subheading">
|
|
220
|
-
This is the content for {tabs[selectedTab].toLowerCase()}
|
|
221
|
-
</Heading>
|
|
222
|
-
</Box>
|
|
223
|
-
</Paper>
|
|
224
|
-
|
|
225
|
-
<Box sx={{ display: 'flex', gap: 2 }}>
|
|
226
|
-
<Paper sx={{ p: 2, flex: 1 }}>
|
|
227
|
-
<Heading level="h3" color="success" data-testid="card1-title">
|
|
228
|
-
Success Card
|
|
229
|
-
</Heading>
|
|
230
|
-
</Paper>
|
|
231
|
-
<Paper sx={{ p: 2, flex: 1 }}>
|
|
232
|
-
<Heading level="h3" color="warning" data-testid="card2-title">
|
|
233
|
-
Warning Card
|
|
234
|
-
</Heading>
|
|
235
|
-
</Paper>
|
|
236
|
-
<Paper sx={{ p: 2, flex: 1 }}>
|
|
237
|
-
<Heading level="h3" color="danger" data-testid="card3-title">
|
|
238
|
-
Danger Card
|
|
239
|
-
</Heading>
|
|
240
|
-
</Paper>
|
|
241
|
-
</Box>
|
|
242
|
-
</Stack>
|
|
243
|
-
);
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
// Basic Interaction Tests
|
|
247
|
-
export const BasicInteraction: Story = {
|
|
248
|
-
render: () => <BasicInteractionComponent />,
|
|
249
|
-
play: async ({ canvasElement }) => {
|
|
250
|
-
const canvas = within(canvasElement);
|
|
251
|
-
|
|
252
|
-
// Test basic rendering
|
|
253
|
-
const heading = canvas.getByTestId('clickable-heading');
|
|
254
|
-
expect(heading).toBeInTheDocument();
|
|
255
|
-
expect(heading).toHaveTextContent('Click me! (Clicked: 0)');
|
|
256
|
-
|
|
257
|
-
// Test click interaction
|
|
258
|
-
await userEvent.click(heading);
|
|
259
|
-
await waitFor(() => {
|
|
260
|
-
expect(heading).toHaveTextContent('Click me! (Clicked: 1)');
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
// Test multiple clicks
|
|
264
|
-
await userEvent.click(heading);
|
|
265
|
-
await userEvent.click(heading);
|
|
266
|
-
await waitFor(() => {
|
|
267
|
-
expect(heading).toHaveTextContent('Click me! (Clicked: 3)');
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
// Test container exists
|
|
271
|
-
expect(canvas.getByTestId('basic-interaction-container')).toBeInTheDocument();
|
|
272
|
-
},
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
// Anchor Links Test
|
|
276
|
-
export const AnchorLinks: Story = {
|
|
277
|
-
render: () => (
|
|
278
|
-
<Stack spacing={4} data-testid="anchor-links-container">
|
|
279
|
-
<Heading level="h1" id="main-title" data-testid="main-heading">
|
|
280
|
-
Main Title
|
|
281
|
-
</Heading>
|
|
282
|
-
<Heading level="h2" id="section-1" data-testid="section-heading">
|
|
283
|
-
Section 1
|
|
284
|
-
</Heading>
|
|
285
|
-
<Heading level="h3" id="subsection-1-1" data-testid="subsection-heading">
|
|
286
|
-
Subsection 1.1
|
|
287
|
-
</Heading>
|
|
288
|
-
<Box sx={{ mt: 4 }}>
|
|
289
|
-
<a href="#main-title" data-testid="main-link">
|
|
290
|
-
Go to Main Title
|
|
291
|
-
</a>
|
|
292
|
-
<br />
|
|
293
|
-
<a href="#section-1" data-testid="section-link">
|
|
294
|
-
Go to Section 1
|
|
295
|
-
</a>
|
|
296
|
-
<br />
|
|
297
|
-
<a href="#subsection-1-1" data-testid="subsection-link">
|
|
298
|
-
Go to Subsection 1.1
|
|
299
|
-
</a>
|
|
300
|
-
</Box>
|
|
301
|
-
</Stack>
|
|
302
|
-
),
|
|
303
|
-
play: async ({ canvasElement }) => {
|
|
304
|
-
const canvas = within(canvasElement);
|
|
305
|
-
|
|
306
|
-
// Test heading elements exist with proper IDs
|
|
307
|
-
const mainHeading = canvas.getByTestId('main-heading');
|
|
308
|
-
const sectionHeading = canvas.getByTestId('section-heading');
|
|
309
|
-
const subsectionHeading = canvas.getByTestId('subsection-heading');
|
|
310
|
-
|
|
311
|
-
expect(mainHeading).toHaveAttribute('id', 'main-title');
|
|
312
|
-
expect(sectionHeading).toHaveAttribute('id', 'section-1');
|
|
313
|
-
expect(subsectionHeading).toHaveAttribute('id', 'subsection-1-1');
|
|
314
|
-
|
|
315
|
-
// Test anchor links exist
|
|
316
|
-
const mainLink = canvas.getByTestId('main-link');
|
|
317
|
-
const sectionLink = canvas.getByTestId('section-link');
|
|
318
|
-
const subsectionLink = canvas.getByTestId('subsection-link');
|
|
319
|
-
|
|
320
|
-
expect(mainLink).toHaveAttribute('href', '#main-title');
|
|
321
|
-
expect(sectionLink).toHaveAttribute('href', '#section-1');
|
|
322
|
-
expect(subsectionLink).toHaveAttribute('href', '#subsection-1-1');
|
|
323
|
-
|
|
324
|
-
// Test clicking anchor links
|
|
325
|
-
await userEvent.click(mainLink);
|
|
326
|
-
await userEvent.click(sectionLink);
|
|
327
|
-
await userEvent.click(subsectionLink);
|
|
328
|
-
},
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
// Keyboard Navigation Test
|
|
332
|
-
export const KeyboardNavigation: Story = {
|
|
333
|
-
render: () => <KeyboardNavigationComponent />,
|
|
334
|
-
play: async ({ canvasElement }) => {
|
|
335
|
-
const canvas = within(canvasElement);
|
|
336
|
-
|
|
337
|
-
// Test keyboard navigation
|
|
338
|
-
const h1 = canvas.getByTestId('heading-h1');
|
|
339
|
-
const h2 = canvas.getByTestId('heading-h2');
|
|
340
|
-
const h3 = canvas.getByTestId('heading-h3');
|
|
341
|
-
const focusDisplay = canvas.getByTestId('focused-element');
|
|
342
|
-
|
|
343
|
-
// Tab to first heading
|
|
344
|
-
await userEvent.tab();
|
|
345
|
-
await waitFor(() => expect(h1).toHaveFocus());
|
|
346
|
-
await waitFor(() => {
|
|
347
|
-
expect(focusDisplay).toHaveTextContent('Focused: h1');
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
// Tab to second heading
|
|
351
|
-
await userEvent.tab();
|
|
352
|
-
await waitFor(() => expect(h2).toHaveFocus());
|
|
353
|
-
await waitFor(() => {
|
|
354
|
-
expect(focusDisplay).toHaveTextContent('Focused: h2');
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
// Tab to third heading
|
|
358
|
-
await userEvent.tab();
|
|
359
|
-
await waitFor(() => expect(h3).toHaveFocus());
|
|
360
|
-
await waitFor(() => {
|
|
361
|
-
expect(focusDisplay).toHaveTextContent('Focused: h3');
|
|
362
|
-
});
|
|
363
|
-
},
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
// Screen Reader Test
|
|
367
|
-
export const ScreenReader: Story = {
|
|
368
|
-
render: () => (
|
|
369
|
-
<Stack spacing={2} data-testid="screen-reader-container">
|
|
370
|
-
<Heading level="h1" data-testid="main-heading">
|
|
371
|
-
Main Page Title
|
|
372
|
-
</Heading>
|
|
373
|
-
<Heading level="h2" aria-label="Section heading for navigation" data-testid="section-heading">
|
|
374
|
-
Navigation Section
|
|
375
|
-
</Heading>
|
|
376
|
-
<Heading level="h3" role="heading" aria-level={3} data-testid="custom-heading">
|
|
377
|
-
Custom Semantic Heading
|
|
378
|
-
</Heading>
|
|
379
|
-
<Heading level="h4" aria-describedby="heading-description" data-testid="described-heading">
|
|
380
|
-
Heading with Description
|
|
381
|
-
</Heading>
|
|
382
|
-
<div id="heading-description">This heading describes important content below</div>
|
|
383
|
-
<Heading level="display" data-testid="display-heading">
|
|
384
|
-
Display Style Heading
|
|
385
|
-
</Heading>
|
|
386
|
-
</Stack>
|
|
387
|
-
),
|
|
388
|
-
play: async ({ canvasElement }) => {
|
|
389
|
-
const canvas = within(canvasElement);
|
|
390
|
-
|
|
391
|
-
// Test semantic heading elements
|
|
392
|
-
const mainHeading = canvas.getByTestId('main-heading');
|
|
393
|
-
const sectionHeading = canvas.getByTestId('section-heading');
|
|
394
|
-
const customHeading = canvas.getByTestId('custom-heading');
|
|
395
|
-
const describedHeading = canvas.getByTestId('described-heading');
|
|
396
|
-
const displayHeading = canvas.getByTestId('display-heading');
|
|
397
|
-
|
|
398
|
-
// Test correct HTML elements
|
|
399
|
-
expect(mainHeading.tagName).toBe('H1');
|
|
400
|
-
expect(sectionHeading.tagName).toBe('H2');
|
|
401
|
-
expect(customHeading.tagName).toBe('H3');
|
|
402
|
-
expect(describedHeading.tagName).toBe('H4');
|
|
403
|
-
expect(displayHeading.tagName).toBe('H1'); // display level maps to h1
|
|
404
|
-
|
|
405
|
-
// Test accessibility attributes
|
|
406
|
-
expect(sectionHeading).toHaveAttribute('aria-label', 'Section heading for navigation');
|
|
407
|
-
expect(customHeading).toHaveAttribute('role', 'heading');
|
|
408
|
-
expect(customHeading).toHaveAttribute('aria-level', '3');
|
|
409
|
-
expect(describedHeading).toHaveAttribute('aria-describedby', 'heading-description');
|
|
410
|
-
|
|
411
|
-
// Test heading hierarchy
|
|
412
|
-
const headings = canvas.getAllByRole('heading');
|
|
413
|
-
expect(headings).toHaveLength(5);
|
|
414
|
-
},
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
// Focus Management Test
|
|
418
|
-
export const FocusManagement: Story = {
|
|
419
|
-
render: () => <FocusManagementComponent />,
|
|
420
|
-
play: async ({ canvasElement }) => {
|
|
421
|
-
const canvas = within(canvasElement);
|
|
422
|
-
|
|
423
|
-
// Test programmatic focus
|
|
424
|
-
const focusH1Btn = canvas.getByTestId('focus-h1-btn');
|
|
425
|
-
const focusH2Btn = canvas.getByTestId('focus-h2-btn');
|
|
426
|
-
const focusH3Btn = canvas.getByTestId('focus-h3-btn');
|
|
427
|
-
|
|
428
|
-
const h1 = canvas.getByTestId('managed-h1');
|
|
429
|
-
const h2 = canvas.getByTestId('managed-h2');
|
|
430
|
-
const h3 = canvas.getByTestId('managed-h3');
|
|
431
|
-
|
|
432
|
-
const activeDisplay = canvas.getByTestId('active-heading');
|
|
433
|
-
|
|
434
|
-
// Focus H1
|
|
435
|
-
await userEvent.click(focusH1Btn);
|
|
436
|
-
await waitFor(() => expect(h1).toHaveFocus());
|
|
437
|
-
await waitFor(() => {
|
|
438
|
-
expect(activeDisplay).toHaveTextContent('Active: h1');
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
// Focus H2
|
|
442
|
-
await userEvent.click(focusH2Btn);
|
|
443
|
-
await waitFor(() => expect(h2).toHaveFocus());
|
|
444
|
-
await waitFor(() => {
|
|
445
|
-
expect(activeDisplay).toHaveTextContent('Active: h2');
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
// Focus H3
|
|
449
|
-
await userEvent.click(focusH3Btn);
|
|
450
|
-
await waitFor(() => expect(h3).toHaveFocus());
|
|
451
|
-
await waitFor(() => {
|
|
452
|
-
expect(activeDisplay).toHaveTextContent('Active: h3');
|
|
453
|
-
});
|
|
454
|
-
},
|
|
455
|
-
};
|
|
456
|
-
|
|
457
|
-
// Responsive Design Test
|
|
458
|
-
export const ResponsiveDesign: Story = {
|
|
459
|
-
parameters: {
|
|
460
|
-
viewport: { defaultViewport: 'mobile1' },
|
|
461
|
-
},
|
|
462
|
-
render: () => (
|
|
463
|
-
<Stack spacing={2} data-testid="responsive-container">
|
|
464
|
-
<Heading
|
|
465
|
-
level="h1"
|
|
466
|
-
sx={{
|
|
467
|
-
fontSize: { xs: '1.5rem', sm: '2rem', md: '2.5rem' },
|
|
468
|
-
}}
|
|
469
|
-
data-testid="responsive-h1"
|
|
470
|
-
>
|
|
471
|
-
Responsive H1
|
|
472
|
-
</Heading>
|
|
473
|
-
|
|
474
|
-
<Heading
|
|
475
|
-
level="h2"
|
|
476
|
-
sx={{
|
|
477
|
-
display: { xs: 'none', md: 'block' },
|
|
478
|
-
}}
|
|
479
|
-
data-testid="desktop-only-h2"
|
|
480
|
-
>
|
|
481
|
-
Desktop Only H2
|
|
482
|
-
</Heading>
|
|
483
|
-
|
|
484
|
-
<Heading
|
|
485
|
-
level="h2"
|
|
486
|
-
sx={{
|
|
487
|
-
display: { xs: 'block', md: 'none' },
|
|
488
|
-
}}
|
|
489
|
-
data-testid="mobile-only-h2"
|
|
490
|
-
>
|
|
491
|
-
Mobile Only H2
|
|
492
|
-
</Heading>
|
|
493
|
-
|
|
494
|
-
<Heading
|
|
495
|
-
level="h3"
|
|
496
|
-
sx={{
|
|
497
|
-
textAlign: { xs: 'center', md: 'left' },
|
|
498
|
-
}}
|
|
499
|
-
data-testid="adaptive-alignment-h3"
|
|
500
|
-
>
|
|
501
|
-
Adaptive Alignment H3
|
|
502
|
-
</Heading>
|
|
503
|
-
</Stack>
|
|
504
|
-
),
|
|
505
|
-
play: async ({ canvasElement }) => {
|
|
506
|
-
const canvas = within(canvasElement);
|
|
507
|
-
|
|
508
|
-
// Test responsive elements exist
|
|
509
|
-
expect(canvas.getByTestId('responsive-h1')).toBeInTheDocument();
|
|
510
|
-
expect(canvas.getByTestId('desktop-only-h2')).toBeInTheDocument();
|
|
511
|
-
expect(canvas.getByTestId('mobile-only-h2')).toBeInTheDocument();
|
|
512
|
-
expect(canvas.getByTestId('adaptive-alignment-h3')).toBeInTheDocument();
|
|
513
|
-
|
|
514
|
-
// Test responsive breakpoints applied (basic style verification)
|
|
515
|
-
const responsiveH1 = canvas.getByTestId('responsive-h1');
|
|
516
|
-
expect(responsiveH1).toHaveStyle('font-family: Roboto, Helvetica, Arial, sans-serif');
|
|
517
|
-
},
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
// Theme Variations Test
|
|
521
|
-
export const ThemeVariations: Story = {
|
|
522
|
-
render: () => {
|
|
523
|
-
const lightTheme = createTheme({ palette: { mode: 'light' } });
|
|
524
|
-
const darkTheme = createTheme({ palette: { mode: 'dark' } });
|
|
525
|
-
|
|
526
|
-
return (
|
|
527
|
-
<Stack spacing={4} data-testid="theme-variations-container">
|
|
528
|
-
<ThemeProvider theme={lightTheme}>
|
|
529
|
-
<Paper sx={{ p: 2 }} data-testid="light-theme-section">
|
|
530
|
-
<Heading level="h2" color="primary" data-testid="light-primary-heading">
|
|
531
|
-
Light Theme Primary
|
|
532
|
-
</Heading>
|
|
533
|
-
<Heading level="h3" color="secondary" data-testid="light-secondary-heading">
|
|
534
|
-
Light Theme Secondary
|
|
535
|
-
</Heading>
|
|
536
|
-
<Heading level="h4" color="neutral" data-testid="light-neutral-heading">
|
|
537
|
-
Light Theme Neutral
|
|
538
|
-
</Heading>
|
|
539
|
-
</Paper>
|
|
540
|
-
</ThemeProvider>
|
|
541
|
-
|
|
542
|
-
<ThemeProvider theme={darkTheme}>
|
|
543
|
-
<Paper sx={{ p: 2, bgcolor: 'background.paper' }} data-testid="dark-theme-section">
|
|
544
|
-
<Heading level="h2" color="primary" data-testid="dark-primary-heading">
|
|
545
|
-
Dark Theme Primary
|
|
546
|
-
</Heading>
|
|
547
|
-
<Heading level="h3" color="secondary" data-testid="dark-secondary-heading">
|
|
548
|
-
Dark Theme Secondary
|
|
549
|
-
</Heading>
|
|
550
|
-
<Heading level="h4" color="neutral" data-testid="dark-neutral-heading">
|
|
551
|
-
Dark Theme Neutral
|
|
552
|
-
</Heading>
|
|
553
|
-
</Paper>
|
|
554
|
-
</ThemeProvider>
|
|
555
|
-
</Stack>
|
|
556
|
-
);
|
|
557
|
-
},
|
|
558
|
-
play: async ({ canvasElement }) => {
|
|
559
|
-
const canvas = within(canvasElement);
|
|
560
|
-
|
|
561
|
-
// Test theme sections exist
|
|
562
|
-
expect(canvas.getByTestId('light-theme-section')).toBeInTheDocument();
|
|
563
|
-
expect(canvas.getByTestId('dark-theme-section')).toBeInTheDocument();
|
|
564
|
-
|
|
565
|
-
// Test headings exist in both themes
|
|
566
|
-
expect(canvas.getByTestId('light-primary-heading')).toBeInTheDocument();
|
|
567
|
-
expect(canvas.getByTestId('light-secondary-heading')).toBeInTheDocument();
|
|
568
|
-
expect(canvas.getByTestId('light-neutral-heading')).toBeInTheDocument();
|
|
569
|
-
|
|
570
|
-
expect(canvas.getByTestId('dark-primary-heading')).toBeInTheDocument();
|
|
571
|
-
expect(canvas.getByTestId('dark-secondary-heading')).toBeInTheDocument();
|
|
572
|
-
expect(canvas.getByTestId('dark-neutral-heading')).toBeInTheDocument();
|
|
573
|
-
},
|
|
574
|
-
};
|
|
575
|
-
|
|
576
|
-
// Visual States Test
|
|
577
|
-
export const VisualStates: Story = {
|
|
578
|
-
render: () => (
|
|
579
|
-
<Stack spacing={3} data-testid="visual-states-container">
|
|
580
|
-
<Stack spacing={1}>
|
|
581
|
-
<div>Heading Levels:</div>
|
|
582
|
-
<Heading level="h1" data-testid="level-h1">
|
|
583
|
-
H1 Heading
|
|
584
|
-
</Heading>
|
|
585
|
-
<Heading level="h2" data-testid="level-h2">
|
|
586
|
-
H2 Heading
|
|
587
|
-
</Heading>
|
|
588
|
-
<Heading level="h3" data-testid="level-h3">
|
|
589
|
-
H3 Heading
|
|
590
|
-
</Heading>
|
|
591
|
-
<Heading level="h4" data-testid="level-h4">
|
|
592
|
-
H4 Heading
|
|
593
|
-
</Heading>
|
|
594
|
-
<Heading level="h5" data-testid="level-h5">
|
|
595
|
-
H5 Heading
|
|
596
|
-
</Heading>
|
|
597
|
-
<Heading level="h6" data-testid="level-h6">
|
|
598
|
-
H6 Heading
|
|
599
|
-
</Heading>
|
|
600
|
-
<Heading level="display" data-testid="level-display">
|
|
601
|
-
Display Heading
|
|
602
|
-
</Heading>
|
|
603
|
-
</Stack>
|
|
604
|
-
|
|
605
|
-
<Stack spacing={1}>
|
|
606
|
-
<div>Color Variations:</div>
|
|
607
|
-
<Heading level="h3" color="primary" data-testid="color-primary">
|
|
608
|
-
Primary Color
|
|
609
|
-
</Heading>
|
|
610
|
-
<Heading level="h3" color="secondary" data-testid="color-secondary">
|
|
611
|
-
Secondary Color
|
|
612
|
-
</Heading>
|
|
613
|
-
<Heading level="h3" color="success" data-testid="color-success">
|
|
614
|
-
Success Color
|
|
615
|
-
</Heading>
|
|
616
|
-
<Heading level="h3" color="warning" data-testid="color-warning">
|
|
617
|
-
Warning Color
|
|
618
|
-
</Heading>
|
|
619
|
-
<Heading level="h3" color="danger" data-testid="color-danger">
|
|
620
|
-
Danger Color
|
|
621
|
-
</Heading>
|
|
622
|
-
<Heading level="h3" color="neutral" data-testid="color-neutral">
|
|
623
|
-
Neutral Color
|
|
624
|
-
</Heading>
|
|
625
|
-
</Stack>
|
|
626
|
-
|
|
627
|
-
<Stack spacing={1}>
|
|
628
|
-
<div>Weight Variations:</div>
|
|
629
|
-
<Heading level="h3" weight="light" data-testid="weight-light">
|
|
630
|
-
Light Weight
|
|
631
|
-
</Heading>
|
|
632
|
-
<Heading level="h3" weight="normal" data-testid="weight-normal">
|
|
633
|
-
Normal Weight
|
|
634
|
-
</Heading>
|
|
635
|
-
<Heading level="h3" weight="medium" data-testid="weight-medium">
|
|
636
|
-
Medium Weight
|
|
637
|
-
</Heading>
|
|
638
|
-
<Heading level="h3" weight="semibold" data-testid="weight-semibold">
|
|
639
|
-
Semibold Weight
|
|
640
|
-
</Heading>
|
|
641
|
-
<Heading level="h3" weight="bold" data-testid="weight-bold">
|
|
642
|
-
Bold Weight
|
|
643
|
-
</Heading>
|
|
644
|
-
</Stack>
|
|
645
|
-
|
|
646
|
-
<Stack spacing={1}>
|
|
647
|
-
<div>Gradient Effect:</div>
|
|
648
|
-
<Heading level="h2" gradient={true} data-testid="gradient-heading">
|
|
649
|
-
Gradient Heading
|
|
650
|
-
</Heading>
|
|
651
|
-
<Heading level="h2" gradient={false} data-testid="non-gradient-heading">
|
|
652
|
-
Non-Gradient Heading
|
|
653
|
-
</Heading>
|
|
654
|
-
</Stack>
|
|
655
|
-
</Stack>
|
|
656
|
-
),
|
|
657
|
-
play: async ({ canvasElement }) => {
|
|
658
|
-
const canvas = within(canvasElement);
|
|
659
|
-
|
|
660
|
-
// Test all heading levels
|
|
661
|
-
expect(canvas.getByTestId('level-h1').tagName).toBe('H1');
|
|
662
|
-
expect(canvas.getByTestId('level-h2').tagName).toBe('H2');
|
|
663
|
-
expect(canvas.getByTestId('level-h3').tagName).toBe('H3');
|
|
664
|
-
expect(canvas.getByTestId('level-h4').tagName).toBe('H4');
|
|
665
|
-
expect(canvas.getByTestId('level-h5').tagName).toBe('H5');
|
|
666
|
-
expect(canvas.getByTestId('level-h6').tagName).toBe('H6');
|
|
667
|
-
expect(canvas.getByTestId('level-display').tagName).toBe('H1');
|
|
668
|
-
|
|
669
|
-
// Test color variations exist
|
|
670
|
-
expect(canvas.getByTestId('color-primary')).toBeInTheDocument();
|
|
671
|
-
expect(canvas.getByTestId('color-secondary')).toBeInTheDocument();
|
|
672
|
-
expect(canvas.getByTestId('color-success')).toBeInTheDocument();
|
|
673
|
-
expect(canvas.getByTestId('color-warning')).toBeInTheDocument();
|
|
674
|
-
expect(canvas.getByTestId('color-danger')).toBeInTheDocument();
|
|
675
|
-
expect(canvas.getByTestId('color-neutral')).toBeInTheDocument();
|
|
676
|
-
|
|
677
|
-
// Test weight variations exist
|
|
678
|
-
expect(canvas.getByTestId('weight-light')).toBeInTheDocument();
|
|
679
|
-
expect(canvas.getByTestId('weight-normal')).toBeInTheDocument();
|
|
680
|
-
expect(canvas.getByTestId('weight-medium')).toBeInTheDocument();
|
|
681
|
-
expect(canvas.getByTestId('weight-semibold')).toBeInTheDocument();
|
|
682
|
-
expect(canvas.getByTestId('weight-bold')).toBeInTheDocument();
|
|
683
|
-
|
|
684
|
-
// Test gradient variations exist
|
|
685
|
-
expect(canvas.getByTestId('gradient-heading')).toBeInTheDocument();
|
|
686
|
-
expect(canvas.getByTestId('non-gradient-heading')).toBeInTheDocument();
|
|
687
|
-
},
|
|
688
|
-
};
|
|
689
|
-
|
|
690
|
-
// Performance Test
|
|
691
|
-
export const Performance: Story = {
|
|
692
|
-
render: () => <PerformanceTestComponent />,
|
|
693
|
-
play: async ({ canvasElement }) => {
|
|
694
|
-
const canvas = within(canvasElement);
|
|
695
|
-
|
|
696
|
-
// Test all performance headings render
|
|
697
|
-
for (let i = 0; i < 50; i++) {
|
|
698
|
-
expect(canvas.getByTestId(`perf-heading-${i}`)).toBeInTheDocument();
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
// Test render time is reasonable (under 100ms)
|
|
702
|
-
const renderTimeElement = canvas.getByTestId('render-time');
|
|
703
|
-
const renderTimeText = renderTimeElement.textContent;
|
|
704
|
-
const renderTime = parseFloat(renderTimeText?.match(/[\d.]+/)?.[0] || '0');
|
|
705
|
-
|
|
706
|
-
expect(renderTime).toBeLessThan(100);
|
|
707
|
-
},
|
|
708
|
-
};
|
|
709
|
-
|
|
710
|
-
// Edge Cases Test
|
|
711
|
-
export const EdgeCases: Story = {
|
|
712
|
-
render: () => (
|
|
713
|
-
<Stack spacing={2} data-testid="edge-cases-container">
|
|
714
|
-
<Heading level="h1" data-testid="empty-content"></Heading>
|
|
715
|
-
|
|
716
|
-
<Heading level="h2" data-testid="very-long-content">
|
|
717
|
-
This is a very long heading that should wrap properly and maintain readability even when the
|
|
718
|
-
content extends beyond the normal width of the container and continues to multiple lines to
|
|
719
|
-
test text overflow and wrapping behavior
|
|
720
|
-
</Heading>
|
|
721
|
-
|
|
722
|
-
<Heading level="h3" data-testid="special-characters">
|
|
723
|
-
Special Characters: !@#$%^&*()_+-=[]{}|;:'",./?`~
|
|
724
|
-
</Heading>
|
|
725
|
-
|
|
726
|
-
<Heading level="h4" data-testid="unicode-content">
|
|
727
|
-
Unicode: 你好 🌟 العربية Ελληνικά 🚀 日本語
|
|
728
|
-
</Heading>
|
|
729
|
-
|
|
730
|
-
<Heading level="h5" data-testid="html-entities">
|
|
731
|
-
HTML Entities: <div> & "quotes" 'apostrophes'
|
|
732
|
-
</Heading>
|
|
733
|
-
|
|
734
|
-
<Heading level="h6" data-testid="numbers-and-symbols">
|
|
735
|
-
123456789 αβγδε ∑∆∏π ∞≠≤≥ → ← ↑ ↓
|
|
736
|
-
</Heading>
|
|
737
|
-
|
|
738
|
-
<Heading level="display" data-testid="mixed-content">
|
|
739
|
-
Mixed: Text123 🎯 <span>HTML</span> & More!
|
|
740
|
-
</Heading>
|
|
741
|
-
|
|
742
|
-
<Box sx={{ width: 200, overflow: 'hidden' }}>
|
|
743
|
-
<Heading level="h3" data-testid="constrained-width">
|
|
744
|
-
Constrained Width Heading That Should Wrap
|
|
745
|
-
</Heading>
|
|
746
|
-
</Box>
|
|
747
|
-
|
|
748
|
-
<Heading
|
|
749
|
-
level="h2"
|
|
750
|
-
data-testid="all-props"
|
|
751
|
-
color="primary"
|
|
752
|
-
weight="bold"
|
|
753
|
-
gradient={true}
|
|
754
|
-
style={{ textDecoration: 'underline' }}
|
|
755
|
-
>
|
|
756
|
-
All Props Combined
|
|
757
|
-
</Heading>
|
|
758
|
-
</Stack>
|
|
759
|
-
),
|
|
760
|
-
play: async ({ canvasElement }) => {
|
|
761
|
-
const canvas = within(canvasElement);
|
|
762
|
-
|
|
763
|
-
// Test empty content handling
|
|
764
|
-
const emptyHeading = canvas.getByTestId('empty-content');
|
|
765
|
-
expect(emptyHeading).toBeInTheDocument();
|
|
766
|
-
|
|
767
|
-
// Test very long content
|
|
768
|
-
const longHeading = canvas.getByTestId('very-long-content');
|
|
769
|
-
expect(longHeading).toBeInTheDocument();
|
|
770
|
-
expect(longHeading.textContent).toContain('very long heading');
|
|
771
|
-
|
|
772
|
-
// Test special characters
|
|
773
|
-
const specialCharsHeading = canvas.getByTestId('special-characters');
|
|
774
|
-
expect(specialCharsHeading).toHaveTextContent('Special Characters');
|
|
775
|
-
|
|
776
|
-
// Test unicode content
|
|
777
|
-
const unicodeHeading = canvas.getByTestId('unicode-content');
|
|
778
|
-
expect(unicodeHeading).toHaveTextContent('你好 🌟 العربية Ελληνικά 🚀 日本語');
|
|
779
|
-
|
|
780
|
-
// Test HTML entities
|
|
781
|
-
const entitiesHeading = canvas.getByTestId('html-entities');
|
|
782
|
-
expect(entitiesHeading).toBeInTheDocument();
|
|
783
|
-
|
|
784
|
-
// Test numbers and symbols
|
|
785
|
-
const numbersHeading = canvas.getByTestId('numbers-and-symbols');
|
|
786
|
-
expect(numbersHeading).toBeInTheDocument();
|
|
787
|
-
|
|
788
|
-
// Test mixed content
|
|
789
|
-
const mixedHeading = canvas.getByTestId('mixed-content');
|
|
790
|
-
expect(mixedHeading).toBeInTheDocument();
|
|
791
|
-
|
|
792
|
-
// Test constrained width
|
|
793
|
-
const constrainedHeading = canvas.getByTestId('constrained-width');
|
|
794
|
-
expect(constrainedHeading).toBeInTheDocument();
|
|
795
|
-
|
|
796
|
-
// Test all props combined
|
|
797
|
-
const allPropsHeading = canvas.getByTestId('all-props');
|
|
798
|
-
expect(allPropsHeading).toBeInTheDocument();
|
|
799
|
-
expect(allPropsHeading.tagName).toBe('H2');
|
|
800
|
-
},
|
|
801
|
-
};
|
|
802
|
-
|
|
803
|
-
// Integration Test
|
|
804
|
-
export const Integration: Story = {
|
|
805
|
-
render: () => <IntegrationTestComponent />,
|
|
806
|
-
play: async ({ canvasElement }) => {
|
|
807
|
-
const canvas = within(canvasElement);
|
|
808
|
-
|
|
809
|
-
// Test initial state
|
|
810
|
-
expect(canvas.getByTestId('page-title')).toHaveTextContent('Integration Testing Page');
|
|
811
|
-
expect(canvas.getByTestId('section-title')).toHaveTextContent('Content Section');
|
|
812
|
-
expect(canvas.getByTestId('tab-heading')).toHaveTextContent('Tab 1 Content');
|
|
813
|
-
|
|
814
|
-
// Test tab switching
|
|
815
|
-
const tab2Button = canvas.getByTestId('tab-1');
|
|
816
|
-
await userEvent.click(tab2Button);
|
|
817
|
-
|
|
818
|
-
await waitFor(() => {
|
|
819
|
-
expect(canvas.getByTestId('tab-heading')).toHaveTextContent('Tab 2 Content');
|
|
820
|
-
expect(canvas.getByTestId('tab-subheading')).toHaveTextContent(
|
|
821
|
-
'This is the content for tab 2',
|
|
822
|
-
);
|
|
823
|
-
});
|
|
824
|
-
|
|
825
|
-
// Test card titles
|
|
826
|
-
expect(canvas.getByTestId('card1-title')).toHaveTextContent('Success Card');
|
|
827
|
-
expect(canvas.getByTestId('card2-title')).toHaveTextContent('Warning Card');
|
|
828
|
-
expect(canvas.getByTestId('card3-title')).toHaveTextContent('Danger Card');
|
|
829
|
-
},
|
|
830
|
-
};
|