@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,129 +0,0 @@
|
|
|
1
|
-
import { Box, Button, Typography } from '@mui/material';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
|
|
5
|
-
import { ContentToolbar } from './ContentToolbar';
|
|
6
|
-
import { FilterTrigger } from './FilterTrigger';
|
|
7
|
-
import { MultiSelectDropdown } from './MultiSelectDropdown';
|
|
8
|
-
import { SortByDropdown } from './SortByDropdown';
|
|
9
|
-
import { ViewSelector } from './ViewSelector';
|
|
10
|
-
import type { SortFieldDefinition, ViewMode } from './ContentToolbar.types';
|
|
11
|
-
|
|
12
|
-
const meta: Meta<typeof ContentToolbar> = {
|
|
13
|
-
title: 'Layout/ContentToolbar',
|
|
14
|
-
component: ContentToolbar,
|
|
15
|
-
parameters: {
|
|
16
|
-
layout: 'padded',
|
|
17
|
-
docs: {
|
|
18
|
-
description: {
|
|
19
|
-
component:
|
|
20
|
-
'Shared content-page toolbar (Favorites / Personal Space / Recents style): a Select All / Clear All / count / actions cluster on the left and a free `rightControls` slot on the right. Ships with `ViewSelector`, `SortByDropdown`, `MultiSelectDropdown` and `FilterTrigger` to compose that slot.',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
tags: ['autodocs'],
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default meta;
|
|
28
|
-
type Story = StoryObj<typeof meta>;
|
|
29
|
-
|
|
30
|
-
const SORT_FIELDS: SortFieldDefinition[] = [
|
|
31
|
-
{
|
|
32
|
-
value: 'size',
|
|
33
|
-
label: 'Size',
|
|
34
|
-
triggerLabelStyle: 'range',
|
|
35
|
-
orderOptions: [
|
|
36
|
-
{ value: 'large', label: 'Large' },
|
|
37
|
-
{ value: 'small', label: 'Small' },
|
|
38
|
-
],
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
value: 'name',
|
|
42
|
-
label: 'Name',
|
|
43
|
-
orderOptions: [
|
|
44
|
-
{ value: 'asc', label: 'A–Z' },
|
|
45
|
-
{ value: 'desc', label: 'Z–A' },
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
{ value: 'modified', label: 'Modified', showOrderInTrigger: false },
|
|
49
|
-
];
|
|
50
|
-
|
|
51
|
-
const CONTENT_TYPES = [
|
|
52
|
-
{ value: 'workbooks', label: 'Workbooks', count: 12 },
|
|
53
|
-
{ value: 'views', label: 'Views', count: 8 },
|
|
54
|
-
{ value: 'datasources', label: 'Data Sources', count: 3 },
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
/** A full reference toolbar with page title/description above it. */
|
|
58
|
-
function ToolbarHarness({ withSelection }: { withSelection: boolean }): React.JSX.Element {
|
|
59
|
-
const [view, setView] = useState<ViewMode>('grid');
|
|
60
|
-
const [zoom, setZoom] = useState<number[]>([50]);
|
|
61
|
-
const [sortField, setSortField] = useState('size');
|
|
62
|
-
const [sortOrder, setSortOrder] = useState('large');
|
|
63
|
-
const [types, setTypes] = useState<Set<string>>(new Set());
|
|
64
|
-
const [panelOpen, setPanelOpen] = useState(false);
|
|
65
|
-
const [selected, setSelected] = useState<Set<string>>(withSelection ? new Set(['a', 'b']) : new Set());
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<Box sx={{ maxWidth: 1100 }}>
|
|
69
|
-
<Box sx={{ borderBottom: 1, borderColor: 'divider', pb: 2, mb: 2 }}>
|
|
70
|
-
<Typography variant="h5" sx={{ fontWeight: 600 }}>
|
|
71
|
-
Favorites
|
|
72
|
-
</Typography>
|
|
73
|
-
<Typography sx={{ fontSize: '0.875rem', color: 'text.secondary', mt: 0.5 }}>
|
|
74
|
-
Drag and drop items in grid view to reorder your favorites. Access your custom order using the Sort By menu.
|
|
75
|
-
</Typography>
|
|
76
|
-
</Box>
|
|
77
|
-
<ContentToolbar
|
|
78
|
-
hasSelection={selected.size > 0}
|
|
79
|
-
selectedCount={selected.size}
|
|
80
|
-
selectAll={() => setSelected(new Set(['a', 'b', 'c', 'd']))}
|
|
81
|
-
clearSelection={() => setSelected(new Set())}
|
|
82
|
-
selectAllTestId="fav-select-all"
|
|
83
|
-
clearAllTestId="fav-clear-all"
|
|
84
|
-
actions={
|
|
85
|
-
<Button variant="text" size="small" color="inherit" sx={{ textTransform: 'none' }}>
|
|
86
|
-
Delete
|
|
87
|
-
</Button>
|
|
88
|
-
}
|
|
89
|
-
rightControls={
|
|
90
|
-
<>
|
|
91
|
-
<ViewSelector viewMode={view} onViewModeChange={setView} zoom={zoom} onZoomChange={setZoom} />
|
|
92
|
-
<SortByDropdown
|
|
93
|
-
fields={SORT_FIELDS}
|
|
94
|
-
activeField={sortField}
|
|
95
|
-
activeOrder={sortOrder}
|
|
96
|
-
onFieldChange={setSortField}
|
|
97
|
-
onOrderChange={setSortOrder}
|
|
98
|
-
data-testid="sort-trigger"
|
|
99
|
-
/>
|
|
100
|
-
<MultiSelectDropdown
|
|
101
|
-
label="Content Type"
|
|
102
|
-
options={CONTENT_TYPES}
|
|
103
|
-
selected={types}
|
|
104
|
-
onToggle={(value, checked) =>
|
|
105
|
-
setTypes((prev) => {
|
|
106
|
-
const next = new Set(prev);
|
|
107
|
-
if (checked) next.add(value);
|
|
108
|
-
else next.delete(value);
|
|
109
|
-
return next;
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
onClear={() => setTypes(new Set())}
|
|
113
|
-
data-testid="content-type-trigger"
|
|
114
|
-
/>
|
|
115
|
-
<FilterTrigger open={panelOpen} onOpenChange={setPanelOpen} hasActiveFilters={types.size > 0} />
|
|
116
|
-
</>
|
|
117
|
-
}
|
|
118
|
-
/>
|
|
119
|
-
</Box>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export const Default: Story = {
|
|
124
|
-
render: () => <ToolbarHarness withSelection={false} />,
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export const WithSelection: Story = {
|
|
128
|
-
render: () => <ToolbarHarness withSelection />,
|
|
129
|
-
};
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import { Box } from '@mui/material';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
|
|
4
|
-
import { useState } from 'react';
|
|
5
|
-
|
|
6
|
-
import { ContentToolbar } from './ContentToolbar';
|
|
7
|
-
import { FilterTrigger } from './FilterTrigger';
|
|
8
|
-
import { MultiSelectDropdown } from './MultiSelectDropdown';
|
|
9
|
-
import { SortByDropdown } from './SortByDropdown';
|
|
10
|
-
import type { SortFieldDefinition } from './ContentToolbar.types';
|
|
11
|
-
|
|
12
|
-
const meta: Meta<typeof ContentToolbar> = {
|
|
13
|
-
title: 'Layout/ContentToolbar/Tests',
|
|
14
|
-
component: ContentToolbar,
|
|
15
|
-
parameters: { layout: 'padded', chromatic: { disableSnapshot: false } },
|
|
16
|
-
tags: ['autodocs', 'test', 'component:ContentToolbar', 'checked'],
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default meta;
|
|
20
|
-
type Story = StoryObj<typeof meta>;
|
|
21
|
-
|
|
22
|
-
const SORT_FIELDS: SortFieldDefinition[] = [
|
|
23
|
-
{
|
|
24
|
-
value: 'name',
|
|
25
|
-
label: 'Name',
|
|
26
|
-
orderOptions: [
|
|
27
|
-
{ value: 'asc', label: 'A–Z' },
|
|
28
|
-
{ value: 'desc', label: 'Z–A' },
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
{ value: 'modified', label: 'Modified', showOrderInTrigger: false },
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
const CONTENT_TYPES = [
|
|
35
|
-
{ value: 'workbooks', label: 'Workbooks', count: 12 },
|
|
36
|
-
{ value: 'views', label: 'Views', count: 8 },
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
export const SelectAndClear: Story = {
|
|
40
|
-
name: '🧪 Select All → selection chrome → Clear All',
|
|
41
|
-
render: () => {
|
|
42
|
-
const [selected, setSelected] = useState<Set<string>>(new Set());
|
|
43
|
-
return (
|
|
44
|
-
<ContentToolbar
|
|
45
|
-
hasSelection={selected.size > 0}
|
|
46
|
-
selectedCount={selected.size}
|
|
47
|
-
selectAll={() => setSelected(new Set(['a', 'b', 'c']))}
|
|
48
|
-
clearSelection={() => setSelected(new Set())}
|
|
49
|
-
selectAllTestId="t-select-all"
|
|
50
|
-
clearAllTestId="t-clear-all"
|
|
51
|
-
rightControls={<Box data-testid="right-slot">right</Box>}
|
|
52
|
-
/>
|
|
53
|
-
);
|
|
54
|
-
},
|
|
55
|
-
play: async ({ canvasElement, step }) => {
|
|
56
|
-
const canvas = within(canvasElement);
|
|
57
|
-
await step('No selection: no count indicator', async () => {
|
|
58
|
-
await waitFor(() => expect(canvas.queryByTestId('selected-count-indicator')).not.toBeInTheDocument());
|
|
59
|
-
});
|
|
60
|
-
await step('Select All shows count + Clear All', async () => {
|
|
61
|
-
await userEvent.click(canvas.getByTestId('t-select-all'));
|
|
62
|
-
await waitFor(() => expect(canvas.getByTestId('selected-count-indicator')).toHaveTextContent('3 items selected'));
|
|
63
|
-
await expect(canvas.getByTestId('t-clear-all')).toBeVisible();
|
|
64
|
-
});
|
|
65
|
-
await step('Clear All resets', async () => {
|
|
66
|
-
await userEvent.click(canvas.getByTestId('t-clear-all'));
|
|
67
|
-
await waitFor(() => expect(canvas.queryByTestId('selected-count-indicator')).not.toBeInTheDocument());
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const SortByInteraction: Story = {
|
|
73
|
-
name: '🧪 Sort By opens and changes field',
|
|
74
|
-
render: () => {
|
|
75
|
-
const onField = fn();
|
|
76
|
-
const [field, setField] = useState('name');
|
|
77
|
-
return (
|
|
78
|
-
<ContentToolbar
|
|
79
|
-
hasSelection={false}
|
|
80
|
-
selectedCount={0}
|
|
81
|
-
selectAll={fn()}
|
|
82
|
-
clearSelection={fn()}
|
|
83
|
-
rightControls={
|
|
84
|
-
<SortByDropdown
|
|
85
|
-
fields={SORT_FIELDS}
|
|
86
|
-
activeField={field}
|
|
87
|
-
activeOrder="asc"
|
|
88
|
-
onFieldChange={(value) => {
|
|
89
|
-
onField(value);
|
|
90
|
-
setField(value);
|
|
91
|
-
}}
|
|
92
|
-
onOrderChange={fn()}
|
|
93
|
-
data-testid="sort-trigger"
|
|
94
|
-
/>
|
|
95
|
-
}
|
|
96
|
-
/>
|
|
97
|
-
);
|
|
98
|
-
},
|
|
99
|
-
play: async ({ canvasElement, step }) => {
|
|
100
|
-
const canvas = within(canvasElement);
|
|
101
|
-
await step('Open the Sort By menu', async () => {
|
|
102
|
-
await userEvent.click(canvas.getByTestId('sort-trigger'));
|
|
103
|
-
await waitFor(() => expect(within(document.body).getByTestId('sort-modified-option')).toBeVisible());
|
|
104
|
-
});
|
|
105
|
-
await step('Pick Modified', async () => {
|
|
106
|
-
await userEvent.click(within(document.body).getByTestId('sort-modified-option'));
|
|
107
|
-
await waitFor(() => expect(canvas.getByTestId('sort-trigger')).toHaveTextContent('Modified'));
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const ContentTypeMultiSelect: Story = {
|
|
113
|
-
name: '🧪 Content Type toggles stay open',
|
|
114
|
-
render: () => {
|
|
115
|
-
const [types, setTypes] = useState<Set<string>>(new Set());
|
|
116
|
-
return (
|
|
117
|
-
<ContentToolbar
|
|
118
|
-
hasSelection={false}
|
|
119
|
-
selectedCount={0}
|
|
120
|
-
selectAll={fn()}
|
|
121
|
-
clearSelection={fn()}
|
|
122
|
-
rightControls={
|
|
123
|
-
<MultiSelectDropdown
|
|
124
|
-
label="Content Type"
|
|
125
|
-
options={CONTENT_TYPES}
|
|
126
|
-
selected={types}
|
|
127
|
-
onToggle={(value, checked) =>
|
|
128
|
-
setTypes((prev) => {
|
|
129
|
-
const next = new Set(prev);
|
|
130
|
-
if (checked) next.add(value);
|
|
131
|
-
else next.delete(value);
|
|
132
|
-
return next;
|
|
133
|
-
})
|
|
134
|
-
}
|
|
135
|
-
onClear={() => setTypes(new Set())}
|
|
136
|
-
data-testid="content-type-trigger"
|
|
137
|
-
/>
|
|
138
|
-
}
|
|
139
|
-
/>
|
|
140
|
-
);
|
|
141
|
-
},
|
|
142
|
-
play: async ({ canvasElement, step }) => {
|
|
143
|
-
const canvas = within(canvasElement);
|
|
144
|
-
const body = within(document.body);
|
|
145
|
-
await step('Open and select one type; menu stays open; trigger reflects it', async () => {
|
|
146
|
-
await userEvent.click(canvas.getByTestId('content-type-trigger'));
|
|
147
|
-
await waitFor(() => expect(body.getByText('Workbooks')).toBeVisible());
|
|
148
|
-
await userEvent.click(body.getByText('Workbooks'));
|
|
149
|
-
await waitFor(() => expect(canvas.getByTestId('content-type-trigger')).toHaveTextContent('Workbooks'));
|
|
150
|
-
// Menu is still open (multi-select), so the Clear control is present.
|
|
151
|
-
await expect(body.getByTestId('content-type-trigger-clear')).toBeVisible();
|
|
152
|
-
});
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const CATEGORY_TYPES = [
|
|
157
|
-
{ value: 'bebidas', label: 'Bebidas', count: 12 },
|
|
158
|
-
{ value: 'sobremesas', label: 'Sobremesas', count: 8 },
|
|
159
|
-
{ value: 'lanches', label: 'Lanches', count: 23 },
|
|
160
|
-
{ value: 'saladas', label: 'Saladas', count: 5 },
|
|
161
|
-
{ value: 'massas', label: 'Massas', count: 9 },
|
|
162
|
-
{ value: 'carnes', label: 'Carnes', count: 14 },
|
|
163
|
-
{ value: 'peixes', label: 'Peixes', count: 3 },
|
|
164
|
-
{ value: 'vegano', label: 'Vegano', count: 7 },
|
|
165
|
-
{ value: 'infantil', label: 'Infantil', count: 4 },
|
|
166
|
-
];
|
|
167
|
-
|
|
168
|
-
export const MultiSelectSearch: Story = {
|
|
169
|
-
name: '🧪 Long list auto-shows search + filters options',
|
|
170
|
-
render: () => {
|
|
171
|
-
const [types, setTypes] = useState<Set<string>>(new Set());
|
|
172
|
-
return (
|
|
173
|
-
<ContentToolbar
|
|
174
|
-
hasSelection={false}
|
|
175
|
-
selectedCount={0}
|
|
176
|
-
selectAll={fn()}
|
|
177
|
-
clearSelection={fn()}
|
|
178
|
-
rightControls={
|
|
179
|
-
<MultiSelectDropdown
|
|
180
|
-
label="Categoria"
|
|
181
|
-
options={CATEGORY_TYPES}
|
|
182
|
-
selected={types}
|
|
183
|
-
onToggle={(value, checked) =>
|
|
184
|
-
setTypes((prev) => {
|
|
185
|
-
const next = new Set(prev);
|
|
186
|
-
if (checked) next.add(value);
|
|
187
|
-
else next.delete(value);
|
|
188
|
-
return next;
|
|
189
|
-
})
|
|
190
|
-
}
|
|
191
|
-
onClear={() => setTypes(new Set())}
|
|
192
|
-
allLabel="Todas"
|
|
193
|
-
searchPlaceholder="Buscar…"
|
|
194
|
-
noResultsLabel="Nenhum resultado"
|
|
195
|
-
data-testid="category-trigger"
|
|
196
|
-
/>
|
|
197
|
-
}
|
|
198
|
-
/>
|
|
199
|
-
);
|
|
200
|
-
},
|
|
201
|
-
play: async ({ canvasElement, step }) => {
|
|
202
|
-
const canvas = within(canvasElement);
|
|
203
|
-
const body = within(document.body);
|
|
204
|
-
await step('Open: 9 options auto-render a search box', async () => {
|
|
205
|
-
await userEvent.click(canvas.getByTestId('category-trigger'));
|
|
206
|
-
await waitFor(() => expect(body.getByTestId('category-trigger-search')).toBeVisible());
|
|
207
|
-
await expect(body.getByText('Sobremesas')).toBeVisible();
|
|
208
|
-
await expect(body.getByText('Lanches')).toBeVisible();
|
|
209
|
-
});
|
|
210
|
-
await step('Typing filters the list case-insensitively', async () => {
|
|
211
|
-
await userEvent.type(body.getByTestId('category-trigger-search'), 'sobre');
|
|
212
|
-
await waitFor(() => expect(body.queryByText('Lanches')).not.toBeInTheDocument());
|
|
213
|
-
await expect(body.getByText('Sobremesas')).toBeVisible();
|
|
214
|
-
});
|
|
215
|
-
await step('Selecting a filtered option keeps the menu open', async () => {
|
|
216
|
-
await userEvent.click(body.getByText('Sobremesas'));
|
|
217
|
-
await waitFor(() => expect(canvas.getByTestId('category-trigger')).toHaveTextContent('Sobremesas'));
|
|
218
|
-
await expect(body.getByTestId('category-trigger-search')).toBeVisible();
|
|
219
|
-
});
|
|
220
|
-
await step('A non-matching query shows the empty state', async () => {
|
|
221
|
-
await userEvent.clear(body.getByTestId('category-trigger-search'));
|
|
222
|
-
await userEvent.type(body.getByTestId('category-trigger-search'), 'zzz');
|
|
223
|
-
await waitFor(() => expect(body.getByTestId('category-trigger-no-results')).toBeVisible());
|
|
224
|
-
});
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
export const FilterTriggerActiveDot: Story = {
|
|
229
|
-
name: '🧪 Filter trigger toggles + shows active dot',
|
|
230
|
-
render: () => {
|
|
231
|
-
const [open, setOpen] = useState(false);
|
|
232
|
-
return (
|
|
233
|
-
<ContentToolbar
|
|
234
|
-
hasSelection={false}
|
|
235
|
-
selectedCount={0}
|
|
236
|
-
selectAll={fn()}
|
|
237
|
-
clearSelection={fn()}
|
|
238
|
-
rightControls={<FilterTrigger open={open} onOpenChange={setOpen} hasActiveFilters data-testid="filter-btn" />}
|
|
239
|
-
/>
|
|
240
|
-
);
|
|
241
|
-
},
|
|
242
|
-
play: async ({ canvasElement, step }) => {
|
|
243
|
-
const canvas = within(canvasElement);
|
|
244
|
-
await step('Toggle opens the filter', async () => {
|
|
245
|
-
const btn = canvas.getByTestId('filter-btn');
|
|
246
|
-
await expect(btn).toHaveAttribute('aria-expanded', 'false');
|
|
247
|
-
await userEvent.click(btn);
|
|
248
|
-
await waitFor(() => expect(canvas.getByTestId('filter-btn')).toHaveAttribute('aria-expanded', 'true'));
|
|
249
|
-
});
|
|
250
|
-
},
|
|
251
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { fireEvent, render, screen } from "@testing-library/react";
|
|
3
|
-
|
|
4
|
-
import { ColumnsMenu } from "../ColumnsMenu";
|
|
5
|
-
import type { ColumnVisibilityOption } from "../ContentToolbar.types";
|
|
6
|
-
|
|
7
|
-
const columns: ColumnVisibilityOption[] = [
|
|
8
|
-
{ id: "name", label: "Nome", visible: true },
|
|
9
|
-
{ id: "sku", label: "SKU", visible: false },
|
|
10
|
-
];
|
|
11
|
-
|
|
12
|
-
function renderMenu(overrides: Partial<React.ComponentProps<typeof ColumnsMenu>> = {}) {
|
|
13
|
-
const onToggle = vi.fn();
|
|
14
|
-
render(<ColumnsMenu columns={columns} onToggle={onToggle} data-testid="cols" {...overrides} />);
|
|
15
|
-
return onToggle;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
describe("ColumnsMenu", () => {
|
|
19
|
-
it("opens and lists each column with its visibility", () => {
|
|
20
|
-
renderMenu();
|
|
21
|
-
fireEvent.click(screen.getByTestId("cols"));
|
|
22
|
-
expect(screen.getByTestId("cols-name")).toBeInTheDocument();
|
|
23
|
-
expect(screen.getByTestId("cols-sku")).toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("toggles a hidden column on", () => {
|
|
27
|
-
const onToggle = renderMenu();
|
|
28
|
-
fireEvent.click(screen.getByTestId("cols"));
|
|
29
|
-
fireEvent.click(screen.getByTestId("cols-sku"));
|
|
30
|
-
expect(onToggle).toHaveBeenCalledWith("sku", true);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("toggles a visible column off", () => {
|
|
34
|
-
const onToggle = renderMenu();
|
|
35
|
-
fireEvent.click(screen.getByTestId("cols"));
|
|
36
|
-
fireEvent.click(screen.getByTestId("cols-name"));
|
|
37
|
-
expect(onToggle).toHaveBeenCalledWith("name", false);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
|
|
4
|
-
import { MultiSelectDropdown } from '../MultiSelectDropdown';
|
|
5
|
-
|
|
6
|
-
const MANY_OPTIONS = [
|
|
7
|
-
{ value: 'bebidas', label: 'Bebidas' },
|
|
8
|
-
{ value: 'sobremesas', label: 'Sobremesas' },
|
|
9
|
-
{ value: 'lanches', label: 'Lanches' },
|
|
10
|
-
{ value: 'saladas', label: 'Saladas' },
|
|
11
|
-
{ value: 'massas', label: 'Massas' },
|
|
12
|
-
{ value: 'carnes', label: 'Carnes' },
|
|
13
|
-
{ value: 'peixes', label: 'Peixes' },
|
|
14
|
-
{ value: 'vegano', label: 'Vegano' },
|
|
15
|
-
{ value: 'infantil', label: 'Infantil' },
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
function open(): void {
|
|
19
|
-
fireEvent.click(screen.getByTestId('cat'));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
describe('MultiSelectDropdown search (FUT-169)', () => {
|
|
23
|
-
it('auto-shows a search box for long lists and filters options case-insensitively', async () => {
|
|
24
|
-
render(
|
|
25
|
-
<MultiSelectDropdown
|
|
26
|
-
label="Categoria"
|
|
27
|
-
options={MANY_OPTIONS}
|
|
28
|
-
selected={new Set<string>()}
|
|
29
|
-
onToggle={vi.fn()}
|
|
30
|
-
onClear={vi.fn()}
|
|
31
|
-
searchPlaceholder="Buscar…"
|
|
32
|
-
noResultsLabel="Nenhum resultado"
|
|
33
|
-
data-testid="cat"
|
|
34
|
-
/>,
|
|
35
|
-
);
|
|
36
|
-
open();
|
|
37
|
-
|
|
38
|
-
const search = await screen.findByTestId('cat-search');
|
|
39
|
-
expect(screen.getByText('Lanches')).toBeInTheDocument();
|
|
40
|
-
|
|
41
|
-
fireEvent.change(search, { target: { value: 'SOBRE' } });
|
|
42
|
-
|
|
43
|
-
await waitFor(() => expect(screen.queryByText('Lanches')).not.toBeInTheDocument());
|
|
44
|
-
expect(screen.getByText('Sobremesas')).toBeInTheDocument();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('shows the empty state when nothing matches', async () => {
|
|
48
|
-
render(
|
|
49
|
-
<MultiSelectDropdown
|
|
50
|
-
label="Categoria"
|
|
51
|
-
options={MANY_OPTIONS}
|
|
52
|
-
selected={new Set<string>()}
|
|
53
|
-
onToggle={vi.fn()}
|
|
54
|
-
onClear={vi.fn()}
|
|
55
|
-
noResultsLabel="Nenhum resultado"
|
|
56
|
-
data-testid="cat"
|
|
57
|
-
/>,
|
|
58
|
-
);
|
|
59
|
-
open();
|
|
60
|
-
|
|
61
|
-
fireEvent.change(await screen.findByTestId('cat-search'), { target: { value: 'zzz' } });
|
|
62
|
-
|
|
63
|
-
expect(await screen.findByTestId('cat-no-results')).toHaveTextContent('Nenhum resultado');
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('does NOT render a search box for short lists', async () => {
|
|
67
|
-
render(
|
|
68
|
-
<MultiSelectDropdown
|
|
69
|
-
label="Ativo"
|
|
70
|
-
options={[
|
|
71
|
-
{ value: 'sim', label: 'Sim' },
|
|
72
|
-
{ value: 'nao', label: 'Não' },
|
|
73
|
-
]}
|
|
74
|
-
selected={new Set<string>()}
|
|
75
|
-
onToggle={vi.fn()}
|
|
76
|
-
onClear={vi.fn()}
|
|
77
|
-
data-testid="cat"
|
|
78
|
-
/>,
|
|
79
|
-
);
|
|
80
|
-
open();
|
|
81
|
-
|
|
82
|
-
// Presence evidence first (menu open), then assert the search box was never
|
|
83
|
-
// rendered — wrapped in waitFor per the anti-flake rule.
|
|
84
|
-
expect(await screen.findByText('Sim')).toBeInTheDocument();
|
|
85
|
-
await waitFor(() => expect(screen.queryByTestId('cat-search')).not.toBeInTheDocument());
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('toggles a filtered option and keeps the menu open (search still visible)', async () => {
|
|
89
|
-
const onToggle = vi.fn();
|
|
90
|
-
render(
|
|
91
|
-
<MultiSelectDropdown
|
|
92
|
-
label="Categoria"
|
|
93
|
-
options={MANY_OPTIONS}
|
|
94
|
-
selected={new Set<string>()}
|
|
95
|
-
onToggle={onToggle}
|
|
96
|
-
onClear={vi.fn()}
|
|
97
|
-
data-testid="cat"
|
|
98
|
-
/>,
|
|
99
|
-
);
|
|
100
|
-
open();
|
|
101
|
-
|
|
102
|
-
const search = await screen.findByTestId('cat-search');
|
|
103
|
-
fireEvent.change(search, { target: { value: 'peix' } });
|
|
104
|
-
fireEvent.click(await screen.findByText('Peixes'));
|
|
105
|
-
|
|
106
|
-
expect(onToggle).toHaveBeenCalledWith('peixes', true);
|
|
107
|
-
// Multi-select: the menu stays open, so the search box is still mounted.
|
|
108
|
-
expect(screen.getByTestId('cat-search')).toBeInTheDocument();
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
describe('MultiSelectDropdown stacked trigger accessibility', () => {
|
|
113
|
-
it("names the trigger by the field label AND value so it isn't announced as just its value", () => {
|
|
114
|
-
render(
|
|
115
|
-
<MultiSelectDropdown
|
|
116
|
-
label="Papéis"
|
|
117
|
-
layout="stacked"
|
|
118
|
-
options={MANY_OPTIONS}
|
|
119
|
-
selected={new Set<string>()}
|
|
120
|
-
onToggle={vi.fn()}
|
|
121
|
-
onClear={vi.fn()}
|
|
122
|
-
allLabel="Todas"
|
|
123
|
-
data-testid="roles"
|
|
124
|
-
/>,
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
// The accessible name resolves aria-labelledby to "<label> <value>", so the
|
|
128
|
-
// field name (not just "Todas") distinguishes this trigger from a sibling.
|
|
129
|
-
expect(screen.getByRole('button', { name: 'Papéis Todas' })).toBe(screen.getByTestId('roles'));
|
|
130
|
-
});
|
|
131
|
-
});
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
|
3
|
-
|
|
4
|
-
import { SavedViewsMenu } from "../SavedViewsMenu";
|
|
5
|
-
import type { SavedViewLike } from "../ContentToolbar.types";
|
|
6
|
-
|
|
7
|
-
const views: SavedViewLike[] = [
|
|
8
|
-
{ id: "v1", name: "Meus ativos", shared: false, pinned: true, isDefault: true, isOwner: true },
|
|
9
|
-
{ id: "v2", name: "Da equipe", shared: true, pinned: false, isDefault: false, isOwner: false },
|
|
10
|
-
];
|
|
11
|
-
|
|
12
|
-
function renderMenu(overrides: Partial<React.ComponentProps<typeof SavedViewsMenu>> = {}) {
|
|
13
|
-
const handlers = {
|
|
14
|
-
onApply: vi.fn(),
|
|
15
|
-
onSelectMain: vi.fn(),
|
|
16
|
-
onSaveCurrent: vi.fn(),
|
|
17
|
-
onEdit: vi.fn(),
|
|
18
|
-
onDelete: vi.fn(),
|
|
19
|
-
onSetDefault: vi.fn(),
|
|
20
|
-
onTogglePin: vi.fn(),
|
|
21
|
-
onToggleShare: vi.fn(),
|
|
22
|
-
onManageAll: vi.fn(),
|
|
23
|
-
};
|
|
24
|
-
render(<SavedViewsMenu views={views} testIdPrefix="views" {...handlers} {...overrides} />);
|
|
25
|
-
return handlers;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
describe("SavedViewsMenu", () => {
|
|
29
|
-
it("lists pinned + recent sections and a default badge", () => {
|
|
30
|
-
renderMenu();
|
|
31
|
-
fireEvent.click(screen.getByTestId("views-button"));
|
|
32
|
-
expect(screen.getByTestId("views-section-pinned")).toBeInTheDocument();
|
|
33
|
-
expect(screen.getByTestId("views-section-recent")).toBeInTheDocument();
|
|
34
|
-
expect(screen.getByTestId("views-default-v1")).toBeInTheDocument();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("labels the trigger 'Visão principal' by default and the active view name when set", () => {
|
|
38
|
-
const noop = {
|
|
39
|
-
onApply: vi.fn(),
|
|
40
|
-
onSelectMain: vi.fn(),
|
|
41
|
-
onSaveCurrent: vi.fn(),
|
|
42
|
-
onEdit: vi.fn(),
|
|
43
|
-
onDelete: vi.fn(),
|
|
44
|
-
onSetDefault: vi.fn(),
|
|
45
|
-
onTogglePin: vi.fn(),
|
|
46
|
-
onToggleShare: vi.fn(),
|
|
47
|
-
onManageAll: vi.fn(),
|
|
48
|
-
};
|
|
49
|
-
const { rerender } = render(<SavedViewsMenu views={views} testIdPrefix="views" {...noop} />);
|
|
50
|
-
expect(screen.getByTestId("views-button")).toHaveTextContent("Visão principal");
|
|
51
|
-
rerender(<SavedViewsMenu views={views} activeViewName="Meus ativos" testIdPrefix="views" {...noop} />);
|
|
52
|
-
expect(screen.getByTestId("views-button")).toHaveTextContent("Meus ativos");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("offers a Main vision default that resets to the no-filter view", () => {
|
|
56
|
-
const handlers = renderMenu();
|
|
57
|
-
fireEvent.click(screen.getByTestId("views-button"));
|
|
58
|
-
fireEvent.click(screen.getByTestId("views-main"));
|
|
59
|
-
expect(handlers.onSelectMain).toHaveBeenCalled();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("applies a view when its name is clicked", () => {
|
|
63
|
-
const handlers = renderMenu();
|
|
64
|
-
fireEvent.click(screen.getByTestId("views-button"));
|
|
65
|
-
fireEvent.click(screen.getByTestId("views-apply-v1"));
|
|
66
|
-
expect(handlers.onApply).toHaveBeenCalledWith(expect.objectContaining({ id: "v1" }));
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("shows full owner actions (incl. Excluir) for an owned view", () => {
|
|
70
|
-
renderMenu();
|
|
71
|
-
fireEvent.click(screen.getByTestId("views-button"));
|
|
72
|
-
fireEvent.click(screen.getByTestId("views-kebab-v1"));
|
|
73
|
-
expect(screen.getByTestId("views-item-delete-v1")).toBeInTheDocument();
|
|
74
|
-
expect(screen.getByText("Excluir")).toBeInTheDocument();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("shows apply-only for a non-owned shared view", async () => {
|
|
78
|
-
renderMenu();
|
|
79
|
-
fireEvent.click(screen.getByTestId("views-button"));
|
|
80
|
-
fireEvent.click(screen.getByTestId("views-kebab-v2"));
|
|
81
|
-
expect(screen.getByTestId("views-item-apply-v2")).toBeInTheDocument();
|
|
82
|
-
await waitFor(() => {
|
|
83
|
-
expect(screen.queryByTestId("views-item-delete-v2")).not.toBeInTheDocument();
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("offers save-current and manage-all", () => {
|
|
88
|
-
const handlers = renderMenu();
|
|
89
|
-
fireEvent.click(screen.getByTestId("views-button"));
|
|
90
|
-
fireEvent.click(screen.getByTestId("views-save-current"));
|
|
91
|
-
expect(handlers.onSaveCurrent).toHaveBeenCalled();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("shows an empty hint when there are no views", () => {
|
|
95
|
-
renderMenu({ views: [] });
|
|
96
|
-
fireEvent.click(screen.getByTestId("views-button"));
|
|
97
|
-
expect(within(screen.getByTestId("views-popover")).getByText(/Nenhuma visão salva/i)).toBeInTheDocument();
|
|
98
|
-
});
|
|
99
|
-
});
|