@applicaster/zapp-react-native-utils 16.0.0-alpha.2663208063 → 16.0.0-alpha.2710214351

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 (138) hide show
  1. package/actionUtils/index.ts +3 -1
  2. package/actionsExecutor/ActionExecutor.ts +10 -1
  3. package/actionsExecutor/ActionExecutorContext.tsx +29 -1
  4. package/actionsExecutor/__tests__/ActionExecutor.test.ts +71 -0
  5. package/actionsExecutor/__tests__/StorageActions.test.ts +98 -0
  6. package/actionsExecutor/__tests__/feedDecorator.test.ts +91 -0
  7. package/actionsExecutor/__tests__/screenToggleFlag.test.ts +90 -0
  8. package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +3 -0
  9. package/actionsExecutor/actions/__tests__/goBack.test.ts +62 -0
  10. package/actionsExecutor/actions/__tests__/goHome.test.ts +19 -0
  11. package/actionsExecutor/actions/__tests__/navigateToScreen.test.ts +267 -0
  12. package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +24 -0
  13. package/actionsExecutor/actions/__tests__/openBottomSheet.inlineItems.test.ts +273 -1
  14. package/actionsExecutor/actions/__tests__/presentScreen.test.ts +127 -0
  15. package/actionsExecutor/actions/__tests__/showAlert.test.ts +49 -0
  16. package/actionsExecutor/actions/__tests__/showToast.test.ts +2 -2
  17. package/actionsExecutor/actions/dismissBottomSheet.ts +2 -1
  18. package/actionsExecutor/actions/goBack.ts +60 -0
  19. package/actionsExecutor/actions/goHome.ts +31 -0
  20. package/actionsExecutor/actions/index.ts +8 -0
  21. package/actionsExecutor/actions/navigateToScreen.ts +43 -45
  22. package/actionsExecutor/actions/openBottomSheet.ts +36 -16
  23. package/actionsExecutor/actions/presentScreen.ts +78 -0
  24. package/actionsExecutor/actions/screenToggleFlag.ts +1 -3
  25. package/actionsExecutor/actions/showAlert.ts +51 -0
  26. package/actionsExecutor/actions/showToast.ts +2 -2
  27. package/actionsExecutor/consts.ts +4 -0
  28. package/actionsExecutor/feedDecorator.ts +12 -6
  29. package/appUtils/contextKeysManager/__tests__/getKey/failure.test.ts +1 -22
  30. package/appUtils/contextKeysManager/__tests__/getKey/success/fullSearch.test.ts +1 -25
  31. package/appUtils/contextKeysManager/__tests__/getKey/success/searchInSecure.test.ts +1 -7
  32. package/appUtils/contextKeysManager/__tests__/removeKey/failure.test.ts +0 -25
  33. package/appUtils/contextKeysManager/__tests__/removeKey/success.test.ts +0 -6
  34. package/appUtils/contextKeysManager/__tests__/setKey/failure/failedToSaveInStorage.test.ts +0 -40
  35. package/appUtils/contextKeysManager/__tests__/setKey/{success/saveItemAndReference.test.ts → success.test.ts} +2 -42
  36. package/appUtils/contextKeysManager/index.ts +28 -129
  37. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +4 -11
  38. package/appUtils/playerManager/OverlayObserver/__tests__/getUpcomingQueue.test.ts +67 -0
  39. package/appUtils/playerManager/OverlayObserver/__tests__/utils.test.ts +9 -2
  40. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.android.tv.ts +4 -1
  41. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ios.tv.ts +4 -1
  42. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.ts +21 -2
  43. package/appUtils/playerManager/OverlayObserver/getUpcomingQueue.web.ts +4 -1
  44. package/appUtils/playerManager/OverlayObserver/utils.ts +9 -7
  45. package/appUtils/playerManager/__tests__/playerDiagnostics.test.ts +62 -0
  46. package/appUtils/playerManager/__tests__/playerNative.test.ts +114 -0
  47. package/appUtils/playerManager/__tests__/playerNativeCommand.test.ts +62 -0
  48. package/appUtils/playerManager/__tests__/playerToolbox.test.ts +281 -0
  49. package/appUtils/playerManager/__tests__/usePlayerControllerSetup.test.tsx +62 -0
  50. package/appUtils/playerManager/const.ts +13 -0
  51. package/appUtils/playerManager/index.ts +7 -0
  52. package/appUtils/playerManager/player.ts +25 -0
  53. package/appUtils/playerManager/playerNative.ts +27 -3
  54. package/appUtils/playerManager/playerNativeCommand.ts +3 -6
  55. package/appUtils/playerManager/playerToolbox.ts +196 -0
  56. package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -0
  57. package/arrayUtils/__tests__/reorderByIds.test.ts +13 -0
  58. package/arrayUtils/index.ts +26 -43
  59. package/cellUtils/__tests__/getButtonsEnabled.test.ts +28 -0
  60. package/cellUtils/__tests__/getCellNavigationEnabled.test.ts +36 -0
  61. package/cellUtils/__tests__/getIsCellNavigationEnabled.test.ts +35 -0
  62. package/cellUtils/__tests__/isCellNavigationEnabled.test.ts +21 -0
  63. package/cellUtils/index.ts +70 -3
  64. package/configurationUtils/__tests__/manifestKeyParser.test.ts +21 -0
  65. package/configurationUtils/__tests__/modalBlocksParser.test.ts +297 -1
  66. package/configurationUtils/manifestKeyParser.ts +12 -1
  67. package/configurationUtils/modalBlocksParser.ts +78 -4
  68. package/entryActions/__tests__/buildEntryActions.test.ts +235 -0
  69. package/entryActions/aliasPresentation.ts +108 -0
  70. package/entryActions/buildEntryActions.ts +167 -0
  71. package/entryActions/index.ts +15 -0
  72. package/entryActions/types.ts +39 -0
  73. package/focusManager/FocusManager.ts +26 -0
  74. package/focusManager/__tests__/FocusManager.test.ts +9 -0
  75. package/localizationUtils/index.ts +12 -6
  76. package/logger/__tests__/xrayToolbox.test.ts +69 -0
  77. package/logger/xrayToolbox.ts +67 -0
  78. package/manifestUtils/_internals/index.js +8 -3
  79. package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
  80. package/manifestUtils/defaultManifestConfigurations/player.js +30 -1
  81. package/manifestUtils/keys.js +7 -2
  82. package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +21 -0
  83. package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +1 -1
  84. package/manifestUtils/mobileAction/groups/defaults.js +2 -1
  85. package/modalState/ModalOrchestrator.ts +23 -9
  86. package/modalState/RemoteEditableCollection.ts +9 -1
  87. package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +39 -0
  88. package/modalState/__tests__/RemoteEditableCollection.test.ts +90 -1
  89. package/modalState/__tests__/index.test.ts +30 -1
  90. package/modalState/__tests__/useModalStoreState.test.ts +142 -0
  91. package/modalState/index.ts +8 -1
  92. package/modalState/store.ts +9 -2
  93. package/modalState/types.ts +42 -2
  94. package/modalState/useBottomSheetContent.ts +24 -17
  95. package/navigationUtils/xrayNavigator.ts +12 -0
  96. package/package.json +3 -2
  97. package/playerUtils/__tests__/resolvePlayerActions.test.ts +138 -0
  98. package/playerUtils/index.ts +17 -1
  99. package/playerUtils/resolvePlayerActions.ts +71 -0
  100. package/pluginUtils/__tests__/pluginUtils.test.js +32 -0
  101. package/pluginUtils/index.ts +29 -0
  102. package/quickBrickAssets/__tests__/index.test.ts +18 -0
  103. package/quickBrickAssets/index.ts +35 -0
  104. package/reactHooks/__tests__/getPluginConfiguration.test.ts +82 -0
  105. package/reactHooks/actions/index.ts +74 -3
  106. package/reactHooks/cell-click/__tests__/index.test.js +64 -0
  107. package/reactHooks/cell-click/index.ts +21 -14
  108. package/reactHooks/connection/index.tsx +8 -5
  109. package/reactHooks/feed/__tests__/feedInvalidation.test.tsx +338 -0
  110. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +8 -2
  111. package/reactHooks/feed/__tests__/useMarkPipesDataStale.test.tsx +243 -0
  112. package/reactHooks/feed/useFeedLoader.tsx +28 -1
  113. package/reactHooks/feed/useLoadPipesDataDispatch.ts +12 -11
  114. package/reactHooks/feed/useMarkPipesDataStale.ts +68 -23
  115. package/reactHooks/navigation/__tests__/index.test.tsx +176 -1
  116. package/reactHooks/navigation/__tests__/usePresentScreen.test.ts +154 -0
  117. package/reactHooks/navigation/index.ts +2 -0
  118. package/reactHooks/navigation/usePresentScreen.ts +157 -0
  119. package/reactHooks/navigation/useRoute.ts +22 -5
  120. package/reactHooks/usePluginConfiguration.ts +84 -46
  121. package/riverComponetsMeasurementProvider/index.tsx +3 -1
  122. package/uiActionsRegistrator/__tests__/resolveActionIdentifiers.test.ts +93 -0
  123. package/uiActionsRegistrator/__tests__/subscribe.test.ts +133 -0
  124. package/uiActionsRegistrator/__tests__/usableActionItems.test.ts +52 -0
  125. package/uiActionsRegistrator/index.ts +25 -203
  126. package/uiActionsRegistrator/registry.ts +351 -0
  127. package/uiActionsRegistrator/resolveActionIdentifiers.ts +100 -0
  128. package/uiActionsRegistrator/usableActionItems.ts +66 -0
  129. package/appUtils/contextKeysManager/__tests__/getKey/success/byReference.test.ts +0 -56
  130. package/appUtils/contextKeysManager/__tests__/getKeyByReference/failure.test.ts +0 -265
  131. package/appUtils/contextKeysManager/__tests__/getKeyByReference/success.test.ts +0 -303
  132. package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/failure.test.ts +0 -82
  133. package/appUtils/contextKeysManager/__tests__/removeReferenceForKey/success.test.ts +0 -41
  134. package/appUtils/contextKeysManager/__tests__/setKey/success/saveItemButNotReference.test.ts +0 -208
  135. package/appUtils/contextKeysManager/__tests__/setReferenceForKey/failure.test.ts +0 -93
  136. package/appUtils/contextKeysManager/__tests__/setReferenceForKey/success.test.ts +0 -45
  137. package/playerUtils/__tests__/getPlayerActionButtons.test.ts +0 -54
  138. package/playerUtils/getPlayerActionButtons.ts +0 -17
@@ -0,0 +1,267 @@
1
+ import { createNavigateToScreenAction } from "../navigateToScreen";
2
+ import { ActionResult } from "../../ActionExecutor";
3
+
4
+ const river = { id: "screen-id", type: "parent-lock" } as unknown as ZappRiver;
5
+
6
+ const rivers = { "screen-id": river } as Record<string, ZappRiver>;
7
+
8
+ const contentTypes = {
9
+ parentLock: { screen_id: "screen-id" },
10
+ } as unknown as ZappContentTypes;
11
+
12
+ function createNavigator() {
13
+ return {
14
+ push: jest.fn(),
15
+ replace: jest.fn(),
16
+ replaceTop: jest.fn(),
17
+ } as unknown as QuickBrickAppNavigator;
18
+ }
19
+
20
+ describe("navigateToScreen navigationOptions", () => {
21
+ it("forwards navigationOptions to push when navigating to a screen", async () => {
22
+ const navigator = createNavigator();
23
+
24
+ const action = {
25
+ type: "navigateToScreen",
26
+ options: {
27
+ typeMapping: "parentLock",
28
+ navigationAction: "push",
29
+ navigationOptions: { pinFlow: "set-pin" },
30
+ },
31
+ };
32
+
33
+ const result = await createNavigateToScreenAction(
34
+ navigator,
35
+ rivers,
36
+ contentTypes
37
+ )(action);
38
+
39
+ expect(navigator.push).toHaveBeenCalledWith(river, {
40
+ pinFlow: "set-pin",
41
+ });
42
+
43
+ expect(result).toBe(ActionResult.Success);
44
+ });
45
+
46
+ it("forwards navigationOptions to replace when navigating to a screen", async () => {
47
+ const navigator = createNavigator();
48
+
49
+ const action = {
50
+ type: "navigateToScreen",
51
+ options: {
52
+ typeMapping: "parentLock",
53
+ navigationOptions: { pinFlow: "change-pin" },
54
+ },
55
+ };
56
+
57
+ await createNavigateToScreenAction(navigator, rivers, contentTypes)(action);
58
+
59
+ expect(navigator.replace).toHaveBeenCalledWith(river, {
60
+ pinFlow: "change-pin",
61
+ });
62
+ });
63
+
64
+ it("forwards navigationOptions to push when navigating with an entry", async () => {
65
+ const navigator = createNavigator();
66
+ const entry = { id: "entry-id" } as unknown as ZappEntry;
67
+
68
+ const action = {
69
+ type: "navigateToScreen",
70
+ options: {
71
+ typeMapping: "parentLock",
72
+ navigationAction: "push",
73
+ entry,
74
+ navigationOptions: { pinFlow: "set-pin" },
75
+ },
76
+ };
77
+
78
+ await createNavigateToScreenAction(navigator, rivers, contentTypes)(action);
79
+
80
+ expect(navigator.push).toHaveBeenCalledWith(
81
+ { id: "entry-id", type: { value: "parentLock" } },
82
+ { pinFlow: "set-pin" }
83
+ );
84
+ });
85
+
86
+ it("forwards navigationOptions to replace when navigating with an entry", async () => {
87
+ const navigator = createNavigator();
88
+ const entry = { id: "entry-id" } as unknown as ZappEntry;
89
+
90
+ const action = {
91
+ type: "navigateToScreen",
92
+ options: {
93
+ typeMapping: "parentLock",
94
+ entry,
95
+ navigationOptions: { pinFlow: "change-pin" },
96
+ },
97
+ };
98
+
99
+ await createNavigateToScreenAction(navigator, rivers, contentTypes)(action);
100
+
101
+ expect(navigator.replace).toHaveBeenCalledWith(
102
+ { id: "entry-id", type: { value: "parentLock" } },
103
+ { pinFlow: "change-pin" }
104
+ );
105
+
106
+ expect(navigator.replaceTop).not.toHaveBeenCalled();
107
+ });
108
+
109
+ // Regression guard: the no-options path must keep working unchanged.
110
+ it("still navigates when no navigationOptions are configured", async () => {
111
+ const navigator = createNavigator();
112
+
113
+ const action = {
114
+ type: "navigateToScreen",
115
+ options: {
116
+ typeMapping: "parentLock",
117
+ navigationAction: "push",
118
+ },
119
+ };
120
+
121
+ const result = await createNavigateToScreenAction(
122
+ navigator,
123
+ rivers,
124
+ contentTypes
125
+ )(action);
126
+
127
+ expect(navigator.push).toHaveBeenCalledTimes(1);
128
+ expect((navigator.push as jest.Mock).mock.calls[0][0]).toBe(river);
129
+ expect(result).toBe(ActionResult.Success);
130
+ });
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
+ });
@@ -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",
@@ -1,7 +1,23 @@
1
1
  import { openBottomSheetAction } from "../openBottomSheet";
2
- import { ActionResult } from "../../ActionExecutor";
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
  }));
@@ -77,6 +93,150 @@ describe("openBottomSheetAction inline items", () => {
77
93
  });
78
94
  });
79
95
 
96
+ it("opens an empty inline collection when dynamic collection options are present", async () => {
97
+ const result = await openBottomSheetAction({
98
+ type: "openBottomSheet",
99
+ options: {
100
+ header: { title: "Queue" },
101
+ content: {
102
+ items: [],
103
+ emptyMessage: "Queued items will be added here",
104
+ dynamicCollection: {
105
+ operations: ["remove"],
106
+ provider: "@{provider/queue}",
107
+ },
108
+ },
109
+ },
110
+ } as any);
111
+
112
+ expect(result).toBe(ActionResult.Success);
113
+
114
+ const [menu] = (modalOrchestrator.open as jest.Mock).mock.calls[0];
115
+
116
+ expect(menu.content.items).toEqual([]);
117
+ expect(menu.content.emptyMessage).toBe("Queued items will be added here");
118
+
119
+ expect(menu.content.dynamicCollection).toMatchObject({
120
+ operations: ["remove"],
121
+ provider: "@{provider/queue}",
122
+ });
123
+ });
124
+
125
+ it("accepts empty inline items when dynamic_collection_options live on extensions", async () => {
126
+ const result = await openBottomSheetAction({
127
+ type: "openBottomSheet",
128
+ options: {
129
+ content: {
130
+ items: [],
131
+ extensions: {
132
+ dynamic_collection_options: {
133
+ operations: "remove,reorder",
134
+ provider: "@{provider/offline}",
135
+ },
136
+ },
137
+ },
138
+ },
139
+ } as any);
140
+
141
+ expect(result).toBe(ActionResult.Success);
142
+
143
+ const [menu] = (modalOrchestrator.open as jest.Mock).mock.calls[0];
144
+
145
+ expect(menu.content.items).toEqual([]);
146
+
147
+ expect(menu.content.dynamicCollection).toMatchObject({
148
+ operations: ["remove", "reorder"],
149
+ provider: "@{provider/offline}",
150
+ });
151
+ });
152
+
153
+ it("returns an error for an empty items array with no source", async () => {
154
+ const result = await openBottomSheetAction({
155
+ type: "openBottomSheet",
156
+ options: {
157
+ content: { items: [] },
158
+ },
159
+ } as any);
160
+
161
+ expect(result).toBe(ActionResult.Error);
162
+ expect(modalOrchestrator.open).not.toHaveBeenCalled();
163
+ });
164
+
165
+ it("forwards content.emptyMessage onto the menu", async () => {
166
+ const result = await openBottomSheetAction({
167
+ type: "openBottomSheet",
168
+ options: {
169
+ header: { title: "Queue" },
170
+ content: {
171
+ items: [{ id: "t1", title: "Track 1" }],
172
+ emptyMessage: "Queued items will be added here",
173
+ },
174
+ },
175
+ } as any);
176
+
177
+ expect(result).toBe(ActionResult.Success);
178
+
179
+ const [menu] = (modalOrchestrator.open as jest.Mock).mock.calls[0];
180
+
181
+ expect(menu.content.emptyMessage).toBe("Queued items will be added here");
182
+ });
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
+
80
240
  it("pushes a new sheet by default even when another sheet is already open", async () => {
81
241
  (modalOrchestrator as any).stackSize = 1;
82
242
 
@@ -97,4 +257,116 @@ describe("openBottomSheetAction inline items", () => {
97
257
  expect(modalOrchestrator.replace).toHaveBeenCalledTimes(1);
98
258
  expect(modalOrchestrator.open).not.toHaveBeenCalled();
99
259
  });
260
+
261
+ it("executes all actions in tap_actions when onItemPress is called", async () => {
262
+ const multiActionSheet = {
263
+ type: "openBottomSheet",
264
+ options: {
265
+ header: { title: "Target Playlists" },
266
+ content: {
267
+ role: "collection_selector",
268
+ behavior: { selectMode: "none", currentSelection: [] },
269
+ items: [
270
+ {
271
+ id: "playlist-1",
272
+ title: "My Playlist",
273
+ extensions: {
274
+ tap_actions: {
275
+ actions: [
276
+ {
277
+ type: "sendCloudEvent",
278
+ options: { subject: "add_collection_to_collection" },
279
+ },
280
+ {
281
+ type: "showToast",
282
+ options: { message: "Added to playlist" },
283
+ },
284
+ { type: "dismissBottomSheet", options: {} },
285
+ ],
286
+ },
287
+ },
288
+ },
289
+ ],
290
+ },
291
+ },
292
+ } as any;
293
+
294
+ await openBottomSheetAction(multiActionSheet);
295
+
296
+ const [menu, onItemPress] = (modalOrchestrator.open as jest.Mock).mock
297
+ .calls[0];
298
+
299
+ expect(menu.content.items[0].actions).toHaveLength(3);
300
+
301
+ const handleActionsSpy = jest
302
+ .spyOn(actionExecutor, "handleActions")
303
+ .mockResolvedValue(ActionResult.Success);
304
+
305
+ await onItemPress(menu.content.items[0]);
306
+
307
+ expect(handleActionsSpy).toHaveBeenCalledWith(
308
+ [
309
+ {
310
+ type: "sendCloudEvent",
311
+ options: { subject: "add_collection_to_collection" },
312
+ },
313
+ {
314
+ type: "showToast",
315
+ options: { message: "Added to playlist" },
316
+ },
317
+ { type: "dismissBottomSheet", options: {} },
318
+ ],
319
+ expect.objectContaining({
320
+ entry: menu.content.items[0],
321
+ })
322
+ );
323
+
324
+ handleActionsSpy.mockRestore();
325
+ });
326
+
327
+ it("executes preceding actions and excludes presentSubMenu from actionExecutor", async () => {
328
+ const subMenuSheet = {
329
+ type: "openBottomSheet",
330
+ options: {
331
+ header: { title: "Menu" },
332
+ content: {
333
+ items: [
334
+ {
335
+ id: "item-with-submenu",
336
+ title: "More Options",
337
+ extensions: {
338
+ tap_actions: {
339
+ actions: [
340
+ { type: "sendAnalytics", options: { event: "click_more" } },
341
+ {
342
+ type: "presentSubMenu",
343
+ menu: { content: { title: "Sub Options", items: [] } },
344
+ },
345
+ ],
346
+ },
347
+ },
348
+ },
349
+ ],
350
+ },
351
+ },
352
+ } as any;
353
+
354
+ await openBottomSheetAction(subMenuSheet);
355
+
356
+ const [menu, onItemPress] = (modalOrchestrator.open as jest.Mock).mock
357
+ .calls[0];
358
+
359
+ const handleActionsSpy = jest
360
+ .spyOn(actionExecutor, "handleActions")
361
+ .mockResolvedValue(ActionResult.Success);
362
+
363
+ await onItemPress(menu.content.items[0]);
364
+
365
+ expect(handleActionsSpy).toHaveBeenCalledWith(
366
+ [{ type: "sendAnalytics", options: { event: "click_more" } }],
367
+ expect.objectContaining({ entry: menu.content.items[0] })
368
+ );
369
+
370
+ handleActionsSpy.mockRestore();
371
+ });
100
372
  });