Skip to content

Commit 83610ef

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

1 file changed

Lines changed: 49 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':

0 commit comments

Comments
 (0)