@12-apps/ui 1.5.0 → 1.5.1
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 +16 -8
- 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,929 +0,0 @@
|
|
|
1
|
-
import { Box, Button, createTheme, Stack, ThemeProvider, Typography } from '@mui/material';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
|
|
5
|
-
|
|
6
|
-
import { HoverCard } from './HoverCard';
|
|
7
|
-
|
|
8
|
-
const meta: Meta<typeof HoverCard> = {
|
|
9
|
-
title: 'DataDisplay/HoverCard/Tests',
|
|
10
|
-
component: HoverCard,
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: 'centered',
|
|
13
|
-
chromatic: { disableSnapshot: false },
|
|
14
|
-
},
|
|
15
|
-
tags: ['autodocs', 'test', 'component:HoverCard'],
|
|
16
|
-
argTypes: {
|
|
17
|
-
onOpen: { action: 'onOpen' },
|
|
18
|
-
onClose: { action: 'onClose' },
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default meta;
|
|
23
|
-
type Story = StoryObj<typeof meta>;
|
|
24
|
-
|
|
25
|
-
// Test 1: Basic Interaction (hover to show/hide)
|
|
26
|
-
export const BasicInteraction: Story = {
|
|
27
|
-
args: {
|
|
28
|
-
title: 'Test HoverCard',
|
|
29
|
-
description: 'Testing hover interaction',
|
|
30
|
-
enterDelay: 100,
|
|
31
|
-
exitDelay: 100,
|
|
32
|
-
children: <Button data-testid="hover-trigger">Hover Me</Button>,
|
|
33
|
-
},
|
|
34
|
-
play: async ({ canvasElement, step }) => {
|
|
35
|
-
const canvas = within(canvasElement);
|
|
36
|
-
|
|
37
|
-
// Wait to ensure any previous hover cards from other tests are fully closed
|
|
38
|
-
await new Promise((resolve) => window.setTimeout(resolve, 300));
|
|
39
|
-
|
|
40
|
-
await step('Initial state - hover card should not be visible', async () => {
|
|
41
|
-
const trigger = await canvas.findByTestId('hover-trigger');
|
|
42
|
-
expect(trigger).toBeInTheDocument();
|
|
43
|
-
|
|
44
|
-
// Wait and verify no hover cards are visible
|
|
45
|
-
await waitFor(
|
|
46
|
-
async () => {
|
|
47
|
-
const hoverTitle = canvasElement.ownerDocument.body.querySelector('h6');
|
|
48
|
-
expect(hoverTitle).not.toBeInTheDocument();
|
|
49
|
-
},
|
|
50
|
-
{ timeout: 500 },
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
await step('Hover over trigger - hover card should appear', async () => {
|
|
55
|
-
const trigger = await canvas.findByTestId('hover-trigger');
|
|
56
|
-
await userEvent.hover(trigger);
|
|
57
|
-
|
|
58
|
-
// Wait for the enterDelay
|
|
59
|
-
await waitFor(
|
|
60
|
-
async () => {
|
|
61
|
-
const hoverTitle = canvasElement.ownerDocument.body.querySelector('h6');
|
|
62
|
-
expect(hoverTitle).toBeInTheDocument();
|
|
63
|
-
expect(hoverTitle).toHaveTextContent('Test HoverCard');
|
|
64
|
-
},
|
|
65
|
-
{ timeout: 500 },
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
await step('Move mouse away - hover card should disappear', async () => {
|
|
70
|
-
await userEvent.unhover(await canvas.findByTestId('hover-trigger'));
|
|
71
|
-
|
|
72
|
-
// Wait for the exitDelay
|
|
73
|
-
await waitFor(
|
|
74
|
-
async () => {
|
|
75
|
-
const hoverTitle = canvasElement.ownerDocument.body.querySelector('h6');
|
|
76
|
-
expect(hoverTitle).not.toBeInTheDocument();
|
|
77
|
-
},
|
|
78
|
-
{ timeout: 500 },
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// Test 2: Controlled State
|
|
85
|
-
export const ControlledState: Story = {
|
|
86
|
-
render: function ControlledStateRender() {
|
|
87
|
-
const [open, setOpen] = React.useState(false);
|
|
88
|
-
const handleOpenChange = fn();
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<Stack spacing={2} alignItems="center">
|
|
92
|
-
<Button onClick={() => setOpen(!open)} data-testid="control-button">
|
|
93
|
-
Toggle HoverCard (Controlled)
|
|
94
|
-
</Button>
|
|
95
|
-
<HoverCard
|
|
96
|
-
title="Controlled HoverCard"
|
|
97
|
-
description="This is controlled externally"
|
|
98
|
-
onOpen={() => {
|
|
99
|
-
handleOpenChange('opened');
|
|
100
|
-
setOpen(true);
|
|
101
|
-
}}
|
|
102
|
-
onClose={() => {
|
|
103
|
-
handleOpenChange('closed');
|
|
104
|
-
setOpen(false);
|
|
105
|
-
}}
|
|
106
|
-
enterDelay={100}
|
|
107
|
-
>
|
|
108
|
-
<Button data-testid="controlled-trigger">Controlled Trigger</Button>
|
|
109
|
-
</HoverCard>
|
|
110
|
-
<Typography data-testid="open-state">{open ? 'Open' : 'Closed'}</Typography>
|
|
111
|
-
</Stack>
|
|
112
|
-
);
|
|
113
|
-
},
|
|
114
|
-
play: async ({ canvasElement, step }) => {
|
|
115
|
-
const canvas = within(canvasElement);
|
|
116
|
-
|
|
117
|
-
await step('Initial state should be closed', async () => {
|
|
118
|
-
const state = await canvas.findByTestId('open-state');
|
|
119
|
-
expect(state).toHaveTextContent('Closed');
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
await step('Hovering should open the controlled card', async () => {
|
|
123
|
-
const trigger = await canvas.findByTestId('controlled-trigger');
|
|
124
|
-
await userEvent.hover(trigger);
|
|
125
|
-
|
|
126
|
-
await waitFor(
|
|
127
|
-
async () => {
|
|
128
|
-
const hoverTitle = canvasElement.ownerDocument.body.querySelector('h6');
|
|
129
|
-
expect(hoverTitle).toBeInTheDocument();
|
|
130
|
-
expect(hoverTitle).toHaveTextContent('Controlled HoverCard');
|
|
131
|
-
},
|
|
132
|
-
{ timeout: 500 },
|
|
133
|
-
);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
await step('State should update when opened', async () => {
|
|
137
|
-
const state = await canvas.findByTestId('open-state');
|
|
138
|
-
await waitFor(() => {
|
|
139
|
-
expect(state).toHaveTextContent('Open');
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
},
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
// Test 3: Keyboard Navigation
|
|
146
|
-
export const KeyboardNavigation: Story = {
|
|
147
|
-
args: {
|
|
148
|
-
title: 'Keyboard Accessible',
|
|
149
|
-
description: 'Can be triggered via keyboard',
|
|
150
|
-
enterDelay: 100,
|
|
151
|
-
children: <Button data-testid="keyboard-trigger">Tab to me</Button>,
|
|
152
|
-
},
|
|
153
|
-
play: async ({ canvasElement, step }) => {
|
|
154
|
-
const canvas = within(canvasElement);
|
|
155
|
-
|
|
156
|
-
await step('Focus trigger with Tab key', async () => {
|
|
157
|
-
const trigger = await canvas.findByTestId('keyboard-trigger');
|
|
158
|
-
await userEvent.click(trigger);
|
|
159
|
-
await waitFor(() => expect(trigger).toHaveFocus());
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
await step('HoverCard should appear on focus', async () => {
|
|
163
|
-
const trigger = await canvas.findByTestId('keyboard-trigger');
|
|
164
|
-
await userEvent.hover(trigger);
|
|
165
|
-
|
|
166
|
-
await waitFor(
|
|
167
|
-
async () => {
|
|
168
|
-
const hoverTitle = canvasElement.ownerDocument.body.querySelector('h6');
|
|
169
|
-
expect(hoverTitle).toBeInTheDocument();
|
|
170
|
-
},
|
|
171
|
-
{ timeout: 500 },
|
|
172
|
-
);
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
await step('Escape key should close the hover card', async () => {
|
|
176
|
-
await userEvent.keyboard('{Escape}');
|
|
177
|
-
|
|
178
|
-
await waitFor(
|
|
179
|
-
async () => {
|
|
180
|
-
const hoverTitle = canvasElement.ownerDocument.body.querySelector('h6');
|
|
181
|
-
expect(hoverTitle).not.toBeInTheDocument();
|
|
182
|
-
},
|
|
183
|
-
{ timeout: 500 },
|
|
184
|
-
);
|
|
185
|
-
});
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
// Test 4: Screen Reader
|
|
190
|
-
export const ScreenReader: Story = {
|
|
191
|
-
args: {
|
|
192
|
-
title: 'Accessible HoverCard',
|
|
193
|
-
description: 'This content is announced to screen readers',
|
|
194
|
-
enterDelay: 100,
|
|
195
|
-
children: (
|
|
196
|
-
<Button
|
|
197
|
-
aria-label="User profile button with additional information on hover"
|
|
198
|
-
data-testid="aria-trigger"
|
|
199
|
-
>
|
|
200
|
-
User Profile
|
|
201
|
-
</Button>
|
|
202
|
-
),
|
|
203
|
-
},
|
|
204
|
-
play: async ({ canvasElement, step }) => {
|
|
205
|
-
const canvas = within(canvasElement);
|
|
206
|
-
|
|
207
|
-
await step('Trigger should have proper aria-label', async () => {
|
|
208
|
-
const trigger = await canvas.findByTestId('aria-trigger');
|
|
209
|
-
expect(trigger).toHaveAttribute(
|
|
210
|
-
'aria-label',
|
|
211
|
-
'User profile button with additional information on hover',
|
|
212
|
-
);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
await step('HoverCard content should be accessible', async () => {
|
|
216
|
-
// Wait a bit to ensure any previous hover cards are fully closed
|
|
217
|
-
await new Promise((resolve) => window.setTimeout(resolve, 300));
|
|
218
|
-
|
|
219
|
-
const trigger = await canvas.findByTestId('aria-trigger');
|
|
220
|
-
await userEvent.hover(trigger);
|
|
221
|
-
|
|
222
|
-
await waitFor(
|
|
223
|
-
async () => {
|
|
224
|
-
const hoverContent =
|
|
225
|
-
canvasElement.ownerDocument.body.querySelector('[role="presentation"]');
|
|
226
|
-
expect(hoverContent).toBeInTheDocument();
|
|
227
|
-
|
|
228
|
-
// Check that content is readable
|
|
229
|
-
const title = canvasElement.ownerDocument.body.querySelector('h6');
|
|
230
|
-
expect(title).toHaveTextContent('Accessible HoverCard');
|
|
231
|
-
},
|
|
232
|
-
{ timeout: 1000 },
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
// Clean up - unhover to close the card
|
|
236
|
-
await userEvent.unhover(trigger);
|
|
237
|
-
await waitFor(
|
|
238
|
-
async () => {
|
|
239
|
-
const hoverTitle = canvasElement.ownerDocument.body.querySelector('h6');
|
|
240
|
-
expect(hoverTitle).not.toBeInTheDocument();
|
|
241
|
-
},
|
|
242
|
-
{ timeout: 500 },
|
|
243
|
-
);
|
|
244
|
-
});
|
|
245
|
-
},
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
// Test 5: Focus Management
|
|
249
|
-
export const FocusManagement: Story = {
|
|
250
|
-
args: {
|
|
251
|
-
title: 'Focus Test',
|
|
252
|
-
description: 'Testing focus behavior',
|
|
253
|
-
enterDelay: 100,
|
|
254
|
-
onOpen: fn(),
|
|
255
|
-
onClose: fn(),
|
|
256
|
-
children: (
|
|
257
|
-
<Box>
|
|
258
|
-
<Button data-testid="focus-trigger">Hover for Card</Button>
|
|
259
|
-
<Box sx={{ mt: 2 }}>
|
|
260
|
-
<Button variant="contained">Action Button</Button>
|
|
261
|
-
</Box>
|
|
262
|
-
</Box>
|
|
263
|
-
),
|
|
264
|
-
},
|
|
265
|
-
play: async ({ canvasElement, step }) => {
|
|
266
|
-
const canvas = within(canvasElement);
|
|
267
|
-
|
|
268
|
-
await step('Initial focus state', async () => {
|
|
269
|
-
const trigger = await canvas.findByTestId('focus-trigger');
|
|
270
|
-
expect(trigger).toBeInTheDocument();
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
await step('Focus should remain on trigger when hovering', async () => {
|
|
274
|
-
const trigger = await canvas.findByTestId('focus-trigger');
|
|
275
|
-
await userEvent.click(trigger);
|
|
276
|
-
await waitFor(() => expect(trigger).toHaveFocus());
|
|
277
|
-
|
|
278
|
-
await userEvent.hover(trigger);
|
|
279
|
-
|
|
280
|
-
await waitFor(
|
|
281
|
-
async () => {
|
|
282
|
-
const hoverTitle = canvasElement.ownerDocument.body.querySelector('h6');
|
|
283
|
-
expect(hoverTitle).toBeInTheDocument();
|
|
284
|
-
// Focus should still be on trigger
|
|
285
|
-
expect(trigger).toHaveFocus();
|
|
286
|
-
},
|
|
287
|
-
{ timeout: 500 },
|
|
288
|
-
);
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
await step('Focus management after hover card closes', async () => {
|
|
292
|
-
const trigger = await canvas.findByTestId('focus-trigger');
|
|
293
|
-
|
|
294
|
-
await userEvent.unhover(trigger);
|
|
295
|
-
|
|
296
|
-
await waitFor(
|
|
297
|
-
async () => {
|
|
298
|
-
const hoverTitle = canvasElement.ownerDocument.body.querySelector('h6');
|
|
299
|
-
expect(hoverTitle).not.toBeInTheDocument();
|
|
300
|
-
},
|
|
301
|
-
{ timeout: 500 },
|
|
302
|
-
);
|
|
303
|
-
|
|
304
|
-
// Verify the trigger is still accessible
|
|
305
|
-
expect(trigger).toBeInTheDocument();
|
|
306
|
-
|
|
307
|
-
// For non-modal hover cards, focus behavior after unhover is not strictly defined
|
|
308
|
-
// Verify focus wasn't trapped or lost to an inaccessible element
|
|
309
|
-
const activeElement = document.activeElement;
|
|
310
|
-
expect(activeElement).not.toBeNull();
|
|
311
|
-
expect(activeElement).toBeDefined();
|
|
312
|
-
|
|
313
|
-
// Focus should be on a valid accessible element (not trapped in the removed hover card)
|
|
314
|
-
// For non-modal hover cards, focus typically remains on trigger or moves to body
|
|
315
|
-
expect([trigger, document.body]).toContain(activeElement);
|
|
316
|
-
|
|
317
|
-
// If focus is not on body, verify element is keyboard-accessible
|
|
318
|
-
if (activeElement !== document.body) {
|
|
319
|
-
const tabindex = activeElement?.getAttribute('tabindex');
|
|
320
|
-
expect(tabindex).not.toBe('-1');
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
},
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
// Test 6: Responsive Design
|
|
327
|
-
export const ResponsiveDesign: Story = {
|
|
328
|
-
parameters: {
|
|
329
|
-
viewport: {
|
|
330
|
-
viewports: {
|
|
331
|
-
mobile: { name: 'Mobile', styles: { width: '375px', height: '667px' } },
|
|
332
|
-
tablet: { name: 'Tablet', styles: { width: '768px', height: '1024px' } },
|
|
333
|
-
desktop: { name: 'Desktop', styles: { width: '1920px', height: '1080px' } },
|
|
334
|
-
},
|
|
335
|
-
},
|
|
336
|
-
},
|
|
337
|
-
render: () => (
|
|
338
|
-
<Box sx={{ p: 2 }}>
|
|
339
|
-
<Stack spacing={2}>
|
|
340
|
-
<HoverCard
|
|
341
|
-
title="Responsive HoverCard"
|
|
342
|
-
description="This adapts to different screen sizes"
|
|
343
|
-
maxWidth={300}
|
|
344
|
-
placement="bottom"
|
|
345
|
-
enterDelay={100}
|
|
346
|
-
onOpen={fn()}
|
|
347
|
-
onClose={fn()}
|
|
348
|
-
>
|
|
349
|
-
<Button data-testid="responsive-trigger">Hover Me</Button>
|
|
350
|
-
</HoverCard>
|
|
351
|
-
</Stack>
|
|
352
|
-
</Box>
|
|
353
|
-
),
|
|
354
|
-
play: async ({ canvasElement, step }) => {
|
|
355
|
-
const canvas = within(canvasElement);
|
|
356
|
-
|
|
357
|
-
await step('HoverCard should render on all viewports', async () => {
|
|
358
|
-
const trigger = await canvas.findByTestId('responsive-trigger');
|
|
359
|
-
expect(trigger).toBeInTheDocument();
|
|
360
|
-
|
|
361
|
-
await userEvent.hover(trigger);
|
|
362
|
-
|
|
363
|
-
await waitFor(
|
|
364
|
-
async () => {
|
|
365
|
-
const hoverTitle = canvasElement.ownerDocument.body.querySelector('h6');
|
|
366
|
-
expect(hoverTitle).toBeInTheDocument();
|
|
367
|
-
|
|
368
|
-
// Check that card has max width constraint
|
|
369
|
-
const card = canvasElement.ownerDocument.body.querySelector(
|
|
370
|
-
'.MuiCard-root',
|
|
371
|
-
) as HTMLElement;
|
|
372
|
-
expect(card).toBeInTheDocument();
|
|
373
|
-
const computedStyle = window.getComputedStyle(card);
|
|
374
|
-
const maxWidth = parseInt(computedStyle.maxWidth);
|
|
375
|
-
expect(maxWidth).toBeLessThanOrEqual(300);
|
|
376
|
-
},
|
|
377
|
-
{ timeout: 500 },
|
|
378
|
-
);
|
|
379
|
-
});
|
|
380
|
-
},
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
// Test 7: Theme Variations
|
|
384
|
-
export const ThemeVariations: Story = {
|
|
385
|
-
render: () => {
|
|
386
|
-
const lightTheme = createTheme({ palette: { mode: 'light' } });
|
|
387
|
-
const darkTheme = createTheme({ palette: { mode: 'dark' } });
|
|
388
|
-
|
|
389
|
-
return (
|
|
390
|
-
<Stack direction="row" spacing={4}>
|
|
391
|
-
<ThemeProvider theme={lightTheme}>
|
|
392
|
-
<HoverCard
|
|
393
|
-
title="Light Theme"
|
|
394
|
-
description="Card in light mode"
|
|
395
|
-
variant="default"
|
|
396
|
-
enterDelay={100}
|
|
397
|
-
onOpen={fn()}
|
|
398
|
-
onClose={fn()}
|
|
399
|
-
>
|
|
400
|
-
<Button data-testid="light-trigger">Light Mode</Button>
|
|
401
|
-
</HoverCard>
|
|
402
|
-
</ThemeProvider>
|
|
403
|
-
|
|
404
|
-
<ThemeProvider theme={darkTheme}>
|
|
405
|
-
<Box sx={{ bgcolor: 'grey.900', p: 2, borderRadius: 1 }}>
|
|
406
|
-
<HoverCard
|
|
407
|
-
title="Dark Theme"
|
|
408
|
-
description="Card in dark mode"
|
|
409
|
-
variant="default"
|
|
410
|
-
enterDelay={100}
|
|
411
|
-
onOpen={fn()}
|
|
412
|
-
onClose={fn()}
|
|
413
|
-
>
|
|
414
|
-
<Button data-testid="dark-trigger" sx={{ color: 'white' }}>
|
|
415
|
-
Dark Mode
|
|
416
|
-
</Button>
|
|
417
|
-
</HoverCard>
|
|
418
|
-
</Box>
|
|
419
|
-
</ThemeProvider>
|
|
420
|
-
</Stack>
|
|
421
|
-
);
|
|
422
|
-
},
|
|
423
|
-
play: async ({ canvasElement, step }) => {
|
|
424
|
-
const canvas = within(canvasElement);
|
|
425
|
-
|
|
426
|
-
await step('Light theme hover card should render correctly', async () => {
|
|
427
|
-
const lightTrigger = await canvas.findByTestId('light-trigger');
|
|
428
|
-
await userEvent.hover(lightTrigger);
|
|
429
|
-
|
|
430
|
-
await waitFor(
|
|
431
|
-
async () => {
|
|
432
|
-
const cards = canvasElement.ownerDocument.body.querySelectorAll('.MuiCard-root');
|
|
433
|
-
const lightCard = Array.from(cards).find(
|
|
434
|
-
(card) => card.querySelector('h6')?.textContent === 'Light Theme',
|
|
435
|
-
) as HTMLElement;
|
|
436
|
-
|
|
437
|
-
expect(lightCard).toBeInTheDocument();
|
|
438
|
-
const computedStyle = window.getComputedStyle(lightCard);
|
|
439
|
-
// Light theme should have light background
|
|
440
|
-
expect(computedStyle.backgroundColor).toMatch(/rgb/);
|
|
441
|
-
},
|
|
442
|
-
{ timeout: 500 },
|
|
443
|
-
);
|
|
444
|
-
|
|
445
|
-
await userEvent.unhover(lightTrigger);
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
await step('Dark theme hover card should render correctly', async () => {
|
|
449
|
-
const darkTrigger = await canvas.findByTestId('dark-trigger');
|
|
450
|
-
await userEvent.hover(darkTrigger);
|
|
451
|
-
|
|
452
|
-
await waitFor(
|
|
453
|
-
async () => {
|
|
454
|
-
const cards = canvasElement.ownerDocument.body.querySelectorAll('.MuiCard-root');
|
|
455
|
-
const darkCard = Array.from(cards).find(
|
|
456
|
-
(card) => card.querySelector('h6')?.textContent === 'Dark Theme',
|
|
457
|
-
) as HTMLElement;
|
|
458
|
-
|
|
459
|
-
expect(darkCard).toBeInTheDocument();
|
|
460
|
-
},
|
|
461
|
-
{ timeout: 500 },
|
|
462
|
-
);
|
|
463
|
-
});
|
|
464
|
-
},
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
// Test 8: Visual States
|
|
468
|
-
export const VisualStates: Story = {
|
|
469
|
-
render: () => (
|
|
470
|
-
<Stack direction="row" spacing={3} alignItems="center">
|
|
471
|
-
<HoverCard
|
|
472
|
-
variant="default"
|
|
473
|
-
title="Default State"
|
|
474
|
-
description="Standard appearance"
|
|
475
|
-
enterDelay={100}
|
|
476
|
-
onOpen={fn()}
|
|
477
|
-
onClose={fn()}
|
|
478
|
-
>
|
|
479
|
-
<Button data-testid="default-state">Default</Button>
|
|
480
|
-
</HoverCard>
|
|
481
|
-
|
|
482
|
-
<HoverCard
|
|
483
|
-
variant="glass"
|
|
484
|
-
title="Glass Effect"
|
|
485
|
-
description="Glassmorphism style"
|
|
486
|
-
enterDelay={100}
|
|
487
|
-
onOpen={fn()}
|
|
488
|
-
onClose={fn()}
|
|
489
|
-
>
|
|
490
|
-
<Button data-testid="glass-state">Glass</Button>
|
|
491
|
-
</HoverCard>
|
|
492
|
-
|
|
493
|
-
<HoverCard
|
|
494
|
-
variant="default"
|
|
495
|
-
glow={true}
|
|
496
|
-
title="Glow Effect"
|
|
497
|
-
description="With glow animation"
|
|
498
|
-
enterDelay={100}
|
|
499
|
-
onOpen={fn()}
|
|
500
|
-
onClose={fn()}
|
|
501
|
-
>
|
|
502
|
-
<Button data-testid="glow-state">Glow</Button>
|
|
503
|
-
</HoverCard>
|
|
504
|
-
|
|
505
|
-
<HoverCard
|
|
506
|
-
variant="default"
|
|
507
|
-
pulse={true}
|
|
508
|
-
title="Pulse Effect"
|
|
509
|
-
description="With pulse animation"
|
|
510
|
-
enterDelay={100}
|
|
511
|
-
onOpen={fn()}
|
|
512
|
-
onClose={fn()}
|
|
513
|
-
>
|
|
514
|
-
<Button data-testid="pulse-state">Pulse</Button>
|
|
515
|
-
</HoverCard>
|
|
516
|
-
|
|
517
|
-
<HoverCard
|
|
518
|
-
variant="default"
|
|
519
|
-
disabled={true}
|
|
520
|
-
title="Disabled"
|
|
521
|
-
description="Should not appear"
|
|
522
|
-
enterDelay={100}
|
|
523
|
-
onOpen={fn()}
|
|
524
|
-
onClose={fn()}
|
|
525
|
-
>
|
|
526
|
-
<Button data-testid="disabled-state" disabled>
|
|
527
|
-
Disabled
|
|
528
|
-
</Button>
|
|
529
|
-
</HoverCard>
|
|
530
|
-
</Stack>
|
|
531
|
-
),
|
|
532
|
-
play: async ({ canvasElement, step }) => {
|
|
533
|
-
const canvas = within(canvasElement);
|
|
534
|
-
|
|
535
|
-
await step('Default variant should display correctly', async () => {
|
|
536
|
-
const trigger = await canvas.findByTestId('default-state');
|
|
537
|
-
await userEvent.hover(trigger);
|
|
538
|
-
|
|
539
|
-
await waitFor(
|
|
540
|
-
async () => {
|
|
541
|
-
const card = canvasElement.ownerDocument.body.querySelector(
|
|
542
|
-
'.MuiCard-root',
|
|
543
|
-
) as HTMLElement;
|
|
544
|
-
expect(card).toBeInTheDocument();
|
|
545
|
-
const title = card.querySelector('h6');
|
|
546
|
-
expect(title).toHaveTextContent('Default State');
|
|
547
|
-
},
|
|
548
|
-
{ timeout: 500 },
|
|
549
|
-
);
|
|
550
|
-
|
|
551
|
-
await userEvent.unhover(trigger);
|
|
552
|
-
await waitFor(
|
|
553
|
-
() => {
|
|
554
|
-
const card = canvasElement.ownerDocument.body.querySelector('h6');
|
|
555
|
-
expect(card).not.toBeInTheDocument();
|
|
556
|
-
},
|
|
557
|
-
{ timeout: 500 },
|
|
558
|
-
);
|
|
559
|
-
});
|
|
560
|
-
|
|
561
|
-
await step('Glass variant should have glass effect', async () => {
|
|
562
|
-
const trigger = await canvas.findByTestId('glass-state');
|
|
563
|
-
await userEvent.hover(trigger);
|
|
564
|
-
|
|
565
|
-
await waitFor(
|
|
566
|
-
async () => {
|
|
567
|
-
const cards = canvasElement.ownerDocument.body.querySelectorAll('.MuiCard-root');
|
|
568
|
-
const glassCard = Array.from(cards).find(
|
|
569
|
-
(card) => card.querySelector('h6')?.textContent === 'Glass Effect',
|
|
570
|
-
) as HTMLElement;
|
|
571
|
-
|
|
572
|
-
expect(glassCard).toBeInTheDocument();
|
|
573
|
-
const computedStyle = window.getComputedStyle(glassCard);
|
|
574
|
-
// Glass effect should have backdrop filter
|
|
575
|
-
const backdropFilter = computedStyle.backdropFilter ||
|
|
576
|
-
(computedStyle as CSSStyleDeclaration & Record<string, string>).webkitBackdropFilter;
|
|
577
|
-
expect(backdropFilter).toContain('blur');
|
|
578
|
-
},
|
|
579
|
-
{ timeout: 500 },
|
|
580
|
-
);
|
|
581
|
-
|
|
582
|
-
await userEvent.unhover(trigger);
|
|
583
|
-
|
|
584
|
-
// Wait for hover card to close
|
|
585
|
-
await waitFor(
|
|
586
|
-
async () => {
|
|
587
|
-
const glassCard = canvasElement.ownerDocument.body.querySelector('h6');
|
|
588
|
-
expect(glassCard).not.toBeInTheDocument();
|
|
589
|
-
},
|
|
590
|
-
{ timeout: 500 },
|
|
591
|
-
);
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
await step('Disabled state should not show hover card', async () => {
|
|
595
|
-
const trigger = await canvas.findByTestId('disabled-state');
|
|
596
|
-
|
|
597
|
-
// Check the button is disabled
|
|
598
|
-
expect(trigger).toBeDisabled();
|
|
599
|
-
|
|
600
|
-
// For disabled buttons, we can't use userEvent.hover since they have pointer-events: none
|
|
601
|
-
// Instead, we verify that the hover card remains closed
|
|
602
|
-
// Wait a bit to ensure no hover card appears from any other interactions
|
|
603
|
-
await new Promise((resolve) => window.setTimeout(resolve, 200));
|
|
604
|
-
|
|
605
|
-
const disabledCard = canvasElement.ownerDocument.body.querySelector('h6');
|
|
606
|
-
await waitFor(() => expect(disabledCard).not.toBeInTheDocument());
|
|
607
|
-
});
|
|
608
|
-
},
|
|
609
|
-
};
|
|
610
|
-
|
|
611
|
-
// Test 9: Performance
|
|
612
|
-
export const Performance: Story = {
|
|
613
|
-
render: () => {
|
|
614
|
-
const items = Array.from({ length: 20 }, (_, i) => ({
|
|
615
|
-
id: i,
|
|
616
|
-
title: `Item ${i + 1}`,
|
|
617
|
-
description: `Description for item ${i + 1}`,
|
|
618
|
-
}));
|
|
619
|
-
|
|
620
|
-
return (
|
|
621
|
-
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 2 }}>
|
|
622
|
-
{items.map((item) => (
|
|
623
|
-
<HoverCard
|
|
624
|
-
key={item.id}
|
|
625
|
-
title={item.title}
|
|
626
|
-
description={item.description}
|
|
627
|
-
enterDelay={100}
|
|
628
|
-
exitDelay={0}
|
|
629
|
-
onOpen={fn()}
|
|
630
|
-
onClose={fn()}
|
|
631
|
-
>
|
|
632
|
-
<Button variant="outlined" size="small" data-testid={`perf-trigger-${item.id}`}>
|
|
633
|
-
Item {item.id + 1}
|
|
634
|
-
</Button>
|
|
635
|
-
</HoverCard>
|
|
636
|
-
))}
|
|
637
|
-
</Box>
|
|
638
|
-
);
|
|
639
|
-
},
|
|
640
|
-
play: async ({ canvasElement, step }) => {
|
|
641
|
-
const canvas = within(canvasElement);
|
|
642
|
-
|
|
643
|
-
await step('Multiple hover cards should render efficiently', async () => {
|
|
644
|
-
// Check that all triggers are rendered
|
|
645
|
-
const triggers = await canvas.findAllByRole('button');
|
|
646
|
-
expect(triggers).toHaveLength(20);
|
|
647
|
-
});
|
|
648
|
-
|
|
649
|
-
await step('Rapid hover should handle smoothly', async () => {
|
|
650
|
-
const startTime = window.performance.now();
|
|
651
|
-
|
|
652
|
-
// Rapidly hover over multiple items
|
|
653
|
-
for (let i = 0; i < 5; i++) {
|
|
654
|
-
const trigger = await canvas.findByTestId(`perf-trigger-${i}`);
|
|
655
|
-
await userEvent.hover(trigger);
|
|
656
|
-
await new Promise((resolve) => window.setTimeout(resolve, 50));
|
|
657
|
-
await userEvent.unhover(trigger);
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
const endTime = window.performance.now();
|
|
661
|
-
const elapsed = endTime - startTime;
|
|
662
|
-
|
|
663
|
-
// Performance check - should complete rapidly
|
|
664
|
-
expect(elapsed).toBeLessThan(2000);
|
|
665
|
-
});
|
|
666
|
-
|
|
667
|
-
await step('Memory cleanup on unmount', async () => {
|
|
668
|
-
// Hover one more card to check it still works
|
|
669
|
-
const trigger = await canvas.findByTestId('perf-trigger-10');
|
|
670
|
-
await userEvent.hover(trigger);
|
|
671
|
-
|
|
672
|
-
await waitFor(
|
|
673
|
-
async () => {
|
|
674
|
-
const hoverTitle = canvasElement.ownerDocument.body.querySelector('h6');
|
|
675
|
-
expect(hoverTitle).toBeInTheDocument();
|
|
676
|
-
expect(hoverTitle).toHaveTextContent('Item 11');
|
|
677
|
-
},
|
|
678
|
-
{ timeout: 500 },
|
|
679
|
-
);
|
|
680
|
-
});
|
|
681
|
-
},
|
|
682
|
-
};
|
|
683
|
-
|
|
684
|
-
// Test 10: Edge Cases
|
|
685
|
-
export const EdgeCases: Story = {
|
|
686
|
-
render: () => (
|
|
687
|
-
<Stack spacing={3}>
|
|
688
|
-
<HoverCard
|
|
689
|
-
title="Very Long Title That Should Wrap Properly in the HoverCard Component"
|
|
690
|
-
description="This is an extremely long description that tests how the hover card handles text overflow and wrapping. It should display properly without breaking the layout or causing any visual issues in the component."
|
|
691
|
-
maxWidth={250}
|
|
692
|
-
enterDelay={100}
|
|
693
|
-
onOpen={fn()}
|
|
694
|
-
onClose={fn()}
|
|
695
|
-
>
|
|
696
|
-
<Button data-testid="long-content">Long Content</Button>
|
|
697
|
-
</HoverCard>
|
|
698
|
-
|
|
699
|
-
<HoverCard title="" description="" enterDelay={100} onOpen={fn()} onClose={fn()}>
|
|
700
|
-
<Button data-testid="empty-content">Empty Content</Button>
|
|
701
|
-
</HoverCard>
|
|
702
|
-
|
|
703
|
-
<HoverCard loading={true} enterDelay={100} onOpen={fn()} onClose={fn()}>
|
|
704
|
-
<Button data-testid="loading-state">Loading State</Button>
|
|
705
|
-
</HoverCard>
|
|
706
|
-
|
|
707
|
-
<HoverCard
|
|
708
|
-
title="With Custom Loading"
|
|
709
|
-
loading={true}
|
|
710
|
-
loadingComponent={<Typography>Custom Loading...</Typography>}
|
|
711
|
-
enterDelay={100}
|
|
712
|
-
onOpen={fn()}
|
|
713
|
-
onClose={fn()}
|
|
714
|
-
>
|
|
715
|
-
<Button data-testid="custom-loading">Custom Loading</Button>
|
|
716
|
-
</HoverCard>
|
|
717
|
-
|
|
718
|
-
<HoverCard
|
|
719
|
-
title="Touch Enabled"
|
|
720
|
-
description="Works on touch devices"
|
|
721
|
-
touchEnabled={true}
|
|
722
|
-
enterDelay={100}
|
|
723
|
-
onOpen={fn()}
|
|
724
|
-
onClose={fn()}
|
|
725
|
-
>
|
|
726
|
-
<Button data-testid="touch-enabled">Touch Enabled</Button>
|
|
727
|
-
</HoverCard>
|
|
728
|
-
</Stack>
|
|
729
|
-
),
|
|
730
|
-
play: async ({ canvasElement, step }) => {
|
|
731
|
-
const canvas = within(canvasElement);
|
|
732
|
-
|
|
733
|
-
await step('Long content should wrap properly', async () => {
|
|
734
|
-
const trigger = await canvas.findByTestId('long-content');
|
|
735
|
-
await userEvent.hover(trigger);
|
|
736
|
-
|
|
737
|
-
await waitFor(
|
|
738
|
-
async () => {
|
|
739
|
-
const card = canvasElement.ownerDocument.body.querySelector(
|
|
740
|
-
'.MuiCard-root',
|
|
741
|
-
) as HTMLElement;
|
|
742
|
-
expect(card).toBeInTheDocument();
|
|
743
|
-
|
|
744
|
-
const title = card.querySelector('h6');
|
|
745
|
-
expect(title).toHaveTextContent('Very Long Title');
|
|
746
|
-
|
|
747
|
-
// Check max width constraint
|
|
748
|
-
const computedStyle = window.getComputedStyle(card);
|
|
749
|
-
const maxWidth = parseInt(computedStyle.maxWidth);
|
|
750
|
-
expect(maxWidth).toBeLessThanOrEqual(250);
|
|
751
|
-
},
|
|
752
|
-
{ timeout: 500 },
|
|
753
|
-
);
|
|
754
|
-
|
|
755
|
-
await userEvent.unhover(trigger);
|
|
756
|
-
});
|
|
757
|
-
|
|
758
|
-
await step('Empty content should still render card', async () => {
|
|
759
|
-
const trigger = await canvas.findByTestId('empty-content');
|
|
760
|
-
await userEvent.hover(trigger);
|
|
761
|
-
|
|
762
|
-
await waitFor(
|
|
763
|
-
async () => {
|
|
764
|
-
const card = canvasElement.ownerDocument.body.querySelector('.MuiCard-root');
|
|
765
|
-
expect(card).toBeInTheDocument();
|
|
766
|
-
},
|
|
767
|
-
{ timeout: 500 },
|
|
768
|
-
);
|
|
769
|
-
|
|
770
|
-
await userEvent.unhover(trigger);
|
|
771
|
-
});
|
|
772
|
-
|
|
773
|
-
await step('Loading state should show loading indicator', async () => {
|
|
774
|
-
const trigger = await canvas.findByTestId('loading-state');
|
|
775
|
-
await userEvent.hover(trigger);
|
|
776
|
-
|
|
777
|
-
await waitFor(
|
|
778
|
-
async () => {
|
|
779
|
-
const loadingIndicator = canvasElement.ownerDocument.body.querySelector(
|
|
780
|
-
'.MuiCircularProgress-root',
|
|
781
|
-
);
|
|
782
|
-
expect(loadingIndicator).toBeInTheDocument();
|
|
783
|
-
},
|
|
784
|
-
{ timeout: 500 },
|
|
785
|
-
);
|
|
786
|
-
|
|
787
|
-
await userEvent.unhover(trigger);
|
|
788
|
-
});
|
|
789
|
-
|
|
790
|
-
await step('Custom loading component should render', async () => {
|
|
791
|
-
const trigger = await canvas.findByTestId('custom-loading');
|
|
792
|
-
await userEvent.hover(trigger);
|
|
793
|
-
|
|
794
|
-
await waitFor(
|
|
795
|
-
async () => {
|
|
796
|
-
const customLoading =
|
|
797
|
-
canvasElement.ownerDocument.body.querySelector('.MuiTypography-root');
|
|
798
|
-
expect(customLoading).toHaveTextContent('Custom Loading...');
|
|
799
|
-
},
|
|
800
|
-
{ timeout: 500 },
|
|
801
|
-
);
|
|
802
|
-
});
|
|
803
|
-
},
|
|
804
|
-
};
|
|
805
|
-
|
|
806
|
-
// Test 11: Integration with Other Components
|
|
807
|
-
export const Integration: Story = {
|
|
808
|
-
render: () => (
|
|
809
|
-
<Stack spacing={3}>
|
|
810
|
-
<HoverCard
|
|
811
|
-
variant="detailed"
|
|
812
|
-
title="User Profile"
|
|
813
|
-
description="Senior Developer"
|
|
814
|
-
avatar="https://via.placeholder.com/100"
|
|
815
|
-
enterDelay={100}
|
|
816
|
-
>
|
|
817
|
-
<Button startIcon={<span>👤</span>} data-testid="with-avatar">
|
|
818
|
-
With Avatar
|
|
819
|
-
</Button>
|
|
820
|
-
</HoverCard>
|
|
821
|
-
|
|
822
|
-
<HoverCard title="Card with Actions" enterDelay={100}>
|
|
823
|
-
<Button data-testid="with-actions">Hover for Actions</Button>
|
|
824
|
-
<Stack direction="row" spacing={1} sx={{ mt: 2 }}>
|
|
825
|
-
<Button size="small" variant="contained">
|
|
826
|
-
Edit
|
|
827
|
-
</Button>
|
|
828
|
-
<Button size="small" variant="outlined">
|
|
829
|
-
Delete
|
|
830
|
-
</Button>
|
|
831
|
-
</Stack>
|
|
832
|
-
</HoverCard>
|
|
833
|
-
|
|
834
|
-
<Box sx={{ position: 'relative' }}>
|
|
835
|
-
<HoverCard
|
|
836
|
-
title="Positioned Element"
|
|
837
|
-
description="Testing with different positions"
|
|
838
|
-
placement="right"
|
|
839
|
-
showArrow={true}
|
|
840
|
-
enterDelay={100}
|
|
841
|
-
onOpen={fn()}
|
|
842
|
-
onClose={fn()}
|
|
843
|
-
>
|
|
844
|
-
<Button data-testid="with-arrow">With Arrow</Button>
|
|
845
|
-
</HoverCard>
|
|
846
|
-
</Box>
|
|
847
|
-
|
|
848
|
-
<HoverCard variant="glass" title="Different Animations" animation="scale" enterDelay={100}>
|
|
849
|
-
<Button data-testid="with-animation">Scale Animation</Button>
|
|
850
|
-
</HoverCard>
|
|
851
|
-
</Stack>
|
|
852
|
-
),
|
|
853
|
-
play: async ({ canvasElement, step }) => {
|
|
854
|
-
const canvas = within(canvasElement);
|
|
855
|
-
|
|
856
|
-
await step('HoverCard integrates with other components', async () => {
|
|
857
|
-
// Test basic hover functionality
|
|
858
|
-
const trigger = await canvas.findByTestId('with-avatar');
|
|
859
|
-
expect(trigger).toBeInTheDocument();
|
|
860
|
-
|
|
861
|
-
await userEvent.hover(trigger);
|
|
862
|
-
|
|
863
|
-
// Wait for the hover card to appear
|
|
864
|
-
await waitFor(
|
|
865
|
-
async () => {
|
|
866
|
-
const card = canvasElement.ownerDocument.body.querySelector('.MuiCard-root');
|
|
867
|
-
expect(card).toBeInTheDocument();
|
|
868
|
-
},
|
|
869
|
-
{ timeout: 1000 },
|
|
870
|
-
);
|
|
871
|
-
|
|
872
|
-
// Check for title in the hover card
|
|
873
|
-
const titleElement = canvasElement.ownerDocument.body.querySelector('h6');
|
|
874
|
-
if (titleElement) {
|
|
875
|
-
expect(titleElement).toHaveTextContent('User Profile');
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
await userEvent.unhover(trigger);
|
|
879
|
-
|
|
880
|
-
// Wait for hover card to close
|
|
881
|
-
await waitFor(
|
|
882
|
-
async () => {
|
|
883
|
-
const card = canvasElement.ownerDocument.body.querySelector('.MuiCard-root');
|
|
884
|
-
expect(card).not.toBeInTheDocument();
|
|
885
|
-
},
|
|
886
|
-
{ timeout: 500 },
|
|
887
|
-
);
|
|
888
|
-
});
|
|
889
|
-
|
|
890
|
-
await step('Arrow positioning works correctly', async () => {
|
|
891
|
-
const trigger = await canvas.findByTestId('with-arrow');
|
|
892
|
-
await userEvent.hover(trigger);
|
|
893
|
-
|
|
894
|
-
await waitFor(
|
|
895
|
-
async () => {
|
|
896
|
-
const card = canvasElement.ownerDocument.body.querySelector('.MuiCard-root');
|
|
897
|
-
expect(card).toBeInTheDocument();
|
|
898
|
-
},
|
|
899
|
-
{ timeout: 500 },
|
|
900
|
-
);
|
|
901
|
-
|
|
902
|
-
await userEvent.unhover(trigger);
|
|
903
|
-
|
|
904
|
-
// Wait for hover card to close
|
|
905
|
-
await waitFor(
|
|
906
|
-
async () => {
|
|
907
|
-
const card = canvasElement.ownerDocument.body.querySelector('.MuiCard-root');
|
|
908
|
-
expect(card).not.toBeInTheDocument();
|
|
909
|
-
},
|
|
910
|
-
{ timeout: 500 },
|
|
911
|
-
);
|
|
912
|
-
});
|
|
913
|
-
|
|
914
|
-
await step('Animation styles are applied', async () => {
|
|
915
|
-
const trigger = await canvas.findByTestId('with-animation');
|
|
916
|
-
await userEvent.hover(trigger);
|
|
917
|
-
|
|
918
|
-
await waitFor(
|
|
919
|
-
async () => {
|
|
920
|
-
const card = canvasElement.ownerDocument.body.querySelector('.MuiCard-root');
|
|
921
|
-
expect(card).toBeInTheDocument();
|
|
922
|
-
},
|
|
923
|
-
{ timeout: 500 },
|
|
924
|
-
);
|
|
925
|
-
|
|
926
|
-
await userEvent.unhover(trigger);
|
|
927
|
-
});
|
|
928
|
-
},
|
|
929
|
-
};
|