@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.
- package/CHANGELOG.md +88 -0
- package/biome.json +1 -1
- package/package.json +75 -73
- package/src/components/ui/accordion.tsx +1 -1
- package/src/components/ui/breadcrumb.tsx +1 -1
- package/src/components/ui/calendar-app/calendar-page-shell.tsx +4 -0
- package/src/components/ui/calendar-app/components/calendar-connections-settings-content.tsx +239 -33
- package/src/components/ui/calendar-app/components/load-smart-scheduling-tasks.tsx +143 -0
- package/src/components/ui/calendar-app/components/priority-view.tsx +10 -3
- package/src/components/ui/calendar-app/components/tasks-sidebar.tsx +4 -116
- package/src/components/ui/calendar-app/components/use-calendar-connections-manager.ts +67 -2
- package/src/components/ui/calendar.tsx +1 -1
- package/src/components/ui/carousel.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-external-thread-panel.test.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-external-thread-panel.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-operations-panel.test.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-operations-panel.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-setup-panel.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-sidebar.test.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-sidebar.tsx +2 -2
- package/src/components/ui/chat/chat-agent-details-utils.test.ts +1 -1
- package/src/components/ui/chat/chat-agent-details-utils.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-zalo-personal-panel.tsx +2 -2
- package/src/components/ui/checkbox.tsx +1 -1
- package/src/components/ui/color-picker.tsx +1 -1
- package/src/components/ui/command.tsx +1 -1
- package/src/components/ui/context-menu.tsx +5 -1
- package/src/components/ui/currency-input.test.tsx +43 -0
- package/src/components/ui/currency-input.tsx +1 -1
- package/src/components/ui/custom/__tests__/settings-dialog-shell.test.tsx +3 -0
- package/src/components/ui/custom/__tests__/workspace-select-helpers.test.ts +19 -0
- package/src/components/ui/custom/combobox.test.tsx +195 -0
- package/src/components/ui/custom/combobox.tsx +273 -156
- package/src/components/ui/custom/education/modules/youtube/delete-link-button.tsx +5 -13
- package/src/components/ui/custom/facebook-mockup/facebook-mockup.tsx +7 -1
- package/src/components/ui/custom/facebook-mockup/form.tsx +1 -1
- package/src/components/ui/custom/facebook-mockup/image-upload-field.tsx +1 -1
- package/src/components/ui/custom/facebook-mockup/preview.tsx +1 -1
- package/src/components/ui/custom/settings-dialog-shell.tsx +2 -1
- package/src/components/ui/custom/theme-toggle.tsx +1 -1
- package/src/components/ui/custom/workspace-access/workspace-access-default-role-card.tsx +60 -35
- package/src/components/ui/custom/workspace-access/workspace-access-member-row.tsx +176 -167
- package/src/components/ui/custom/workspace-access/workspace-access-members.tsx +16 -10
- package/src/components/ui/custom/workspace-access/workspace-access-page-header.tsx +75 -36
- package/src/components/ui/custom/workspace-access/workspace-access-page.tsx +39 -42
- package/src/components/ui/custom/workspace-access/workspace-access-people-filters.tsx +1 -1
- package/src/components/ui/custom/workspace-access/workspace-access-roles.tsx +113 -91
- package/src/components/ui/custom/workspace-access/workspace-access-tabs-toolbar.tsx +73 -32
- package/src/components/ui/custom/workspace-select.tsx +8 -3
- package/src/components/ui/dialog.test.tsx +52 -0
- package/src/components/ui/dialog.tsx +6 -2
- package/src/components/ui/dropdown-menu.tsx +5 -1
- package/src/components/ui/finance/debts/debt-loan-form.tsx +12 -5
- package/src/components/ui/finance/debts/debt-loan-summary.tsx +3 -2
- package/src/components/ui/finance/debts/debts-page.test.tsx +54 -5
- package/src/components/ui/finance/debts/debts-page.tsx +15 -2
- package/src/components/ui/finance/invoices/components/subscription-group-selector.tsx +3 -5
- package/src/components/ui/finance/invoices/new-invoice-page.test.tsx +25 -5
- package/src/components/ui/finance/invoices/new-invoice-page.tsx +7 -2
- package/src/components/ui/finance/invoices/standard-invoice.tsx +4 -2
- package/src/components/ui/finance/invoices/subscription-invoice.tsx +4 -2
- package/src/components/ui/finance/invoices/utils.ts +3 -1
- package/src/components/ui/finance/transactions/form-content-dialog.tsx +3 -0
- package/src/components/ui/finance/transactions/form-types.ts +3 -0
- package/src/components/ui/finance/transactions/form.tsx +2 -0
- package/src/components/ui/finance/transactions/infinite-transactions-list.tsx +2 -0
- package/src/components/ui/finance/transactions/period-charts/category-breakdown-dialog.tsx +1 -1
- package/src/components/ui/finance/transactions/transaction-card.tsx +21 -9
- package/src/components/ui/finance/transactions/transaction-edit-dialog.tsx +1 -4
- package/src/components/ui/finance/transactions/transactions-create-summary.tsx +3 -0
- package/src/components/ui/finance/transactions/transactions-page.tsx +4 -1
- package/src/components/ui/finance/wallets/form.test.tsx +51 -3
- package/src/components/ui/finance/wallets/form.tsx +15 -4
- package/src/components/ui/finance/wallets/walletId/wallet-details-actions.tsx +4 -0
- package/src/components/ui/finance/wallets/walletId/wallet-details-page.tsx +4 -2
- package/src/components/ui/finance/wallets/wallets-data-table.tsx +1 -0
- package/src/components/ui/finance/wallets/wallets-page.tsx +5 -2
- package/src/components/ui/input-otp.tsx +1 -1
- package/src/components/ui/legacy/calendar/all-day-event-bar.tsx +28 -39
- package/src/components/ui/legacy/calendar/calendar-cell.tsx +2 -0
- package/src/components/ui/legacy/calendar/calendar-content.tsx +10 -6
- package/src/components/ui/legacy/calendar/calendar-header.tsx +23 -3
- package/src/components/ui/legacy/calendar/calendar-loading-skeleton.tsx +135 -0
- package/src/components/ui/legacy/calendar/calendar-matrix.tsx +175 -237
- package/src/components/ui/legacy/calendar/event-card.test.tsx +177 -0
- package/src/components/ui/legacy/calendar/event-card.tsx +220 -131
- package/src/components/ui/legacy/calendar/event-modal.tsx +17 -17
- package/src/components/ui/legacy/calendar/event-provider-display.tsx +69 -0
- package/src/components/ui/legacy/calendar/smart-calendar.test.tsx +86 -4
- package/src/components/ui/legacy/calendar/smart-calendar.tsx +32 -2
- package/src/components/ui/legacy/meet/create-plan-dialog.tsx +19 -10
- package/src/components/ui/money-input.test.tsx +64 -0
- package/src/components/ui/money-input.tsx +63 -0
- package/src/components/ui/navigation-menu.tsx +1 -1
- package/src/components/ui/pagination.tsx +1 -1
- package/src/components/ui/radio-group.tsx +1 -1
- package/src/components/ui/select.tsx +5 -1
- package/src/components/ui/sheet.tsx +1 -1
- package/src/components/ui/sidebar.tsx +1 -1
- package/src/components/ui/storefront/cart-popover.tsx +61 -0
- package/src/components/ui/storefront/cart-summary-parts.tsx +290 -0
- package/src/components/ui/storefront/cart-summary.tsx +104 -80
- package/src/components/ui/storefront/checkout-overlay.tsx +26 -0
- package/src/components/ui/storefront/hero-panel.tsx +2 -8
- package/src/components/ui/storefront/image-panel.tsx +6 -0
- package/src/components/ui/storefront/index.ts +11 -0
- package/src/components/ui/storefront/listing-card.tsx +84 -22
- package/src/components/ui/storefront/merch-sections.tsx +70 -0
- package/src/components/ui/storefront/product-detail.tsx +289 -0
- package/src/components/ui/storefront/product-dialog.tsx +72 -0
- package/src/components/ui/storefront/storefront-surface.test.tsx +221 -3
- package/src/components/ui/storefront/storefront-surface.tsx +288 -153
- package/src/components/ui/storefront/types.ts +27 -1
- package/src/components/ui/storefront/utils.ts +117 -27
- package/src/components/ui/text-editor/__tests__/content-migration.test.ts +32 -0
- package/src/components/ui/text-editor/__tests__/extensions.test.ts +123 -0
- package/src/components/ui/text-editor/__tests__/image-extension.test.ts +69 -1
- package/src/components/ui/text-editor/__tests__/video-extension.test.ts +47 -0
- package/src/components/ui/text-editor/background-color-extension.ts +62 -0
- package/src/components/ui/text-editor/color-controls.tsx +284 -0
- package/src/components/ui/text-editor/content-migration.ts +41 -18
- package/src/components/ui/text-editor/editor.tsx +69 -14
- package/src/components/ui/text-editor/extensions.ts +9 -3
- package/src/components/ui/text-editor/highlight-extension.ts +22 -0
- package/src/components/ui/text-editor/image-extension.ts +40 -18
- package/src/components/ui/text-editor/tool-bar.tsx +9 -16
- package/src/components/ui/text-editor/video-extension.ts +11 -2
- package/src/components/ui/toast.tsx +1 -1
- package/src/components/ui/tu-do/boards/__tests__/board-share-dialog.test.tsx +270 -0
- package/src/components/ui/tu-do/boards/__tests__/workspace-projects-client-page.test.tsx +70 -1
- package/src/components/ui/tu-do/boards/board-public-link-section.tsx +231 -0
- package/src/components/ui/tu-do/boards/board-share-dialog.tsx +222 -109
- package/src/components/ui/tu-do/boards/boardId/board-column-external-retry.test.tsx +127 -0
- package/src/components/ui/tu-do/boards/boardId/board-column.tsx +113 -46
- package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-clear-delete.ts +2 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-move.ts +5 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-updates.ts +3 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/data/kanban-deadline-query.ts +50 -2
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/__tests__/column-reorder.test.ts +17 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/column-reorder.ts +4 -1
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-cache.ts +51 -9
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-order.ts +2 -8
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-sort-key.ts +47 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/use-kanban-dnd.test.ts +63 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/use-kanban-dnd.ts +127 -38
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/__tests__/kanban-planner-island.test.tsx +380 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/kanban-planner-dialog.tsx +204 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-digest-panel.tsx +61 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-item-strip.tsx +54 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-plan-toolbar.tsx +251 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-scope-badge.tsx +27 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-section.tsx +58 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-share-dialog.tsx +238 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-target-controls.tsx +143 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-utils.ts +65 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/use-kanban-planner-state.ts +234 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-columns.test.tsx +410 -4
- package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-columns.tsx +106 -14
- package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-deadline-panels.tsx +443 -19
- package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-skeleton.tsx +94 -32
- package/src/components/ui/tu-do/boards/boardId/kanban.tsx +213 -106
- package/src/components/ui/tu-do/boards/boardId/task-board-server-page.test.tsx +186 -0
- package/src/components/ui/tu-do/boards/boardId/task-board-server-page.tsx +59 -2
- package/src/components/ui/tu-do/boards/boardId/task-card/measured-task-card.tsx +3 -0
- package/src/components/ui/tu-do/boards/boardId/task-card/task-card-comparator.ts +3 -0
- package/src/components/ui/tu-do/boards/boardId/task-card/task-card.tsx +191 -28
- package/src/components/ui/tu-do/boards/boardId/task-filter.test.tsx +152 -0
- package/src/components/ui/tu-do/boards/boardId/task-filter.tsx +555 -545
- package/src/components/ui/tu-do/boards/boardId/task-list.tsx +7 -0
- package/src/components/ui/tu-do/boards/boardId/timeline/timeline-display.ts +9 -0
- package/src/components/ui/tu-do/boards/boardId/timeline/timeline-grid.tsx +8 -16
- package/src/components/ui/tu-do/boards/boardId/timeline/timeline-task-row.tsx +5 -25
- package/src/components/ui/tu-do/boards/boardId/timeline/timeline-utils.test.ts +36 -1
- package/src/components/ui/tu-do/boards/boardId/timeline/timeline-utils.ts +51 -2
- package/src/components/ui/tu-do/boards/share-section.tsx +100 -0
- package/src/components/ui/tu-do/boards/workspace-projects-client-page.tsx +13 -3
- package/src/components/ui/tu-do/drafts/draft-convert-dialog.tsx +10 -12
- package/src/components/ui/tu-do/drafts/drafts-page.tsx +33 -16
- package/src/components/ui/tu-do/initiatives/task-initiatives-client.tsx +56 -88
- package/src/components/ui/tu-do/my-tasks/my-tasks-content.tsx +26 -2
- package/src/components/ui/tu-do/my-tasks/use-my-tasks-state.ts +55 -8
- package/src/components/ui/tu-do/notes/note-edit-dialog.tsx +1 -4
- package/src/components/ui/tu-do/shared/__tests__/board-client.test.tsx +25 -0
- package/src/components/ui/tu-do/shared/__tests__/board-header.test.tsx +341 -38
- package/src/components/ui/tu-do/shared/__tests__/board-switcher.test.tsx +253 -0
- package/src/components/ui/tu-do/shared/__tests__/board-views.test.tsx +237 -3
- package/src/components/ui/tu-do/shared/__tests__/task-board-loading-state.test.tsx +17 -0
- package/src/components/ui/tu-do/shared/__tests__/task-legacy-route-recovery.test.tsx +16 -0
- package/src/components/ui/tu-do/shared/board-client.tsx +2 -7
- package/src/components/ui/tu-do/shared/board-config-storage.ts +7 -1
- package/src/components/ui/tu-do/shared/board-header.tsx +465 -937
- package/src/components/ui/tu-do/shared/board-layout-settings.tsx +165 -136
- package/src/components/ui/tu-do/shared/board-switcher.tsx +209 -217
- package/src/components/ui/tu-do/shared/board-views.tsx +596 -82
- package/src/components/ui/tu-do/shared/cursor-overlay-multi-wrapper.tsx +53 -12
- package/src/components/ui/tu-do/shared/list-view.tsx +227 -1
- package/src/components/ui/tu-do/shared/recycle-bin-panel.tsx +142 -94
- package/src/components/ui/tu-do/shared/special-task-list-pins.ts +51 -0
- package/src/components/ui/tu-do/shared/task-board-loading-state.tsx +28 -0
- package/src/components/ui/tu-do/shared/task-dialog-presentation.test.ts +53 -0
- package/src/components/ui/tu-do/shared/task-dialog-presentation.ts +19 -0
- package/src/components/ui/tu-do/shared/task-edit-dialog/components/compact-task-create-popover.test.tsx +57 -0
- package/src/components/ui/tu-do/shared/task-edit-dialog/components/compact-task-create-popover.tsx +136 -111
- package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-description-editor.tsx +3 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/field-diff-viewer.tsx +3 -2
- package/src/components/ui/tu-do/shared/task-edit-dialog/selective-revert-panel.test.tsx +91 -0
- package/src/components/ui/tu-do/shared/task-edit-dialog/selective-revert-panel.tsx +123 -78
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-activity-section.tsx +7 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-snapshot-dialog.tsx +8 -3
- package/src/components/ui/tu-do/shared/task-edit-dialog.tsx +44 -15
- package/src/components/ui/tu-do/shared/task-legacy-route-recovery.tsx +2 -9
- package/src/declarations.d.ts +1 -0
- package/src/hooks/__tests__/use-calendar-readonly.test.tsx +322 -2
- package/src/hooks/__tests__/use-calendar-sync.test.tsx +446 -0
- package/src/hooks/__tests__/useBoardRealtime.test.tsx +2 -2
- package/src/hooks/__tests__/useCursorTracking.test.tsx +212 -0
- package/src/hooks/use-calendar-sync.tsx +247 -243
- package/src/hooks/use-calendar.tsx +323 -138
- package/src/hooks/use-task-actions.ts +24 -0
- package/src/hooks/use-user-workspace-config.ts +75 -0
- package/src/hooks/use-workspace-currency.ts +8 -3
- package/src/hooks/useBoardRealtime.ts +6 -3
- package/src/hooks/useBoardRealtime.types.ts +11 -0
- package/src/hooks/useBoardRealtimeEventHandler.ts +11 -0
- package/src/hooks/useCursorTracking.ts +91 -27
- package/src/hooks/useTaskUserRealtime.ts +5 -3
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import type {
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
+
import type {
|
|
3
|
+
InventoryStorefront,
|
|
4
|
+
InventoryStorefrontListing,
|
|
5
|
+
} from '@tuturuuu/internal-api/inventory';
|
|
3
6
|
import { describe, expect, it } from 'vitest';
|
|
4
7
|
import { StorefrontSurface } from './storefront-surface';
|
|
5
|
-
import { sanitizeStorefrontAccentColor } from './utils';
|
|
8
|
+
import { formatStorefrontPrice, sanitizeStorefrontAccentColor } from './utils';
|
|
6
9
|
|
|
7
10
|
const storefront: InventoryStorefront = {
|
|
8
11
|
accentColor: '#abc',
|
|
@@ -29,6 +32,39 @@ const storefront: InventoryStorefront = {
|
|
|
29
32
|
wsId: 'ws-1',
|
|
30
33
|
};
|
|
31
34
|
|
|
35
|
+
const listing: InventoryStorefrontListing = {
|
|
36
|
+
availableQuantity: 8,
|
|
37
|
+
bundleId: null,
|
|
38
|
+
compareAtPrice: null,
|
|
39
|
+
createdAt: '2026-06-12T00:00:00.000Z',
|
|
40
|
+
description: 'A mentoring session for checkout tests.',
|
|
41
|
+
id: 'listing-1',
|
|
42
|
+
imageUrl: null,
|
|
43
|
+
listingType: 'product',
|
|
44
|
+
maxPerOrder: 5,
|
|
45
|
+
price: 100,
|
|
46
|
+
productId: 'product-1',
|
|
47
|
+
sortOrder: 1,
|
|
48
|
+
status: 'published',
|
|
49
|
+
storefrontId: storefront.id,
|
|
50
|
+
title: '1:1 Mentoring',
|
|
51
|
+
unitId: 'unit-1',
|
|
52
|
+
unitName: 'Session',
|
|
53
|
+
updatedAt: '2026-06-12T00:00:00.000Z',
|
|
54
|
+
warehouseId: 'warehouse-1',
|
|
55
|
+
warehouseName: 'Main',
|
|
56
|
+
wsId: storefront.wsId,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const secondListing: InventoryStorefrontListing = {
|
|
60
|
+
...listing,
|
|
61
|
+
id: 'listing-2',
|
|
62
|
+
price: 2500,
|
|
63
|
+
productId: 'product-2',
|
|
64
|
+
title: 'Team Workshop With Long Name',
|
|
65
|
+
unitId: 'unit-2',
|
|
66
|
+
};
|
|
67
|
+
|
|
32
68
|
describe('StorefrontSurface', () => {
|
|
33
69
|
it('sanitizes hex accent colors only', () => {
|
|
34
70
|
expect(sanitizeStorefrontAccentColor('#abc')).toBe('#aabbcc');
|
|
@@ -53,9 +89,121 @@ describe('StorefrontSurface', () => {
|
|
|
53
89
|
expect(screen.getAllByText('Preview Store')).toHaveLength(2);
|
|
54
90
|
expect(screen.getByText('No buyer listings')).toBeInTheDocument();
|
|
55
91
|
expect(screen.getByText('Create a listing next.')).toBeInTheDocument();
|
|
92
|
+
fireEvent.click(screen.getByRole('button', { name: 'Cart: 0' }));
|
|
56
93
|
expect(screen.getByText('Preview checkout disabled')).toBeDisabled();
|
|
57
94
|
});
|
|
58
95
|
|
|
96
|
+
it('links storefront chrome back to the store and opens cart from the header popover', () => {
|
|
97
|
+
render(
|
|
98
|
+
<StorefrontSurface
|
|
99
|
+
cartHref="/preview-store/cart"
|
|
100
|
+
cartLines={[{ listingId: listing.id, quantity: 2 }]}
|
|
101
|
+
listings={[listing]}
|
|
102
|
+
mode="store"
|
|
103
|
+
storefront={storefront}
|
|
104
|
+
storefrontHref="/preview-store"
|
|
105
|
+
/>
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
expect(screen.getByRole('link', { name: 'Preview Store' })).toHaveAttribute(
|
|
109
|
+
'href',
|
|
110
|
+
'/preview-store'
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
expect(screen.queryByText('$2.00')).not.toBeInTheDocument();
|
|
114
|
+
|
|
115
|
+
const cartButton = screen.getByRole('button', { name: 'Cart: 2' });
|
|
116
|
+
expect(cartButton).toHaveClass('h-11', 'min-w-14', 'shrink-0');
|
|
117
|
+
expect(cartButton.querySelector('svg')).toHaveClass('size-5', 'shrink-0');
|
|
118
|
+
|
|
119
|
+
fireEvent.click(cartButton);
|
|
120
|
+
|
|
121
|
+
expect(screen.getByRole('region', { name: 'Cart' })).toBeInTheDocument();
|
|
122
|
+
expect(screen.getAllByText('$2.00')).toHaveLength(2);
|
|
123
|
+
expect(screen.getAllByText('1M')).toHaveLength(1);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('keeps the compatibility cart page as a full cart review', () => {
|
|
127
|
+
render(
|
|
128
|
+
<StorefrontSurface
|
|
129
|
+
cartHref="/preview-store/cart"
|
|
130
|
+
cartLines={[{ listingId: listing.id, quantity: 2 }]}
|
|
131
|
+
checkoutHref="/preview-store/checkout"
|
|
132
|
+
listings={[listing]}
|
|
133
|
+
mode="cart"
|
|
134
|
+
onCheckoutOpen={() => undefined}
|
|
135
|
+
storefront={storefront}
|
|
136
|
+
storefrontHref="/preview-store"
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
expect(screen.getByRole('region', { name: 'Cart' })).toBeInTheDocument();
|
|
141
|
+
expect(screen.getByText('1:1 Mentoring')).toBeInTheDocument();
|
|
142
|
+
expect(screen.getAllByText('$2.00')).toHaveLength(2);
|
|
143
|
+
expect(screen.getByRole('button', { name: /Checkout/ })).toBeEnabled();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('keeps long item names and large totals inside the cart row bounds', () => {
|
|
147
|
+
const largeListing: InventoryStorefrontListing = {
|
|
148
|
+
...listing,
|
|
149
|
+
price: 123_456_789,
|
|
150
|
+
title:
|
|
151
|
+
'A very long product title with specifications, measurements, and buyer-facing detail',
|
|
152
|
+
};
|
|
153
|
+
const expectedTotal = formatStorefrontPrice(largeListing.price * 5, 'USD');
|
|
154
|
+
|
|
155
|
+
render(
|
|
156
|
+
<StorefrontSurface
|
|
157
|
+
cartLines={[{ listingId: largeListing.id, quantity: 5 }]}
|
|
158
|
+
listings={[largeListing]}
|
|
159
|
+
mode="cart"
|
|
160
|
+
storefront={storefront}
|
|
161
|
+
/>
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const amount = screen.getByTitle(expectedTotal);
|
|
165
|
+
expect(amount).toHaveClass(
|
|
166
|
+
'max-w-[9rem]',
|
|
167
|
+
'overflow-hidden',
|
|
168
|
+
'text-ellipsis',
|
|
169
|
+
'text-right'
|
|
170
|
+
);
|
|
171
|
+
expect(screen.getByText(largeListing.title)).toHaveClass(
|
|
172
|
+
'line-clamp-2',
|
|
173
|
+
'break-words'
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('prefills checkout buyer details while keeping editable form fields', () => {
|
|
178
|
+
render(
|
|
179
|
+
<StorefrontSurface
|
|
180
|
+
buyerDefaults={{
|
|
181
|
+
email: 'buyer@example.com',
|
|
182
|
+
name: 'Sokora Buyer',
|
|
183
|
+
}}
|
|
184
|
+
cartLines={[
|
|
185
|
+
{ listingId: listing.id, quantity: 1 },
|
|
186
|
+
{ listingId: secondListing.id, quantity: 1 },
|
|
187
|
+
]}
|
|
188
|
+
listings={[listing, secondListing]}
|
|
189
|
+
mode="checkout"
|
|
190
|
+
onCheckoutSubmit={() => undefined}
|
|
191
|
+
storefront={storefront}
|
|
192
|
+
/>
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
expect(
|
|
196
|
+
screen.getByRole('button', { name: /Order summary/ })
|
|
197
|
+
).toBeInTheDocument();
|
|
198
|
+
expect(
|
|
199
|
+
screen.getByRole('button', { name: 'Contact details' })
|
|
200
|
+
).toBeInTheDocument();
|
|
201
|
+
expect(screen.getByLabelText('Name')).toHaveValue('Sokora Buyer');
|
|
202
|
+
expect(screen.getByLabelText('Email')).toHaveValue('buyer@example.com');
|
|
203
|
+
expect(screen.getByLabelText('Name')).toBeEnabled();
|
|
204
|
+
expect(screen.getByLabelText('Email')).toBeEnabled();
|
|
205
|
+
});
|
|
206
|
+
|
|
59
207
|
it('keeps simulated storefront chrome customer-facing', () => {
|
|
60
208
|
render(
|
|
61
209
|
<StorefrontSurface
|
|
@@ -84,6 +232,76 @@ describe('StorefrontSurface', () => {
|
|
|
84
232
|
);
|
|
85
233
|
|
|
86
234
|
expect(screen.queryByText('Checkout disabled')).not.toBeInTheDocument();
|
|
235
|
+
fireEvent.click(screen.getByRole('button', { name: 'Cart: 0' }));
|
|
87
236
|
expect(screen.getByText('Checkout unavailable')).toBeDisabled();
|
|
88
237
|
});
|
|
238
|
+
|
|
239
|
+
it('renders only http storefront section links', () => {
|
|
240
|
+
render(
|
|
241
|
+
<StorefrontSurface
|
|
242
|
+
listings={[]}
|
|
243
|
+
mode="store"
|
|
244
|
+
storefront={{
|
|
245
|
+
...storefront,
|
|
246
|
+
sections: [
|
|
247
|
+
{
|
|
248
|
+
createdAt: null,
|
|
249
|
+
description: null,
|
|
250
|
+
href: null,
|
|
251
|
+
id: 'section-empty',
|
|
252
|
+
imageUrl: null,
|
|
253
|
+
items: [],
|
|
254
|
+
metadata: {},
|
|
255
|
+
sectionType: 'promo',
|
|
256
|
+
sortOrder: 0,
|
|
257
|
+
status: 'published',
|
|
258
|
+
storefrontId: storefront.id,
|
|
259
|
+
title: null,
|
|
260
|
+
updatedAt: null,
|
|
261
|
+
wsId: storefront.wsId,
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
createdAt: null,
|
|
265
|
+
description: null,
|
|
266
|
+
href: 'javascript:alert(document.domain)',
|
|
267
|
+
id: 'section-unsafe',
|
|
268
|
+
imageUrl: null,
|
|
269
|
+
items: [],
|
|
270
|
+
metadata: {},
|
|
271
|
+
sectionType: 'promo',
|
|
272
|
+
sortOrder: 1,
|
|
273
|
+
status: 'published',
|
|
274
|
+
storefrontId: storefront.id,
|
|
275
|
+
title: 'Unsafe section',
|
|
276
|
+
updatedAt: null,
|
|
277
|
+
wsId: storefront.wsId,
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
createdAt: null,
|
|
281
|
+
description: null,
|
|
282
|
+
href: 'https://example.com/promo',
|
|
283
|
+
id: 'section-safe',
|
|
284
|
+
imageUrl: null,
|
|
285
|
+
items: [],
|
|
286
|
+
metadata: {},
|
|
287
|
+
sectionType: 'promo',
|
|
288
|
+
sortOrder: 2,
|
|
289
|
+
status: 'published',
|
|
290
|
+
storefrontId: storefront.id,
|
|
291
|
+
title: 'Safe section',
|
|
292
|
+
updatedAt: null,
|
|
293
|
+
wsId: storefront.wsId,
|
|
294
|
+
},
|
|
295
|
+
],
|
|
296
|
+
}}
|
|
297
|
+
/>
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
expect(screen.getByText('Safe section')).toBeInTheDocument();
|
|
301
|
+
expect(screen.queryByText('Storefront section')).not.toBeInTheDocument();
|
|
302
|
+
expect(
|
|
303
|
+
screen.getByRole('link', { name: 'example.com/promo' })
|
|
304
|
+
).toHaveAttribute('href', 'https://example.com/promo');
|
|
305
|
+
expect(screen.queryByText('javascript:alert(document.domain)')).toBeNull();
|
|
306
|
+
});
|
|
89
307
|
});
|