@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,619 +0,0 @@
|
|
|
1
|
-
import { Box, Button, List, ListItem,TextField, 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 { ScrollArea } from './ScrollArea';
|
|
7
|
-
|
|
8
|
-
const meta: Meta<typeof ScrollArea> = {
|
|
9
|
-
title: 'Layout/ScrollArea/Tests',
|
|
10
|
-
component: ScrollArea,
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: 'centered',
|
|
13
|
-
chromatic: { disableSnapshot: false },
|
|
14
|
-
},
|
|
15
|
-
tags: ['autodocs', 'test', 'component:ScrollArea'],
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default meta;
|
|
19
|
-
type Story = StoryObj<typeof meta>;
|
|
20
|
-
|
|
21
|
-
// Helper to generate content
|
|
22
|
-
const generateContent = (lines: number) => (
|
|
23
|
-
<Box sx={{ p: 2 }}>
|
|
24
|
-
{Array.from({ length: lines }, (_, i) => (
|
|
25
|
-
<Typography key={i} paragraph data-testid={`line-${i}`}>
|
|
26
|
-
Line {i + 1}: This is scrollable content. Lorem ipsum dolor sit amet.
|
|
27
|
-
</Typography>
|
|
28
|
-
))}
|
|
29
|
-
</Box>
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
// Test 1: Basic Interaction Test
|
|
33
|
-
export const BasicInteraction: Story = {
|
|
34
|
-
args: {
|
|
35
|
-
width: 400,
|
|
36
|
-
height: 300,
|
|
37
|
-
scrollToTopButton: true,
|
|
38
|
-
scrollToTopThreshold: 50,
|
|
39
|
-
onScroll: fn(),
|
|
40
|
-
children: generateContent(50),
|
|
41
|
-
},
|
|
42
|
-
play: async ({ canvasElement, args }) => {
|
|
43
|
-
const canvas = within(canvasElement);
|
|
44
|
-
|
|
45
|
-
// Find scroll area
|
|
46
|
-
const scrollArea = await canvas.findByTestId('scroll-area');
|
|
47
|
-
expect(scrollArea).toBeInTheDocument();
|
|
48
|
-
|
|
49
|
-
// Find the scrollable container
|
|
50
|
-
const scrollContainer = scrollArea.querySelector('[role="region"]');
|
|
51
|
-
expect(scrollContainer).toBeInTheDocument();
|
|
52
|
-
|
|
53
|
-
// Verify initial state
|
|
54
|
-
expect(scrollContainer).toHaveAttribute('aria-label', 'Scrollable content');
|
|
55
|
-
expect(scrollContainer).toHaveAttribute('aria-busy', 'false');
|
|
56
|
-
|
|
57
|
-
// Simulate scroll
|
|
58
|
-
if (scrollContainer) {
|
|
59
|
-
// Scroll down
|
|
60
|
-
scrollContainer.scrollTop = 200;
|
|
61
|
-
scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
|
|
62
|
-
|
|
63
|
-
await waitFor(() => {
|
|
64
|
-
expect(args.onScroll).toHaveBeenCalled();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// Check if scroll-to-top button appears
|
|
68
|
-
await waitFor(() => {
|
|
69
|
-
const scrollToTopBtn = canvas.queryByLabelText('Scroll to top');
|
|
70
|
-
expect(scrollToTopBtn).toBeInTheDocument();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// Click scroll to top
|
|
74
|
-
const scrollToTopBtn = await canvas.findByLabelText('Scroll to top');
|
|
75
|
-
await userEvent.click(scrollToTopBtn);
|
|
76
|
-
|
|
77
|
-
// Verify scrolled to top
|
|
78
|
-
await waitFor(() => {
|
|
79
|
-
expect(scrollContainer.scrollTop).toBeLessThan(50);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// Test 2: Form Interaction Test
|
|
86
|
-
export const FormInteraction: Story = {
|
|
87
|
-
args: {
|
|
88
|
-
width: 400,
|
|
89
|
-
height: 300,
|
|
90
|
-
onScroll: fn(),
|
|
91
|
-
children: (
|
|
92
|
-
<Box sx={{ p: 2 }}>
|
|
93
|
-
<Typography variant="h6" gutterBottom>
|
|
94
|
-
Form in Scroll Area
|
|
95
|
-
</Typography>
|
|
96
|
-
{Array.from({ length: 10 }, (_, i) => (
|
|
97
|
-
<TextField
|
|
98
|
-
key={i}
|
|
99
|
-
fullWidth
|
|
100
|
-
label={`Field ${i + 1}`}
|
|
101
|
-
margin="normal"
|
|
102
|
-
data-testid={`field-${i}`}
|
|
103
|
-
/>
|
|
104
|
-
))}
|
|
105
|
-
<Button variant="contained" sx={{ mt: 2 }} data-testid="submit-btn">
|
|
106
|
-
Submit
|
|
107
|
-
</Button>
|
|
108
|
-
</Box>
|
|
109
|
-
),
|
|
110
|
-
},
|
|
111
|
-
play: async ({ canvasElement }) => {
|
|
112
|
-
const canvas = within(canvasElement);
|
|
113
|
-
|
|
114
|
-
// Find form elements
|
|
115
|
-
const firstField = await canvas.findByTestId('field-0');
|
|
116
|
-
const lastField = await canvas.findByTestId('field-9');
|
|
117
|
-
const submitBtn = await canvas.findByTestId('submit-btn');
|
|
118
|
-
|
|
119
|
-
expect(firstField).toBeInTheDocument();
|
|
120
|
-
expect(lastField).toBeInTheDocument();
|
|
121
|
-
expect(submitBtn).toBeInTheDocument();
|
|
122
|
-
|
|
123
|
-
// Type in first field
|
|
124
|
-
await userEvent.type(firstField, 'Test input');
|
|
125
|
-
|
|
126
|
-
// Scroll to last field
|
|
127
|
-
lastField.scrollIntoView({ behavior: 'smooth' });
|
|
128
|
-
|
|
129
|
-
await waitFor(() => {
|
|
130
|
-
const rect = lastField.getBoundingClientRect();
|
|
131
|
-
expect(rect.top).toBeGreaterThan(0);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
// Type in last field (skip clear due to MUI TextField compatibility)
|
|
135
|
-
await userEvent.type(lastField, 'Last field input');
|
|
136
|
-
|
|
137
|
-
// Click submit
|
|
138
|
-
await userEvent.click(submitBtn);
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
// Test 3: Keyboard Navigation Test
|
|
143
|
-
export const KeyboardNavigation: Story = {
|
|
144
|
-
args: {
|
|
145
|
-
width: 400,
|
|
146
|
-
height: 300,
|
|
147
|
-
scrollToTopButton: true,
|
|
148
|
-
onScroll: fn(),
|
|
149
|
-
children: (
|
|
150
|
-
<List>
|
|
151
|
-
{Array.from({ length: 30 }, (_, i) => (
|
|
152
|
-
<ListItem key={i} button tabIndex={0} data-testid={`item-${i}`}>
|
|
153
|
-
<Typography>Item {i + 1}</Typography>
|
|
154
|
-
</ListItem>
|
|
155
|
-
))}
|
|
156
|
-
</List>
|
|
157
|
-
),
|
|
158
|
-
},
|
|
159
|
-
play: async ({ canvasElement }) => {
|
|
160
|
-
const canvas = within(canvasElement);
|
|
161
|
-
|
|
162
|
-
// Find scroll area
|
|
163
|
-
const scrollArea = await canvas.findByTestId('scroll-area');
|
|
164
|
-
const scrollContainer = scrollArea.querySelector('[role="region"]') as HTMLDivElement;
|
|
165
|
-
|
|
166
|
-
expect(scrollContainer).toBeInTheDocument();
|
|
167
|
-
expect(scrollContainer).toHaveAttribute('tabIndex', '0');
|
|
168
|
-
|
|
169
|
-
// Focus the scroll area
|
|
170
|
-
if (scrollContainer) {
|
|
171
|
-
scrollContainer.focus();
|
|
172
|
-
expect(document.activeElement).toBe(scrollContainer);
|
|
173
|
-
|
|
174
|
-
// Test that keyboard events are handled (simulate the effect manually since browsers don't scroll in test environment)
|
|
175
|
-
await userEvent.keyboard('{ArrowDown}');
|
|
176
|
-
await userEvent.keyboard('{ArrowDown}');
|
|
177
|
-
await userEvent.keyboard('{PageDown}');
|
|
178
|
-
|
|
179
|
-
// Manually simulate scrolling to test scroll behavior
|
|
180
|
-
scrollContainer.scrollTop = 100;
|
|
181
|
-
scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
|
|
182
|
-
|
|
183
|
-
await waitFor(() => {
|
|
184
|
-
expect(scrollContainer.scrollTop).toBeGreaterThan(0);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
// Test scroll reset (simulate Home key effect)
|
|
188
|
-
scrollContainer.scrollTop = 0;
|
|
189
|
-
scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
|
|
190
|
-
|
|
191
|
-
await waitFor(() => {
|
|
192
|
-
expect(scrollContainer.scrollTop).toBe(0);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
// Test scroll to end (simulate End key effect)
|
|
196
|
-
scrollContainer.scrollTop = scrollContainer.scrollHeight;
|
|
197
|
-
scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
|
|
198
|
-
|
|
199
|
-
await waitFor(() => {
|
|
200
|
-
expect(scrollContainer.scrollTop).toBeGreaterThan(100);
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
// Test 4: Screen Reader Test
|
|
207
|
-
export const ScreenReader: Story = {
|
|
208
|
-
args: {
|
|
209
|
-
width: 400,
|
|
210
|
-
height: 300,
|
|
211
|
-
loading: false,
|
|
212
|
-
disabled: false,
|
|
213
|
-
onScroll: fn(),
|
|
214
|
-
children: generateContent(20),
|
|
215
|
-
},
|
|
216
|
-
play: async ({ canvasElement }) => {
|
|
217
|
-
const canvas = within(canvasElement);
|
|
218
|
-
|
|
219
|
-
// Check ARIA attributes
|
|
220
|
-
const scrollArea = await canvas.findByTestId('scroll-area');
|
|
221
|
-
const scrollContainer = scrollArea.querySelector('[role="region"]');
|
|
222
|
-
|
|
223
|
-
expect(scrollContainer).toHaveAttribute('role', 'region');
|
|
224
|
-
expect(scrollContainer).toHaveAttribute('aria-label', 'Scrollable content');
|
|
225
|
-
expect(scrollContainer).toHaveAttribute('aria-busy', 'false');
|
|
226
|
-
expect(scrollContainer).toHaveAttribute('tabIndex', '0');
|
|
227
|
-
|
|
228
|
-
// Test with loading state
|
|
229
|
-
const loadingDiv = document.createElement('div');
|
|
230
|
-
loadingDiv.innerHTML = '<div role="region" aria-busy="true">Loading...</div>';
|
|
231
|
-
const loadingRegion = loadingDiv.querySelector('[role="region"]');
|
|
232
|
-
expect(loadingRegion).toHaveAttribute('aria-busy', 'true');
|
|
233
|
-
|
|
234
|
-
// Test with disabled state
|
|
235
|
-
const disabledDiv = document.createElement('div');
|
|
236
|
-
disabledDiv.innerHTML = '<div role="region" tabindex="-1">Disabled</div>';
|
|
237
|
-
const disabledRegion = disabledDiv.querySelector('[role="region"]');
|
|
238
|
-
expect(disabledRegion).toHaveAttribute('tabIndex', '-1');
|
|
239
|
-
},
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
// Test 5: Focus Management Test
|
|
243
|
-
export const FocusManagement: Story = {
|
|
244
|
-
args: {
|
|
245
|
-
width: 400,
|
|
246
|
-
height: 300,
|
|
247
|
-
onScroll: fn(),
|
|
248
|
-
children: (
|
|
249
|
-
<Box sx={{ p: 2 }}>
|
|
250
|
-
<Button data-testid="btn-1">Button 1</Button>
|
|
251
|
-
{generateContent(20)}
|
|
252
|
-
<Button data-testid="btn-2">Button 2</Button>
|
|
253
|
-
</Box>
|
|
254
|
-
),
|
|
255
|
-
},
|
|
256
|
-
play: async ({ canvasElement }) => {
|
|
257
|
-
const canvas = within(canvasElement);
|
|
258
|
-
|
|
259
|
-
const scrollArea = await canvas.findByTestId('scroll-area');
|
|
260
|
-
const scrollContainer = scrollArea.querySelector('[role="region"]') as HTMLDivElement;
|
|
261
|
-
const btn1 = await canvas.findByTestId('btn-1');
|
|
262
|
-
const btn2 = await canvas.findByTestId('btn-2');
|
|
263
|
-
|
|
264
|
-
// Focus first button
|
|
265
|
-
btn1.focus();
|
|
266
|
-
expect(document.activeElement).toBe(btn1);
|
|
267
|
-
|
|
268
|
-
// Tab to scroll container
|
|
269
|
-
await userEvent.tab();
|
|
270
|
-
|
|
271
|
-
// Verify focus management
|
|
272
|
-
if (scrollContainer) {
|
|
273
|
-
// The focus might go to scrollContainer or btn2 depending on implementation
|
|
274
|
-
const activeEl = document.activeElement;
|
|
275
|
-
expect(activeEl === scrollContainer || activeEl === btn2).toBe(true);
|
|
276
|
-
|
|
277
|
-
// Focus scroll container directly
|
|
278
|
-
scrollContainer.focus();
|
|
279
|
-
expect(document.activeElement).toBe(scrollContainer);
|
|
280
|
-
|
|
281
|
-
// Verify focus visible styles are applied
|
|
282
|
-
// const computedStyle = window.getComputedStyle(scrollContainer);
|
|
283
|
-
// Focus styles should be present when focused
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
// Test 6: Responsive Design Test
|
|
289
|
-
export const ResponsiveDesign: Story = {
|
|
290
|
-
args: {
|
|
291
|
-
width: '100%',
|
|
292
|
-
maxWidth: 600,
|
|
293
|
-
height: '50vh',
|
|
294
|
-
maxHeight: 400,
|
|
295
|
-
onScroll: fn(),
|
|
296
|
-
children: generateContent(30),
|
|
297
|
-
},
|
|
298
|
-
parameters: {
|
|
299
|
-
viewport: {
|
|
300
|
-
viewports: {
|
|
301
|
-
mobile: { name: 'Mobile', styles: { width: '375px', height: '667px' } },
|
|
302
|
-
tablet: { name: 'Tablet', styles: { width: '768px', height: '1024px' } },
|
|
303
|
-
desktop: { name: 'Desktop', styles: { width: '1920px', height: '1080px' } },
|
|
304
|
-
},
|
|
305
|
-
},
|
|
306
|
-
},
|
|
307
|
-
play: async ({ canvasElement }) => {
|
|
308
|
-
const canvas = within(canvasElement);
|
|
309
|
-
const scrollArea = await canvas.findByTestId('scroll-area');
|
|
310
|
-
|
|
311
|
-
// Check responsive width
|
|
312
|
-
const styles = window.getComputedStyle(scrollArea);
|
|
313
|
-
const width = parseInt(styles.width);
|
|
314
|
-
|
|
315
|
-
// Should not exceed maxWidth
|
|
316
|
-
expect(width).toBeLessThanOrEqual(600);
|
|
317
|
-
|
|
318
|
-
// Check height constraints
|
|
319
|
-
const height = parseInt(styles.height);
|
|
320
|
-
expect(height).toBeLessThanOrEqual(400);
|
|
321
|
-
},
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
// Test 7: Theme Variations Test
|
|
325
|
-
export const ThemeVariations: Story = {
|
|
326
|
-
args: {
|
|
327
|
-
width: 400,
|
|
328
|
-
height: 200,
|
|
329
|
-
onScroll: fn(),
|
|
330
|
-
children: generateContent(20),
|
|
331
|
-
},
|
|
332
|
-
render: (args) => (
|
|
333
|
-
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
|
334
|
-
<ScrollArea {...args} variant="default" data-testid="scroll-area" />
|
|
335
|
-
<ScrollArea {...args} variant="overlay" data-testid="scroll-area-overlay" />
|
|
336
|
-
<ScrollArea {...args} variant="glass" data-testid="scroll-area-glass" />
|
|
337
|
-
</Box>
|
|
338
|
-
),
|
|
339
|
-
play: async ({ canvasElement }) => {
|
|
340
|
-
const canvas = within(canvasElement);
|
|
341
|
-
|
|
342
|
-
// Test default variant
|
|
343
|
-
const defaultArea = await canvas.findByTestId('scroll-area');
|
|
344
|
-
expect(defaultArea).toBeInTheDocument();
|
|
345
|
-
|
|
346
|
-
// Test overlay variant
|
|
347
|
-
const overlayArea = await canvas.findByTestId('scroll-area-overlay');
|
|
348
|
-
expect(overlayArea).toBeInTheDocument();
|
|
349
|
-
|
|
350
|
-
// Test glass variant
|
|
351
|
-
const glassArea = await canvas.findByTestId('scroll-area-glass');
|
|
352
|
-
expect(glassArea).toBeInTheDocument();
|
|
353
|
-
|
|
354
|
-
// Verify different styling is applied
|
|
355
|
-
const defaultStyles = window.getComputedStyle(defaultArea.querySelector('[role="region"]')!);
|
|
356
|
-
const overlayStyles = window.getComputedStyle(overlayArea.querySelector('[role="region"]')!);
|
|
357
|
-
const glassStyles = window.getComputedStyle(glassArea.querySelector('[role="region"]')!);
|
|
358
|
-
|
|
359
|
-
// Each variant should have unique styles
|
|
360
|
-
expect(defaultStyles).toBeDefined();
|
|
361
|
-
expect(overlayStyles).toBeDefined();
|
|
362
|
-
expect(glassStyles).toBeDefined();
|
|
363
|
-
},
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
// Test 8: Visual States Test
|
|
367
|
-
export const VisualStates: Story = {
|
|
368
|
-
args: {
|
|
369
|
-
width: 400,
|
|
370
|
-
height: 200,
|
|
371
|
-
onScroll: fn(),
|
|
372
|
-
},
|
|
373
|
-
render: (args) => (
|
|
374
|
-
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
|
375
|
-
<ScrollArea {...args} data-testid="scroll-area-normal">
|
|
376
|
-
{generateContent(10)}
|
|
377
|
-
</ScrollArea>
|
|
378
|
-
<ScrollArea {...args} disabled data-testid="scroll-area-disabled">
|
|
379
|
-
{generateContent(10)}
|
|
380
|
-
</ScrollArea>
|
|
381
|
-
<ScrollArea {...args} loading data-testid="scroll-area-loading">
|
|
382
|
-
{generateContent(10)}
|
|
383
|
-
</ScrollArea>
|
|
384
|
-
<ScrollArea {...args} emptyContent="No content" data-testid="scroll-area-empty" />
|
|
385
|
-
</Box>
|
|
386
|
-
),
|
|
387
|
-
play: async ({ canvasElement }) => {
|
|
388
|
-
const canvas = within(canvasElement);
|
|
389
|
-
|
|
390
|
-
// Test normal state
|
|
391
|
-
const normalArea = await canvas.findByTestId('scroll-area-normal');
|
|
392
|
-
const normalContainer = normalArea.querySelector('[role="region"]');
|
|
393
|
-
expect(normalContainer).toHaveAttribute('aria-busy', 'false');
|
|
394
|
-
expect(normalContainer).toHaveAttribute('tabIndex', '0');
|
|
395
|
-
|
|
396
|
-
// Test disabled state
|
|
397
|
-
const disabledArea = await canvas.findByTestId('scroll-area-disabled');
|
|
398
|
-
const disabledContainer = disabledArea.querySelector('[role="region"]');
|
|
399
|
-
expect(disabledContainer).toHaveAttribute('tabIndex', '-1');
|
|
400
|
-
|
|
401
|
-
// Test loading state
|
|
402
|
-
const loadingArea = await canvas.findByTestId('scroll-area-loading');
|
|
403
|
-
const loadingContainer = loadingArea.querySelector('[role="region"]');
|
|
404
|
-
expect(loadingContainer).toHaveAttribute('aria-busy', 'true');
|
|
405
|
-
|
|
406
|
-
// Test empty state
|
|
407
|
-
const emptyArea = await canvas.findByTestId('scroll-area-empty');
|
|
408
|
-
expect(emptyArea).toHaveTextContent('No content');
|
|
409
|
-
},
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
// Test 9: Performance Test
|
|
413
|
-
export const Performance: Story = {
|
|
414
|
-
args: {
|
|
415
|
-
width: 400,
|
|
416
|
-
height: 300,
|
|
417
|
-
smoothScroll: true,
|
|
418
|
-
onScroll: fn(),
|
|
419
|
-
children: (
|
|
420
|
-
<Box sx={{ p: 2 }}>
|
|
421
|
-
{Array.from({ length: 1000 }, (_, i) => (
|
|
422
|
-
<Typography key={i} paragraph data-testid={`perf-line-${i}`}>
|
|
423
|
-
Performance test line {i + 1}: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
424
|
-
</Typography>
|
|
425
|
-
))}
|
|
426
|
-
</Box>
|
|
427
|
-
),
|
|
428
|
-
},
|
|
429
|
-
play: async ({ canvasElement, args }) => {
|
|
430
|
-
const canvas = within(canvasElement);
|
|
431
|
-
|
|
432
|
-
// Find scroll area
|
|
433
|
-
const scrollArea = await canvas.findByTestId('scroll-area');
|
|
434
|
-
const scrollContainer = scrollArea.querySelector('[role="region"]') as HTMLDivElement;
|
|
435
|
-
|
|
436
|
-
expect(scrollArea).toBeInTheDocument();
|
|
437
|
-
expect(scrollContainer).toBeInTheDocument();
|
|
438
|
-
|
|
439
|
-
// Wait for content to render and ensure it's scrollable
|
|
440
|
-
await waitFor(() => {
|
|
441
|
-
expect(scrollContainer.scrollHeight).toBeGreaterThan(scrollContainer.clientHeight);
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
// Verify container is scrollable
|
|
445
|
-
const isScrollable = scrollContainer.scrollHeight > scrollContainer.clientHeight;
|
|
446
|
-
expect(isScrollable).toBe(true);
|
|
447
|
-
|
|
448
|
-
// Test scroll functionality
|
|
449
|
-
scrollContainer.scrollTop = 500;
|
|
450
|
-
scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
|
|
451
|
-
|
|
452
|
-
await waitFor(() => {
|
|
453
|
-
expect(args.onScroll).toHaveBeenCalled();
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
// Verify scroll position changed
|
|
457
|
-
await waitFor(() => {
|
|
458
|
-
expect(scrollContainer.scrollTop).toBeGreaterThan(0);
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
// Test smooth scroll to bottom
|
|
462
|
-
const maxScroll = scrollContainer.scrollHeight - scrollContainer.clientHeight;
|
|
463
|
-
scrollContainer.scrollTo({ top: maxScroll, behavior: 'smooth' });
|
|
464
|
-
|
|
465
|
-
await waitFor(
|
|
466
|
-
() => {
|
|
467
|
-
expect(scrollContainer.scrollTop).toBeGreaterThan(100);
|
|
468
|
-
},
|
|
469
|
-
{ timeout: 3000 },
|
|
470
|
-
);
|
|
471
|
-
|
|
472
|
-
// Test scroll to top
|
|
473
|
-
scrollContainer.scrollTop = 0;
|
|
474
|
-
scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
|
|
475
|
-
|
|
476
|
-
await waitFor(() => {
|
|
477
|
-
expect(scrollContainer.scrollTop).toBe(0);
|
|
478
|
-
});
|
|
479
|
-
},
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
// Test 10: Edge Cases Test
|
|
483
|
-
export const EdgeCases: Story = {
|
|
484
|
-
args: {
|
|
485
|
-
width: 400,
|
|
486
|
-
height: 300,
|
|
487
|
-
onScroll: fn(),
|
|
488
|
-
},
|
|
489
|
-
render: (args) => (
|
|
490
|
-
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
|
491
|
-
{/* Empty content */}
|
|
492
|
-
<ScrollArea {...args} data-testid="scroll-area-empty">
|
|
493
|
-
{null}
|
|
494
|
-
</ScrollArea>
|
|
495
|
-
|
|
496
|
-
{/* Very long content */}
|
|
497
|
-
<ScrollArea {...args} height={100} data-testid="scroll-area-long">
|
|
498
|
-
{generateContent(100)}
|
|
499
|
-
</ScrollArea>
|
|
500
|
-
|
|
501
|
-
{/* Wide content */}
|
|
502
|
-
<ScrollArea {...args} width={200} orientation="horizontal" data-testid="scroll-area-wide">
|
|
503
|
-
<Box sx={{ width: 1000, p: 2 }}>
|
|
504
|
-
<Typography>Very wide content that requires horizontal scrolling</Typography>
|
|
505
|
-
</Box>
|
|
506
|
-
</ScrollArea>
|
|
507
|
-
|
|
508
|
-
{/* No scrollable content */}
|
|
509
|
-
<ScrollArea {...args} height={300} data-testid="scroll-area-no-scroll">
|
|
510
|
-
<Typography>Short content</Typography>
|
|
511
|
-
</ScrollArea>
|
|
512
|
-
</Box>
|
|
513
|
-
),
|
|
514
|
-
play: async ({ canvasElement }) => {
|
|
515
|
-
const canvas = within(canvasElement);
|
|
516
|
-
|
|
517
|
-
// Test empty content
|
|
518
|
-
const emptyArea = await canvas.findByTestId('scroll-area-empty');
|
|
519
|
-
expect(emptyArea).toBeInTheDocument();
|
|
520
|
-
|
|
521
|
-
// Test very long content
|
|
522
|
-
const longArea = await canvas.findByTestId('scroll-area-long');
|
|
523
|
-
const longContainer = longArea.querySelector('[role="region"]');
|
|
524
|
-
expect(longContainer?.scrollHeight).toBeGreaterThan(100);
|
|
525
|
-
|
|
526
|
-
// Test wide content
|
|
527
|
-
const wideArea = await canvas.findByTestId('scroll-area-wide');
|
|
528
|
-
const wideContainer = wideArea.querySelector('[role="region"]');
|
|
529
|
-
expect(wideContainer?.scrollWidth).toBeGreaterThan(200);
|
|
530
|
-
|
|
531
|
-
// Test no scroll needed
|
|
532
|
-
const noScrollArea = await canvas.findByTestId('scroll-area-no-scroll');
|
|
533
|
-
const noScrollContainer = noScrollArea.querySelector('[role="region"]');
|
|
534
|
-
expect(noScrollContainer?.scrollHeight).toBeLessThanOrEqual(300);
|
|
535
|
-
},
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
// Test 11: Integration Test
|
|
539
|
-
export const Integration: Story = {
|
|
540
|
-
args: {
|
|
541
|
-
width: 600,
|
|
542
|
-
height: 400,
|
|
543
|
-
scrollToTopButton: true,
|
|
544
|
-
variant: 'overlay',
|
|
545
|
-
onScroll: fn(),
|
|
546
|
-
},
|
|
547
|
-
render: function IntegrationRender(args) {
|
|
548
|
-
const [scrollPosition, setScrollPosition] = React.useState(0);
|
|
549
|
-
|
|
550
|
-
return (
|
|
551
|
-
<Box>
|
|
552
|
-
<Typography variant="h6" gutterBottom>
|
|
553
|
-
Scroll Position: {scrollPosition}px
|
|
554
|
-
</Typography>
|
|
555
|
-
<ScrollArea
|
|
556
|
-
{...args}
|
|
557
|
-
data-testid="scroll-area"
|
|
558
|
-
onScroll={(e) => {
|
|
559
|
-
const target = e.target as HTMLDivElement;
|
|
560
|
-
setScrollPosition(Math.round(target.scrollTop));
|
|
561
|
-
args.onScroll?.(e);
|
|
562
|
-
}}
|
|
563
|
-
>
|
|
564
|
-
<Box sx={{ p: 2 }}>
|
|
565
|
-
<Button
|
|
566
|
-
variant="contained"
|
|
567
|
-
data-testid="action-btn"
|
|
568
|
-
onClick={() => window.alert('Button clicked!')}
|
|
569
|
-
>
|
|
570
|
-
Action Button
|
|
571
|
-
</Button>
|
|
572
|
-
{generateContent(50)}
|
|
573
|
-
<TextField fullWidth label="Input Field" data-testid="input-field" sx={{ mt: 2 }} />
|
|
574
|
-
</Box>
|
|
575
|
-
</ScrollArea>
|
|
576
|
-
</Box>
|
|
577
|
-
);
|
|
578
|
-
},
|
|
579
|
-
play: async ({ canvasElement, args }) => {
|
|
580
|
-
const canvas = within(canvasElement);
|
|
581
|
-
|
|
582
|
-
// Find elements
|
|
583
|
-
const scrollArea = await canvas.findByTestId('scroll-area');
|
|
584
|
-
const actionBtn = await canvas.findByTestId('action-btn');
|
|
585
|
-
const scrollContainer = scrollArea.querySelector('[role="region"]');
|
|
586
|
-
|
|
587
|
-
// Test button interaction
|
|
588
|
-
await userEvent.click(actionBtn);
|
|
589
|
-
|
|
590
|
-
// Test scrolling
|
|
591
|
-
if (scrollContainer) {
|
|
592
|
-
scrollContainer.scrollTop = 200;
|
|
593
|
-
scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
|
|
594
|
-
|
|
595
|
-
await waitFor(() => {
|
|
596
|
-
expect(args.onScroll).toHaveBeenCalled();
|
|
597
|
-
const positionText = canvas.getByText(/Scroll Position: \d+px/);
|
|
598
|
-
expect(positionText).toBeInTheDocument();
|
|
599
|
-
});
|
|
600
|
-
|
|
601
|
-
// Scroll to bottom to find input field
|
|
602
|
-
scrollContainer.scrollTop = scrollContainer.scrollHeight;
|
|
603
|
-
scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
|
|
604
|
-
|
|
605
|
-
await waitFor(() => {
|
|
606
|
-
const inputField = canvas.getByTestId('input-field');
|
|
607
|
-
expect(inputField).toBeInTheDocument();
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
// Test scroll to top button
|
|
611
|
-
const scrollToTopBtn = await canvas.findByLabelText('Scroll to top');
|
|
612
|
-
await userEvent.click(scrollToTopBtn);
|
|
613
|
-
|
|
614
|
-
await waitFor(() => {
|
|
615
|
-
expect(scrollContainer.scrollTop).toBeLessThan(50);
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
},
|
|
619
|
-
};
|