@12-apps/ui 1.4.1 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/package.json +17 -8
  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 -77
  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 -753
  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 -503
  27. package/src/components/data-display/Carousel/Carousel.stories.tsx +0 -607
  28. package/src/components/data-display/Carousel/Carousel.test.stories.tsx +0 -691
  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 -1101
  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 -955
  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 -975
  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 -909
  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 -918
  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 -750
  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 -472
  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 -762
  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,727 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { expect, fn,Mock,userEvent, waitFor, within } from 'storybook/test';
3
-
4
- import { AddressAutocomplete } from './AddressAutocomplete';
5
-
6
- const meta: Meta<typeof AddressAutocomplete> = {
7
- title: 'Form/AddressAutocomplete/Tests',
8
- component: AddressAutocomplete,
9
- parameters: {
10
- layout: 'centered',
11
- chromatic: { disableSnapshot: false },
12
- },
13
- tags: ['autodocs', 'test', 'component:AddressAutocomplete'],
14
- };
15
-
16
- export default meta;
17
- type Story = StoryObj<typeof meta>;
18
-
19
- // Basic Interaction Test - Tests autocomplete suggestions appear
20
- export const BasicInteraction: Story = {
21
- args: {
22
- label: 'Address',
23
- placeholder: 'Enter address...',
24
- googleMapsApiKey: 'demo-key',
25
- onSelect: fn(),
26
- },
27
- play: async ({ canvasElement, args }) => {
28
- const canvas = within(canvasElement);
29
-
30
- try {
31
- // Wait for component to finish loading, then find the input field
32
- const input = await canvas.findByPlaceholderText('Enter address...') as HTMLInputElement;
33
- await expect(input).toBeInTheDocument();
34
- await expect(input).not.toBeDisabled();
35
-
36
- // Type in the input to trigger autocomplete
37
- await userEvent.type(input, '123 main');
38
- await expect(input).toHaveValue('123 main');
39
-
40
- // Wait for autocomplete suggestions to appear
41
- // Note: suggestions are portaled to document.body, not in canvas
42
- const body = within(document.body);
43
- await waitFor(
44
- () => {
45
- const firstSuggestion = body.getByTestId('address-suggestion-0');
46
- expect(firstSuggestion).toBeInTheDocument();
47
- },
48
- { timeout: 2000 },
49
- );
50
-
51
- // Verify first suggestion contains main street text
52
- const firstSuggestion = body.getByTestId('address-suggestion-0');
53
- await expect(firstSuggestion).toBeInTheDocument();
54
- await expect(firstSuggestion.textContent).toContain('Main Street');
55
-
56
- // Click on the first suggestion
57
- await userEvent.click(firstSuggestion);
58
-
59
- // Verify the callback was called with address details
60
- await waitFor(() => {
61
- expect(args.onSelect).toHaveBeenCalledWith(
62
- expect.objectContaining({
63
- formatted: expect.stringContaining('Main Street'),
64
- street: expect.stringContaining('Main Street'),
65
- coordinates: expect.objectContaining({
66
- lat: expect.any(Number),
67
- lng: expect.any(Number),
68
- }),
69
- }),
70
- );
71
- });
72
-
73
- // Verify input shows the formatted address
74
- await waitFor(() => {
75
- expect(input.value).toContain('Main Street');
76
- });
77
-
78
- // Set status to pass
79
- const statusElement = document.createElement('div');
80
- statusElement.setAttribute('aria-label', 'Status of the test run');
81
- statusElement.textContent = 'PASS';
82
- canvasElement.appendChild(statusElement);
83
- } catch (error) {
84
- const statusElement = document.createElement('div');
85
- statusElement.setAttribute('aria-label', 'Status of the test run');
86
- statusElement.textContent = 'FAIL';
87
- canvasElement.appendChild(statusElement);
88
- throw error;
89
- }
90
- },
91
- };
92
-
93
- // Form Interaction Test - Tests address selection and data extraction
94
- export const FormInteraction: Story = {
95
- args: {
96
- label: 'Delivery Address',
97
- placeholder: 'Enter delivery address...',
98
- googleMapsApiKey: 'demo-key',
99
- required: true,
100
- onSelect: fn(),
101
- },
102
- play: async ({ canvasElement, args }) => {
103
- const canvas = within(canvasElement);
104
-
105
- try {
106
- // Wait for component to finish loading, then find the input field
107
- const input = await canvas.findByPlaceholderText('Enter delivery address...');
108
- await expect(input).toBeInTheDocument();
109
- await expect(input).not.toBeDisabled();
110
-
111
- // Verify required attribute
112
- const label = canvas.getByText('Delivery Address');
113
- await expect(label).toBeInTheDocument();
114
-
115
- // Type to trigger suggestions
116
- await userEvent.type(input, '456 oak');
117
- await expect(input).toHaveValue('456 oak');
118
-
119
- // Wait for autocomplete suggestions
120
- // Note: suggestions are portaled to document.body, not in canvas
121
- const body = within(document.body);
122
- await waitFor(
123
- () => {
124
- const firstSuggestion = body.getByTestId('address-suggestion-0');
125
- expect(firstSuggestion).toBeInTheDocument();
126
- },
127
- { timeout: 1500 },
128
- );
129
-
130
- // Find and click the New York address (Oak Avenue)
131
- // Mock data returns Oak Avenue as second suggestion for 'oak'
132
- const oakSuggestion = body.getByTestId('address-suggestion-0');
133
- await expect(oakSuggestion).toBeInTheDocument();
134
- await expect(oakSuggestion.textContent).toContain('Oak Avenue');
135
- await userEvent.click(oakSuggestion);
136
-
137
- // Verify the onSelect callback was called with address details
138
- await waitFor(() => {
139
- expect(args.onSelect).toHaveBeenCalledWith(
140
- expect.objectContaining({
141
- formatted: expect.stringContaining('456 Oak Avenue'),
142
- street: expect.stringContaining('Oak Avenue'),
143
- city: 'New York',
144
- state: 'New York',
145
- country: 'United States',
146
- postalCode: '10001',
147
- coordinates: expect.objectContaining({
148
- lat: expect.any(Number),
149
- lng: expect.any(Number),
150
- }),
151
- }),
152
- );
153
- });
154
-
155
- // Verify input shows the formatted address
156
- await waitFor(() => {
157
- expect(input).toHaveValue('456 Oak Avenue, New York, NY 10001, USA');
158
- });
159
-
160
- // Set status to pass
161
- const statusElement = document.createElement('div');
162
- statusElement.setAttribute('aria-label', 'Status of the test run');
163
- statusElement.textContent = 'PASS';
164
- canvasElement.appendChild(statusElement);
165
- } catch (error) {
166
- const statusElement = document.createElement('div');
167
- statusElement.setAttribute('aria-label', 'Status of the test run');
168
- statusElement.textContent = 'FAIL';
169
- canvasElement.appendChild(statusElement);
170
- throw error;
171
- }
172
- },
173
- };
174
-
175
- // Keyboard Navigation Test - Tests keyboard navigation through suggestions
176
- export const KeyboardNavigation: Story = {
177
- args: {
178
- label: 'Navigate with keyboard',
179
- placeholder: 'Use Tab and Enter...',
180
- googleMapsApiKey: 'demo-key',
181
- onSelect: fn(),
182
- },
183
- play: async ({ canvasElement, args }) => {
184
- const canvas = within(canvasElement);
185
-
186
- try {
187
- // Wait for component to finish loading, then find the input
188
- const input = await canvas.findByPlaceholderText('Use Tab and Enter...');
189
- await expect(input).not.toBeDisabled();
190
-
191
- // Focus the input the way a user would
192
- await userEvent.click(input);
193
- await waitFor(() => expect(input).toHaveFocus());
194
-
195
- // Type to trigger suggestions
196
- await userEvent.type(input, 'main');
197
-
198
- // Wait for suggestions to appear
199
- // Note: suggestions are portaled to document.body, not in canvas
200
- // With optimized mock delays: 300ms debounce + 100ms mock API = ~400ms + overhead
201
- const body = within(document.body);
202
- await waitFor(
203
- () => {
204
- const firstSuggestion = body.getByTestId('address-suggestion-0');
205
- expect(firstSuggestion).toBeInTheDocument();
206
- },
207
- { timeout: 1500 },
208
- );
209
-
210
- // Test keyboard navigation (arrow keys)
211
- await userEvent.keyboard('{ArrowDown}');
212
- await userEvent.keyboard('{ArrowUp}');
213
- await userEvent.keyboard('{ArrowDown}');
214
-
215
- // Try to select with Enter key
216
- await userEvent.keyboard('{Enter}');
217
-
218
- // Selection resolves the place asynchronously, so wait on the callback
219
- // rather than on the clock.
220
- await waitFor(() => expect(args.onSelect).toHaveBeenCalled());
221
-
222
- // Test Escape key closes suggestions
223
- await userEvent.clear(input);
224
- await userEvent.type(input, 'main');
225
- await waitFor(
226
- () => {
227
- const firstSuggestion = body.getByTestId('address-suggestion-0');
228
- expect(firstSuggestion).toBeInTheDocument();
229
- },
230
- { timeout: 2000 },
231
- );
232
-
233
- await userEvent.keyboard('{Escape}');
234
- await waitFor(
235
- () => {
236
- const firstSuggestion = body.queryByTestId('address-suggestion-0');
237
- expect(firstSuggestion).not.toBeInTheDocument();
238
- },
239
- { timeout: 1000 },
240
- );
241
-
242
- // Set status to pass
243
- const statusElement = document.createElement('div');
244
- statusElement.setAttribute('aria-label', 'Status of the test run');
245
- statusElement.textContent = 'PASS';
246
- canvasElement.appendChild(statusElement);
247
- } catch (error) {
248
- const statusElement = document.createElement('div');
249
- statusElement.setAttribute('aria-label', 'Status of the test run');
250
- statusElement.textContent = 'FAIL';
251
- canvasElement.appendChild(statusElement);
252
- throw error;
253
- }
254
- },
255
- };
256
-
257
- // Screen Reader Test
258
- export const ScreenReaderTest: Story = {
259
- args: {
260
- label: 'Accessible Address',
261
- placeholder: 'Screen reader friendly...',
262
- googleMapsApiKey: 'demo-key',
263
- helperText: 'Enter your complete address',
264
- onSelect: fn(),
265
- },
266
- play: async ({ canvasElement }) => {
267
- const canvas = within(canvasElement);
268
-
269
- try {
270
- // First wait for component to finish loading
271
- const input = await canvas.findByPlaceholderText('Screen reader friendly...');
272
- await expect(input).not.toBeDisabled();
273
-
274
- // Now check for combobox role after loading is complete
275
- await waitFor(() => {
276
- const inputField = canvas.getByRole('combobox', { name: /accessible address/i });
277
- expect(inputField).toBeInTheDocument();
278
- });
279
-
280
- const inputField = canvas.getByRole('combobox', { name: /accessible address/i });
281
- await expect(inputField).toHaveAttribute('type', 'text');
282
-
283
- // Check for helper text
284
- const helperText = canvas.getByText('Enter your complete address');
285
- await expect(helperText).toBeInTheDocument();
286
-
287
- // Set status to pass
288
- const statusElement = document.createElement('div');
289
- statusElement.setAttribute('aria-label', 'Status of the test run');
290
- statusElement.textContent = 'PASS';
291
- canvasElement.appendChild(statusElement);
292
- } catch (error) {
293
- const statusElement = document.createElement('div');
294
- statusElement.setAttribute('aria-label', 'Status of the test run');
295
- statusElement.textContent = 'FAIL';
296
- canvasElement.appendChild(statusElement);
297
- throw error;
298
- }
299
- },
300
- };
301
-
302
- // Focus Management Test
303
- export const FocusManagementTest: Story = {
304
- args: {
305
- label: 'Focus Test',
306
- placeholder: 'Test focus behavior...',
307
- googleMapsApiKey: 'demo-key',
308
- onSelect: fn(),
309
- },
310
- play: async ({ canvasElement }) => {
311
- const canvas = within(canvasElement);
312
-
313
- try {
314
- const input = await canvas.findByPlaceholderText('Test focus behavior...');
315
- await expect(input).not.toBeDisabled();
316
-
317
- // Clicking focuses the field and tabbing away releases it. The DOM
318
- // focus()/blur() calls this used to make asserted the browser's own API
319
- // rather than the component's focus handling.
320
- await userEvent.click(input);
321
- await waitFor(() => expect(input).toHaveFocus());
322
-
323
- await userEvent.tab();
324
- await waitFor(() => expect(input).not.toHaveFocus());
325
-
326
- // Focus again and type
327
- await userEvent.click(input);
328
- await userEvent.type(input, 'Focus test');
329
- await expect(input).toHaveValue('Focus test');
330
-
331
- // Set status to pass
332
- const statusElement = document.createElement('div');
333
- statusElement.setAttribute('aria-label', 'Status of the test run');
334
- statusElement.textContent = 'PASS';
335
- canvasElement.appendChild(statusElement);
336
- } catch (error) {
337
- const statusElement = document.createElement('div');
338
- statusElement.setAttribute('aria-label', 'Status of the test run');
339
- statusElement.textContent = 'FAIL';
340
- canvasElement.appendChild(statusElement);
341
- throw error;
342
- }
343
- },
344
- };
345
-
346
- // Responsive Design Test
347
- export const ResponsiveDesignTest: Story = {
348
- args: {
349
- label: 'Responsive Address',
350
- placeholder: 'Adapts to screen size...',
351
- fullWidth: true,
352
- googleMapsApiKey: 'demo-key',
353
- onSelect: fn(),
354
- },
355
- parameters: {
356
- viewport: {
357
- viewports: {
358
- mobile: {
359
- name: 'Mobile',
360
- styles: { width: '375px', height: '667px' },
361
- },
362
- tablet: {
363
- name: 'Tablet',
364
- styles: { width: '768px', height: '1024px' },
365
- },
366
- },
367
- defaultViewport: 'mobile',
368
- },
369
- },
370
- play: async ({ canvasElement }) => {
371
- const canvas = within(canvasElement);
372
-
373
- try {
374
- // Check component renders in mobile view
375
- const input = await canvas.findByPlaceholderText('Adapts to screen size...');
376
- await expect(input).toBeInTheDocument();
377
- await expect(input).not.toBeDisabled();
378
-
379
- // Verify full width behavior
380
- const container = input.closest('.MuiTextField-root');
381
- await expect(container).toBeInTheDocument();
382
-
383
- // Set status to pass
384
- const statusElement = document.createElement('div');
385
- statusElement.setAttribute('aria-label', 'Status of the test run');
386
- statusElement.textContent = 'PASS';
387
- canvasElement.appendChild(statusElement);
388
- } catch (error) {
389
- const statusElement = document.createElement('div');
390
- statusElement.setAttribute('aria-label', 'Status of the test run');
391
- statusElement.textContent = 'FAIL';
392
- canvasElement.appendChild(statusElement);
393
- throw error;
394
- }
395
- },
396
- };
397
-
398
- // Theme Variations Test
399
- export const ThemeVariationsTest: Story = {
400
- args: {
401
- variant: 'glass',
402
- label: 'Glass Theme',
403
- placeholder: 'Glass effect...',
404
- googleMapsApiKey: 'demo-key',
405
- onSelect: fn(),
406
- },
407
- parameters: {
408
- backgrounds: {
409
- default: 'gradient',
410
- values: [
411
- {
412
- name: 'gradient',
413
- value: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
414
- },
415
- ],
416
- },
417
- },
418
- play: async ({ canvasElement }) => {
419
- const canvas = within(canvasElement);
420
-
421
- try {
422
- // Verify glass variant renders
423
- const input = await canvas.findByPlaceholderText('Glass effect...');
424
- await expect(input).toBeInTheDocument();
425
- await expect(input).not.toBeDisabled();
426
-
427
- // Check for glass styling elements
428
- const container = input.closest('.MuiAutocomplete-root');
429
- await expect(container).toBeInTheDocument();
430
-
431
- // Set status to pass
432
- const statusElement = document.createElement('div');
433
- statusElement.setAttribute('aria-label', 'Status of the test run');
434
- statusElement.textContent = 'PASS';
435
- canvasElement.appendChild(statusElement);
436
- } catch (error) {
437
- const statusElement = document.createElement('div');
438
- statusElement.setAttribute('aria-label', 'Status of the test run');
439
- statusElement.textContent = 'FAIL';
440
- canvasElement.appendChild(statusElement);
441
- throw error;
442
- }
443
- },
444
- };
445
-
446
- // Visual States Test
447
- export const VisualStatesTest: Story = {
448
- args: {
449
- label: 'Visual States',
450
- placeholder: 'Test visual states...',
451
- googleMapsApiKey: 'demo-key',
452
- onSelect: fn(),
453
- },
454
- play: async ({ canvasElement }) => {
455
- const canvas = within(canvasElement);
456
-
457
- try {
458
- const input = await canvas.findByPlaceholderText('Test visual states...');
459
- await expect(input).not.toBeDisabled();
460
-
461
- // Test hover state
462
- await userEvent.hover(input);
463
- await waitFor(() => expect(input).toBeInTheDocument());
464
-
465
- // Test focus state
466
- await userEvent.click(input);
467
- await waitFor(() => expect(input).toHaveFocus());
468
-
469
- // Test typing state
470
- await userEvent.type(input, 'Testing');
471
- await expect(input).toHaveValue('Testing');
472
-
473
- // Set status to pass
474
- const statusElement = document.createElement('div');
475
- statusElement.setAttribute('aria-label', 'Status of the test run');
476
- statusElement.textContent = 'PASS';
477
- canvasElement.appendChild(statusElement);
478
- } catch (error) {
479
- const statusElement = document.createElement('div');
480
- statusElement.setAttribute('aria-label', 'Status of the test run');
481
- statusElement.textContent = 'FAIL';
482
- canvasElement.appendChild(statusElement);
483
- throw error;
484
- }
485
- },
486
- };
487
-
488
- // Performance Test
489
- export const PerformanceTest: Story = {
490
- args: {
491
- label: 'Performance Test',
492
- placeholder: 'Testing performance...',
493
- googleMapsApiKey: 'demo-key',
494
- onSelect: fn(),
495
- },
496
- play: async ({ canvasElement }) => {
497
- const canvas = within(canvasElement);
498
-
499
- try {
500
- const startTime = window.performance.now();
501
-
502
- // Find and interact with input
503
- const input = await canvas.findByPlaceholderText('Testing performance...');
504
- await expect(input).toBeInTheDocument();
505
- await expect(input).not.toBeDisabled();
506
-
507
- // Rapid typing test
508
- await userEvent.type(input, 'Performance test address input');
509
-
510
- // Clear and retype
511
- await userEvent.clear(input);
512
- await userEvent.type(input, 'Second performance test');
513
-
514
- const endTime = window.performance.now();
515
- const duration = endTime - startTime;
516
-
517
- // Performance should be under 3 seconds
518
- await expect(duration).toBeLessThan(3000);
519
-
520
- // Set status to pass
521
- const statusElement = document.createElement('div');
522
- statusElement.setAttribute('aria-label', 'Status of the test run');
523
- statusElement.textContent = 'PASS';
524
- canvasElement.appendChild(statusElement);
525
- } catch (error) {
526
- const statusElement = document.createElement('div');
527
- statusElement.setAttribute('aria-label', 'Status of the test run');
528
- statusElement.textContent = 'FAIL';
529
- canvasElement.appendChild(statusElement);
530
- throw error;
531
- }
532
- },
533
- };
534
-
535
- // Edge Cases Test - Tests error handling and edge cases
536
- export const EdgeCasesTest: Story = {
537
- args: {
538
- label: 'Edge Cases',
539
- placeholder: 'Test edge cases...',
540
- googleMapsApiKey: 'demo-key',
541
- onSelect: fn(),
542
- },
543
- play: async ({ canvasElement }) => {
544
- const canvas = within(canvasElement);
545
- // Note: suggestions are portaled to document.body, not in canvas
546
- const body = within(document.body);
547
-
548
- try {
549
- const input = await canvas.findByPlaceholderText('Test edge cases...');
550
- await expect(input).not.toBeDisabled();
551
-
552
- // Test empty input doesn't trigger suggestions
553
- await expect(input).toHaveValue('');
554
- await waitFor(() => {
555
- const initialSuggestion = body.queryByTestId('address-suggestion-0');
556
- expect(initialSuggestion).not.toBeInTheDocument();
557
- });
558
-
559
- // Test minimum characters requirement (less than 3 chars)
560
- await userEvent.type(input, 'ab');
561
- await waitFor(
562
- () => {
563
- // Check that no suggestions appear for less than 3 characters
564
- const suggestion = body.queryByTestId('address-suggestion-0');
565
- expect(suggestion).not.toBeInTheDocument();
566
- },
567
- { timeout: 1000 },
568
- );
569
-
570
- // Clear and test no results scenario
571
- await userEvent.clear(input);
572
- await userEvent.type(input, 'zzzzzzzzzzz');
573
- await waitFor(
574
- () => {
575
- // With invalid search, no suggestions should appear
576
- const suggestion = body.queryByTestId('address-suggestion-0');
577
- expect(suggestion).not.toBeInTheDocument();
578
- },
579
- { timeout: 2000 },
580
- );
581
-
582
- // Test reasonable length input that should find matches
583
- await userEvent.clear(input);
584
- await userEvent.type(input, 'main street');
585
- await waitFor(
586
- () => {
587
- const firstSuggestion = body.getByTestId('address-suggestion-0');
588
- expect(firstSuggestion).toBeInTheDocument();
589
- },
590
- { timeout: 2000 },
591
- );
592
-
593
- // Test special characters in search
594
- await userEvent.clear(input);
595
- await userEvent.type(input, '123 main & oak');
596
- await expect(input).toHaveValue('123 main & oak');
597
-
598
- // Test numbers in address (with enough characters to trigger search)
599
- await userEvent.clear(input);
600
- await userEvent.type(input, '123 main');
601
- await waitFor(
602
- async () => {
603
- const firstSuggestion = await body.findByTestId('address-suggestion-0');
604
- expect(firstSuggestion).toBeInTheDocument();
605
- },
606
- { timeout: 3000 },
607
- );
608
-
609
- // Set status to pass
610
- const statusElement = document.createElement('div');
611
- statusElement.setAttribute('aria-label', 'Status of the test run');
612
- statusElement.textContent = 'PASS';
613
- canvasElement.appendChild(statusElement);
614
- } catch (error) {
615
- const statusElement = document.createElement('div');
616
- statusElement.setAttribute('aria-label', 'Status of the test run');
617
- statusElement.textContent = 'FAIL';
618
- canvasElement.appendChild(statusElement);
619
- throw error;
620
- }
621
- },
622
- };
623
-
624
- // Integration Test - Tests geolocation and current location feature
625
- export const IntegrationTest: Story = {
626
- args: {
627
- label: 'Integration Test',
628
- placeholder: 'Test with other components...',
629
- googleMapsApiKey: 'demo-key',
630
- error: false,
631
- helperText: 'Helper text for integration',
632
- required: true,
633
- fullWidth: true,
634
- getCurrentLocation: true,
635
- onSelect: fn(),
636
- },
637
- play: async ({ canvasElement, args }) => {
638
- const canvas = within(canvasElement);
639
- // Note: suggestions are portaled to document.body, not in canvas
640
- const body = within(document.body);
641
-
642
- try {
643
- // Test all props work together
644
- const input = await canvas.findByPlaceholderText('Test with other components...') as HTMLInputElement;
645
- await expect(input).toBeInTheDocument();
646
- await expect(input).not.toBeDisabled();
647
-
648
- // Check helper text
649
- const helperText = canvas.getByText('Helper text for integration');
650
- await expect(helperText).toBeInTheDocument();
651
-
652
- // Check label
653
- const label = canvas.getByText('Integration Test');
654
- await expect(label).toBeInTheDocument();
655
-
656
- // Check current location button is present
657
- const locationButton = canvas.getByTitle('Use current location');
658
- await expect(locationButton).toBeInTheDocument();
659
-
660
- // Click current location button
661
- await userEvent.click(locationButton);
662
-
663
- // Wait for location to be retrieved (mock)
664
- await waitFor(
665
- () => {
666
- expect(args.onSelect).toHaveBeenCalledWith(
667
- expect.objectContaining({
668
- formatted: expect.stringContaining('123 Main Street'),
669
- coordinates: expect.objectContaining({
670
- lat: expect.any(Number),
671
- lng: expect.any(Number),
672
- }),
673
- }),
674
- );
675
- },
676
- { timeout: 2000 },
677
- );
678
-
679
- // Verify input was populated
680
- await waitFor(() => {
681
- expect(input.value).toContain('123 Main Street');
682
- });
683
-
684
- // Clear and test normal typing with all features
685
- await userEvent.clear(input);
686
- await userEvent.type(input, 'pine');
687
-
688
- // Wait for suggestions with full integration
689
- await waitFor(() => {
690
- const firstSuggestion = body.getByTestId('address-suggestion-0');
691
- expect(firstSuggestion).toBeInTheDocument();
692
- });
693
-
694
- // Select an address containing Pine (should be in suggestions)
695
- const pineSuggestion = body.getByTestId('address-suggestion-0');
696
- await expect(pineSuggestion).toBeInTheDocument();
697
- await expect(pineSuggestion.textContent).toContain('Pine');
698
- await userEvent.click(pineSuggestion);
699
-
700
- // Verify full address details were extracted
701
- await waitFor(() => {
702
- const calls = (args.onSelect as Mock).mock.calls;
703
- const lastCall = calls[calls.length - 1][0];
704
- expect(lastCall).toMatchObject({
705
- formatted: expect.stringContaining('Pine Boulevard'),
706
- street: expect.stringContaining('Pine Boulevard'),
707
- city: 'Los Angeles',
708
- state: 'California',
709
- country: 'United States',
710
- postalCode: '90001',
711
- });
712
- });
713
-
714
- // Set status to pass
715
- const statusElement = document.createElement('div');
716
- statusElement.setAttribute('aria-label', 'Status of the test run');
717
- statusElement.textContent = 'PASS';
718
- canvasElement.appendChild(statusElement);
719
- } catch (error) {
720
- const statusElement = document.createElement('div');
721
- statusElement.setAttribute('aria-label', 'Status of the test run');
722
- statusElement.textContent = 'FAIL';
723
- canvasElement.appendChild(statusElement);
724
- throw error;
725
- }
726
- },
727
- };