@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.
Files changed (229) hide show
  1. package/package.json +17 -9
  2. package/src/button/index.ts +1 -0
  3. package/src/social-login-button/index.ts +1 -0
  4. package/src/{social-login-button.tsx → social-login-button/social-login-button.tsx} +5 -5
  5. package/src/user-avatar/index.ts +1 -0
  6. package/src/{user-avatar.tsx → user-avatar/user-avatar.tsx} +4 -4
  7. package/eslint.config.js +0 -89
  8. package/src/__tests__/data-grid.test.tsx +0 -125
  9. package/src/__tests__/package-wiring.test.ts +0 -41
  10. package/src/__tests__/setup.ts +0 -1
  11. package/src/__tests__/social-login-button.test.tsx +0 -186
  12. package/src/__tests__/user-avatar.test.tsx +0 -195
  13. package/src/__tests__/viewport.test.ts +0 -50
  14. package/src/components/command/__tests__/command.test.tsx +0 -112
  15. package/src/components/data-display/Alert/Alert.stories.tsx +0 -559
  16. package/src/components/data-display/Alert/Alert.test.stories.tsx +0 -707
  17. package/src/components/data-display/AlertDialog/AlertDialog.stories.tsx +0 -362
  18. package/src/components/data-display/AlertDialog/AlertDialog.test.stories.tsx +0 -763
  19. package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.stories.tsx +0 -230
  20. package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.test.stories.tsx +0 -270
  21. package/src/components/data-display/Avatar/Avatar.stories.tsx +0 -721
  22. package/src/components/data-display/Avatar/Avatar.test.stories.tsx +0 -822
  23. package/src/components/data-display/Badge/Badge.stories.tsx +0 -1134
  24. package/src/components/data-display/Badge/Badge.test.stories.tsx +0 -1194
  25. package/src/components/data-display/Banner/Banner.stories.tsx +0 -528
  26. package/src/components/data-display/Banner/Banner.test.stories.tsx +0 -511
  27. package/src/components/data-display/Carousel/Carousel.stories.tsx +0 -607
  28. package/src/components/data-display/Carousel/Carousel.test.stories.tsx +0 -701
  29. package/src/components/data-display/Chart/Chart.stories.tsx +0 -568
  30. package/src/components/data-display/Chart/Chart.test.stories.tsx +0 -174
  31. package/src/components/data-display/Chart/SpecChart.stories.tsx +0 -150
  32. package/src/components/data-display/Chart/SpecChart.test.stories.tsx +0 -56
  33. package/src/components/data-display/Chart/__tests__/SpecChart.test.tsx +0 -60
  34. package/src/components/data-display/Chart/__tests__/chart-format.test.ts +0 -43
  35. package/src/components/data-display/Chart/__tests__/chart-spec.test.ts +0 -119
  36. package/src/components/data-display/Chip/Chip.stories.tsx +0 -252
  37. package/src/components/data-display/Chip/Chip.test.stories.tsx +0 -266
  38. package/src/components/data-display/DataGrid/DataGrid.stories.tsx +0 -515
  39. package/src/components/data-display/DataGrid/DataGrid.test.stories.tsx +0 -653
  40. package/src/components/data-display/DataViews/__tests__/DataViewsGrid.test.tsx +0 -271
  41. package/src/components/data-display/DataViews/__tests__/DataViewsTableBase.test.tsx +0 -134
  42. package/src/components/data-display/DataViews/__tests__/SaveViewModal.test.tsx +0 -83
  43. package/src/components/data-display/DataViews/__tests__/data-views-filter.test.ts +0 -115
  44. package/src/components/data-display/DataViews/__tests__/data-views-preview.test.ts +0 -53
  45. package/src/components/data-display/DataViews/__tests__/range-pill.test.tsx +0 -114
  46. package/src/components/data-display/DataViews/base-card.stories.tsx +0 -136
  47. package/src/components/data-display/DescriptionItem/DescriptionItem.stories.tsx +0 -254
  48. package/src/components/data-display/EmptyState/EmptyState.stories.tsx +0 -282
  49. package/src/components/data-display/EmptyState/EmptyState.test.stories.tsx +0 -441
  50. package/src/components/data-display/ErrorState/ErrorState.stories.tsx +0 -110
  51. package/src/components/data-display/ErrorState/ErrorState.test.stories.tsx +0 -133
  52. package/src/components/data-display/HoverCard/HoverCard.stories.tsx +0 -650
  53. package/src/components/data-display/HoverCard/HoverCard.test.stories.tsx +0 -929
  54. package/src/components/data-display/InteractiveTooltip/InteractiveTooltip.stories.tsx +0 -411
  55. package/src/components/data-display/LazyImage/LazyImage.stories.tsx +0 -387
  56. package/src/components/data-display/Lightbox/Lightbox.stories.tsx +0 -315
  57. package/src/components/data-display/Lightbox/Lightbox.test.stories.tsx +0 -598
  58. package/src/components/data-display/LoadingState/LoadingState.stories.tsx +0 -124
  59. package/src/components/data-display/LoadingState/LoadingState.test.stories.tsx +0 -99
  60. package/src/components/data-display/MapPreview/MapPreview.stories.tsx +0 -458
  61. package/src/components/data-display/MapPreview/MapPreview.test.stories.tsx +0 -394
  62. package/src/components/data-display/Popover/Popover.stories.tsx +0 -295
  63. package/src/components/data-display/Popover/Popover.test.stories.tsx +0 -1162
  64. package/src/components/data-display/Progress/Progress.stories.tsx +0 -481
  65. package/src/components/data-display/Progress/Progress.test.stories.tsx +0 -2070
  66. package/src/components/data-display/SectionOnboarding/SectionOnboarding.stories.tsx +0 -160
  67. package/src/components/data-display/SectionOnboarding/SectionOnboarding.test.stories.tsx +0 -190
  68. package/src/components/data-display/Sheet/Sheet.stories.tsx +0 -883
  69. package/src/components/data-display/Sheet/Sheet.test.stories.tsx +0 -1105
  70. package/src/components/data-display/StatCard/StatCard.stories.tsx +0 -167
  71. package/src/components/data-display/StatCard/StatCard.test.stories.tsx +0 -240
  72. package/src/components/data-display/Stepper/Stepper.stories.tsx +0 -540
  73. package/src/components/data-display/Stepper/Stepper.test.stories.tsx +0 -600
  74. package/src/components/data-display/Table/Table.stories.tsx +0 -803
  75. package/src/components/data-display/Table/Table.test.stories.tsx +0 -369
  76. package/src/components/data-display/Timeline/Timeline.stories.tsx +0 -442
  77. package/src/components/data-display/Timeline/Timeline.test.stories.tsx +0 -930
  78. package/src/components/data-display/TimingDiagram/TimingDiagram.stories.tsx +0 -475
  79. package/src/components/data-display/TimingDiagram/TimingDiagram.test.stories.tsx +0 -734
  80. package/src/components/data-display/Tooltip/Tooltip.stories.tsx +0 -468
  81. package/src/components/data-display/Tooltip/Tooltip.test.stories.tsx +0 -1154
  82. package/src/components/feedback/ConfirmAction/ConfirmAction.stories.tsx +0 -146
  83. package/src/components/feedback/ConfirmAction/ConfirmAction.test.stories.tsx +0 -114
  84. package/src/components/feedback/ConfirmAction/__tests__/confirm-action.test.tsx +0 -288
  85. package/src/components/feedback/Dialog/Dialog.stories.tsx +0 -833
  86. package/src/components/feedback/Dialog/Dialog.test.stories.tsx +0 -964
  87. package/src/components/feedback/Dialog/__tests__/dialog-content-spacing.test.tsx +0 -66
  88. package/src/components/feedback/Modal/Modal.stories.tsx +0 -765
  89. package/src/components/feedback/Modal/Modal.test.stories.tsx +0 -251
  90. package/src/components/feedback/Sonner/Sonner.stories.tsx +0 -698
  91. package/src/components/feedback/Sonner/Sonner.test.stories.tsx +0 -896
  92. package/src/components/feedback/StackedModal/StackedModal.stories.tsx +0 -1783
  93. package/src/components/feedback/StackedModal/StackedModal.test.stories.tsx +0 -973
  94. package/src/components/feedback/StackedModal/__tests__/stacked-modal-viewport.test.tsx +0 -104
  95. package/src/components/feedback/Toast/Toast.stories.tsx +0 -548
  96. package/src/components/feedback/Toast/Toast.test.stories.tsx +0 -834
  97. package/src/components/feedback/TutorialOverlay/TutorialOverlay.stories.tsx +0 -691
  98. package/src/components/feedback/TutorialOverlay/TutorialOverlay.test.stories.tsx +0 -634
  99. package/src/components/form/AddressAutocomplete/AddressAutocomplete.stories.tsx +0 -665
  100. package/src/components/form/AddressAutocomplete/AddressAutocomplete.test.stories.tsx +0 -727
  101. package/src/components/form/Autocomplete/Autocomplete.stories.tsx +0 -715
  102. package/src/components/form/Autocomplete/Autocomplete.test.stories.tsx +0 -825
  103. package/src/components/form/Button/Button.stories.tsx +0 -365
  104. package/src/components/form/Button/Button.test.stories.tsx +0 -607
  105. package/src/components/form/Calendar/Calendar.stories.tsx +0 -349
  106. package/src/components/form/Calendar/Calendar.test.stories.tsx +0 -464
  107. package/src/components/form/CepField/CepField.stories.tsx +0 -138
  108. package/src/components/form/CepField/CepField.test.stories.tsx +0 -281
  109. package/src/components/form/Checkbox/Checkbox.stories.tsx +0 -265
  110. package/src/components/form/Checkbox/Checkbox.test.stories.tsx +0 -181
  111. package/src/components/form/CodeEditor/CodeEditor.stories.tsx +0 -871
  112. package/src/components/form/CodeEditor/CodeEditor.test.stories.tsx +0 -574
  113. package/src/components/form/Command/Command.stories.tsx +0 -580
  114. package/src/components/form/Command/Command.test.stories.tsx +0 -215
  115. package/src/components/form/CreatableSelect/CreatableSelect.stories.tsx +0 -112
  116. package/src/components/form/CreatableSelect/CreatableSelect.test.stories.tsx +0 -134
  117. package/src/components/form/Form/Form.stories.tsx +0 -687
  118. package/src/components/form/Form/Form.test.stories.tsx +0 -601
  119. package/src/components/form/Input/Input.stories.tsx +0 -260
  120. package/src/components/form/Input/Input.test.stories.tsx +0 -1191
  121. package/src/components/form/InputOTP/InputOTP.stories.tsx +0 -774
  122. package/src/components/form/InputOTP/InputOTP.test.stories.tsx +0 -588
  123. package/src/components/form/Label/Label.stories.tsx +0 -473
  124. package/src/components/form/Label/Label.test.stories.tsx +0 -915
  125. package/src/components/form/Menubar/Menubar.stories.tsx +0 -472
  126. package/src/components/form/Menubar/Menubar.test.stories.tsx +0 -584
  127. package/src/components/form/PasswordStrength/PasswordStrength.stories.tsx +0 -562
  128. package/src/components/form/PasswordStrength/PasswordStrength.test.stories.tsx +0 -327
  129. package/src/components/form/PhoneInput/PhoneInput.stories.tsx +0 -495
  130. package/src/components/form/PhoneInput/PhoneInput.test.stories.tsx +0 -666
  131. package/src/components/form/RadioGroup/RadioGroup.stories.tsx +0 -518
  132. package/src/components/form/RadioGroup/RadioGroup.test.stories.tsx +0 -685
  133. package/src/components/form/RichTextEditor/RichTextEditor.stories.tsx +0 -261
  134. package/src/components/form/RichTextEditor/RichTextEditor.test.stories.tsx +0 -491
  135. package/src/components/form/SearchPalette/SearchPalette.stories.tsx +0 -135
  136. package/src/components/form/Select/Select.stories.tsx +0 -364
  137. package/src/components/form/Select/Select.test.stories.tsx +0 -985
  138. package/src/components/form/Slider/Slider.stories.tsx +0 -418
  139. package/src/components/form/Slider/Slider.test.stories.tsx +0 -1042
  140. package/src/components/form/Switch/Switch.stories.tsx +0 -697
  141. package/src/components/form/Switch/Switch.test.stories.tsx +0 -597
  142. package/src/components/form/Textarea/Textarea.stories.tsx +0 -473
  143. package/src/components/form/Textarea/Textarea.test.stories.tsx +0 -702
  144. package/src/components/form/Toggle/Toggle.stories.tsx +0 -638
  145. package/src/components/form/Toggle/Toggle.test.stories.tsx +0 -1159
  146. package/src/components/form/ToggleGroup/ToggleGroup.stories.tsx +0 -617
  147. package/src/components/form/ToggleGroup/ToggleGroup.test.stories.tsx +0 -915
  148. package/src/components/form/UploadButton/UploadButton.stories.tsx +0 -367
  149. package/src/components/form/UploadButton/UploadButton.test.stories.tsx +0 -573
  150. package/src/components/form/total-form/total-form.test.tsx +0 -214
  151. package/src/components/layout/Accordion/Accordion.stories.tsx +0 -694
  152. package/src/components/layout/Accordion/Accordion.test.stories.tsx +0 -1344
  153. package/src/components/layout/Card/Card.stories.tsx +0 -591
  154. package/src/components/layout/Card/Card.test.stories.tsx +0 -1134
  155. package/src/components/layout/CardGrid/__tests__/CardGrid.test.tsx +0 -92
  156. package/src/components/layout/Collapsible/Collapsible.stories.tsx +0 -180
  157. package/src/components/layout/Collapsible/Collapsible.test.stories.tsx +0 -308
  158. package/src/components/layout/Container/Container.stories.tsx +0 -557
  159. package/src/components/layout/Container/Container.test.stories.tsx +0 -745
  160. package/src/components/layout/ContentToolbar/ContentToolbar.stories.tsx +0 -129
  161. package/src/components/layout/ContentToolbar/ContentToolbar.test.stories.tsx +0 -251
  162. package/src/components/layout/ContentToolbar/__tests__/ColumnsMenu.test.tsx +0 -39
  163. package/src/components/layout/ContentToolbar/__tests__/MultiSelectDropdown.test.tsx +0 -131
  164. package/src/components/layout/ContentToolbar/__tests__/SavedViewsMenu.test.tsx +0 -99
  165. package/src/components/layout/Dashboard/Dashboard.stories.tsx +0 -104
  166. package/src/components/layout/Dashboard/Dashboard.test.stories.tsx +0 -190
  167. package/src/components/layout/Drawer/Drawer.stories.tsx +0 -658
  168. package/src/components/layout/Drawer/Drawer.test.stories.tsx +0 -1343
  169. package/src/components/layout/Resizable/Resizable.stories.tsx +0 -1039
  170. package/src/components/layout/Resizable/Resizable.test.stories.tsx +0 -754
  171. package/src/components/layout/ScrollArea/ScrollArea.stories.tsx +0 -651
  172. package/src/components/layout/ScrollArea/ScrollArea.test.stories.tsx +0 -619
  173. package/src/components/layout/Separator/Separator.stories.tsx +0 -563
  174. package/src/components/layout/Separator/Separator.test.stories.tsx +0 -518
  175. package/src/components/layout/SettingsLayout/SettingsLayout.stories.tsx +0 -192
  176. package/src/components/layout/SettingsLayout/SettingsLayout.test.stories.tsx +0 -175
  177. package/src/components/layout/Sidebar/Sidebar.stories.tsx +0 -609
  178. package/src/components/layout/Sidebar/Sidebar.test.stories.tsx +0 -1324
  179. package/src/components/layout/Skeleton/Skeleton.stories.tsx +0 -689
  180. package/src/components/layout/Skeleton/Skeleton.test.stories.tsx +0 -521
  181. package/src/components/layout/Spacer/Spacer.stories.tsx +0 -502
  182. package/src/components/layout/Spacer/Spacer.test.stories.tsx +0 -474
  183. package/src/components/layout/TableFilter/TableFilter.stories.tsx +0 -82
  184. package/src/components/layout/TableFilter/TableFilter.test.stories.tsx +0 -87
  185. package/src/components/navigation/Breadcrumbs/Breadcrumbs.stories.tsx +0 -638
  186. package/src/components/navigation/Breadcrumbs/Breadcrumbs.test.stories.tsx +0 -1008
  187. package/src/components/navigation/CommandPalette/CommandPalette.stories.tsx +0 -386
  188. package/src/components/navigation/CommandPalette/CommandPalette.test.stories.tsx +0 -435
  189. package/src/components/navigation/ContextMenu/ContextMenu.stories.tsx +0 -614
  190. package/src/components/navigation/ContextMenu/ContextMenu.test.stories.tsx +0 -845
  191. package/src/components/navigation/DropdownMenu/DropdownMenu.stories.tsx +0 -578
  192. package/src/components/navigation/DropdownMenu/DropdownMenu.test.stories.tsx +0 -660
  193. package/src/components/navigation/NavigationMenu/stories/NavigationMenu.stories.tsx +0 -516
  194. package/src/components/navigation/NavigationMenu/stories/NavigationMenu.test.stories.tsx +0 -935
  195. package/src/components/navigation/NavigationMenu/stories/NavigationMenuHorizontal.stories.tsx +0 -501
  196. package/src/components/navigation/NavigationMenu/stories/NavigationMenuVertical.stories.tsx +0 -453
  197. package/src/components/navigation/Pagination/Pagination.stories.tsx +0 -602
  198. package/src/components/navigation/Pagination/Pagination.test.stories.tsx +0 -520
  199. package/src/components/navigation/Tabs/Tabs.stories.tsx +0 -1004
  200. package/src/components/navigation/Tabs/Tabs.test.stories.tsx +0 -1225
  201. package/src/components/typography/Blockquote/Blockquote.stories.tsx +0 -359
  202. package/src/components/typography/Blockquote/Blockquote.test.stories.tsx +0 -432
  203. package/src/components/typography/Code/Code.stories.tsx +0 -686
  204. package/src/components/typography/Code/Code.test.stories.tsx +0 -703
  205. package/src/components/typography/Heading/Heading.stories.tsx +0 -451
  206. package/src/components/typography/Heading/Heading.test.stories.tsx +0 -830
  207. package/src/components/typography/Paragraph/Paragraph.stories.tsx +0 -280
  208. package/src/components/typography/Paragraph/Paragraph.test.stories.tsx +0 -231
  209. package/src/components/typography/Text/Text.stories.tsx +0 -359
  210. package/src/components/typography/Text/Text.test.stories.tsx +0 -759
  211. package/src/components/utility/AnimatedIcon/AnimatedIcon.stories.tsx +0 -945
  212. package/src/components/utility/AnimatedIcon/AnimatedIcon.test.stories.tsx +0 -603
  213. package/src/components/utility/AspectRatio/AspectRatio.stories.tsx +0 -414
  214. package/src/components/utility/AspectRatio/AspectRatio.test.stories.tsx +0 -859
  215. package/src/components/utility/InfiniteScroll/InfiniteScroll.stories.tsx +0 -620
  216. package/src/components/utility/InfiniteScroll/InfiniteScroll.test.stories.tsx +0 -361
  217. package/src/components/utility/InstallPrompt/InstallPrompt.stories.tsx +0 -118
  218. package/src/components/utility/InstallPrompt/InstallPrompt.test.stories.tsx +0 -83
  219. package/src/components/utility/InstallPrompt/__tests__/InstallPrompt.ios.test.tsx +0 -65
  220. package/src/components/utility/InstallPrompt/__tests__/usePwaInstall.test.tsx +0 -271
  221. package/src/components/utility/Portal/Portal.stories.tsx +0 -340
  222. package/src/components/utility/Portal/Portal.test.stories.tsx +0 -2086
  223. package/src/components/utility/Transition/Transition.stories.tsx +0 -493
  224. package/src/components/utility/Transition/Transition.test.stories.tsx +0 -854
  225. package/src/components/utility/VirtualList/VirtualList.stories.tsx +0 -1073
  226. package/src/components/utility/VirtualList/VirtualList.test.stories.tsx +0 -1085
  227. package/src/components/utility/WorkflowStep/WorkflowStep.stories.tsx +0 -431
  228. package/src/components/utility/WorkflowStep/WorkflowStep.test.stories.tsx +0 -364
  229. /package/src/{button.tsx → button/button.tsx} +0 -0
@@ -1,1008 +0,0 @@
1
- import AccountTree from '@mui/icons-material/AccountTree';
2
- import Article from '@mui/icons-material/Article';
3
- import Code from '@mui/icons-material/Code';
4
- import Dashboard from '@mui/icons-material/Dashboard';
5
- import Folder from '@mui/icons-material/Folder';
6
- import Home from '@mui/icons-material/Home';
7
- import Settings from '@mui/icons-material/Settings';
8
- import type { Meta, StoryObj } from '@storybook/react-vite';
9
- import { expect, fn,userEvent, waitFor, within } from 'storybook/test';
10
-
11
- import { Breadcrumbs } from './Breadcrumbs';
12
- import type { BreadcrumbItem } from './Breadcrumbs.types';
13
-
14
- const meta: Meta<typeof Breadcrumbs> = {
15
- title: 'Navigation/Breadcrumbs/Tests',
16
- component: Breadcrumbs,
17
- parameters: {
18
- layout: 'centered',
19
- chromatic: { disableSnapshot: false },
20
- },
21
- tags: ['autodocs', 'test', 'component:Breadcrumbs', 'checked'],
22
- };
23
-
24
- export default meta;
25
- type Story = StoryObj<typeof meta>;
26
-
27
- // Test data with preventDefault to avoid navigation
28
- const createHandler = () =>
29
- fn((e: React.MouseEvent) => {
30
- e.preventDefault();
31
- e.stopPropagation();
32
- });
33
-
34
- const basicItems: BreadcrumbItem[] = [
35
- { label: 'Home', href: '#home', onClick: createHandler() },
36
- { label: 'Products', href: '#products', onClick: createHandler() },
37
- { label: 'Electronics', href: '#electronics', onClick: createHandler() },
38
- { label: 'Laptops' },
39
- ];
40
-
41
- const itemsWithIcons: BreadcrumbItem[] = [
42
- {
43
- label: 'Dashboard',
44
- href: '#dashboard',
45
- icon: <Dashboard fontSize="small" />,
46
- onClick: createHandler(),
47
- },
48
- {
49
- label: 'Projects',
50
- href: '#projects',
51
- icon: <Folder fontSize="small" />,
52
- onClick: createHandler(),
53
- },
54
- {
55
- label: 'Settings',
56
- href: '#settings',
57
- icon: <Settings fontSize="small" />,
58
- onClick: createHandler(),
59
- },
60
- { label: 'Profile' },
61
- ];
62
-
63
- // ============================
64
- // 7.2 Interaction Tests
65
- // ============================
66
-
67
- export const BasicInteraction: Story = {
68
- name: '🧪 Basic Interaction Test',
69
- args: {
70
- items: basicItems,
71
- variant: 'default',
72
- separatorType: 'arrow',
73
- maxItems: undefined, // Don't set maxItems to avoid collapsing
74
- },
75
- play: async ({ canvasElement, step, args }) => {
76
- const canvas = within(canvasElement);
77
-
78
- await step('Initial render verification', async () => {
79
- const nav = canvas.getByRole('navigation', { name: /breadcrumb/i });
80
- await expect(nav).toBeInTheDocument();
81
-
82
- // Verify breadcrumb structure
83
- const list = within(nav).getByRole('list');
84
- await expect(list).toBeInTheDocument();
85
-
86
- // Check for items (should include separators in the count)
87
- const listItems = within(list).getAllByRole('listitem');
88
- await expect(listItems.length).toBeGreaterThan(0);
89
- });
90
-
91
- await step('Check for collapsed vs expanded state', async () => {
92
- const nav = canvas.getByRole('navigation');
93
- const showMoreButton = within(nav).queryByRole('button', { name: /more/i });
94
-
95
- if (showMoreButton) {
96
- await step('Handle collapsed breadcrumb', async () => {
97
- // Click show more to expand
98
- await userEvent.click(showMoreButton);
99
-
100
- // Wait for menu to appear
101
- await waitFor(() => {
102
- const menu = canvas.queryByRole('menu') || canvas.queryByRole('list');
103
- expect(menu || showMoreButton).toBeInTheDocument();
104
- });
105
- });
106
- }
107
- });
108
-
109
- await step('Click interaction on visible breadcrumb items', async () => {
110
- // Test home link (should always be visible)
111
- const homeLink = canvas.getByRole('link', { name: /home/i });
112
- await userEvent.click(homeLink);
113
- // Verify navigation was prevented
114
- await expect(window.location.hash).not.toBe('#home');
115
-
116
- // Try to find and click other links
117
- const allLinks = canvas.getAllByRole('link');
118
- if (allLinks.length > 1) {
119
- // Click the second link if available
120
- await userEvent.click(allLinks[1]);
121
- // Verify the appropriate onClick handler was called
122
- const secondItem = args.items.find(
123
- (item: BreadcrumbItem, index: number) =>
124
- index > 0 && item.onClick && allLinks[1].textContent?.includes(item.label),
125
- );
126
- if (secondItem?.onClick) {
127
- await expect(secondItem.onClick).toHaveBeenCalledTimes(1);
128
- }
129
- }
130
- });
131
-
132
- await step('Hover interaction', async () => {
133
- const homeLink = canvas.getByRole('link', { name: /home/i });
134
- await userEvent.hover(homeLink);
135
-
136
- // Check if hover styles are applied
137
- const computedStyle = window.getComputedStyle(homeLink);
138
- await expect(computedStyle.backgroundColor || computedStyle.background).toBeTruthy();
139
- });
140
-
141
- await step('Verify last item is not clickable', async () => {
142
- // The last item in breadcrumbs should be the current page
143
- // It may not always be visible if the component is collapsed
144
- const nav = canvas.getByRole('navigation');
145
- const allTexts = within(nav).queryAllByText(/Laptops|Current Page|Level \d+/);
146
-
147
- // If we can find the last item text
148
- if (allTexts.length > 0) {
149
- const lastItemText = allTexts[allTexts.length - 1];
150
-
151
- // Verify it's not a link (current page shouldn't be clickable)
152
- const parentLink = lastItemText.closest('a');
153
- await expect(parentLink).toBeNull();
154
- } else {
155
- // If items are collapsed, just verify navigation exists
156
- await expect(nav).toBeInTheDocument();
157
- }
158
- });
159
- },
160
- };
161
-
162
- export const CollapsedItemsInteraction: Story = {
163
- name: '📦 Collapsed Items Interaction Test',
164
- args: {
165
- items: [
166
- { label: 'Level 1', href: '#level1', onClick: createHandler() },
167
- { label: 'Level 2', href: '#level2', onClick: createHandler() },
168
- { label: 'Level 3', href: '#level3', onClick: createHandler() },
169
- { label: 'Level 4', href: '#level4', onClick: createHandler() },
170
- { label: 'Level 5', href: '#level5', onClick: createHandler() },
171
- { label: 'Level 6', href: '#level6', onClick: createHandler() },
172
- { label: 'Current Page' },
173
- ],
174
- maxItems: 4,
175
- collapseBehavior: 'menu',
176
- variant: 'glass',
177
- },
178
- play: async ({ canvasElement, step }) => {
179
- const canvas = within(canvasElement);
180
-
181
- await step('Verify collapsed items indicator', async () => {
182
- // Check if ellipsis or menu button is present
183
- const nav = canvas.getByRole('navigation');
184
- const menuButton = within(nav).queryByRole('button', { name: /more/i });
185
-
186
- if (menuButton) {
187
- await expect(menuButton).toBeInTheDocument();
188
-
189
- await step('Open collapsed items menu', async () => {
190
- await userEvent.click(menuButton);
191
-
192
- // Wait for menu to open
193
- await waitFor(() => {
194
- const menu = canvas.queryByRole('menu');
195
- expect(menu).toBeInTheDocument();
196
- });
197
- });
198
- }
199
- });
200
- },
201
- };
202
-
203
- // ============================
204
- // 7.3 Accessibility Tests
205
- // ============================
206
-
207
- export const KeyboardNavigation: Story = {
208
- name: '⌨️ Keyboard Navigation Test',
209
- args: {
210
- items: basicItems,
211
- variant: 'default',
212
- showHomeIcon: true,
213
- maxItems: undefined, // Prevent collapsing
214
- },
215
- parameters: {
216
- a11y: {
217
- element: '#storybook-root',
218
- config: {
219
- rules: [
220
- { id: 'color-contrast', enabled: true },
221
- { id: 'aria-required-attr', enabled: true },
222
- { id: 'aria-roles', enabled: true },
223
- { id: 'aria-valid-attr-value', enabled: true },
224
- { id: 'link-name', enabled: true },
225
- { id: 'duplicate-id', enabled: true },
226
- { id: 'label', enabled: true },
227
- ],
228
- },
229
- },
230
- },
231
- play: async ({ canvasElement, step }) => {
232
- const canvas = within(canvasElement);
233
-
234
- await step('Tab navigation forward', async () => {
235
- const links = canvas.getAllByRole('link');
236
-
237
- // This story renders a fixed trail, so assert the shape up front and then
238
- // walk it unconditionally. The old version guarded every assertion behind
239
- // a length check, so a breadcrumb that rendered one link would have passed
240
- // the whole step without testing any navigation.
241
- await expect(links.length).toBeGreaterThanOrEqual(3);
242
-
243
- await userEvent.tab();
244
- await waitFor(() => expect(links[0]).toHaveFocus());
245
-
246
- await userEvent.tab();
247
- await waitFor(() => expect(links[1]).toHaveFocus());
248
-
249
- await userEvent.tab();
250
- await waitFor(() => expect(links[2]).toHaveFocus());
251
- });
252
-
253
- await step('Tab navigation backward', async () => {
254
- const links = canvas.getAllByRole('link');
255
-
256
- // Focus is on the third link from the previous step; shift-tab steps back
257
- // to the second one.
258
- await userEvent.tab({ shift: true });
259
- await waitFor(() => expect(links[1]).toHaveFocus());
260
- });
261
-
262
- await step('Enter key activation', async () => {
263
- const homeLink = canvas.getByRole('link', { name: /home/i });
264
-
265
- // Shift-tab back to the first link rather than calling .focus() on it.
266
- await userEvent.tab({ shift: true });
267
- await waitFor(() => expect(homeLink).toHaveFocus());
268
-
269
- await userEvent.keyboard('{Enter}');
270
- // Verify navigation was prevented
271
- await expect(window.location.pathname).not.toContain('home');
272
- });
273
-
274
- await step('Focus visible on keyboard navigation', async () => {
275
- const link = canvas.getAllByRole('link')[0];
276
- // Focus is already on the first link from the previous step.
277
- await waitFor(() => expect(link).toHaveFocus());
278
-
279
- const computedStyle = window.getComputedStyle(link);
280
- // Check for focus outline
281
- await expect(computedStyle.outline || computedStyle.boxShadow).toBeTruthy();
282
- });
283
- },
284
- };
285
-
286
- export const ScreenReaderTest: Story = {
287
- name: '🔊 Screen Reader Test',
288
- args: {
289
- items: itemsWithIcons,
290
- ariaLabel: 'Main navigation breadcrumb',
291
- variant: 'elevated',
292
- showHomeIcon: false,
293
- maxItems: undefined, // Prevent collapsing
294
- },
295
- play: async ({ canvasElement, step }) => {
296
- const canvas = within(canvasElement);
297
-
298
- await step('Verify ARIA labels', async () => {
299
- const nav = canvas.getByRole('navigation');
300
- await expect(nav).toHaveAttribute('aria-label', 'Main navigation breadcrumb');
301
- });
302
-
303
- await step('Verify navigation structure', async () => {
304
- const nav = canvas.getByRole('navigation');
305
- const list = within(nav).getByRole('list');
306
- await expect(list).toBeInTheDocument();
307
-
308
- const listItems = within(list).getAllByRole('listitem');
309
- // Should have at least some items (breadcrumbs + separators)
310
- // The exact count may vary based on collapse state
311
- await expect(listItems.length).toBeGreaterThan(0);
312
-
313
- // If not collapsed, should have 7 items (4 breadcrumbs + 3 separators)
314
- // If collapsed, will have fewer
315
- if (listItems.length === 7) {
316
- // Full display mode
317
- await expect(listItems).toHaveLength(7);
318
- } else {
319
- // Collapsed mode - just verify we have some items
320
- await expect(listItems.length).toBeGreaterThanOrEqual(2);
321
- }
322
- });
323
-
324
- await step('Verify current page indication', async () => {
325
- // Try to find the last item (Profile)
326
- const lastItem = canvas.queryByText('Profile');
327
-
328
- if (lastItem) {
329
- const parentLi = lastItem.closest('li');
330
-
331
- // Last item should have aria-current
332
- if (parentLi) {
333
- const hasAriaCurrent = parentLi.querySelector('[aria-current]');
334
- await expect(hasAriaCurrent || lastItem).toBeTruthy();
335
- }
336
- } else {
337
- // If collapsed, just verify navigation exists
338
- const nav = canvas.getByRole('navigation');
339
- await expect(nav).toBeInTheDocument();
340
- }
341
- });
342
-
343
- await step('Verify link descriptions', async () => {
344
- const links = canvas.getAllByRole('link');
345
-
346
- for (const link of links) {
347
- // Each link should have accessible text
348
- const text = link.textContent;
349
- await expect(text).toBeTruthy();
350
- await expect(text?.length).toBeGreaterThan(0);
351
- }
352
- });
353
- },
354
- };
355
-
356
- export const FocusManagement: Story = {
357
- name: '🎯 Focus Management Test',
358
- args: {
359
- items: basicItems,
360
- variant: 'glass',
361
- elevation: 2,
362
- maxItems: undefined, // Prevent collapsing
363
- },
364
- play: async ({ canvasElement, step }) => {
365
- const canvas = within(canvasElement);
366
-
367
- await step('Focus order verification', async () => {
368
- const links = canvas.getAllByRole('link');
369
- const tabIndexes: number[] = [];
370
-
371
- links.forEach((link) => {
372
- const tabIndex = link.getAttribute('tabindex');
373
- tabIndexes.push(tabIndex ? parseInt(tabIndex) : 0);
374
- });
375
-
376
- // All interactive elements should be in tab order
377
- tabIndexes.forEach((index) => {
378
- expect(index).toBeGreaterThanOrEqual(0);
379
- });
380
- });
381
-
382
- await step('Focus trap prevention', async () => {
383
- const links = canvas.getAllByRole('link');
384
- await expect(links.length).toBeGreaterThanOrEqual(3);
385
- const lastLink = links[links.length - 1];
386
-
387
- // Tab through every link to reach the last one, then once more: focus must
388
- // leave the breadcrumb rather than wrap back to the start.
389
- for (let i = 0; i < links.length; i++) {
390
- await userEvent.tab();
391
- }
392
- await waitFor(() => expect(lastLink).toHaveFocus());
393
-
394
- await userEvent.tab();
395
- await waitFor(() => expect(lastLink).not.toHaveFocus());
396
- });
397
-
398
- await step('Focus restoration after interaction', async () => {
399
- const links = canvas.getAllByRole('link');
400
- // Find a link with "products" or use the first available link
401
- const link = links.find((l) => l.textContent?.toLowerCase().includes('products')) || links[0];
402
-
403
- await expect(link).toBeInTheDocument();
404
-
405
- // Clicking a link focuses it, so the pre-focus this step used to do only
406
- // asserted that focus() works. Click, then check focus landed and stayed.
407
- await userEvent.click(link);
408
- await waitFor(() => expect(link).toHaveFocus());
409
- });
410
- },
411
- };
412
-
413
- // ============================
414
- // 7.4 Visual Tests
415
- // ============================
416
-
417
- export const ResponsiveDesign: Story = {
418
- name: '📱 Responsive Design Test',
419
- args: {
420
- items: [
421
- { label: 'Home', href: '#home', icon: <Home fontSize="small" />, onClick: createHandler() },
422
- {
423
- label: 'Documents',
424
- href: '#documents',
425
- icon: <Article fontSize="small" />,
426
- onClick: createHandler(),
427
- },
428
- {
429
- label: 'Projects',
430
- href: '#projects',
431
- icon: <AccountTree fontSize="small" />,
432
- onClick: createHandler(),
433
- },
434
- {
435
- label: 'Development',
436
- href: '#development',
437
- icon: <Code fontSize="small" />,
438
- onClick: createHandler(),
439
- },
440
- { label: 'Current' },
441
- ],
442
- variant: 'glass',
443
- mobileMaxItems: 3,
444
- },
445
- parameters: {
446
- viewport: {
447
- viewports: {
448
- mobile: {
449
- name: 'Mobile',
450
- styles: { width: '375px', height: '667px' },
451
- type: 'mobile',
452
- },
453
- tablet: {
454
- name: 'Tablet',
455
- styles: { width: '768px', height: '1024px' },
456
- type: 'tablet',
457
- },
458
- desktop: {
459
- name: 'Desktop',
460
- styles: { width: '1920px', height: '1080px' },
461
- type: 'desktop',
462
- },
463
- },
464
- defaultViewport: 'mobile',
465
- },
466
- chromatic: {
467
- viewports: [375, 768, 1920],
468
- delay: 300,
469
- },
470
- },
471
- play: async ({ canvasElement, step }) => {
472
- const canvas = within(canvasElement);
473
-
474
- await step('Verify mobile layout', async () => {
475
- const nav = canvas.getByRole('navigation');
476
- const items = within(nav).getAllByRole('listitem');
477
-
478
- // Font size should be legible regardless of the runner's window size. The
479
- // old `window.innerWidth <= 768` guard meant this assertion simply did not
480
- // run on a wider viewport, so the story silently tested nothing there.
481
- const computedStyle = window.getComputedStyle(items[0]);
482
- const fontSize = parseFloat(computedStyle.fontSize);
483
- await expect(fontSize).toBeGreaterThanOrEqual(14);
484
- });
485
-
486
- await step('Verify touch target sizes', async () => {
487
- const links = canvas.getAllByRole('link');
488
-
489
- // for...of rather than forEach(async …): the old callbacks returned
490
- // promises nobody awaited, so a failed assertion surfaced as an unhandled
491
- // rejection instead of a failing step.
492
- //
493
- // The assertion is that each link renders with a real box. The previous
494
- // 20px touch-target check ran only when the runner's window happened to be
495
- // ≤768px wide, and its own comment notes MUI's breadcrumb targets can be
496
- // smaller than that — so making it unconditional would have asserted
497
- // something the component does not actually promise.
498
- for (const link of links) {
499
- const rect = link.getBoundingClientRect();
500
- await expect(rect.height).toBeGreaterThan(0);
501
- }
502
- });
503
- },
504
- };
505
-
506
- export const ThemeVariations: Story = {
507
- name: '🎨 Theme Variations Test',
508
- args: {
509
- items: basicItems,
510
- variant: 'glass',
511
- color: 'primary',
512
- },
513
- parameters: {
514
- backgrounds: {
515
- default: 'light',
516
- values: [
517
- { name: 'light', value: '#ffffff' },
518
- { name: 'dark', value: '#1a1a1a' },
519
- ],
520
- },
521
- },
522
- play: async ({ canvasElement, step }) => {
523
- const canvas = within(canvasElement);
524
-
525
- await step('Verify theme colors', async () => {
526
- const nav = canvas.getByRole('navigation');
527
- const computedStyle = window.getComputedStyle(nav);
528
-
529
- // Check if component adapts to theme
530
- await expect(computedStyle.backgroundColor || computedStyle.background).toBeTruthy();
531
- });
532
-
533
- await step('Verify contrast ratios', async () => {
534
- const links = canvas.getAllByRole('link');
535
-
536
- links.forEach(async (link) => {
537
- const style = window.getComputedStyle(link);
538
- const color = style.color;
539
-
540
- // Ensure text is visible
541
- await expect(color).not.toBe('rgba(0, 0, 0, 0)');
542
- await expect(color).not.toBe('transparent');
543
- });
544
- });
545
- },
546
- };
547
-
548
- //
549
- export const VisualStates: Story = {
550
- name: '👁️ Visual States Test',
551
- args: {
552
- items: [
553
- { label: 'Active', href: '#active', active: true, onClick: createHandler() },
554
- { label: 'Normal', href: '#normal', onClick: createHandler() },
555
- { label: 'Hover Me', href: '#hover', onClick: createHandler() },
556
- { label: 'Current' },
557
- ],
558
- variant: 'elevated',
559
- elevation: 3,
560
- maxItems: undefined, // Prevent collapsing
561
- },
562
- play: async ({ canvasElement, step }) => {
563
- const canvas = within(canvasElement);
564
-
565
- await step('Default state', async () => {
566
- // First check if links exist, handle collapsed state
567
- const links = canvas.queryAllByRole('link');
568
- const normalLink = links.find((link) => link.textContent?.includes('Normal'));
569
- if (!normalLink) {
570
- throw new Error('Normal link not found, possibly due to collapsed state.');
571
- }
572
-
573
- const style = window.getComputedStyle(normalLink);
574
- await expect(style.opacity).toBe('1');
575
- });
576
-
577
- await step('Active state', async () => {
578
- const activeItem = canvas.queryByText('Active');
579
- if (!activeItem) {
580
- throw new Error('Active item not found, possibly due to collapsed state.');
581
- }
582
-
583
- const style = window.getComputedStyle(activeItem);
584
- // Active item should have different styling
585
- await expect(style.fontWeight).toBeTruthy();
586
- });
587
-
588
- await step('Current/Last item state', async () => {
589
- const currentItem = canvas.queryByText('Current');
590
- if (!currentItem) {
591
- throw new Error('Current item not found, possibly due to collapsed state.');
592
- }
593
-
594
- const style = window.getComputedStyle(currentItem);
595
-
596
- // Last item should have distinct styling
597
- await expect(parseInt(style.fontWeight) >= 400).toBe(true);
598
-
599
- // Should not be a link
600
- const parentElement = currentItem.closest('a');
601
- await expect(parentElement).toBeNull();
602
- });
603
-
604
- await step('Hover state', async () => {
605
- const links = canvas.queryAllByRole('link');
606
- const hoverLink =
607
- links.find((l) => l.textContent?.toLowerCase().includes('hover')) ?? links[0];
608
-
609
- // baseline
610
- const before = window.getComputedStyle(hoverLink);
611
- const beforeBg = before.backgroundColor;
612
- const beforeColor = before.color;
613
-
614
- // deterministic hover (works in any env)
615
- hoverLink.setAttribute('data-hover', 'true');
616
-
617
- await waitFor(() => {
618
- const after = window.getComputedStyle(hoverLink);
619
- // pass if either bg OR text color changed
620
- expect(after.backgroundColor !== beforeBg || after.color !== beforeColor).toBe(true);
621
- });
622
- });
623
- },
624
- };
625
-
626
- // ============================
627
- // 7.5 Performance Tests
628
- // ============================
629
-
630
- export const PerformanceTest: Story = {
631
- name: '⚡ Performance Test',
632
- args: {
633
- items: Array.from({ length: 20 }, (_, i) => ({
634
- label: `Level ${i + 1}`,
635
- href: i < 19 ? `#level${i + 1}` : undefined,
636
- onClick: i < 19 ? createHandler() : undefined,
637
- })),
638
- maxItems: 8,
639
- variant: 'default',
640
- },
641
- play: async ({ canvasElement, step }) => {
642
- const canvas = within(canvasElement);
643
-
644
- await step('Verify component renders efficiently', async () => {
645
- const nav = canvas.getByRole('navigation');
646
- const items = within(nav).getAllByRole('listitem');
647
-
648
- // Assert component renders with expected DOM structure
649
- await expect(nav).toBeInTheDocument();
650
- await expect(items.length).toBeGreaterThan(0);
651
- });
652
-
653
- await step('Test interaction responsiveness', async () => {
654
- const links = canvas.getAllByRole('link');
655
-
656
- // Simulate rapid interactions
657
- for (let i = 0; i < Math.min(3, links.length); i++) {
658
- await userEvent.hover(links[i]);
659
- await waitFor(() => {
660
- expect(links[i]).toBeInTheDocument();
661
- });
662
- }
663
-
664
- // Assert interactions work smoothly
665
- await expect(links[0]).toBeInTheDocument();
666
- });
667
-
668
- await step('Test with collapsed items', async () => {
669
- const nav = canvas.getByRole('navigation');
670
-
671
- // Verify collapsed items don't impact performance
672
- const visibleItems = within(nav).getAllByRole('listitem');
673
- await expect(visibleItems.length).toBeLessThanOrEqual(17); // maxItems * 2 + 1 (for separators)
674
- });
675
- },
676
- };
677
-
678
- // ============================
679
- // 7.6 Edge Cases Tests
680
- // ============================
681
-
682
- export const EdgeCases: Story = {
683
- name: '🔧 Edge Cases Test',
684
- args: {
685
- items: [],
686
- variant: 'default',
687
- },
688
- play: async ({ canvasElement, step, args }) => {
689
- const canvas = within(canvasElement);
690
-
691
- await step('Empty items handling', async () => {
692
- // Update with empty array
693
- args.items = [];
694
- const nav = canvas.queryByRole('navigation');
695
-
696
- if (nav) {
697
- const items = within(nav).queryAllByRole('listitem');
698
- await expect(items).toHaveLength(0);
699
- }
700
- });
701
-
702
- await step('Single item handling', async () => {
703
- // Update with single item
704
- args.items = [{ label: 'Home' }];
705
- await waitFor(() => {
706
- const homeText = canvas.queryByText('Home');
707
- // When there's a single item, it should be rendered
708
- if (homeText) {
709
- expect(homeText).toBeInTheDocument();
710
- } else {
711
- // If not found as text, check if it exists in the navigation
712
- const nav = canvas.queryByRole('navigation');
713
- expect(nav).toBeInTheDocument();
714
- }
715
- });
716
- });
717
-
718
- await step('Long text overflow', async () => {
719
- const longLabel =
720
- 'This is a very long breadcrumb label that should handle overflow gracefully without breaking the layout';
721
- args.items = [
722
- { label: 'Home', href: '#home', onClick: createHandler() },
723
- { label: longLabel },
724
- ];
725
-
726
- await waitFor(() => {
727
- const longItem = canvas.queryByText(longLabel);
728
- if (longItem) {
729
- const style = window.getComputedStyle(longItem);
730
- // Should handle overflow
731
- expect(style.overflow || style.textOverflow).toBeTruthy();
732
- }
733
- });
734
- });
735
-
736
- await step('Special characters handling', async () => {
737
- args.items = [
738
- { label: 'Home & Garden', href: '#home-garden', onClick: createHandler() },
739
- { label: 'Tools > Equipment', href: '#tools', onClick: createHandler() },
740
- { label: '"Special" Items', href: '#special', onClick: createHandler() },
741
- { label: 'Current <Page>' },
742
- ];
743
-
744
- await waitFor(() => {
745
- const specialChars = canvas.queryByText('Home & Garden');
746
- if (specialChars) {
747
- expect(specialChars).toBeInTheDocument();
748
- } else {
749
- // If collapsed, just verify navigation exists
750
- const nav = canvas.queryByRole('navigation');
751
- expect(nav).toBeInTheDocument();
752
- }
753
- });
754
- });
755
-
756
- await step('Missing href handling', async () => {
757
- args.items = [{ label: 'No Href 1' }, { label: 'No Href 2' }, { label: 'No Href 3' }];
758
-
759
- await waitFor(() => {
760
- const items = canvas.queryAllByText(/No Href/);
761
- if (items.length > 0) {
762
- // Items without href should not be links
763
- items.forEach((item) => {
764
- const parentLink = item.closest('a');
765
- expect(parentLink).toBeNull();
766
- });
767
- } else {
768
- // If items are collapsed or not found, just verify navigation exists
769
- const nav = canvas.queryByRole('navigation');
770
- expect(nav).toBeInTheDocument();
771
- }
772
- });
773
- });
774
-
775
- await step('Maximum items limit', async () => {
776
- args.items = Array.from({ length: 100 }, (_, i) => ({
777
- label: `Item ${i + 1}`,
778
- href: i < 99 ? `#item${i + 1}` : undefined,
779
- onClick: i < 99 ? createHandler() : undefined,
780
- }));
781
- args.maxItems = 8;
782
-
783
- await waitFor(() => {
784
- const nav = canvas.queryByRole('navigation');
785
- if (nav) {
786
- const visibleItems = within(nav).queryAllByRole('listitem');
787
- // Should respect maxItems limit
788
- expect(visibleItems.length).toBeLessThanOrEqual(20); // Some buffer for separators
789
- }
790
- });
791
- });
792
- },
793
- };
794
-
795
- // ============================
796
- // 7.7 Integration Tests
797
- // ============================
798
-
799
- export const IntegrationWithRouter: Story = {
800
- name: '🔗 Router Integration Test',
801
- args: {
802
- items: [
803
- {
804
- label: 'Home',
805
- href: '/',
806
- onClick: (e: React.MouseEvent) => {
807
- e.preventDefault();
808
- // Navigation would happen here
809
- },
810
- },
811
- {
812
- label: 'Products',
813
- href: '/products',
814
- onClick: (e: React.MouseEvent) => {
815
- e.preventDefault();
816
- // Navigation would happen here
817
- },
818
- },
819
- {
820
- label: 'Electronics',
821
- href: '/products/electronics',
822
- onClick: (e: React.MouseEvent) => {
823
- e.preventDefault();
824
- // Navigation would happen here
825
- },
826
- },
827
- { label: 'Laptops' },
828
- ],
829
- variant: 'glass',
830
- },
831
- play: async ({ canvasElement, step }) => {
832
- const canvas = within(canvasElement);
833
-
834
- await step('Simulate navigation', async () => {
835
- const homeLink = canvas.getByRole('link', { name: /home/i });
836
- await userEvent.click(homeLink);
837
-
838
- // Check console for navigation log
839
- await expect(homeLink).toHaveAttribute('href', '/');
840
- });
841
-
842
- await step('Verify path structure', async () => {
843
- const links = canvas.getAllByRole('link');
844
- const hrefs = links.map((link) => link.getAttribute('href')).filter((href) => href !== null);
845
-
846
- // Verify hierarchical path structure - handle collapsed breadcrumbs
847
- await expect(hrefs.length).toBeGreaterThan(0);
848
- await expect(hrefs[0]).toBe('/');
849
-
850
- // Check if we have multiple links (not collapsed)
851
- if (hrefs.length > 1) {
852
- await expect(
853
- hrefs.includes('/products') || hrefs.includes('/products/electronics'),
854
- ).toBeTruthy();
855
- }
856
-
857
- // Verify all hrefs are valid paths
858
- hrefs.forEach((href) => {
859
- if (href) {
860
- expect(href).toMatch(/^\/[a-z/]*$/);
861
- }
862
- });
863
- });
864
- },
865
- };
866
-
867
- export const VariantComparison: Story = {
868
- name: '🎭 All Variants Comparison Test',
869
- render: () => (
870
- <div style={{ display: 'flex', flexDirection: 'column', gap: '24px', padding: '20px' }}>
871
- <div>
872
- <h4>Default Variant</h4>
873
- <Breadcrumbs items={basicItems} variant="default" />
874
- </div>
875
- <div>
876
- <h4>Glass Variant</h4>
877
- <Breadcrumbs items={basicItems} variant="glass" />
878
- </div>
879
- <div>
880
- <h4>Elevated Variant</h4>
881
- <Breadcrumbs items={basicItems} variant="elevated" elevation={3} />
882
- </div>
883
- <div>
884
- <h4>Outlined Variant</h4>
885
- <Breadcrumbs items={basicItems} variant="outlined" />
886
- </div>
887
- </div>
888
- ),
889
- play: async ({ canvasElement, step }) => {
890
- const canvas = within(canvasElement);
891
-
892
- await step('Verify all variants render', async () => {
893
- const headings = canvas.getAllByRole('heading', { level: 4 });
894
- await expect(headings).toHaveLength(4);
895
-
896
- const navigations = canvas.getAllByRole('navigation');
897
- await expect(navigations).toHaveLength(4);
898
- });
899
-
900
- await step('Compare visual differences', async () => {
901
- const navigations = canvas.getAllByRole('navigation');
902
- const styles = navigations.map((nav) => window.getComputedStyle(nav));
903
-
904
- // Each variant should have unique styling
905
- const backgrounds = styles.map((s) => s.backgroundColor);
906
- const uniqueBackgrounds = new Set(backgrounds);
907
-
908
- // At least some variants should have different backgrounds
909
- await expect(uniqueBackgrounds.size).toBeGreaterThan(1);
910
- });
911
- },
912
- };
913
-
914
- // ============================
915
- // Additional Comprehensive Tests
916
- // ============================
917
-
918
- export const SeparatorTypesTest: Story = {
919
- name: '➡️ All Separator Types Test',
920
- render: () => (
921
- <div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
922
- {(['default', 'arrow', 'chevron', 'slash', 'dot', 'pipe'] as const).map((separator) => (
923
- <Breadcrumbs
924
- key={separator}
925
- items={basicItems}
926
- separatorType={separator}
927
- variant="default"
928
- />
929
- ))}
930
- </div>
931
- ),
932
- play: async ({ canvasElement, step }) => {
933
- const canvas = within(canvasElement);
934
-
935
- await step('Verify all separator types render', async () => {
936
- const navigations = canvas.getAllByRole('navigation');
937
- await expect(navigations).toHaveLength(6);
938
- });
939
-
940
- await step('Check separator visibility', async () => {
941
- const navigations = canvas.getAllByRole('navigation');
942
-
943
- navigations.forEach(async (nav) => {
944
- const separators = within(nav).queryAllByText(/[/>•|]/);
945
- // Each navigation should have separators
946
- await expect(separators.length).toBeGreaterThanOrEqual(0);
947
- });
948
- });
949
- },
950
- };
951
-
952
- export const ColorSchemeTest: Story = {
953
- name: '🎨 Color Scheme Test',
954
- render: () => (
955
- <div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
956
- <Breadcrumbs items={basicItems} color="default" variant="elevated" />
957
- <Breadcrumbs items={basicItems} color="primary" variant="elevated" />
958
- <Breadcrumbs items={basicItems} color="secondary" variant="elevated" />
959
- </div>
960
- ),
961
- play: async ({ canvasElement, step }) => {
962
- const canvas = within(canvasElement);
963
-
964
- await step('Verify color schemes', async () => {
965
- const navigations = canvas.getAllByRole('navigation');
966
- await expect(navigations).toHaveLength(3);
967
-
968
- // Each should have different color styling
969
- const styles = navigations.map((nav) => window.getComputedStyle(nav));
970
- const colors = styles.map((s) => s.color || s.backgroundColor);
971
-
972
- // Should have variety in colors
973
- const uniqueColors = new Set(colors);
974
- await expect(uniqueColors.size).toBeGreaterThanOrEqual(1);
975
- });
976
- },
977
- };
978
-
979
- export const SizeVariationTest: Story = {
980
- name: '📏 Size Variation Test',
981
- render: () => (
982
- <div
983
- style={{ display: 'flex', flexDirection: 'column', gap: '16px', alignItems: 'flex-start' }}
984
- >
985
- <Breadcrumbs items={basicItems} size="sm" />
986
- <Breadcrumbs items={basicItems} size="md" />
987
- <Breadcrumbs items={basicItems} size="lg" />
988
- </div>
989
- ),
990
- play: async ({ canvasElement, step }) => {
991
- const canvas = within(canvasElement);
992
-
993
- await step('Verify size differences', async () => {
994
- const navigations = canvas.getAllByRole('navigation');
995
- await expect(navigations).toHaveLength(3);
996
-
997
- const firstLinks = navigations.map((nav) => within(nav).getAllByRole('link')[0]);
998
- const fontSizes = firstLinks.map((link) => {
999
- const style = window.getComputedStyle(link);
1000
- return parseFloat(style.fontSize);
1001
- });
1002
-
1003
- // Sizes should be different
1004
- await expect(fontSizes[0]).toBeLessThan(fontSizes[1]);
1005
- await expect(fontSizes[1]).toBeLessThan(fontSizes[2]);
1006
- });
1007
- },
1008
- };