@akinon/pz-theme 2.0.152-rc.3 → 2.0.153-beta.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 +8 -52
- package/package.json +4 -4
- package/src/blocks/__tests__/add-to-cart-action.test.tsx +1 -0
- package/src/blocks/__tests__/add-to-cart-stock-alert.test.tsx +673 -0
- package/src/blocks/add-to-cart-block.tsx +400 -10
- package/src/blocks/item-template.tsx +19 -25
- package/src/blocks/order-list-block.tsx +2 -25
- package/src/blocks/product-block-utils.tsx +40 -0
- package/src/blocks/stock-alert-pick.ts +106 -0
- package/src/blocks/variant-selector-block.tsx +167 -9
- package/src/chrome/__tests__/page-context-builders.test.ts +1 -14
- package/src/chrome/page-context.ts +0 -4
- package/src/custom/README.md +0 -20
- package/src/overlays/overlay-surface.tsx +21 -12
- package/src/__tests__/row-scope.test.tsx +0 -118
- package/src/blocks/__tests__/order-list-rows.test.tsx +0 -112
- package/src/blocks/row-scope.tsx +0 -35
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import OrderListBlock from '../order-list-block';
|
|
4
|
-
|
|
5
|
-
const captured: { items: Record<string, unknown>[] } = { items: [] };
|
|
6
|
-
|
|
7
|
-
jest.mock('../item-template', () => ({
|
|
8
|
-
__esModule: true,
|
|
9
|
-
hasItemTemplate: () => true,
|
|
10
|
-
ItemTemplateList: ({ items }: { items: Record<string, unknown>[] }) => {
|
|
11
|
-
captured.items = items;
|
|
12
|
-
return <div data-testid="item-template-list" />;
|
|
13
|
-
}
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
jest.mock('next-auth/react', () => ({
|
|
17
|
-
useSession: () => ({ data: null, status: 'authenticated' })
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
-
jest.mock('@akinon/next/hooks', () => ({
|
|
21
|
-
__esModule: true,
|
|
22
|
-
useLocalization: () => ({ locale: 'tr', currency: 'try' })
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
jest.mock('@akinon/next/redux/hooks', () => ({
|
|
26
|
-
__esModule: true,
|
|
27
|
-
useAppSelector: () => undefined,
|
|
28
|
-
useAppDispatch: () => jest.fn()
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
jest.mock('@akinon/next/data/client/account', () => ({
|
|
32
|
-
__esModule: true,
|
|
33
|
-
useGetOrdersQuery: () => ({
|
|
34
|
-
data: {
|
|
35
|
-
count: 1,
|
|
36
|
-
results: [
|
|
37
|
-
{
|
|
38
|
-
id: 42,
|
|
39
|
-
number: 'ORD-42',
|
|
40
|
-
amount: '100.00',
|
|
41
|
-
created_date: '2026-09-01T10:00:00Z',
|
|
42
|
-
status: { value: '550', label: 'Delivered' },
|
|
43
|
-
orderitem_set: [
|
|
44
|
-
{
|
|
45
|
-
id: 7,
|
|
46
|
-
status: { value: 550, label: 'Delivered' },
|
|
47
|
-
product: {
|
|
48
|
-
sku: 'SKU-1',
|
|
49
|
-
base_code: 'BASE-1',
|
|
50
|
-
name: 'Sneaker',
|
|
51
|
-
image: '/s.jpg'
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
status: { value: '400', label: 'Approved' },
|
|
56
|
-
product: { name: 'Boot' }
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
},
|
|
62
|
-
isLoading: false
|
|
63
|
-
})
|
|
64
|
-
}));
|
|
65
|
-
|
|
66
|
-
describe('order list rows', () => {
|
|
67
|
-
it('publishes the order items with their product codes and status code', () => {
|
|
68
|
-
render(
|
|
69
|
-
<OrderListBlock
|
|
70
|
-
block={{
|
|
71
|
-
id: 'order-list-1',
|
|
72
|
-
type: 'order-list',
|
|
73
|
-
properties: {},
|
|
74
|
-
styles: {},
|
|
75
|
-
blocks: []
|
|
76
|
-
}}
|
|
77
|
-
placeholderId="p1"
|
|
78
|
-
sectionId="s1"
|
|
79
|
-
/>
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
expect(captured.items).toHaveLength(1);
|
|
83
|
-
expect(captured.items[0]).toMatchObject({
|
|
84
|
-
id: 42,
|
|
85
|
-
number: 'ORD-42',
|
|
86
|
-
createdDate: '2026-09-01T10:00:00Z'
|
|
87
|
-
});
|
|
88
|
-
expect(captured.items[0].items).toEqual([
|
|
89
|
-
{
|
|
90
|
-
id: 7,
|
|
91
|
-
name: 'Sneaker',
|
|
92
|
-
image: '/s.jpg',
|
|
93
|
-
status: 'Delivered',
|
|
94
|
-
statusValue: '550',
|
|
95
|
-
product: {
|
|
96
|
-
sku: 'SKU-1',
|
|
97
|
-
base_code: 'BASE-1',
|
|
98
|
-
name: 'Sneaker',
|
|
99
|
-
image: '/s.jpg'
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
id: 1,
|
|
104
|
-
name: 'Boot',
|
|
105
|
-
image: '',
|
|
106
|
-
status: 'Approved',
|
|
107
|
-
statusValue: '400',
|
|
108
|
-
product: { sku: '', base_code: '', name: 'Boot', image: '' }
|
|
109
|
-
}
|
|
110
|
-
]);
|
|
111
|
-
});
|
|
112
|
-
});
|
package/src/blocks/row-scope.tsx
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
export interface ThemeRowScopeValue {
|
|
6
|
-
listType: string;
|
|
7
|
-
row: Record<string, unknown>;
|
|
8
|
-
index: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const ThemeRowScopeContext = React.createContext<ThemeRowScopeValue | null>(
|
|
12
|
-
null
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
export const ThemeRowScopeProvider = ({
|
|
16
|
-
listType,
|
|
17
|
-
row,
|
|
18
|
-
index,
|
|
19
|
-
children
|
|
20
|
-
}: ThemeRowScopeValue & { children: React.ReactNode }) => {
|
|
21
|
-
const value = React.useMemo(
|
|
22
|
-
() => ({ listType, row, index }),
|
|
23
|
-
[listType, row, index]
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<ThemeRowScopeContext.Provider value={value}>
|
|
28
|
-
{children}
|
|
29
|
-
</ThemeRowScopeContext.Provider>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/** Non-null while a repeated row of any list renders; null everywhere else. */
|
|
34
|
-
export const useThemeRowScope = (): ThemeRowScopeValue | null =>
|
|
35
|
-
React.useContext(ThemeRowScopeContext);
|