@tuturuuu/ui 0.7.0 → 0.9.0

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 (226) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/biome.json +1 -1
  3. package/package.json +75 -73
  4. package/src/components/ui/accordion.tsx +1 -1
  5. package/src/components/ui/breadcrumb.tsx +1 -1
  6. package/src/components/ui/calendar-app/calendar-page-shell.tsx +4 -0
  7. package/src/components/ui/calendar-app/components/calendar-connections-settings-content.tsx +239 -33
  8. package/src/components/ui/calendar-app/components/load-smart-scheduling-tasks.tsx +143 -0
  9. package/src/components/ui/calendar-app/components/priority-view.tsx +10 -3
  10. package/src/components/ui/calendar-app/components/tasks-sidebar.tsx +4 -116
  11. package/src/components/ui/calendar-app/components/use-calendar-connections-manager.ts +67 -2
  12. package/src/components/ui/calendar.tsx +1 -1
  13. package/src/components/ui/carousel.tsx +1 -1
  14. package/src/components/ui/chat/chat-agent-details-external-thread-panel.test.tsx +1 -1
  15. package/src/components/ui/chat/chat-agent-details-external-thread-panel.tsx +1 -1
  16. package/src/components/ui/chat/chat-agent-details-operations-panel.test.tsx +1 -1
  17. package/src/components/ui/chat/chat-agent-details-operations-panel.tsx +1 -1
  18. package/src/components/ui/chat/chat-agent-details-setup-panel.tsx +1 -1
  19. package/src/components/ui/chat/chat-agent-details-sidebar.test.tsx +1 -1
  20. package/src/components/ui/chat/chat-agent-details-sidebar.tsx +2 -2
  21. package/src/components/ui/chat/chat-agent-details-utils.test.ts +1 -1
  22. package/src/components/ui/chat/chat-agent-details-utils.tsx +1 -1
  23. package/src/components/ui/chat/chat-agent-details-zalo-personal-panel.tsx +2 -2
  24. package/src/components/ui/checkbox.tsx +1 -1
  25. package/src/components/ui/color-picker.tsx +1 -1
  26. package/src/components/ui/command.tsx +1 -1
  27. package/src/components/ui/context-menu.tsx +5 -1
  28. package/src/components/ui/currency-input.test.tsx +43 -0
  29. package/src/components/ui/currency-input.tsx +1 -1
  30. package/src/components/ui/custom/__tests__/settings-dialog-shell.test.tsx +3 -0
  31. package/src/components/ui/custom/__tests__/workspace-select-helpers.test.ts +19 -0
  32. package/src/components/ui/custom/combobox.test.tsx +195 -0
  33. package/src/components/ui/custom/combobox.tsx +273 -156
  34. package/src/components/ui/custom/education/modules/youtube/delete-link-button.tsx +5 -13
  35. package/src/components/ui/custom/facebook-mockup/facebook-mockup.tsx +7 -1
  36. package/src/components/ui/custom/facebook-mockup/form.tsx +1 -1
  37. package/src/components/ui/custom/facebook-mockup/image-upload-field.tsx +1 -1
  38. package/src/components/ui/custom/facebook-mockup/preview.tsx +1 -1
  39. package/src/components/ui/custom/settings-dialog-shell.tsx +2 -1
  40. package/src/components/ui/custom/theme-toggle.tsx +1 -1
  41. package/src/components/ui/custom/workspace-access/workspace-access-default-role-card.tsx +60 -35
  42. package/src/components/ui/custom/workspace-access/workspace-access-member-row.tsx +176 -167
  43. package/src/components/ui/custom/workspace-access/workspace-access-members.tsx +16 -10
  44. package/src/components/ui/custom/workspace-access/workspace-access-page-header.tsx +75 -36
  45. package/src/components/ui/custom/workspace-access/workspace-access-page.tsx +39 -42
  46. package/src/components/ui/custom/workspace-access/workspace-access-people-filters.tsx +1 -1
  47. package/src/components/ui/custom/workspace-access/workspace-access-roles.tsx +113 -91
  48. package/src/components/ui/custom/workspace-access/workspace-access-tabs-toolbar.tsx +73 -32
  49. package/src/components/ui/custom/workspace-select.tsx +8 -3
  50. package/src/components/ui/dialog.test.tsx +52 -0
  51. package/src/components/ui/dialog.tsx +6 -2
  52. package/src/components/ui/dropdown-menu.tsx +5 -1
  53. package/src/components/ui/finance/debts/debt-loan-form.tsx +12 -5
  54. package/src/components/ui/finance/debts/debt-loan-summary.tsx +3 -2
  55. package/src/components/ui/finance/debts/debts-page.test.tsx +54 -5
  56. package/src/components/ui/finance/debts/debts-page.tsx +15 -2
  57. package/src/components/ui/finance/invoices/components/subscription-group-selector.tsx +3 -5
  58. package/src/components/ui/finance/invoices/new-invoice-page.test.tsx +25 -5
  59. package/src/components/ui/finance/invoices/new-invoice-page.tsx +7 -2
  60. package/src/components/ui/finance/invoices/standard-invoice.tsx +4 -2
  61. package/src/components/ui/finance/invoices/subscription-invoice.tsx +4 -2
  62. package/src/components/ui/finance/invoices/utils.ts +3 -1
  63. package/src/components/ui/finance/transactions/form-content-dialog.tsx +3 -0
  64. package/src/components/ui/finance/transactions/form-types.ts +3 -0
  65. package/src/components/ui/finance/transactions/form.tsx +2 -0
  66. package/src/components/ui/finance/transactions/infinite-transactions-list.tsx +2 -0
  67. package/src/components/ui/finance/transactions/period-charts/category-breakdown-dialog.tsx +1 -1
  68. package/src/components/ui/finance/transactions/transaction-card.tsx +21 -9
  69. package/src/components/ui/finance/transactions/transaction-edit-dialog.tsx +1 -4
  70. package/src/components/ui/finance/transactions/transactions-create-summary.tsx +3 -0
  71. package/src/components/ui/finance/transactions/transactions-page.tsx +4 -1
  72. package/src/components/ui/finance/wallets/form.test.tsx +51 -3
  73. package/src/components/ui/finance/wallets/form.tsx +15 -4
  74. package/src/components/ui/finance/wallets/walletId/wallet-details-actions.tsx +4 -0
  75. package/src/components/ui/finance/wallets/walletId/wallet-details-page.tsx +4 -2
  76. package/src/components/ui/finance/wallets/wallets-data-table.tsx +1 -0
  77. package/src/components/ui/finance/wallets/wallets-page.tsx +5 -2
  78. package/src/components/ui/input-otp.tsx +1 -1
  79. package/src/components/ui/legacy/calendar/all-day-event-bar.tsx +28 -39
  80. package/src/components/ui/legacy/calendar/calendar-cell.tsx +2 -0
  81. package/src/components/ui/legacy/calendar/calendar-content.tsx +10 -6
  82. package/src/components/ui/legacy/calendar/calendar-header.tsx +23 -3
  83. package/src/components/ui/legacy/calendar/calendar-loading-skeleton.tsx +135 -0
  84. package/src/components/ui/legacy/calendar/calendar-matrix.tsx +175 -237
  85. package/src/components/ui/legacy/calendar/event-card.test.tsx +177 -0
  86. package/src/components/ui/legacy/calendar/event-card.tsx +220 -131
  87. package/src/components/ui/legacy/calendar/event-modal.tsx +17 -17
  88. package/src/components/ui/legacy/calendar/event-provider-display.tsx +69 -0
  89. package/src/components/ui/legacy/calendar/smart-calendar.test.tsx +86 -4
  90. package/src/components/ui/legacy/calendar/smart-calendar.tsx +32 -2
  91. package/src/components/ui/legacy/meet/create-plan-dialog.tsx +19 -10
  92. package/src/components/ui/money-input.test.tsx +64 -0
  93. package/src/components/ui/money-input.tsx +63 -0
  94. package/src/components/ui/navigation-menu.tsx +1 -1
  95. package/src/components/ui/pagination.tsx +1 -1
  96. package/src/components/ui/radio-group.tsx +1 -1
  97. package/src/components/ui/select.tsx +5 -1
  98. package/src/components/ui/sheet.tsx +1 -1
  99. package/src/components/ui/sidebar.tsx +1 -1
  100. package/src/components/ui/storefront/cart-popover.tsx +61 -0
  101. package/src/components/ui/storefront/cart-summary-parts.tsx +290 -0
  102. package/src/components/ui/storefront/cart-summary.tsx +104 -80
  103. package/src/components/ui/storefront/checkout-overlay.tsx +26 -0
  104. package/src/components/ui/storefront/hero-panel.tsx +2 -8
  105. package/src/components/ui/storefront/image-panel.tsx +6 -0
  106. package/src/components/ui/storefront/index.ts +11 -0
  107. package/src/components/ui/storefront/listing-card.tsx +84 -22
  108. package/src/components/ui/storefront/merch-sections.tsx +70 -0
  109. package/src/components/ui/storefront/product-detail.tsx +289 -0
  110. package/src/components/ui/storefront/product-dialog.tsx +72 -0
  111. package/src/components/ui/storefront/storefront-surface.test.tsx +221 -3
  112. package/src/components/ui/storefront/storefront-surface.tsx +288 -153
  113. package/src/components/ui/storefront/types.ts +27 -1
  114. package/src/components/ui/storefront/utils.ts +117 -27
  115. package/src/components/ui/text-editor/__tests__/content-migration.test.ts +32 -0
  116. package/src/components/ui/text-editor/__tests__/extensions.test.ts +123 -0
  117. package/src/components/ui/text-editor/__tests__/image-extension.test.ts +69 -1
  118. package/src/components/ui/text-editor/__tests__/video-extension.test.ts +47 -0
  119. package/src/components/ui/text-editor/background-color-extension.ts +62 -0
  120. package/src/components/ui/text-editor/color-controls.tsx +284 -0
  121. package/src/components/ui/text-editor/content-migration.ts +41 -18
  122. package/src/components/ui/text-editor/editor.tsx +69 -14
  123. package/src/components/ui/text-editor/extensions.ts +9 -3
  124. package/src/components/ui/text-editor/highlight-extension.ts +22 -0
  125. package/src/components/ui/text-editor/image-extension.ts +40 -18
  126. package/src/components/ui/text-editor/tool-bar.tsx +9 -16
  127. package/src/components/ui/text-editor/video-extension.ts +11 -2
  128. package/src/components/ui/toast.tsx +1 -1
  129. package/src/components/ui/tu-do/boards/__tests__/board-share-dialog.test.tsx +270 -0
  130. package/src/components/ui/tu-do/boards/__tests__/workspace-projects-client-page.test.tsx +70 -1
  131. package/src/components/ui/tu-do/boards/board-public-link-section.tsx +231 -0
  132. package/src/components/ui/tu-do/boards/board-share-dialog.tsx +222 -109
  133. package/src/components/ui/tu-do/boards/boardId/board-column-external-retry.test.tsx +127 -0
  134. package/src/components/ui/tu-do/boards/boardId/board-column.tsx +113 -46
  135. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-clear-delete.ts +2 -0
  136. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-move.ts +5 -0
  137. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-updates.ts +3 -0
  138. package/src/components/ui/tu-do/boards/boardId/kanban/data/kanban-deadline-query.ts +50 -2
  139. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/__tests__/column-reorder.test.ts +17 -0
  140. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/column-reorder.ts +4 -1
  141. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-cache.ts +51 -9
  142. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-order.ts +2 -8
  143. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-sort-key.ts +47 -0
  144. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/use-kanban-dnd.test.ts +63 -0
  145. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/use-kanban-dnd.ts +127 -38
  146. package/src/components/ui/tu-do/boards/boardId/kanban/planner/__tests__/kanban-planner-island.test.tsx +380 -0
  147. package/src/components/ui/tu-do/boards/boardId/kanban/planner/kanban-planner-dialog.tsx +204 -0
  148. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-digest-panel.tsx +61 -0
  149. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-item-strip.tsx +54 -0
  150. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-plan-toolbar.tsx +251 -0
  151. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-scope-badge.tsx +27 -0
  152. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-section.tsx +58 -0
  153. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-share-dialog.tsx +238 -0
  154. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-target-controls.tsx +143 -0
  155. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-utils.ts +65 -0
  156. package/src/components/ui/tu-do/boards/boardId/kanban/planner/use-kanban-planner-state.ts +234 -0
  157. package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-columns.test.tsx +410 -4
  158. package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-columns.tsx +106 -14
  159. package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-deadline-panels.tsx +443 -19
  160. package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-skeleton.tsx +94 -32
  161. package/src/components/ui/tu-do/boards/boardId/kanban.tsx +213 -106
  162. package/src/components/ui/tu-do/boards/boardId/task-board-server-page.test.tsx +186 -0
  163. package/src/components/ui/tu-do/boards/boardId/task-board-server-page.tsx +59 -2
  164. package/src/components/ui/tu-do/boards/boardId/task-card/measured-task-card.tsx +3 -0
  165. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-comparator.ts +3 -0
  166. package/src/components/ui/tu-do/boards/boardId/task-card/task-card.tsx +191 -28
  167. package/src/components/ui/tu-do/boards/boardId/task-filter.test.tsx +152 -0
  168. package/src/components/ui/tu-do/boards/boardId/task-filter.tsx +555 -545
  169. package/src/components/ui/tu-do/boards/boardId/task-list.tsx +7 -0
  170. package/src/components/ui/tu-do/boards/boardId/timeline/timeline-display.ts +9 -0
  171. package/src/components/ui/tu-do/boards/boardId/timeline/timeline-grid.tsx +8 -16
  172. package/src/components/ui/tu-do/boards/boardId/timeline/timeline-task-row.tsx +5 -25
  173. package/src/components/ui/tu-do/boards/boardId/timeline/timeline-utils.test.ts +36 -1
  174. package/src/components/ui/tu-do/boards/boardId/timeline/timeline-utils.ts +51 -2
  175. package/src/components/ui/tu-do/boards/share-section.tsx +100 -0
  176. package/src/components/ui/tu-do/boards/workspace-projects-client-page.tsx +13 -3
  177. package/src/components/ui/tu-do/drafts/draft-convert-dialog.tsx +10 -12
  178. package/src/components/ui/tu-do/drafts/drafts-page.tsx +33 -16
  179. package/src/components/ui/tu-do/initiatives/task-initiatives-client.tsx +56 -88
  180. package/src/components/ui/tu-do/my-tasks/my-tasks-content.tsx +26 -2
  181. package/src/components/ui/tu-do/my-tasks/use-my-tasks-state.ts +55 -8
  182. package/src/components/ui/tu-do/notes/note-edit-dialog.tsx +1 -4
  183. package/src/components/ui/tu-do/shared/__tests__/board-client.test.tsx +25 -0
  184. package/src/components/ui/tu-do/shared/__tests__/board-header.test.tsx +341 -38
  185. package/src/components/ui/tu-do/shared/__tests__/board-switcher.test.tsx +253 -0
  186. package/src/components/ui/tu-do/shared/__tests__/board-views.test.tsx +237 -3
  187. package/src/components/ui/tu-do/shared/__tests__/task-board-loading-state.test.tsx +17 -0
  188. package/src/components/ui/tu-do/shared/__tests__/task-legacy-route-recovery.test.tsx +16 -0
  189. package/src/components/ui/tu-do/shared/board-client.tsx +2 -7
  190. package/src/components/ui/tu-do/shared/board-config-storage.ts +7 -1
  191. package/src/components/ui/tu-do/shared/board-header.tsx +465 -937
  192. package/src/components/ui/tu-do/shared/board-layout-settings.tsx +165 -136
  193. package/src/components/ui/tu-do/shared/board-switcher.tsx +209 -217
  194. package/src/components/ui/tu-do/shared/board-views.tsx +596 -82
  195. package/src/components/ui/tu-do/shared/cursor-overlay-multi-wrapper.tsx +53 -12
  196. package/src/components/ui/tu-do/shared/list-view.tsx +227 -1
  197. package/src/components/ui/tu-do/shared/recycle-bin-panel.tsx +142 -94
  198. package/src/components/ui/tu-do/shared/special-task-list-pins.ts +51 -0
  199. package/src/components/ui/tu-do/shared/task-board-loading-state.tsx +28 -0
  200. package/src/components/ui/tu-do/shared/task-dialog-presentation.test.ts +53 -0
  201. package/src/components/ui/tu-do/shared/task-dialog-presentation.ts +19 -0
  202. package/src/components/ui/tu-do/shared/task-edit-dialog/components/compact-task-create-popover.test.tsx +57 -0
  203. package/src/components/ui/tu-do/shared/task-edit-dialog/components/compact-task-create-popover.tsx +136 -111
  204. package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-description-editor.tsx +3 -1
  205. package/src/components/ui/tu-do/shared/task-edit-dialog/field-diff-viewer.tsx +3 -2
  206. package/src/components/ui/tu-do/shared/task-edit-dialog/selective-revert-panel.test.tsx +91 -0
  207. package/src/components/ui/tu-do/shared/task-edit-dialog/selective-revert-panel.tsx +123 -78
  208. package/src/components/ui/tu-do/shared/task-edit-dialog/task-activity-section.tsx +7 -1
  209. package/src/components/ui/tu-do/shared/task-edit-dialog/task-snapshot-dialog.tsx +8 -3
  210. package/src/components/ui/tu-do/shared/task-edit-dialog.tsx +44 -15
  211. package/src/components/ui/tu-do/shared/task-legacy-route-recovery.tsx +2 -9
  212. package/src/declarations.d.ts +1 -0
  213. package/src/hooks/__tests__/use-calendar-readonly.test.tsx +322 -2
  214. package/src/hooks/__tests__/use-calendar-sync.test.tsx +446 -0
  215. package/src/hooks/__tests__/useBoardRealtime.test.tsx +2 -2
  216. package/src/hooks/__tests__/useCursorTracking.test.tsx +212 -0
  217. package/src/hooks/use-calendar-sync.tsx +247 -243
  218. package/src/hooks/use-calendar.tsx +323 -138
  219. package/src/hooks/use-task-actions.ts +24 -0
  220. package/src/hooks/use-user-workspace-config.ts +75 -0
  221. package/src/hooks/use-workspace-currency.ts +8 -3
  222. package/src/hooks/useBoardRealtime.ts +6 -3
  223. package/src/hooks/useBoardRealtime.types.ts +11 -0
  224. package/src/hooks/useBoardRealtimeEventHandler.ts +11 -0
  225. package/src/hooks/useCursorTracking.ts +91 -27
  226. package/src/hooks/useTaskUserRealtime.ts +5 -3
@@ -1,26 +1,32 @@
1
1
  import '@testing-library/jest-dom';
2
2
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
3
- import { render, screen } from '@testing-library/react';
3
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
4
4
  import type React from 'react';
5
5
  import { beforeEach, describe, expect, it, vi } from 'vitest';
6
6
  import { BoardHeader } from '../board-header';
7
7
 
8
- let boardLayoutSettingsProps:
9
- | React.ComponentProps<
10
- typeof import('../board-layout-settings')['BoardLayoutSettings']
11
- >
12
- | undefined;
8
+ const navigationMocks = vi.hoisted(() => ({
9
+ replace: vi.fn(),
10
+ }));
11
+ const internalApiMocks = vi.hoisted(() => ({
12
+ getWorkspaceTaskBoard: vi.fn(),
13
+ }));
14
+ const comboboxMocks = vi.hoisted(() => ({
15
+ seenOptions: [] as { description?: string; label: string; value: string }[][],
16
+ }));
13
17
 
14
18
  vi.mock('next-intl', () => ({
15
19
  useTranslations: () => (key: string) => key,
16
20
  }));
17
21
 
18
22
  vi.mock('next/navigation', () => ({
23
+ usePathname: () => '/ws-1/tasks/boards/board-1',
19
24
  useRouter: () => ({
20
25
  push: vi.fn(),
21
- replace: vi.fn(),
26
+ replace: navigationMocks.replace,
22
27
  refresh: vi.fn(),
23
28
  }),
29
+ useSearchParams: () => new URLSearchParams('existing=1'),
24
30
  }));
25
31
 
26
32
  vi.mock('next/link', () => ({
@@ -40,23 +46,95 @@ vi.mock('@tuturuuu/ui/hooks/use-board-actions', () => ({
40
46
  }),
41
47
  }));
42
48
 
43
- vi.mock('../tasks-route-context', () => ({
44
- useTasksHref: () => '/tasks',
45
- }));
49
+ vi.mock('@tuturuuu/ui/custom/combobox', () => ({
50
+ Combobox: function MockCombobox({
51
+ ariaLabel,
52
+ className,
53
+ colorizeTriggerIcon,
54
+ disabled,
55
+ hideTriggerLabel,
56
+ onChange,
57
+ options,
58
+ placeholder,
59
+ selected,
60
+ triggerIcon,
61
+ triggerTooltip,
62
+ }: {
63
+ ariaLabel?: string;
64
+ className?: string;
65
+ colorizeTriggerIcon?: boolean;
66
+ disabled?: boolean;
67
+ hideTriggerLabel?: boolean;
68
+ onChange?: (value: string) => void;
69
+ options: { description?: string; label: string; value: string }[];
70
+ placeholder?: string;
71
+ selected: string;
72
+ triggerIcon?: React.ReactNode;
73
+ triggerTooltip?: React.ReactNode;
74
+ }) {
75
+ comboboxMocks.seenOptions.push(options);
46
76
 
47
- vi.mock('../board-layout-settings', () => ({
48
- BoardLayoutSettings: (props: any) => {
49
- boardLayoutSettingsProps = props;
50
77
  return (
51
- <div
52
- data-testid="board-layout-settings"
53
- data-board-id={props.boardId}
54
- data-ws-id={props.wsId ?? ''}
55
- />
78
+ <select
79
+ aria-label={
80
+ ariaLabel ??
81
+ (hideTriggerLabel
82
+ ? options.find((option) => option.value === selected)?.label
83
+ : placeholder)
84
+ }
85
+ className={className}
86
+ data-colorize-trigger-icon={String(colorizeTriggerIcon)}
87
+ data-has-trigger-icon={String(Boolean(triggerIcon))}
88
+ data-trigger-tooltip={
89
+ typeof triggerTooltip === 'string' ? triggerTooltip : undefined
90
+ }
91
+ disabled={disabled}
92
+ value={selected}
93
+ onChange={(event) => onChange?.(event.target.value)}
94
+ >
95
+ {options.map((option) => (
96
+ <option key={option.value} value={option.value}>
97
+ {option.label}
98
+ </option>
99
+ ))}
100
+ </select>
56
101
  );
57
102
  },
58
103
  }));
59
104
 
105
+ vi.mock('@tuturuuu/internal-api/tasks', () => ({
106
+ getWorkspaceTaskBoard: (
107
+ ...args: Parameters<typeof internalApiMocks.getWorkspaceTaskBoard>
108
+ ) => internalApiMocks.getWorkspaceTaskBoard(...args),
109
+ }));
110
+
111
+ vi.mock('@tuturuuu/ui/dropdown-menu', () => ({
112
+ DropdownMenu: ({ children }: { children: React.ReactNode }) => (
113
+ <div>{children}</div>
114
+ ),
115
+ DropdownMenuContent: ({ children }: { children: React.ReactNode }) => (
116
+ <div>{children}</div>
117
+ ),
118
+ DropdownMenuItem: ({
119
+ children,
120
+ onClick,
121
+ }: {
122
+ children: React.ReactNode;
123
+ onClick?: () => void;
124
+ }) => (
125
+ <button onClick={onClick} type="button">
126
+ {children}
127
+ </button>
128
+ ),
129
+ DropdownMenuTrigger: ({ children }: { children: React.ReactNode }) => (
130
+ <>{children}</>
131
+ ),
132
+ }));
133
+
134
+ vi.mock('../tasks-route-context', () => ({
135
+ useTasksHref: () => '/tasks',
136
+ }));
137
+
60
138
  vi.mock('../board-switcher', () => ({
61
139
  BoardSwitcher: () => <div data-testid="board-switcher" />,
62
140
  }));
@@ -71,6 +149,16 @@ vi.mock('../boards/boardId/task-filter', () => ({
71
149
  TaskFilter: () => <div data-testid="task-filter" />,
72
150
  }));
73
151
 
152
+ vi.mock('../boards/boardId/kanban/planner/kanban-planner-dialog', () => ({
153
+ KanbanPlannerDialog: ({ open }: { open: boolean }) =>
154
+ open ? <div role="dialog">planner-dialog</div> : null,
155
+ }));
156
+
157
+ vi.mock('../boards/board-share-dialog', () => ({
158
+ BoardShareDialog: ({ open }: { open: boolean }) =>
159
+ open ? <div role="dialog">share-dialog</div> : null,
160
+ }));
161
+
74
162
  vi.mock('../boards/copy-board-dialog', () => ({
75
163
  CopyBoardDialog: () => <div data-testid="copy-board-dialog" />,
76
164
  }));
@@ -137,36 +225,251 @@ function renderBoardHeader(
137
225
 
138
226
  describe('BoardHeader', () => {
139
227
  beforeEach(() => {
140
- boardLayoutSettingsProps = undefined;
228
+ comboboxMocks.seenOptions = [];
229
+ navigationMocks.replace.mockReset();
230
+ internalApiMocks.getWorkspaceTaskBoard.mockReset();
231
+ internalApiMocks.getWorkspaceTaskBoard.mockResolvedValue({
232
+ board: mockBoard,
233
+ });
234
+ });
235
+
236
+ it('renders a direct board settings button with compact outline header styling', () => {
237
+ renderBoardHeader();
238
+
239
+ const settingsButton = screen.getByRole('button', {
240
+ name: 'ws-task-boards.actions.board_settings',
241
+ });
242
+
243
+ expect(settingsButton).toHaveClass('border', 'h-7', 'w-7', 'px-0');
244
+ expect(settingsButton).toHaveClass('sm:h-8', 'sm:w-8');
245
+ expect(settingsButton).not.toHaveTextContent(
246
+ 'ws-task-boards.actions.board_settings'
247
+ );
141
248
  });
142
249
 
143
- it('passes the workspace id to board layout settings', () => {
250
+ it('prefetches current board settings before opening the dialog', async () => {
144
251
  renderBoardHeader();
145
252
 
146
- expect(screen.getByTestId('board-layout-settings')).toHaveAttribute(
147
- 'data-ws-id',
148
- 'ws-1'
253
+ fireEvent.mouseEnter(
254
+ screen.getByRole('button', {
255
+ name: 'ws-task-boards.actions.board_settings',
256
+ })
257
+ );
258
+
259
+ await waitFor(() => {
260
+ expect(internalApiMocks.getWorkspaceTaskBoard).toHaveBeenCalledWith(
261
+ 'ws-1',
262
+ 'board-1',
263
+ expect.objectContaining({ baseUrl: expect.any(String) })
264
+ );
265
+ });
266
+ });
267
+
268
+ it('calls the board settings intent hook before opening the dialog', () => {
269
+ const onBoardSettingsIntent = vi.fn();
270
+
271
+ renderBoardHeader({ onBoardSettingsIntent });
272
+
273
+ fireEvent.pointerDown(
274
+ screen.getByRole('button', {
275
+ name: 'ws-task-boards.actions.board_settings',
276
+ })
149
277
  );
150
- expect(boardLayoutSettingsProps?.boardId).toBe('board-1');
151
- expect(boardLayoutSettingsProps?.wsId).toBe('ws-1');
278
+
279
+ expect(onBoardSettingsIntent).toHaveBeenCalledTimes(1);
152
280
  });
153
281
 
154
- it('uses the explicit workspace id when the board payload omits ws_id', () => {
282
+ it('opens contextual board settings through query state', () => {
283
+ renderBoardHeader();
284
+
285
+ fireEvent.click(
286
+ screen.getByRole('button', {
287
+ name: 'ws-task-boards.actions.board_settings',
288
+ })
289
+ );
290
+
291
+ expect(navigationMocks.replace).toHaveBeenCalledWith(
292
+ '/ws-1/tasks/boards/board-1?existing=1&settingsDialog=open&settingsTab=task_board&settingsBoardId=board-1',
293
+ { scroll: false }
294
+ );
295
+ });
296
+
297
+ it('renders a natural public title and hides member-only controls in read-only mode', () => {
155
298
  renderBoardHeader({
156
- workspaceId: 'ws-fallback',
157
- board: {
158
- archived_at: null,
159
- id: 'board-1',
160
- name: 'Roadmap',
161
- ticket_prefix: 'RD',
162
- ws_id: null,
163
- },
299
+ publicView: true,
300
+ readOnly: true,
301
+ titlePrefix: <span data-testid="public-title-prefix">Tuturuuu /</span>,
302
+ });
303
+
304
+ expect(screen.queryByTestId('board-switcher')).not.toBeInTheDocument();
305
+ expect(screen.getByTestId('public-title-prefix')).toBeInTheDocument();
306
+ expect(screen.getByText('Roadmap')).toBeInTheDocument();
307
+ expect(screen.queryByTestId('board-user-presence')).not.toBeInTheDocument();
308
+ expect(screen.queryByTestId('task-filter')).not.toBeInTheDocument();
309
+ expect(
310
+ screen.queryByLabelText('ws-task-boards.share.action')
311
+ ).not.toBeInTheDocument();
312
+ expect(
313
+ screen.queryByLabelText('ws-task-plans.planner')
314
+ ).not.toBeInTheDocument();
315
+ });
316
+
317
+ it('hides the board picker when showing My Tasks', () => {
318
+ renderBoardHeader({
319
+ currentView: 'my_tasks',
320
+ });
321
+
322
+ expect(screen.queryByTestId('board-switcher')).not.toBeInTheDocument();
323
+ expect(
324
+ screen.getByText('ws-task-boards.views.my_tasks')
325
+ ).toBeInTheDocument();
326
+ });
327
+
328
+ it('shows planner as a personal kanban toolbar button and opens the dialog', () => {
329
+ renderBoardHeader({
330
+ isPersonalWorkspace: true,
331
+ });
332
+
333
+ fireEvent.click(screen.getByLabelText('ws-task-plans.planner'));
334
+
335
+ expect(screen.getByRole('dialog')).toHaveTextContent('planner');
336
+ });
337
+
338
+ it('hides planner outside personal kanban editing', () => {
339
+ const { rerender } = renderBoardHeader({
340
+ currentView: 'list',
341
+ isPersonalWorkspace: true,
342
+ });
343
+
344
+ expect(
345
+ screen.queryByLabelText('ws-task-plans.planner')
346
+ ).not.toBeInTheDocument();
347
+
348
+ rerender(
349
+ <QueryClientProvider client={new QueryClient()}>
350
+ <BoardHeader
351
+ workspaceId="ws-1"
352
+ board={mockBoard}
353
+ currentView="kanban"
354
+ filters={{
355
+ assignees: [],
356
+ dueDateRange: null,
357
+ estimationRange: null,
358
+ includeMyTasks: false,
359
+ includeUnassigned: false,
360
+ labels: [],
361
+ priorities: [],
362
+ projects: [],
363
+ sourceBoardIds: [],
364
+ sourceScope: 'all_visible',
365
+ sourceWorkspaceIds: [],
366
+ }}
367
+ isMultiSelectMode={false}
368
+ isPersonalWorkspace
369
+ listStatusFilter="all"
370
+ onFiltersChange={vi.fn()}
371
+ onListStatusFilterChange={vi.fn()}
372
+ onUpdate={vi.fn()}
373
+ onViewChange={vi.fn()}
374
+ publicView
375
+ setIsMultiSelectMode={vi.fn()}
376
+ />
377
+ </QueryClientProvider>
378
+ );
379
+
380
+ expect(
381
+ screen.queryByLabelText('ws-task-plans.planner')
382
+ ).not.toBeInTheDocument();
383
+ });
384
+
385
+ it('updates status, view, and sort through combobox controls', () => {
386
+ const onFiltersChange = vi.fn();
387
+ const onListStatusFilterChange = vi.fn();
388
+ const onViewChange = vi.fn();
389
+
390
+ renderBoardHeader({
391
+ onFiltersChange,
392
+ onListStatusFilterChange,
393
+ onViewChange,
394
+ });
395
+
396
+ fireEvent.change(screen.getByLabelText('common.all'), {
397
+ target: { value: 'active' },
398
+ });
399
+ expect(onListStatusFilterChange).toHaveBeenCalledWith('active');
400
+
401
+ fireEvent.change(screen.getByLabelText('ws-task-boards.views.kanban'), {
402
+ target: { value: 'list' },
403
+ });
404
+ expect(onViewChange).toHaveBeenCalledWith('list');
405
+
406
+ fireEvent.change(screen.getByLabelText('common.sort'), {
407
+ target: { value: 'priority-high' },
408
+ });
409
+ expect(onFiltersChange).toHaveBeenCalledWith(
410
+ expect.objectContaining({ sortBy: 'priority-high' })
411
+ );
412
+ });
413
+
414
+ it('uses short board view descriptions including drafts and recycle bin keys', () => {
415
+ renderBoardHeader({
416
+ availableViews: ['kanban', 'list', 'timeline', 'drafts', 'recycle_bin'],
164
417
  });
165
418
 
166
- expect(screen.getByTestId('board-layout-settings')).toHaveAttribute(
167
- 'data-ws-id',
168
- 'ws-fallback'
419
+ const viewOptions = comboboxMocks.seenOptions.find((options) =>
420
+ options.some((option) => option.value === 'kanban')
421
+ );
422
+
423
+ expect(viewOptions).toEqual(
424
+ expect.arrayContaining([
425
+ expect.objectContaining({
426
+ value: 'kanban',
427
+ description: 'ws-task-boards.views.kanban_description',
428
+ }),
429
+ expect.objectContaining({
430
+ value: 'list',
431
+ description: 'ws-task-boards.views.list_description',
432
+ }),
433
+ expect.objectContaining({
434
+ value: 'timeline',
435
+ description: 'ws-task-boards.views.timeline_description',
436
+ }),
437
+ expect.objectContaining({
438
+ value: 'drafts',
439
+ description: 'task-drafts.board_view_description',
440
+ }),
441
+ expect.objectContaining({
442
+ value: 'recycle_bin',
443
+ description: 'common.recycle_bin_board_description',
444
+ }),
445
+ ])
446
+ );
447
+ });
448
+
449
+ it('passes instant tooltip labels and monochrome trigger mode to toolbar comboboxes', () => {
450
+ renderBoardHeader();
451
+
452
+ const status = screen.getByLabelText('common.all');
453
+ const view = screen.getByLabelText('ws-task-boards.views.kanban');
454
+ const sort = screen.getByLabelText('common.sort');
455
+
456
+ expect(status).toHaveAttribute(
457
+ 'data-trigger-tooltip',
458
+ 'common.status: common.all'
169
459
  );
170
- expect(boardLayoutSettingsProps?.wsId).toBe('ws-fallback');
460
+ expect(view).toHaveAttribute(
461
+ 'data-trigger-tooltip',
462
+ 'common.view: ws-task-boards.views.kanban'
463
+ );
464
+ expect(view).toHaveAttribute('data-has-trigger-icon', 'true');
465
+ expect(sort).toHaveAttribute(
466
+ 'data-trigger-tooltip',
467
+ 'common.sort: common.sort'
468
+ );
469
+
470
+ for (const control of [status, view, sort]) {
471
+ expect(control).toHaveAttribute('data-colorize-trigger-icon', 'false');
472
+ expect(control.className).toContain('[&_button_svg]:text-current');
473
+ }
171
474
  });
172
475
  });
@@ -0,0 +1,253 @@
1
+ import '@testing-library/jest-dom';
2
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
3
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
4
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
5
+ import { BoardSwitcher } from '../board-switcher';
6
+
7
+ const {
8
+ createWorkspaceTaskBoardMock,
9
+ isTaskRememberLastBoardEnabledMock,
10
+ listWorkspaceTaskBoardsMock,
11
+ pushMock,
12
+ rememberLastBoardConfig,
13
+ updateUserWorkspaceConfigMock,
14
+ useUserWorkspaceConfigMock,
15
+ } = vi.hoisted(() => ({
16
+ createWorkspaceTaskBoardMock: vi.fn(),
17
+ isTaskRememberLastBoardEnabledMock: vi.fn(
18
+ (value: string | null | undefined) => value !== 'false'
19
+ ),
20
+ listWorkspaceTaskBoardsMock: vi.fn(),
21
+ pushMock: vi.fn(),
22
+ rememberLastBoardConfig: {
23
+ value: 'true' as string | null | undefined,
24
+ },
25
+ updateUserWorkspaceConfigMock: vi.fn(),
26
+ useUserWorkspaceConfigMock: vi.fn(),
27
+ }));
28
+
29
+ let comboboxProps:
30
+ | {
31
+ createText?: string;
32
+ creatingText?: string;
33
+ onChange: (value: string) => void;
34
+ onCreate?: (value: string) => Promise<{ label: string; value: string }>;
35
+ options: Array<{ icon?: unknown; label: string; value: string }>;
36
+ searchPlaceholder?: string;
37
+ selected?: string;
38
+ showSelectedIcon?: boolean;
39
+ }
40
+ | undefined;
41
+
42
+ vi.mock('@tuturuuu/internal-api/tasks', () => ({
43
+ createWorkspaceTaskBoard: (
44
+ ...args: Parameters<typeof createWorkspaceTaskBoardMock>
45
+ ) => createWorkspaceTaskBoardMock(...args),
46
+ listWorkspaceTaskBoards: (
47
+ ...args: Parameters<typeof listWorkspaceTaskBoardsMock>
48
+ ) => listWorkspaceTaskBoardsMock(...args),
49
+ }));
50
+
51
+ vi.mock('@tuturuuu/internal-api/users', () => ({
52
+ isTaskRememberLastBoardEnabled: (value: string | null | undefined): boolean =>
53
+ isTaskRememberLastBoardEnabledMock(value),
54
+ TASK_DEFAULT_BOARD_ID_CONFIG_ID: 'TASK_DEFAULT_BOARD_ID',
55
+ TASK_REMEMBER_LAST_BOARD_CONFIG_ID: 'TASK_REMEMBER_LAST_BOARD',
56
+ }));
57
+
58
+ vi.mock('../../../../../hooks/use-user-workspace-config', () => ({
59
+ useUpdateUserWorkspaceConfig: () => ({
60
+ isPending: false,
61
+ mutate: updateUserWorkspaceConfigMock,
62
+ }),
63
+ useUserWorkspaceConfig: (...args: unknown[]) => {
64
+ useUserWorkspaceConfigMock(...args);
65
+ return {
66
+ data: rememberLastBoardConfig.value,
67
+ isLoading: false,
68
+ };
69
+ },
70
+ }));
71
+
72
+ vi.mock('@tuturuuu/ui/custom/combobox', () => ({
73
+ Combobox: (props: any) => {
74
+ comboboxProps = props;
75
+ return (
76
+ <div>
77
+ <button
78
+ type="button"
79
+ data-testid="board-combobox"
80
+ onClick={() => props.onChange('board-2')}
81
+ >
82
+ {props.label}
83
+ </button>
84
+ <button
85
+ type="button"
86
+ data-testid="create-board"
87
+ onClick={async () => {
88
+ const result = await props.onCreate?.('Launch Board');
89
+ const boardId = typeof result === 'string' ? result : result?.value;
90
+ if (boardId) props.onChange(boardId);
91
+ }}
92
+ >
93
+ Create board
94
+ </button>
95
+ </div>
96
+ );
97
+ },
98
+ }));
99
+
100
+ vi.mock('@tuturuuu/ui/sonner', () => ({
101
+ toast: {
102
+ error: vi.fn(),
103
+ },
104
+ }));
105
+
106
+ vi.mock('next/navigation', () => ({
107
+ useRouter: () => ({
108
+ push: pushMock,
109
+ }),
110
+ }));
111
+
112
+ vi.mock('../tasks-route-context', () => ({
113
+ useTasksHref: () => (path: string) => `/tasks${path}`,
114
+ }));
115
+
116
+ function renderBoardSwitcher() {
117
+ const queryClient = new QueryClient({
118
+ defaultOptions: {
119
+ queries: {
120
+ retry: false,
121
+ },
122
+ },
123
+ });
124
+
125
+ return render(
126
+ <QueryClientProvider client={queryClient}>
127
+ <BoardSwitcher
128
+ board={{
129
+ id: 'board-1',
130
+ name: 'Tasks',
131
+ ticket_prefix: 'T',
132
+ ws_id: 'ws-1',
133
+ }}
134
+ translations={{
135
+ activeBoards: 'Active boards',
136
+ archivedBoards: 'Archived boards',
137
+ deletedBoards: 'Deleted boards',
138
+ createBoard: 'Create Board',
139
+ creatingBoard: 'Creating',
140
+ searchBoards: 'Search boards...',
141
+ tasks: 'Tasks',
142
+ }}
143
+ />
144
+ </QueryClientProvider>
145
+ );
146
+ }
147
+
148
+ describe('BoardSwitcher', () => {
149
+ beforeEach(() => {
150
+ vi.clearAllMocks();
151
+ comboboxProps = undefined;
152
+ rememberLastBoardConfig.value = 'true';
153
+ listWorkspaceTaskBoardsMock.mockResolvedValue({
154
+ boards: [
155
+ {
156
+ archived_at: null,
157
+ created_at: '2026-06-01T00:00:00.000Z',
158
+ deleted_at: null,
159
+ icon: null,
160
+ id: 'board-2',
161
+ name: 'Roadmap',
162
+ },
163
+ ],
164
+ });
165
+ });
166
+
167
+ it('uses the shared combobox and navigates when a board is selected', async () => {
168
+ renderBoardSwitcher();
169
+
170
+ expect(screen.getByTestId('board-combobox')).toBeInTheDocument();
171
+
172
+ await waitFor(() => {
173
+ expect(comboboxProps?.options).toEqual(
174
+ expect.arrayContaining([
175
+ expect.objectContaining({
176
+ label: 'Roadmap',
177
+ value: 'board-2',
178
+ }),
179
+ ])
180
+ );
181
+ });
182
+
183
+ expect(comboboxProps).toMatchObject({
184
+ createText: 'Create Board',
185
+ creatingText: 'Creating',
186
+ searchPlaceholder: 'Search boards...',
187
+ selected: 'board-1',
188
+ });
189
+ expect(comboboxProps?.showSelectedIcon).toBeUndefined();
190
+ expect(comboboxProps?.options.some((option) => option.icon)).toBe(true);
191
+
192
+ fireEvent.click(screen.getByTestId('board-combobox'));
193
+
194
+ expect(pushMock).toHaveBeenCalledWith('/ws-1/tasks/boards/board-2');
195
+ expect(useUserWorkspaceConfigMock).toHaveBeenCalledWith(
196
+ 'ws-1',
197
+ 'TASK_REMEMBER_LAST_BOARD',
198
+ 'true'
199
+ );
200
+ expect(isTaskRememberLastBoardEnabledMock).toHaveBeenCalledWith('true');
201
+ expect(updateUserWorkspaceConfigMock).toHaveBeenCalledWith({
202
+ configId: 'TASK_DEFAULT_BOARD_ID',
203
+ value: 'board-2',
204
+ workspaceId: 'ws-1',
205
+ });
206
+ });
207
+
208
+ it('navigates without updating the default board when board memory is disabled', async () => {
209
+ rememberLastBoardConfig.value = 'false';
210
+ renderBoardSwitcher();
211
+
212
+ await waitFor(() => {
213
+ expect(comboboxProps?.options.length).toBeGreaterThan(0);
214
+ });
215
+
216
+ fireEvent.click(screen.getByTestId('board-combobox'));
217
+
218
+ expect(pushMock).toHaveBeenCalledWith('/ws-1/tasks/boards/board-2');
219
+ expect(updateUserWorkspaceConfigMock).not.toHaveBeenCalled();
220
+ });
221
+
222
+ it('creates a new board from the picker and opens it', async () => {
223
+ createWorkspaceTaskBoardMock.mockResolvedValue({
224
+ board: {
225
+ archived_at: null,
226
+ created_at: '2026-06-24T00:00:00.000Z',
227
+ deleted_at: null,
228
+ icon: null,
229
+ id: 'board-3',
230
+ name: 'Launch Board',
231
+ },
232
+ });
233
+
234
+ renderBoardSwitcher();
235
+
236
+ fireEvent.click(screen.getByTestId('create-board'));
237
+
238
+ await waitFor(() => {
239
+ expect(createWorkspaceTaskBoardMock).toHaveBeenCalledWith('ws-1', {
240
+ name: 'Launch Board',
241
+ });
242
+ });
243
+
244
+ await waitFor(() => {
245
+ expect(pushMock).toHaveBeenCalledWith('/ws-1/tasks/boards/board-3');
246
+ });
247
+ expect(updateUserWorkspaceConfigMock).toHaveBeenCalledWith({
248
+ configId: 'TASK_DEFAULT_BOARD_ID',
249
+ value: 'board-3',
250
+ workspaceId: 'ws-1',
251
+ });
252
+ });
253
+ });