@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,491 +0,0 @@
|
|
|
1
|
-
import { Box } from '@mui/material';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import React, { useState } from 'react';
|
|
4
|
-
import { expect, userEvent, waitFor, within } from 'storybook/test';
|
|
5
|
-
|
|
6
|
-
import { RichTextEditor } from './RichTextEditor';
|
|
7
|
-
|
|
8
|
-
const meta: Meta<typeof RichTextEditor> = {
|
|
9
|
-
title: 'Enhanced/RichTextEditor/Tests',
|
|
10
|
-
component: RichTextEditor,
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: 'centered',
|
|
13
|
-
chromatic: { disableSnapshot: false },
|
|
14
|
-
},
|
|
15
|
-
tags: ['autodocs', 'test', 'component:RichTextEditor'],
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default meta;
|
|
19
|
-
export type Story = StoryObj<typeof meta>;
|
|
20
|
-
|
|
21
|
-
// Test wrapper with state management
|
|
22
|
-
interface TestWrapperProps {
|
|
23
|
-
children: (props: { value: string; setValue: (value: string) => void }) => React.ReactNode;
|
|
24
|
-
value?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const TestWrapper = ({ children, ...props }: TestWrapperProps) => {
|
|
28
|
-
const [value, setValue] = useState(props.value || '');
|
|
29
|
-
return <Box sx={{ width: 600 }}>{children({ value, setValue, ...props })}</Box>;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const BasicInteraction: Story = {
|
|
33
|
-
render: () => (
|
|
34
|
-
<TestWrapper>
|
|
35
|
-
{({ value, setValue }) => (
|
|
36
|
-
<RichTextEditor
|
|
37
|
-
value={value}
|
|
38
|
-
onChange={setValue}
|
|
39
|
-
placeholder="Type here to test basic interaction..."
|
|
40
|
-
data-testid="rich-editor-basic"
|
|
41
|
-
/>
|
|
42
|
-
)}
|
|
43
|
-
</TestWrapper>
|
|
44
|
-
),
|
|
45
|
-
play: async ({ canvasElement }) => {
|
|
46
|
-
const canvas = within(canvasElement);
|
|
47
|
-
|
|
48
|
-
// Find the editor
|
|
49
|
-
const editor = canvas.getByRole('textbox', { name: /rich text editor/i });
|
|
50
|
-
await expect(editor).toBeInTheDocument();
|
|
51
|
-
|
|
52
|
-
// Test typing
|
|
53
|
-
await userEvent.click(editor);
|
|
54
|
-
await userEvent.type(editor, 'Hello World');
|
|
55
|
-
await waitFor(() => {
|
|
56
|
-
expect(editor.innerHTML).toContain('Hello World');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// Test toolbar buttons
|
|
60
|
-
const boldButton = canvas.getByLabelText('Bold');
|
|
61
|
-
await expect(boldButton).toBeInTheDocument();
|
|
62
|
-
await userEvent.click(boldButton);
|
|
63
|
-
|
|
64
|
-
// Test more typing after formatting
|
|
65
|
-
await userEvent.type(editor, ' Bold Text');
|
|
66
|
-
await waitFor(() => {
|
|
67
|
-
expect(editor.innerHTML).toContain('Bold Text');
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const FormInteraction: Story = {
|
|
73
|
-
render: () => (
|
|
74
|
-
<TestWrapper>
|
|
75
|
-
{({ value, setValue }) => (
|
|
76
|
-
<RichTextEditor
|
|
77
|
-
value={value}
|
|
78
|
-
onChange={setValue}
|
|
79
|
-
maxLength={50}
|
|
80
|
-
placeholder="Test form interaction (50 char limit)..."
|
|
81
|
-
data-testid="rich-editor-form"
|
|
82
|
-
/>
|
|
83
|
-
)}
|
|
84
|
-
</TestWrapper>
|
|
85
|
-
),
|
|
86
|
-
play: async ({ canvasElement }) => {
|
|
87
|
-
const canvas = within(canvasElement);
|
|
88
|
-
|
|
89
|
-
const editor = canvas.getByRole('textbox');
|
|
90
|
-
|
|
91
|
-
// Test character limit
|
|
92
|
-
await userEvent.click(editor);
|
|
93
|
-
const longText =
|
|
94
|
-
'This is a very long text that should exceed the character limit set for this editor';
|
|
95
|
-
await userEvent.type(editor, longText);
|
|
96
|
-
|
|
97
|
-
// Check character count display
|
|
98
|
-
const charCount = canvas.getByText(/\d+\/50/);
|
|
99
|
-
await expect(charCount).toBeInTheDocument();
|
|
100
|
-
|
|
101
|
-
// Test that text is limited
|
|
102
|
-
await waitFor(() => {
|
|
103
|
-
const plainText = editor.textContent || '';
|
|
104
|
-
expect(plainText.length).toBeLessThanOrEqual(50);
|
|
105
|
-
});
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export const KeyboardNavigation: Story = {
|
|
110
|
-
render: () => (
|
|
111
|
-
<TestWrapper>
|
|
112
|
-
{({ value, setValue }) => (
|
|
113
|
-
<RichTextEditor
|
|
114
|
-
value={value}
|
|
115
|
-
onChange={setValue}
|
|
116
|
-
placeholder="Test keyboard navigation..."
|
|
117
|
-
data-testid="rich-editor-keyboard"
|
|
118
|
-
/>
|
|
119
|
-
)}
|
|
120
|
-
</TestWrapper>
|
|
121
|
-
),
|
|
122
|
-
play: async ({ canvasElement }) => {
|
|
123
|
-
const canvas = within(canvasElement);
|
|
124
|
-
|
|
125
|
-
const editor = canvas.getByRole('textbox');
|
|
126
|
-
const boldButton = canvas.getByLabelText('Bold');
|
|
127
|
-
const italicButton = canvas.getByLabelText('Italic');
|
|
128
|
-
|
|
129
|
-
// Test tab navigation to toolbar
|
|
130
|
-
await userEvent.tab();
|
|
131
|
-
await waitFor(() => expect(boldButton).toHaveFocus());
|
|
132
|
-
|
|
133
|
-
await userEvent.tab();
|
|
134
|
-
await waitFor(() => expect(italicButton).toHaveFocus());
|
|
135
|
-
|
|
136
|
-
// Test formatting via toolbar buttons after selecting text
|
|
137
|
-
await userEvent.click(editor);
|
|
138
|
-
await userEvent.type(editor, 'Test text');
|
|
139
|
-
|
|
140
|
-
// Select all text
|
|
141
|
-
await userEvent.keyboard('{Control>}a{/Control}');
|
|
142
|
-
|
|
143
|
-
// Test bold formatting via toolbar button
|
|
144
|
-
const boldToolbarButton = canvas.getByLabelText('Bold');
|
|
145
|
-
await userEvent.click(boldToolbarButton);
|
|
146
|
-
|
|
147
|
-
await waitFor(() => {
|
|
148
|
-
// Check if text is formatted with strong tags
|
|
149
|
-
const hasStrong = editor.innerHTML.includes('<strong>');
|
|
150
|
-
expect(hasStrong).toBeTruthy();
|
|
151
|
-
});
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export const ScreenReader: Story = {
|
|
156
|
-
render: () => (
|
|
157
|
-
<TestWrapper>
|
|
158
|
-
{({ value, setValue }) => (
|
|
159
|
-
<RichTextEditor
|
|
160
|
-
value={value}
|
|
161
|
-
onChange={setValue}
|
|
162
|
-
aria-label="Rich text editor for testing accessibility"
|
|
163
|
-
aria-describedby="editor-help"
|
|
164
|
-
placeholder="Screen reader accessible editor..."
|
|
165
|
-
/>
|
|
166
|
-
)}
|
|
167
|
-
</TestWrapper>
|
|
168
|
-
),
|
|
169
|
-
play: async ({ canvasElement }) => {
|
|
170
|
-
const canvas = within(canvasElement);
|
|
171
|
-
|
|
172
|
-
// Test ARIA attributes
|
|
173
|
-
const editor = canvas.getByRole('textbox', {
|
|
174
|
-
name: /rich text editor for testing accessibility/i,
|
|
175
|
-
});
|
|
176
|
-
await expect(editor).toHaveAttribute(
|
|
177
|
-
'aria-label',
|
|
178
|
-
'Rich text editor for testing accessibility',
|
|
179
|
-
);
|
|
180
|
-
await expect(editor).toHaveAttribute('aria-multiline', 'true');
|
|
181
|
-
await expect(editor).toHaveAttribute('aria-describedby', 'editor-help');
|
|
182
|
-
|
|
183
|
-
// Test toolbar button labels
|
|
184
|
-
const boldButton = canvas.getByRole('button', { name: /bold/i });
|
|
185
|
-
const italicButton = canvas.getByRole('button', { name: /italic/i });
|
|
186
|
-
|
|
187
|
-
await expect(boldButton).toHaveAttribute('aria-label', 'Bold');
|
|
188
|
-
await expect(italicButton).toHaveAttribute('aria-label', 'Italic');
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
export const FocusManagement: Story = {
|
|
193
|
-
render: () => (
|
|
194
|
-
<TestWrapper>
|
|
195
|
-
{({ value, setValue }) => (
|
|
196
|
-
<RichTextEditor
|
|
197
|
-
value={value}
|
|
198
|
-
onChange={setValue}
|
|
199
|
-
placeholder="Test focus management..."
|
|
200
|
-
onFocus={() => {}}
|
|
201
|
-
onBlur={() => {}}
|
|
202
|
-
/>
|
|
203
|
-
)}
|
|
204
|
-
</TestWrapper>
|
|
205
|
-
),
|
|
206
|
-
play: async ({ canvasElement }) => {
|
|
207
|
-
const canvas = within(canvasElement);
|
|
208
|
-
|
|
209
|
-
const editor = canvas.getByRole('textbox');
|
|
210
|
-
const boldButton = canvas.getByLabelText('Bold');
|
|
211
|
-
|
|
212
|
-
// Test initial focus
|
|
213
|
-
await userEvent.click(editor);
|
|
214
|
-
await waitFor(() => expect(editor).toHaveFocus());
|
|
215
|
-
|
|
216
|
-
// Test focus on toolbar button
|
|
217
|
-
await userEvent.click(boldButton);
|
|
218
|
-
|
|
219
|
-
// Focus should return to editor after toolbar action
|
|
220
|
-
await waitFor(() => {
|
|
221
|
-
expect(editor).toHaveFocus();
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
// Test blur
|
|
225
|
-
await userEvent.tab(); // Move away from editor
|
|
226
|
-
await waitFor(() => expect(editor).not.toHaveFocus());
|
|
227
|
-
},
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
export const ResponsiveDesign: Story = {
|
|
231
|
-
parameters: {
|
|
232
|
-
viewport: {
|
|
233
|
-
viewports: {
|
|
234
|
-
mobile: { name: 'Mobile', styles: { width: '375px', height: '667px' } },
|
|
235
|
-
tablet: { name: 'Tablet', styles: { width: '768px', height: '1024px' } },
|
|
236
|
-
desktop: { name: 'Desktop', styles: { width: '1024px', height: '768px' } },
|
|
237
|
-
},
|
|
238
|
-
defaultViewport: 'mobile',
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
render: () => (
|
|
242
|
-
<TestWrapper>
|
|
243
|
-
{({ value, setValue }) => (
|
|
244
|
-
<RichTextEditor
|
|
245
|
-
value={value}
|
|
246
|
-
onChange={setValue}
|
|
247
|
-
placeholder="Responsive editor test..."
|
|
248
|
-
height="200px"
|
|
249
|
-
/>
|
|
250
|
-
)}
|
|
251
|
-
</TestWrapper>
|
|
252
|
-
),
|
|
253
|
-
play: async ({ canvasElement }) => {
|
|
254
|
-
const canvas = within(canvasElement);
|
|
255
|
-
|
|
256
|
-
const editor = canvas.getByRole('textbox');
|
|
257
|
-
await expect(editor).toBeInTheDocument();
|
|
258
|
-
|
|
259
|
-
// Test that editor is usable on mobile
|
|
260
|
-
await userEvent.click(editor);
|
|
261
|
-
await userEvent.type(editor, 'Mobile test');
|
|
262
|
-
|
|
263
|
-
await waitFor(() => {
|
|
264
|
-
expect(editor.innerHTML).toContain('Mobile test');
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
// Test toolbar buttons are accessible
|
|
268
|
-
const boldButton = canvas.getByLabelText('Bold');
|
|
269
|
-
await userEvent.click(boldButton);
|
|
270
|
-
await expect(boldButton).toBeInTheDocument();
|
|
271
|
-
},
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
export const ThemeVariations: Story = {
|
|
275
|
-
render: () => (
|
|
276
|
-
<TestWrapper>
|
|
277
|
-
{({ value, setValue }) => (
|
|
278
|
-
<Box sx={{ p: 2, bgcolor: 'background.default' }}>
|
|
279
|
-
<RichTextEditor
|
|
280
|
-
value={value}
|
|
281
|
-
onChange={setValue}
|
|
282
|
-
placeholder="Theme variation test..."
|
|
283
|
-
data-testid="theme-editor"
|
|
284
|
-
/>
|
|
285
|
-
</Box>
|
|
286
|
-
)}
|
|
287
|
-
</TestWrapper>
|
|
288
|
-
),
|
|
289
|
-
play: async ({ canvasElement }) => {
|
|
290
|
-
const canvas = within(canvasElement);
|
|
291
|
-
|
|
292
|
-
const editor = canvas.getByRole('textbox');
|
|
293
|
-
await expect(editor).toBeInTheDocument();
|
|
294
|
-
|
|
295
|
-
// Test that editor adapts to theme using the Paper component (root container)
|
|
296
|
-
const editorContainer = canvas.getByTestId('theme-editor');
|
|
297
|
-
const styles = window.getComputedStyle(editorContainer);
|
|
298
|
-
|
|
299
|
-
// The Paper component should have a background color
|
|
300
|
-
expect(styles.backgroundColor).toBeTruthy();
|
|
301
|
-
expect(styles.backgroundColor).not.toBe('');
|
|
302
|
-
},
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
export const VisualStates: Story = {
|
|
306
|
-
render: () => (
|
|
307
|
-
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 2, width: 600 }}>
|
|
308
|
-
<TestWrapper>
|
|
309
|
-
{({ value, setValue }) => (
|
|
310
|
-
<RichTextEditor value={value} onChange={setValue} placeholder="Normal state..." />
|
|
311
|
-
)}
|
|
312
|
-
</TestWrapper>
|
|
313
|
-
|
|
314
|
-
<TestWrapper>
|
|
315
|
-
{({ value, setValue }) => (
|
|
316
|
-
<RichTextEditor
|
|
317
|
-
value={value}
|
|
318
|
-
onChange={setValue}
|
|
319
|
-
disabled
|
|
320
|
-
placeholder="Disabled state..."
|
|
321
|
-
/>
|
|
322
|
-
)}
|
|
323
|
-
</TestWrapper>
|
|
324
|
-
|
|
325
|
-
<TestWrapper value="<p>Read-only state with content</p>">
|
|
326
|
-
{({ value, setValue }) => (
|
|
327
|
-
<RichTextEditor value={value} onChange={setValue} readOnly toolbar={{}} />
|
|
328
|
-
)}
|
|
329
|
-
</TestWrapper>
|
|
330
|
-
</Box>
|
|
331
|
-
),
|
|
332
|
-
play: async ({ canvasElement }) => {
|
|
333
|
-
const canvas = within(canvasElement);
|
|
334
|
-
|
|
335
|
-
const editors = canvas.getAllByRole('textbox');
|
|
336
|
-
expect(editors).toHaveLength(3);
|
|
337
|
-
|
|
338
|
-
// Test normal editor
|
|
339
|
-
const normalEditor = editors[0];
|
|
340
|
-
await userEvent.click(normalEditor);
|
|
341
|
-
await userEvent.type(normalEditor, 'Test');
|
|
342
|
-
await expect(normalEditor).toContainHTML('Test');
|
|
343
|
-
|
|
344
|
-
// Test disabled editor
|
|
345
|
-
const disabledEditor = editors[1];
|
|
346
|
-
expect(disabledEditor).toHaveAttribute('contenteditable', 'false');
|
|
347
|
-
|
|
348
|
-
// Test readonly editor
|
|
349
|
-
const readOnlyEditor = editors[2];
|
|
350
|
-
expect(readOnlyEditor).toHaveAttribute('contenteditable', 'false');
|
|
351
|
-
expect(readOnlyEditor.innerHTML).toContain('Read-only state');
|
|
352
|
-
},
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
export const Performance: Story = {
|
|
356
|
-
render: () => (
|
|
357
|
-
<TestWrapper>
|
|
358
|
-
{({ value, setValue }) => (
|
|
359
|
-
<RichTextEditor
|
|
360
|
-
value={value}
|
|
361
|
-
onChange={setValue}
|
|
362
|
-
placeholder="Performance test - type quickly..."
|
|
363
|
-
height={400}
|
|
364
|
-
/>
|
|
365
|
-
)}
|
|
366
|
-
</TestWrapper>
|
|
367
|
-
),
|
|
368
|
-
play: async ({ canvasElement }) => {
|
|
369
|
-
const canvas = within(canvasElement);
|
|
370
|
-
|
|
371
|
-
const editor = canvas.getByRole('textbox');
|
|
372
|
-
|
|
373
|
-
// Performance test - rapid typing
|
|
374
|
-
|
|
375
|
-
await userEvent.click(editor);
|
|
376
|
-
|
|
377
|
-
// Type a long text rapidly - reduced to 5 repetitions for faster test
|
|
378
|
-
const longText = 'This is a performance test with a lot of text content. '.repeat(5);
|
|
379
|
-
await userEvent.type(editor, longText, { delay: 1 });
|
|
380
|
-
|
|
381
|
-
// Content should be rendered correctly
|
|
382
|
-
await waitFor(() => {
|
|
383
|
-
expect(editor.innerHTML).toContain('performance test');
|
|
384
|
-
});
|
|
385
|
-
},
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
export const EdgeCases: Story = {
|
|
389
|
-
render: () => (
|
|
390
|
-
<TestWrapper>
|
|
391
|
-
{({ value, setValue }) => (
|
|
392
|
-
<RichTextEditor
|
|
393
|
-
value={value}
|
|
394
|
-
onChange={setValue}
|
|
395
|
-
placeholder="Edge cases test..."
|
|
396
|
-
maxLength={20}
|
|
397
|
-
/>
|
|
398
|
-
)}
|
|
399
|
-
</TestWrapper>
|
|
400
|
-
),
|
|
401
|
-
play: async ({ canvasElement }) => {
|
|
402
|
-
const canvas = within(canvasElement);
|
|
403
|
-
|
|
404
|
-
const editor = canvas.getByRole('textbox');
|
|
405
|
-
|
|
406
|
-
// Test empty state
|
|
407
|
-
expect(editor.innerHTML).toBe('');
|
|
408
|
-
|
|
409
|
-
// Test special characters
|
|
410
|
-
await userEvent.click(editor);
|
|
411
|
-
await userEvent.type(editor, '<>&"\'');
|
|
412
|
-
|
|
413
|
-
await waitFor(() => {
|
|
414
|
-
// Special characters should be handled safely
|
|
415
|
-
expect(editor).toBeInTheDocument();
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
// Test character limit edge case
|
|
419
|
-
await userEvent.clear(editor);
|
|
420
|
-
await userEvent.type(editor, '12345678901234567890EXTRA');
|
|
421
|
-
|
|
422
|
-
await waitFor(() => {
|
|
423
|
-
const text = editor.textContent || '';
|
|
424
|
-
expect(text.length).toBeLessThanOrEqual(20);
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
// Test HTML injection prevention
|
|
428
|
-
await userEvent.clear(editor);
|
|
429
|
-
await userEvent.type(editor, '<script>alert("xss")</script>');
|
|
430
|
-
|
|
431
|
-
// Should not execute script
|
|
432
|
-
await expect(editor).toBeInTheDocument();
|
|
433
|
-
},
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
export const Integration: Story = {
|
|
437
|
-
render: () => (
|
|
438
|
-
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 2, width: 600 }}>
|
|
439
|
-
<TestWrapper>
|
|
440
|
-
{({ value, setValue }) => (
|
|
441
|
-
<RichTextEditor
|
|
442
|
-
value={value}
|
|
443
|
-
onChange={setValue}
|
|
444
|
-
placeholder="First editor..."
|
|
445
|
-
toolbar={{ bold: true, italic: true, link: false }}
|
|
446
|
-
/>
|
|
447
|
-
)}
|
|
448
|
-
</TestWrapper>
|
|
449
|
-
|
|
450
|
-
<TestWrapper>
|
|
451
|
-
{({ value, setValue }) => (
|
|
452
|
-
<RichTextEditor
|
|
453
|
-
value={value}
|
|
454
|
-
onChange={setValue}
|
|
455
|
-
placeholder="Second editor with different toolbar..."
|
|
456
|
-
toolbar={{ bold: false, italic: false, orderedList: true, unorderedList: true }}
|
|
457
|
-
/>
|
|
458
|
-
)}
|
|
459
|
-
</TestWrapper>
|
|
460
|
-
</Box>
|
|
461
|
-
),
|
|
462
|
-
play: async ({ canvasElement }) => {
|
|
463
|
-
const canvas = within(canvasElement);
|
|
464
|
-
|
|
465
|
-
const editors = canvas.getAllByRole('textbox');
|
|
466
|
-
expect(editors).toHaveLength(2);
|
|
467
|
-
|
|
468
|
-
// Test first editor
|
|
469
|
-
const editor1 = editors[0];
|
|
470
|
-
const boldButton1 = canvas.getAllByLabelText('Bold')[0];
|
|
471
|
-
|
|
472
|
-
await userEvent.click(editor1);
|
|
473
|
-
await userEvent.type(editor1, 'First editor');
|
|
474
|
-
await userEvent.click(boldButton1);
|
|
475
|
-
|
|
476
|
-
// Test second editor
|
|
477
|
-
const editor2 = editors[1];
|
|
478
|
-
const listButtons = canvas.getAllByLabelText('Bulleted List');
|
|
479
|
-
const listButton = listButtons[1]; // Second editor's button
|
|
480
|
-
|
|
481
|
-
await userEvent.click(editor2);
|
|
482
|
-
await userEvent.type(editor2, 'Second editor');
|
|
483
|
-
await userEvent.click(listButton);
|
|
484
|
-
|
|
485
|
-
// Both editors should work independently
|
|
486
|
-
await waitFor(() => {
|
|
487
|
-
expect(editor1.innerHTML).toContain('First editor');
|
|
488
|
-
expect(editor2.innerHTML).toContain('Second editor');
|
|
489
|
-
});
|
|
490
|
-
},
|
|
491
|
-
};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import Inventory2Icon from '@mui/icons-material/Inventory2';
|
|
2
|
-
import { CssBaseline } from '@mui/material';
|
|
3
|
-
import { createTheme, ThemeProvider } from '@mui/material/styles';
|
|
4
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
5
|
-
import { expect, userEvent, waitFor, within } from 'storybook/test';
|
|
6
|
-
import { useState } from 'react';
|
|
7
|
-
|
|
8
|
-
import { SearchPalette } from './SearchPalette';
|
|
9
|
-
import type { SearchResultLead } from './SearchPalette.types';
|
|
10
|
-
|
|
11
|
-
interface Item {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
sub?: string;
|
|
15
|
-
image?: string;
|
|
16
|
-
date?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const PRODUCTS: Item[] = [
|
|
20
|
-
{ id: 'p1', name: 'Sabão em pó 1kg', sub: 'Limpeza Roupas', date: 'Jul 12' },
|
|
21
|
-
{ id: 'p2', name: 'Sabonete 90g', sub: 'Cuidado Pessoal', date: 'Jul 11' },
|
|
22
|
-
{ id: 'p3', name: 'Detergente 500ml', sub: 'Limpeza Cozinha', date: 'Jul 10' },
|
|
23
|
-
{ id: 'p4', name: 'Sabão líquido 3L', sub: 'Limpeza Roupas', date: 'Jul 9' },
|
|
24
|
-
{ id: 'p5', name: 'Esponja (un)', sub: 'Limpeza Cozinha', date: 'Jul 8' },
|
|
25
|
-
{ id: 'p6', name: 'Escova de dente', sub: 'Cuidado Bucal', date: 'Jul 7' },
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
const FILTERS = [
|
|
29
|
-
{ id: 'last7', label: 'Últimos 7 dias' },
|
|
30
|
-
{ id: 'mine', label: 'Criados por mim' },
|
|
31
|
-
{ id: 'active', label: 'Ativos' },
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
const theme = createTheme();
|
|
35
|
-
|
|
36
|
-
const meta: Meta<typeof SearchPalette<Item>> = {
|
|
37
|
-
title: 'Form/SearchPalette',
|
|
38
|
-
component: SearchPalette,
|
|
39
|
-
tags: ['autodocs', 'component:SearchPalette'],
|
|
40
|
-
parameters: {
|
|
41
|
-
docs: {
|
|
42
|
-
description: {
|
|
43
|
-
component:
|
|
44
|
-
'A Gmail-style search palette: input + filter chips + rich result rows + "see all" footer. App-agnostic and configurable.',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
decorators: [
|
|
49
|
-
(Story) => (
|
|
50
|
-
<ThemeProvider theme={theme}>
|
|
51
|
-
<CssBaseline />
|
|
52
|
-
<div style={{ maxWidth: 640, padding: 24, background: '#f1f3f4' }}>
|
|
53
|
-
<Story />
|
|
54
|
-
</div>
|
|
55
|
-
</ThemeProvider>
|
|
56
|
-
),
|
|
57
|
-
],
|
|
58
|
-
};
|
|
59
|
-
export default meta;
|
|
60
|
-
|
|
61
|
-
type Story = StoryObj<typeof SearchPalette<Item>>;
|
|
62
|
-
|
|
63
|
-
function lead(item: Item): SearchResultLead {
|
|
64
|
-
return item.image
|
|
65
|
-
? { kind: 'image', src: item.image }
|
|
66
|
-
: { kind: 'icon', node: <Inventory2Icon fontSize="small" /> };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function Harness({ initial = '' }: { initial?: string }) {
|
|
70
|
-
const [query, setQuery] = useState(initial);
|
|
71
|
-
const [active, setActive] = useState<string[]>(['last7']);
|
|
72
|
-
const matches = PRODUCTS.filter((p) => p.name.toLowerCase().includes(query.trim().toLowerCase()));
|
|
73
|
-
return (
|
|
74
|
-
<SearchPalette<Item>
|
|
75
|
-
value={query}
|
|
76
|
-
onChange={setQuery}
|
|
77
|
-
items={query.trim() ? matches : []}
|
|
78
|
-
getKey={(p) => p.id}
|
|
79
|
-
getPrimary={(p) => p.name}
|
|
80
|
-
getSecondary={(p) => p.sub}
|
|
81
|
-
getLead={lead}
|
|
82
|
-
getTrailing={(p) => p.date}
|
|
83
|
-
onSelect={(p) => setQuery(p.name)}
|
|
84
|
-
filters={FILTERS}
|
|
85
|
-
activeFilterIds={active}
|
|
86
|
-
onToggleFilter={(id) =>
|
|
87
|
-
setActive((cur) => (cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id]))
|
|
88
|
-
}
|
|
89
|
-
onSubmitAll={() => undefined}
|
|
90
|
-
emptyQueryContent={
|
|
91
|
-
<div style={{ padding: '8px 16px', color: '#5f6368', fontSize: 13 }}>
|
|
92
|
-
Comece a digitar para buscar…
|
|
93
|
-
</div>
|
|
94
|
-
}
|
|
95
|
-
inputAriaLabel="Buscar"
|
|
96
|
-
placeholder="Buscar páginas e registros…"
|
|
97
|
-
/>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export const Default: Story = {
|
|
102
|
-
render: () => <Harness />,
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export const WithResults: Story = {
|
|
106
|
-
render: () => <Harness initial="Sab" />,
|
|
107
|
-
play: async ({ canvasElement }) => {
|
|
108
|
-
const canvas = within(canvasElement);
|
|
109
|
-
// Chips render and results are filtered + capped.
|
|
110
|
-
await expect(canvas.getByTestId('search-palette-filters')).toBeInTheDocument();
|
|
111
|
-
await waitFor(() => expect(canvas.getByTestId('search-palette-results')).toBeInTheDocument());
|
|
112
|
-
await expect(canvas.getAllByText(/Sab/).length).toBeGreaterThan(0);
|
|
113
|
-
// Footer "see all" is present with a non-empty query.
|
|
114
|
-
await expect(canvas.getByTestId('search-palette-submit-all')).toBeInTheDocument();
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export const ToggleFilter: Story = {
|
|
119
|
-
render: () => <Harness initial="a" />,
|
|
120
|
-
play: async ({ canvasElement }) => {
|
|
121
|
-
const canvas = within(canvasElement);
|
|
122
|
-
const chip = canvas.getByTestId('search-palette-filter-mine');
|
|
123
|
-
await expect(chip).toHaveAttribute('aria-pressed', 'false');
|
|
124
|
-
await userEvent.click(chip);
|
|
125
|
-
await waitFor(() => expect(chip).toHaveAttribute('aria-pressed', 'true'));
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
export const EmptyQuery: Story = {
|
|
130
|
-
render: () => <Harness />,
|
|
131
|
-
play: async ({ canvasElement }) => {
|
|
132
|
-
const canvas = within(canvasElement);
|
|
133
|
-
await expect(canvas.getByTestId('search-palette-empty-query')).toBeInTheDocument();
|
|
134
|
-
},
|
|
135
|
-
};
|