@applicaster/zapp-react-native-utils 16.0.0-rc.98 → 17.0.0-alpha.1984136194

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 (152) hide show
  1. package/actionUtils/index.ts +3 -1
  2. package/actionsExecutor/ActionExecutor.ts +2 -2
  3. package/actionsExecutor/ActionExecutorContext.tsx +2 -2
  4. package/actionsExecutor/__tests__/StorageActions.test.ts +98 -0
  5. package/actionsExecutor/__tests__/feedDecorator.test.ts +30 -0
  6. package/actionsExecutor/__tests__/screenToggleFlag.test.ts +90 -0
  7. package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +186 -5
  8. package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +24 -0
  9. package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +72 -0
  10. package/actionsExecutor/actions/appRestart.ts +2 -2
  11. package/actionsExecutor/actions/confirmDialog.ts +2 -2
  12. package/actionsExecutor/actions/dismissBottomSheet.ts +2 -2
  13. package/actionsExecutor/actions/goBack.ts +2 -2
  14. package/actionsExecutor/actions/goHome.ts +2 -2
  15. package/actionsExecutor/actions/navigateToScreen.ts +35 -45
  16. package/actionsExecutor/actions/openBottomSheet.ts +4 -2
  17. package/actionsExecutor/actions/presentScreen.ts +2 -2
  18. package/actionsExecutor/actions/refreshComponent.ts +2 -2
  19. package/actionsExecutor/actions/screenToggleFlag.ts +1 -3
  20. package/actionsExecutor/actions/sendCloudEvent.ts +2 -2
  21. package/actionsExecutor/actions/showAlert.ts +2 -2
  22. package/actionsExecutor/actions/switchLayout.ts +2 -2
  23. package/actionsExecutor/feedDecorator.ts +8 -2
  24. package/actionsExecutor/types.ts +7 -0
  25. package/analyticsUtils/__tests__/playerAnalyticsSafeguard.test.ts +62 -0
  26. package/analyticsUtils/logger.ts +9 -4
  27. package/analyticsUtils/playerAnalyticsTracker.ts +1 -0
  28. package/appUtils/HooksManager/logger.ts +5 -2
  29. package/appUtils/accessibilityManager/logger.ts +2 -4
  30. package/appUtils/accessibilityManager/utils.ts +1 -1
  31. package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -22
  32. package/appUtils/contextKeysManager/__tests__/getKey/success/fullSearch.test.ts +1 -25
  33. package/appUtils/contextKeysManager/__tests__/getKey/success/searchInSecure.test.ts +1 -7
  34. package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +0 -25
  35. package/appUtils/contextKeysManager/__tests__/removeKey/success.test.ts +0 -6
  36. package/appUtils/contextKeysManager/__tests__/setKey/failure/failedToSaveInStorage.test.ts +0 -40
  37. package/appUtils/contextKeysManager/__tests__/setKey/{success/saveItemAndReference.test.ts → success.test.ts} +2 -42
  38. package/appUtils/contextKeysManager/index.ts +30 -131
  39. package/appUtils/focusManager/__tests__/focusManager.test.js +33 -0
  40. package/appUtils/focusManager/__tests__/focusToolbox.test.ts +357 -0
  41. package/appUtils/focusManager/focusToolbox.ts +223 -0
  42. package/appUtils/focusManager/index.ios.ts +7 -1
  43. package/appUtils/focusManager/index.ts +3 -3
  44. package/appUtils/focusManager/logger.ts +2 -2
  45. package/appUtils/focusManagerAux/index.ts +2 -2
  46. package/appUtils/orientationHelper.ts +2 -2
  47. package/appUtils/platform/platformUtils.ts +2 -2
  48. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +1 -1
  49. package/appUtils/playerManager/__tests__/playerDiagnostics.test.ts +62 -0
  50. package/appUtils/playerManager/__tests__/playerNative.test.ts +76 -0
  51. package/appUtils/playerManager/__tests__/playerNativeCommand.test.ts +62 -0
  52. package/appUtils/playerManager/__tests__/playerToolbox.test.ts +281 -0
  53. package/appUtils/playerManager/__tests__/usePlayerControllerSetup.test.tsx +62 -0
  54. package/appUtils/playerManager/const.ts +13 -0
  55. package/appUtils/playerManager/index.ts +9 -2
  56. package/appUtils/playerManager/player.ts +26 -1
  57. package/appUtils/playerManager/playerNative.ts +23 -1
  58. package/appUtils/playerManager/playerNativeCommand.ts +3 -6
  59. package/appUtils/playerManager/playerToolbox.ts +196 -0
  60. package/appUtils/playerManager/usePlayNextOverlay.tsx +2 -2
  61. package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -0
  62. package/appUtils/playerManager/userCellPlayerMutedPreference.ts +1 -1
  63. package/appUtils/playerManager/userLanguagePreference.ts +1 -1
  64. package/arrayUtils/__tests__/reorderByIds.test.ts +13 -0
  65. package/arrayUtils/index.ts +26 -43
  66. package/cellUtils/__tests__/getButtonsEnabled.test.ts +28 -0
  67. package/cellUtils/__tests__/getCellNavigationEnabled.test.ts +36 -0
  68. package/cellUtils/__tests__/getIsCellNavigationEnabled.test.ts +35 -0
  69. package/cellUtils/__tests__/isCellNavigationEnabled.test.ts +21 -0
  70. package/cellUtils/index.ts +40 -0
  71. package/cellUtils/logger.ts +2 -2
  72. package/configurationUtils/__tests__/modalBlocksParser.test.ts +134 -0
  73. package/configurationUtils/modalBlocksParser.ts +38 -0
  74. package/domUtils/logger.ts +2 -2
  75. package/entryActions/aliasPresentation.ts +1 -0
  76. package/entryActions/buildEntryActions.ts +1 -1
  77. package/focusManager/FocusManager.ts +26 -0
  78. package/focusManager/__tests__/FocusManager.test.ts +9 -0
  79. package/focusManager/logger.ts +2 -6
  80. package/headersUtils/index.ts +2 -2
  81. package/localizationUtils/index.ts +12 -6
  82. package/logger/__tests__/subsystems.test.ts +148 -0
  83. package/logger/__tests__/xrayToolbox.test.ts +69 -0
  84. package/logger/index.ts +48 -9
  85. package/logger/subsystems.ts +112 -0
  86. package/logger/xrayToolbox.ts +69 -0
  87. package/manifestUtils/__tests__/createConfig.test.js +17 -7
  88. package/manifestUtils/_internals/getDefaultConfiguration.js +9 -11
  89. package/manifestUtils/defaultManifestConfigurations/player.js +8 -0
  90. package/manifestUtils/keys.js +7 -2
  91. package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +21 -0
  92. package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +1 -1
  93. package/manifestUtils/mobileAction/groups/defaults.js +2 -1
  94. package/modalState/EditableCollectionRegistry.ts +1 -1
  95. package/modalState/ModalOrchestrator.ts +1 -0
  96. package/modalState/RemoteEditableCollection.ts +1 -1
  97. package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +23 -0
  98. package/modalState/index.ts +2 -0
  99. package/modalState/types.ts +11 -0
  100. package/navigationUtils/index.ts +5 -2
  101. package/navigationUtils/xrayNavigator.ts +12 -0
  102. package/numberUtils/index.ts +2 -2
  103. package/package.json +3 -2
  104. package/playerUtils/PlayerTTS/PlayerTTS.ts +1 -1
  105. package/playerUtils/imaScriptDom.ts +1 -1
  106. package/playerUtils/useValidatePlayerConfig.tsx +1 -1
  107. package/pluginUtils/logger.ts +2 -2
  108. package/quickBrickAssets/__tests__/index.test.ts +18 -0
  109. package/quickBrickAssets/index.ts +35 -0
  110. package/reactHooks/__tests__/getPluginConfiguration.test.ts +82 -0
  111. package/reactHooks/actions/index.ts +29 -23
  112. package/reactHooks/cell-click/__tests__/index.test.js +67 -1
  113. package/reactHooks/cell-click/index.ts +10 -2
  114. package/reactHooks/connection/index.tsx +8 -5
  115. package/reactHooks/feed/__tests__/feedInvalidation.test.tsx +338 -0
  116. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +8 -2
  117. package/reactHooks/feed/__tests__/useMarkPipesDataStale.test.tsx +243 -0
  118. package/reactHooks/feed/useBuildPipesUrl.ts +5 -2
  119. package/reactHooks/feed/useFeedLoader.tsx +30 -3
  120. package/reactHooks/feed/useLoadPipesDataDispatch.ts +12 -11
  121. package/reactHooks/feed/useMarkPipesDataStale.ts +68 -23
  122. package/reactHooks/hookModal/hooks/useHookModalScreenData.ts +5 -2
  123. package/reactHooks/logger.ts +5 -2
  124. package/reactHooks/navigation/usePresentScreen.ts +2 -2
  125. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +2 -2
  126. package/reactHooks/screen/useScreenData.ts +2 -2
  127. package/reactHooks/usePluginConfiguration.ts +84 -46
  128. package/reactHooks/videoModal/hooks/useChangeOrientation.ts +2 -7
  129. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +1 -1
  130. package/reactUtils/createContext/helpers.ts +2 -2
  131. package/reactUtils/logger.ts +2 -2
  132. package/riverComponetsMeasurementProvider/index.tsx +5 -5
  133. package/storage/ScreenSingleValueProvider.ts +1 -1
  134. package/storage/ScreenStateMultiSelectProvider.ts +1 -1
  135. package/storage/StorageMultiSelectProvider.ts +1 -1
  136. package/storage/StorageSingleSelectProvider.ts +1 -1
  137. package/stylesUtils/logger.ts +2 -2
  138. package/uiActionsRegistrator/__tests__/subscribe.test.ts +26 -0
  139. package/uiActionsRegistrator/registry.ts +17 -1
  140. package/uiActionsRegistrator/resolveActionIdentifiers.ts +1 -1
  141. package/uiActionsRegistrator/usableActionItems.ts +1 -1
  142. package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +2 -1
  143. package/zappFrameworkUtils/loginPluginUtils.ts +2 -1
  144. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -1
  145. package/appUtils/contextKeysManager/__tests__/getKey/success/byReference.test.ts +0 -56
  146. package/appUtils/contextKeysManager/__tests__/getKeyByReference/failure.test.ts +0 -265
  147. package/appUtils/contextKeysManager/__tests__/getKeyByReference/success.test.ts +0 -303
  148. package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/failure.test.ts +0 -82
  149. package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/success.test.ts +0 -41
  150. package/appUtils/contextKeysManager/__tests__/setKey/success/saveItemButNotReference.test.ts +0 -208
  151. package/appUtils/contextKeysManager/__tests__/setReferenceForKey/failure.test.ts +0 -93
  152. package/appUtils/contextKeysManager/__tests__/setReferenceForKey/success.test.ts +0 -45
@@ -3,5 +3,7 @@ import { isTV } from "../reactUtils";
3
3
 
4
4
  export const resolveDefaultAssetUri = (source: string | number): string =>
5
5
  isTV()
6
- ? (source as string)
6
+ ? typeof source === "number"
7
+ ? Image.resolveAssetSource(source)?.uri || ""
8
+ : (source as string)
7
9
  : Image.resolveAssetSource(source as number)?.uri || "";
@@ -8,8 +8,8 @@ export enum ActionResult {
8
8
  }
9
9
 
10
10
  const { log_error, log_debug, log_info } = createLogger({
11
- subsystem: "ActionExecutor",
12
- category: "General",
11
+ subsystem: "core/actions",
12
+ category: "ActionExecutor",
13
13
  });
14
14
 
15
15
  export class ActionExecutor {
@@ -42,8 +42,8 @@ import {
42
42
  import { ACTION_TYPES } from "./consts";
43
43
 
44
44
  export const { log_error, log_info, log_debug } = createLogger({
45
- subsystem: "ActionExecutorContext",
46
- category: "General",
45
+ subsystem: "core/actions",
46
+ category: "ActionExecutorContext",
47
47
  });
48
48
 
49
49
  export type ActionExecutorContextType = {
@@ -0,0 +1,98 @@
1
+ import { ActionResult } from "../ActionExecutor";
2
+ import { localStorageToggleFlag } from "../StorageActions";
3
+ import { TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT } from "../consts";
4
+ import { postEvent } from "../../reactHooks/useSubscriberFor";
5
+
6
+ jest.mock("../ActionExecutorContext", () => ({
7
+ log_error: jest.fn(),
8
+ log_info: jest.fn(),
9
+ }));
10
+
11
+ jest.mock("../../reactHooks/useSubscriberFor", () => ({
12
+ postEvent: jest.fn(),
13
+ }));
14
+
15
+ // In-memory stand-in for the storage-backed provider; the limit check under
16
+ // test lives in storageToggleFlag, not in the provider.
17
+ const mockStore: Record<string, string[]> = {};
18
+
19
+ jest.mock("../../storage/StorageMultiSelectProvider", () => ({
20
+ StorageMultiSelectProvider: {
21
+ getProvider: (keyNamespace: string) => ({
22
+ getSelectedAsync: async () => [...(mockStore[keyNamespace] ?? [])],
23
+ addItem: async (item: string) => {
24
+ mockStore[keyNamespace] = [...(mockStore[keyNamespace] ?? []), item];
25
+ },
26
+ removeItem: async (item: string) => {
27
+ mockStore[keyNamespace] = (mockStore[keyNamespace] ?? []).filter(
28
+ (it) => it !== item
29
+ );
30
+ },
31
+ }),
32
+ },
33
+ }));
34
+
35
+ const KEY = "user_preferences.teams";
36
+
37
+ // Entries of a team selection feed with explicit tap actions
38
+ // (localStorageToggleFlag with key and selector).
39
+ const teamEntry = (n: number) =>
40
+ ({
41
+ id: `team-${n}`,
42
+ title: `Team ${n}`,
43
+ type: { value: "action" },
44
+ extensions: { tag: `TEAM ${n}` },
45
+ }) as unknown as ZappEntry;
46
+
47
+ const tapAction = (extraOptions = {}) =>
48
+ ({
49
+ type: "localStorageToggleFlag",
50
+ options: { key: KEY, selector: "extensions.tag", ...extraOptions },
51
+ }) as unknown as ActionType;
52
+
53
+ const tapTeams = async (count: number, extraOptions = {}) => {
54
+ const results: ActionResult[] = [];
55
+
56
+ for (let n = 1; n <= count; n++) {
57
+ results.push(
58
+ await localStorageToggleFlag(
59
+ { entry: teamEntry(n) },
60
+ tapAction(extraOptions)
61
+ )
62
+ );
63
+ }
64
+
65
+ return results;
66
+ };
67
+
68
+ describe("localStorageToggleFlag max_items", () => {
69
+ beforeEach(() => {
70
+ delete mockStore[KEY];
71
+ jest.clearAllMocks();
72
+ });
73
+
74
+ it("blocks the 11th team when max_items is in the action options", async () => {
75
+ const results = await tapTeams(11, { max_items: "10" });
76
+
77
+ expect(results.slice(0, 10)).toEqual(Array(10).fill(ActionResult.Success));
78
+ expect(results[10]).toBe(ActionResult.Cancel);
79
+ expect(mockStore[KEY]).toHaveLength(10);
80
+
81
+ expect(postEvent).toHaveBeenCalledWith(
82
+ TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT,
83
+ [expect.objectContaining({ maxItems: "10", tag: "TEAM 11" })]
84
+ );
85
+ });
86
+
87
+ it("still lets a selected team be removed at the limit", async () => {
88
+ await tapTeams(10, { max_items: "10" });
89
+
90
+ const result = await localStorageToggleFlag(
91
+ { entry: teamEntry(1) },
92
+ tapAction({ max_items: "10" })
93
+ );
94
+
95
+ expect(result).toBe(ActionResult.Success);
96
+ expect(mockStore[KEY]).toHaveLength(9);
97
+ });
98
+ });
@@ -59,3 +59,33 @@ describe("decorateFeed", () => {
59
59
  expect(decorated.entry[0].extensions.tap_actions).toBeUndefined();
60
60
  });
61
61
  });
62
+
63
+ describe("decorateFeed max_items", () => {
64
+ const toggleAction = (feed: ZappFeed) =>
65
+ decorateFeed(feed).entry[0].extensions.tap_actions.actions[0];
66
+
67
+ it.each([
68
+ ["screen", "screenToggleFlag"],
69
+ ["session", "sessionStorageToggleFlag"],
70
+ ["ctx", "localStorageToggleFlag"],
71
+ ])("passes max_items to the %s toggle action", (scope, type) => {
72
+ const feed = preferenceFeed("multi");
73
+ feed.extensions.preference_editor_options.scope = scope;
74
+ feed.extensions.preference_editor_options.max_items = "10";
75
+
76
+ const toggle = toggleAction(feed);
77
+
78
+ expect(toggle.type).toBe(type);
79
+ expect(toggle.options).toEqual({ key: "agree", max_items: 10 });
80
+ });
81
+
82
+ it.each([undefined, 0, "0", "ten", -1])(
83
+ "does not set a limit for max_items %p",
84
+ (maxItems) => {
85
+ const feed = preferenceFeed("multi");
86
+ feed.extensions.preference_editor_options.max_items = maxItems;
87
+
88
+ expect(toggleAction(feed).options).toEqual({ key: "agree" });
89
+ }
90
+ );
91
+ });
@@ -0,0 +1,90 @@
1
+ import { ActionExecutor, ActionResult } from "../ActionExecutor";
2
+ import { screenToggleFlagAction } from "../actions/screenToggleFlag";
3
+
4
+ jest.mock("../ActionExecutorContext", () => ({
5
+ log_error: jest.fn(),
6
+ log_info: jest.fn(),
7
+ }));
8
+
9
+ jest.mock("../StorageActions", () => ({
10
+ onMaxTagsReached: jest.fn(),
11
+ }));
12
+
13
+ // not used here, but it pulls the native bridge logger in at import time
14
+ jest.mock("../../storage/ScreenSingleValueProvider", () => ({}));
15
+
16
+ jest.mock("../../logger", () => ({
17
+ createLogger: () => ({
18
+ log_error: jest.fn(),
19
+ log_debug: jest.fn(),
20
+ log_info: jest.fn(),
21
+ }),
22
+ }));
23
+
24
+ const mockSelected: string[] = [];
25
+
26
+ jest.mock("../../storage/ScreenStateMultiSelectProvider", () => ({
27
+ ScreenMultiSelectProvider: {
28
+ getProvider: () => ({
29
+ getSelectedAsync: async () => [...mockSelected],
30
+ addItem: async (item: string) => {
31
+ mockSelected.push(item);
32
+ },
33
+ removeItem: async (item: string) => {
34
+ mockSelected.splice(mockSelected.indexOf(item), 1);
35
+ },
36
+ }),
37
+ },
38
+ }));
39
+
40
+ const toggleAction = (options = {}) =>
41
+ ({
42
+ type: "screenToggleFlag",
43
+ options: { key: "teams", selector: "extensions.tag", ...options },
44
+ }) as unknown as ActionType;
45
+
46
+ const context = (tag: string) => ({
47
+ screenRoute: "/screen",
48
+ screenStateStore: {},
49
+ entry: { id: tag, extensions: { tag } },
50
+ });
51
+
52
+ describe("screenToggleFlagAction at the max_items limit", () => {
53
+ beforeEach(() => {
54
+ mockSelected.length = 0;
55
+ });
56
+
57
+ it("returns the cancellation so the chained actions do not run", async () => {
58
+ const afterToggle = jest.fn();
59
+ const executor = new ActionExecutor();
60
+
61
+ executor.registerAction("screenToggleFlag", screenToggleFlagAction);
62
+
63
+ executor.registerAction("sendCloudEvent", async () => {
64
+ afterToggle();
65
+
66
+ return ActionResult.Success;
67
+ });
68
+
69
+ mockSelected.push("A", "B");
70
+
71
+ const result = await executor.handleActions(
72
+ [toggleAction({ max_items: 2 }), { type: "sendCloudEvent" }],
73
+ context("C") as never
74
+ );
75
+
76
+ expect(result).toBe(ActionResult.Cancel);
77
+ expect(afterToggle).not.toHaveBeenCalled();
78
+ expect(mockSelected).toEqual(["A", "B"]);
79
+ });
80
+
81
+ it("lets the chain continue below the limit", async () => {
82
+ const result = await screenToggleFlagAction(
83
+ toggleAction({ max_items: 2 }),
84
+ context("A") as never
85
+ );
86
+
87
+ expect(result).toBe(ActionResult.Success);
88
+ expect(mockSelected).toEqual(["A"]);
89
+ });
90
+ });
@@ -83,9 +83,7 @@ describe("navigateToScreen navigationOptions", () => {
83
83
  );
84
84
  });
85
85
 
86
- // Entries cannot go through replace(), which only accepts a river, so the
87
- // non-push path falls back to replaceTop().
88
- it("forwards navigationOptions to replaceTop when navigating with an entry", async () => {
86
+ it("forwards navigationOptions to replace when navigating with an entry", async () => {
89
87
  const navigator = createNavigator();
90
88
  const entry = { id: "entry-id" } as unknown as ZappEntry;
91
89
 
@@ -100,12 +98,12 @@ describe("navigateToScreen navigationOptions", () => {
100
98
 
101
99
  await createNavigateToScreenAction(navigator, rivers, contentTypes)(action);
102
100
 
103
- expect(navigator.replaceTop).toHaveBeenCalledWith(
101
+ expect(navigator.replace).toHaveBeenCalledWith(
104
102
  { id: "entry-id", type: { value: "parentLock" } },
105
103
  { pinFlow: "change-pin" }
106
104
  );
107
105
 
108
- expect(navigator.replace).not.toHaveBeenCalled();
106
+ expect(navigator.replaceTop).not.toHaveBeenCalled();
109
107
  });
110
108
 
111
109
  // Regression guard: the no-options path must keep working unchanged.
@@ -131,3 +129,186 @@ describe("navigateToScreen navigationOptions", () => {
131
129
  expect(result).toBe(ActionResult.Success);
132
130
  });
133
131
  });
132
+
133
+ describe("navigateToScreen target resolution", () => {
134
+ function run(options, context?) {
135
+ const navigator = createNavigator();
136
+
137
+ const result = createNavigateToScreenAction(
138
+ navigator,
139
+ rivers,
140
+ contentTypes
141
+ )({ type: "navigateToScreen", options }, context);
142
+
143
+ return { navigator, result };
144
+ }
145
+
146
+ it("overrides entry.type with typeMapping when both are provided", async () => {
147
+ const entry = {
148
+ id: "entry-id",
149
+ type: { value: "video" },
150
+ } as unknown as ZappEntry;
151
+
152
+ const { navigator, result } = run({
153
+ typeMapping: "parentLock",
154
+ navigationAction: "push",
155
+ entry,
156
+ });
157
+
158
+ expect(await result).toBe(ActionResult.Success);
159
+
160
+ expect(navigator.push).toHaveBeenCalledWith(
161
+ { id: "entry-id", type: { value: "parentLock" } },
162
+ undefined
163
+ );
164
+
165
+ expect(entry.type).toEqual({ value: "video" });
166
+ });
167
+
168
+ it("navigates with the entry's own type when typeMapping is not provided", async () => {
169
+ const entry = {
170
+ id: "entry-id",
171
+ type: { value: "video" },
172
+ } as unknown as ZappEntry;
173
+
174
+ const { navigator, result } = run({ navigationAction: "push", entry });
175
+
176
+ expect(await result).toBe(ActionResult.Success);
177
+
178
+ expect(navigator.push).toHaveBeenCalledWith(
179
+ { id: "entry-id", type: { value: "video" } },
180
+ undefined
181
+ );
182
+ });
183
+
184
+ it("resolves the context entry when entry is @{entry/} and typeMapping is not provided", async () => {
185
+ const entry = {
186
+ id: "context-entry-id",
187
+ type: { value: "video" },
188
+ } as unknown as ZappEntry;
189
+
190
+ const { navigator, result } = run({ entry: "@{entry/}" }, { entry });
191
+
192
+ expect(await result).toBe(ActionResult.Success);
193
+
194
+ expect(navigator.replace).toHaveBeenCalledWith(
195
+ { id: "context-entry-id", type: { value: "video" } },
196
+ undefined
197
+ );
198
+ });
199
+
200
+ it("returns an error when neither typeMapping nor entry type is provided", async () => {
201
+ const entry = { id: "entry-id" } as unknown as ZappEntry;
202
+
203
+ const { navigator, result } = run({ navigationAction: "push", entry });
204
+
205
+ expect(await result).toBe(ActionResult.Error);
206
+ expect(navigator.push).not.toHaveBeenCalled();
207
+ expect(navigator.replace).not.toHaveBeenCalled();
208
+ });
209
+
210
+ it("returns an error when neither typeMapping nor entry is provided", async () => {
211
+ const { navigator, result } = run({ navigationAction: "push" });
212
+
213
+ expect(await result).toBe(ActionResult.Error);
214
+ expect(navigator.push).not.toHaveBeenCalled();
215
+ });
216
+
217
+ it("returns an error when typeMapping has no screen_id mapping", async () => {
218
+ const callback = jest.fn();
219
+
220
+ const { navigator, result } = run(
221
+ { typeMapping: "unknownType", navigationAction: "push" },
222
+ { callback }
223
+ );
224
+
225
+ expect(await result).toBe(ActionResult.Error);
226
+ expect(navigator.push).not.toHaveBeenCalled();
227
+ expect(callback).not.toHaveBeenCalled();
228
+ });
229
+
230
+ it("returns an error when the mapped screen_id has no river", async () => {
231
+ const navigator = createNavigator();
232
+ const callback = jest.fn();
233
+
234
+ const result = await createNavigateToScreenAction(navigator, rivers, {
235
+ orphan: { screen_id: "missing-screen-id" },
236
+ } as unknown as ZappContentTypes)(
237
+ {
238
+ type: "navigateToScreen",
239
+ options: { typeMapping: "orphan", navigationAction: "push" },
240
+ },
241
+ { callback }
242
+ );
243
+
244
+ expect(result).toBe(ActionResult.Error);
245
+ expect(navigator.push).not.toHaveBeenCalled();
246
+ expect(callback).not.toHaveBeenCalled();
247
+ });
248
+
249
+ it("aborts the action pipeline before navigating to a resolved river", async () => {
250
+ const callback = jest.fn();
251
+
252
+ const { navigator, result } = run(
253
+ { typeMapping: "parentLock" },
254
+ { callback }
255
+ );
256
+
257
+ expect(await result).toBe(ActionResult.Success);
258
+
259
+ expect(callback).toHaveBeenCalledWith({
260
+ success: false,
261
+ error: null,
262
+ abort: true,
263
+ });
264
+
265
+ expect(navigator.replace).toHaveBeenCalledWith(river, undefined);
266
+ });
267
+ });
268
+
269
+ describe("navigateToScreen entry context", () => {
270
+ it("sets the entry context for the destination before navigating", async () => {
271
+ const navigator = createNavigator();
272
+ const setEntryContext = jest.fn();
273
+ const entry = { id: "entry-id" } as unknown as ZappEntry;
274
+
275
+ const action = {
276
+ type: "navigateToScreen",
277
+ options: {
278
+ typeMapping: "parentLock",
279
+ navigationAction: "push",
280
+ entry: "@{entry/}",
281
+ },
282
+ };
283
+
284
+ await createNavigateToScreenAction(
285
+ navigator,
286
+ rivers,
287
+ contentTypes
288
+ )(action, { entry, setEntryContext });
289
+
290
+ expect(setEntryContext).toHaveBeenCalledWith(entry);
291
+
292
+ expect(
293
+ (setEntryContext as jest.Mock).mock.invocationCallOrder[0]
294
+ ).toBeLessThan((navigator.push as jest.Mock).mock.invocationCallOrder[0]);
295
+ });
296
+
297
+ it("does not set the entry context when it navigates without an entry", async () => {
298
+ const navigator = createNavigator();
299
+ const setEntryContext = jest.fn();
300
+
301
+ const action = {
302
+ type: "navigateToScreen",
303
+ options: { typeMapping: "parentLock", navigationAction: "push" },
304
+ };
305
+
306
+ await createNavigateToScreenAction(
307
+ navigator,
308
+ rivers,
309
+ contentTypes
310
+ )(action, { setEntryContext });
311
+
312
+ expect(setEntryContext).not.toHaveBeenCalled();
313
+ });
314
+ });
@@ -60,6 +60,30 @@ describe("openBottomSheetAction custom content", () => {
60
60
  });
61
61
  });
62
62
 
63
+ it("passes themePluginId through to the name sheet", async () => {
64
+ const CustomContent = function CustomContent() {
65
+ return null;
66
+ };
67
+
68
+ await openBottomSheetAction({
69
+ type: "openBottomSheet",
70
+ options: {
71
+ header: { title: "Create New Playlist" },
72
+ themePluginId: "playlist-experience",
73
+ content: {
74
+ component: CustomContent,
75
+ props: { buttonLabel: "Create" },
76
+ },
77
+ },
78
+ } as any);
79
+
80
+ const args = (openBottomSheetModal as jest.Mock).mock.calls[0][0];
81
+
82
+ expect(args.modalBottomSheetContentProps.themePluginId).toBe(
83
+ "playlist-experience"
84
+ );
85
+ });
86
+
63
87
  it("returns Error when neither list data nor content.component is provided", async () => {
64
88
  const result = await openBottomSheetAction({
65
89
  type: "openBottomSheet",
@@ -2,6 +2,22 @@ import { openBottomSheetAction } from "../openBottomSheet";
2
2
  import { actionExecutor, ActionResult } from "../../ActionExecutor";
3
3
  import { modalOrchestrator } from "../../../modalState/ModalOrchestrator";
4
4
 
5
+ jest.mock("@applicaster/zapp-pipes-v2-client", () => ({
6
+ PipesClientResponseHelper: jest.fn(() => ({ error: null })),
7
+ RequestBuilder: jest.fn(() => ({
8
+ setEntryContext: jest.fn().mockReturnThis(),
9
+ setScreenContext: jest.fn().mockReturnThis(),
10
+ setUrl: jest.fn().mockReturnThis(),
11
+ buildAxiosRequest: jest.fn().mockResolvedValue(undefined),
12
+ call: jest.fn().mockResolvedValue({
13
+ response: {
14
+ entry: [],
15
+ extensions: { dynamic_collection_options: { operations: "add" } },
16
+ },
17
+ }),
18
+ })),
19
+ }));
20
+
5
21
  jest.mock("../../../modalState/store", () => ({
6
22
  openBottomSheetModal: jest.fn(),
7
23
  }));
@@ -165,6 +181,62 @@ describe("openBottomSheetAction inline items", () => {
165
181
  expect(menu.content.emptyMessage).toBe("Queued items will be added here");
166
182
  });
167
183
 
184
+ it("forwards content.operationButtons onto the menu", async () => {
185
+ const result = await openBottomSheetAction({
186
+ type: "openBottomSheet",
187
+ options: {
188
+ header: { title: "Playlists" },
189
+ content: {
190
+ items: [{ id: "p1", title: "Playlist 1" }],
191
+ operationButtons: {
192
+ add: {
193
+ title: "Create New Playlist",
194
+ iconURL: "https://example.com/add.png",
195
+ },
196
+ },
197
+ },
198
+ },
199
+ } as any);
200
+
201
+ expect(result).toBe(ActionResult.Success);
202
+
203
+ const [menu] = (modalOrchestrator.open as jest.Mock).mock.calls[0];
204
+
205
+ expect(menu.content.operationButtons).toEqual({
206
+ add: {
207
+ title: "Create New Playlist",
208
+ iconURL: "https://example.com/add.png",
209
+ },
210
+ });
211
+ });
212
+
213
+ it("preserves Add presentation when loading itemsUrl content", async () => {
214
+ const result = await openBottomSheetAction({
215
+ type: "openBottomSheet",
216
+ options: {
217
+ content: {
218
+ itemsUrl: "https://example.com/collections",
219
+ operationButtons: {
220
+ add: {
221
+ title: "Create Collection",
222
+ iconURL: "file:///bundled-add.png",
223
+ },
224
+ },
225
+ },
226
+ },
227
+ });
228
+
229
+ expect(result).toBe(ActionResult.Success);
230
+ const [menu] = (modalOrchestrator.open as jest.Mock).mock.calls[0];
231
+
232
+ expect(menu.content).toMatchObject({
233
+ operationButtons: {
234
+ add: { title: "Create Collection", iconURL: "file:///bundled-add.png" },
235
+ },
236
+ dynamicCollection: { operations: ["add"] },
237
+ });
238
+ });
239
+
168
240
  it("pushes a new sheet by default even when another sheet is already open", async () => {
169
241
  (modalOrchestrator as any).stackSize = 1;
170
242
 
@@ -6,8 +6,8 @@ import { ActionHandler } from "../types";
6
6
  import { createLogger } from "../../logger";
7
7
 
8
8
  const { log_info } = createLogger({
9
- subsystem: "ActionExecutorContext",
10
- category: "General",
9
+ subsystem: "core/actions",
10
+ category: "ActionExecutor",
11
11
  });
12
12
 
13
13
  /**
@@ -5,8 +5,8 @@ import { ActionHandler } from "../types";
5
5
  import { createLogger } from "../../logger";
6
6
 
7
7
  const { log_info } = createLogger({
8
- subsystem: "ActionExecutorContext",
9
- category: "General",
8
+ subsystem: "core/actions",
9
+ category: "ActionExecutor",
10
10
  });
11
11
 
12
12
  /**
@@ -5,8 +5,8 @@ import { ActionHandler } from "../types";
5
5
  import { createLogger } from "../../logger";
6
6
 
7
7
  const { log_info } = createLogger({
8
- subsystem: "ActionExecutorContext",
9
- category: "General",
8
+ subsystem: "core/actions",
9
+ category: "ActionExecutor",
10
10
  });
11
11
 
12
12
  /**
@@ -4,8 +4,8 @@ import { ActionHandler } from "../types";
4
4
  import { createLogger } from "../../logger";
5
5
 
6
6
  const { log_info } = createLogger({
7
- subsystem: "ActionExecutorContext",
8
- category: "General",
7
+ subsystem: "core/actions",
8
+ category: "ActionExecutor",
9
9
  });
10
10
 
11
11
  /**
@@ -4,8 +4,8 @@ import { ActionHandler } from "../types";
4
4
  import { createLogger } from "../../logger";
5
5
 
6
6
  const { log_info } = createLogger({
7
- subsystem: "ActionExecutorContext",
8
- category: "General",
7
+ subsystem: "core/actions",
8
+ category: "ActionExecutor",
9
9
  });
10
10
 
11
11
  /**