Skip to content

Commit c9e53ce

Browse files
committed
fix(pos): add mock factory for pos.app.ready.data in ui-extensions-tester
1 parent e02def9 commit c9e53ce

7 files changed

Lines changed: 63698 additions & 0 deletions

File tree

packages/ui-extensions-tester/src/point-of-sale/factories.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
RenderExtensionTarget,
55
StandardApi,
66
ActionTargetApi,
7+
DataTargetApi,
78
ActionApi,
89
CartApi,
910
OrderApi,
@@ -429,6 +430,51 @@ function createActionTargetCashDrawerMock<T extends RenderExtensionTarget>(
429430
};
430431
}
431432

433+
// Data target factories
434+
function createDataTargetMock<T extends ExtensionTarget>(
435+
target: T,
436+
): DataTargetApi<T> {
437+
return {
438+
extensionPoint: target,
439+
i18n: createMockI18n(),
440+
session: {
441+
currentSession: createSessionCurrentSession(),
442+
getSessionToken: async () => 'mock-session-token',
443+
deviceId: 1,
444+
},
445+
storage: createStorage(),
446+
locale: {current: createReadonlySignalLike('en-US')},
447+
connectivity: {
448+
current: createReadonlySignalLike(createConnectivityState()),
449+
},
450+
device: {
451+
name: 'Mock POS Device',
452+
registerName: 'Register 1',
453+
getDeviceId: async () => 'mock-device-id',
454+
isTablet: async () => false,
455+
},
456+
productSearch: {
457+
searchProducts: async () => ({items: [], hasNextPage: false}),
458+
fetchProductWithId: async () => undefined,
459+
fetchProductsWithIds: async () => ({
460+
fetchedResources: [],
461+
idsForResourcesNotFound: [],
462+
}),
463+
fetchProductVariantWithId: async () => undefined,
464+
fetchProductVariantsWithIds: async () => ({
465+
fetchedResources: [],
466+
idsForResourcesNotFound: [],
467+
}),
468+
fetchProductVariantsWithProductId: async () => [],
469+
fetchPaginatedProductVariantsWithProductId: async () => ({
470+
items: [],
471+
hasNextPage: false,
472+
}),
473+
},
474+
...createMockCartApi(),
475+
};
476+
}
477+
432478
// Event target factories
433479
function createTransactionCompleteMock<T extends ExtensionTarget>(
434480
_target: T,
@@ -548,6 +594,9 @@ const posMockFactories: PosMockFactory = {
548594
// Group Q: ActionTargetApi + CashDrawerApi
549595
'pos.register-details.action.render': createActionTargetCashDrawerMock,
550596

597+
// Data targets
598+
'pos.app.ready.data': createDataTargetMock,
599+
551600
// Event targets
552601
'pos.transaction-complete.event.observe': createTransactionCompleteMock,
553602
'pos.cash-tracking-session-start.event.observe':

packages/ui-extensions/docs/surfaces/admin/generated/generated_docs_data.json

Lines changed: 32512 additions & 0 deletions
Large diffs are not rendered by default.

packages/ui-extensions/docs/surfaces/admin/generated/generated_static_pages.json

Lines changed: 625 additions & 0 deletions
Large diffs are not rendered by default.

packages/ui-extensions/docs/surfaces/point-of-sale/generated/generated_docs_data.json

Lines changed: 16177 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
[
2+
{
3+
"title": "Targets overview",
4+
"description": "\nA [target](/docs/apps/app-extensions/configuration#targets) represents where your POS UI extension will appear.\n",
5+
"id": "extension-targets-overview",
6+
"image": "/assets/landing-pages/templated-apis/hero.png",
7+
"darkImage": "/assets/landing-pages/templated-apis/hero-dark.png",
8+
"tabletImage": "/assets/landing-pages/templated-apis/hero.png",
9+
"tabletDarkImage": "/assets/landing-pages/templated-apis/hero-dark.png",
10+
"mobileImage": "/assets/landing-pages/templated-apis/hero.png",
11+
"mobileDarkImage": "/assets/landing-pages/templated-apis/hero-dark.png",
12+
"sections": [
13+
{
14+
"type": "GenericAccordion",
15+
"title": "Smart grid",
16+
"anchorLink": "smart-grid",
17+
"sectionContent": "The smart grid. Learn more about [the smart grid](/docs/apps/pos#home-screen).",
18+
"accordionContent": [
19+
{
20+
"title": "Tile",
21+
"description": "\nDisplays a tile on the smart grid.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
22+
},
23+
{
24+
"title": "Modal",
25+
"description": "\nDisplays a modal when a tile is tapped.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
26+
}
27+
]
28+
},
29+
{
30+
"type": "GenericAccordion",
31+
"title": "Post-purchase",
32+
"anchorLink": "post-purchase",
33+
"sectionContent": "The post-purchase screen",
34+
"accordionContent": [
35+
{
36+
"title": "Menu item",
37+
"description": "\nDisplays a menu item on the post-purchase screen.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
38+
},
39+
{
40+
"title": "Action",
41+
"description": "\nDisplays a modal when a menu item is tapped.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
42+
},
43+
{
44+
"title": "Block",
45+
"description": "\nRenders a custom section within the native post purchase screen.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
46+
}
47+
]
48+
},
49+
{
50+
"type": "GenericAccordion",
51+
"title": "Customer details",
52+
"anchorLink": "customer-details",
53+
"sectionContent": "The customer details screen",
54+
"accordionContent": [
55+
{
56+
"title": "Menu item",
57+
"description": "\nDisplays a menu item on the customer details screen.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
58+
},
59+
{
60+
"title": "Action",
61+
"description": "\nDisplays an action target modally when a menu item is tapped.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
62+
},
63+
{
64+
"title": "Block",
65+
"description": "\nRenders a custom section within the customer details screen.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
66+
}
67+
]
68+
},
69+
{
70+
"type": "GenericAccordion",
71+
"title": "Product details",
72+
"anchorLink": "product-details",
73+
"sectionContent": "The product details screen",
74+
"accordionContent": [
75+
{
76+
"title": "Menu item",
77+
"description": "\nDisplays a menu item on the product details screen.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
78+
},
79+
{
80+
"title": "Action",
81+
"description": "\nDisplays an action target modally when a menu item is tapped.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
82+
},
83+
{
84+
"title": "Block",
85+
"description": "\nRenders a custom section within the native product details screen.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
86+
}
87+
]
88+
},
89+
{
90+
"type": "GenericAccordion",
91+
"title": "Order details",
92+
"anchorLink": "order-details",
93+
"sectionContent": "The order details screen",
94+
"accordionContent": [
95+
{
96+
"title": "Menu item",
97+
"description": "\nDisplays a menu item on the order details screen.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
98+
},
99+
{
100+
"title": "Action",
101+
"description": "\nDisplays an action target modally when a menu item is tapped.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
102+
},
103+
{
104+
"title": "Block",
105+
"description": "\nRenders a custom section within the native order details screen.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
106+
}
107+
]
108+
},
109+
{
110+
"type": "GenericAccordion",
111+
"title": "Draft Order details",
112+
"anchorLink": "draft-order-details",
113+
"sectionContent": "The draft order details screen",
114+
"accordionContent": [
115+
{
116+
"title": "Menu item",
117+
"description": "\nDisplays a menu item on the draft order details screen.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
118+
},
119+
{
120+
"title": "Action",
121+
"description": "\nDisplays an action target modally when a menu item is tapped.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
122+
},
123+
{
124+
"title": "Block",
125+
"description": "\nRenders a custom section within the native draft order details screen.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
126+
}
127+
]
128+
},
129+
{
130+
"type": "GenericAccordion",
131+
"title": "Cart line item details",
132+
"anchorLink": "cart-line-item-details",
133+
"sectionContent": "The cart line item details screen",
134+
"accordionContent": [
135+
{
136+
"title": "Action",
137+
"description": "\nDisplays an action target in the cart line item details screen.\n\nReview [all extension targets](/docs/api/pos-ui-extensions/targets).\n"
138+
}
139+
]
140+
}
141+
]
142+
},
143+
{
144+
"title": "POS UI extensions",
145+
"description": "The UI Extensions library enables individuals to build extensions that use interface elements and behaviors that mirror the look and feel of the POS retail experience. These elements render natively, providing the performance and accessibility inherent to a native app.",
146+
"id": "pos-ui-extensions",
147+
"image": "/assets/landing-pages/templated-apis/hero.png",
148+
"darkImage": "/assets/landing-pages/templated-apis/hero-dark.png",
149+
"tabletImage": "/assets/landing-pages/templated-apis/hero.png",
150+
"tabletDarkImage": "/assets/landing-pages/templated-apis/hero-dark.png",
151+
"mobileImage": "/assets/landing-pages/templated-apis/hero.png",
152+
"mobileDarkImage": "/assets/landing-pages/templated-apis/hero-dark.png",
153+
"sections": [
154+
{
155+
"type": "Generic",
156+
"anchorLink": "api-versioning",
157+
"title": "API versioning",
158+
"sectionContent": "POS UI extensions are built on a versioned API that receives regular updates with new features, improvements, and additional targets. We recommend using the latest supported API version to access the most current capabilities and ensure optimal compatibility with POS devices.\n\nYou can track new releases and update your extensions by referencing the [developer changelog](/changelog)."
159+
},
160+
{
161+
"type": "Generic",
162+
"anchorLink": "overview",
163+
"title": "Overview",
164+
"sectionContent": "Extend the Shopify POS with UI Extensions.",
165+
"sectionCard": [
166+
{
167+
"subtitle": "Extension targets",
168+
"name": "See all available extension targets",
169+
"url": "targets",
170+
"type": "pickaxe-1"
171+
},
172+
{
173+
"subtitle": "APIs",
174+
"name": "See all available APIs",
175+
"url": "apis",
176+
"type": "pickaxe-2"
177+
},
178+
{
179+
"subtitle": "Components",
180+
"name": "See all available components",
181+
"url": "components",
182+
"type": "blocks"
183+
}
184+
]
185+
},
186+
{
187+
"type": "Generic",
188+
"anchorLink": "getting-started",
189+
"title": "Getting Started",
190+
"sectionContent": "Get started with POS UI Extensions with Shopify CLI.",
191+
"sectionCard": [
192+
{
193+
"name": "Getting started guide",
194+
"subtitle": "Set up your development environment",
195+
"url": "/docs/apps/build/pos/getting-started",
196+
"type": "blocks"
197+
}
198+
]
199+
}
200+
]
201+
}
202+
]

0 commit comments

Comments
 (0)