@applicaster/zapp-react-native-utils 16.0.0-rc.70 → 16.0.0-rc.72

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.
@@ -0,0 +1,156 @@
1
+ import { buildEntryActions } from "../buildEntryActions";
2
+
3
+ describe("buildEntryActions - alias & label resolution", () => {
4
+ const mockDeps = {
5
+ actionExecutor: { handleActions: jest.fn() } as any,
6
+ actionContext: {},
7
+ };
8
+
9
+ const resolveEntryActions = (entry: ZappEntry) =>
10
+ buildEntryActions(entry, mockDeps);
11
+
12
+ it("resolves entry action with explicit button title", () => {
13
+ const entry = {
14
+ id: "entry-1",
15
+ extensions: {
16
+ entry_action: [
17
+ {
18
+ button: {
19
+ title: "Custom Action Title",
20
+ iconURL: "http://example.com/icon.png",
21
+ },
22
+ actions: [{ type: "test" }],
23
+ dismiss_on_action: true,
24
+ },
25
+ ],
26
+ },
27
+ };
28
+
29
+ const actions = resolveEntryActions(entry as any);
30
+
31
+ expect(actions).toHaveLength(1);
32
+ expect(actions[0].identifier).toBe("entry_action_0");
33
+
34
+ const state = actions[0].action.initialEntryState(entry as any);
35
+
36
+ expect(state).toEqual({
37
+ state: 0,
38
+ label: "Custom Action Title",
39
+ asset: "http://example.com/icon.png",
40
+ });
41
+ });
42
+
43
+ it("resolves entry action with button label property", () => {
44
+ const entry = {
45
+ id: "entry-2",
46
+ extensions: {
47
+ entry_action: [
48
+ {
49
+ button: { label: "Label Property Action" },
50
+ actions: [{ type: "test" }],
51
+ },
52
+ ],
53
+ },
54
+ };
55
+
56
+ const actions = resolveEntryActions(entry as any);
57
+
58
+ expect(actions).toHaveLength(1);
59
+ const state = actions[0].action.initialEntryState(entry as any);
60
+ expect(state.label).toBe("Label Property Action");
61
+ });
62
+
63
+ it("resolves entry action with known backend button alias (e.g. add_all_to_queue)", () => {
64
+ const entry = {
65
+ id: "entry-3",
66
+ extensions: {
67
+ entry_action: [
68
+ {
69
+ button: { alias: "add_all_to_queue" },
70
+ actions: [{ type: "test" }],
71
+ dismiss_on_action: true,
72
+ },
73
+ {
74
+ button: { alias: "add_to_playlist" },
75
+ actions: [{ type: "test" }],
76
+ },
77
+ {
78
+ button: { alias: "delete_collection" },
79
+ actions: [{ type: "test" }],
80
+ },
81
+ ],
82
+ },
83
+ };
84
+
85
+ const actions = resolveEntryActions(entry as any);
86
+
87
+ expect(actions).toHaveLength(3);
88
+
89
+ expect(actions[0].action.initialEntryState(entry as any)).toMatchObject({
90
+ state: 0,
91
+ label: "Add all to Queue",
92
+ });
93
+
94
+ expect(actions[1].action.initialEntryState(entry as any)).toMatchObject({
95
+ state: 0,
96
+ label: "Add to Playlist",
97
+ });
98
+
99
+ expect(actions[2].action.initialEntryState(entry as any)).toMatchObject({
100
+ state: 0,
101
+ label: "Delete collection",
102
+ });
103
+ });
104
+
105
+ it("formats unknown alias nicely as fallback", () => {
106
+ const entry = {
107
+ id: "entry-4",
108
+ extensions: {
109
+ entry_action: [
110
+ {
111
+ button: { alias: "custom_unknown_action" },
112
+ actions: [{ type: "test" }],
113
+ },
114
+ ],
115
+ },
116
+ };
117
+
118
+ const actions = resolveEntryActions(entry as any);
119
+
120
+ expect(actions).toHaveLength(1);
121
+ const state = actions[0].action.initialEntryState(entry as any);
122
+ expect(state.label).toBe("Custom unknown action");
123
+ });
124
+
125
+ it("uses actionExecutor.getActionState for plugin-provided label and asset", () => {
126
+ mockDeps.actionExecutor.getActionState = jest.fn(() => ({
127
+ label: "From Plugin",
128
+ asset: "plugin_asset",
129
+ }));
130
+
131
+ const entry = {
132
+ id: "entry-plugin-state",
133
+ extensions: {
134
+ entry_action: [
135
+ {
136
+ button: { alias: "custom_plugin_action" },
137
+ actions: [{ type: "plugin-action" }],
138
+ },
139
+ ],
140
+ },
141
+ };
142
+
143
+ const actions = resolveEntryActions(entry as any);
144
+ const state = actions[0].action.initialEntryState(entry as any);
145
+
146
+ expect(mockDeps.actionExecutor.getActionState).toHaveBeenCalledWith(
147
+ "plugin-action",
148
+ entry
149
+ );
150
+
151
+ expect(state).toMatchObject({
152
+ label: "From Plugin",
153
+ asset: "plugin_asset",
154
+ });
155
+ });
156
+ });
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Presentation defaults for backend action aliases.
3
+ *
4
+ * Entries may declare an action by `alias` alone, without a label or an icon.
5
+ * These maps are the last-resort labels/icons for the aliases we know about; an
6
+ * unknown alias falls back to a humanized version of the alias itself.
7
+ *
8
+ * They are defaults, not a framework guarantee: an app that speaks a different
9
+ * alias vocabulary, needs other languages, or does not want to depend on these
10
+ * icon hosts passes its own through `EntryActionDeps.aliasPresentation`.
11
+ */
12
+
13
+ import { EntryAction } from "./types";
14
+
15
+ const ADD_TO_PLAYLIST_ICON =
16
+ "https://assets-secure.applicaster.com/zapp/assets/app_family/1710/906728572617/playlist_add_24dp_FFFFFF_FILL0_wght400_GRAD0_opsz24.png";
17
+
18
+ const REMOVE_ICON =
19
+ "https://assets-secure.applicaster.com/zapp/assets/app_family/1710/372097240191/remove_24dp_EA3323_FILL0_wght400_GRAD0_opsz24.png";
20
+
21
+ const EDIT_ICON =
22
+ "https://upload.wikimedia.org/wikipedia/commons/b/b6/Edit-icon.png";
23
+
24
+ /** Known backend action alias labels. */
25
+ export const ALIAS_LABELS: Record<string, string> = {
26
+ add_to_playlist: "Add to Playlist",
27
+ add_to_queue: "Add to Queue",
28
+ add_all_to_queue: "Add all to Queue",
29
+ play_all: "Play All",
30
+ remove_item: "Remove item",
31
+ delete_collection: "Delete collection",
32
+ create_collection: "Create collection",
33
+ edit: "Edit",
34
+ edit_name: "Edit Name & Details",
35
+ };
36
+
37
+ /** Known backend action alias image assets. */
38
+ export const ALIAS_ASSETS: Record<string, string> = {
39
+ add_to_playlist: ADD_TO_PLAYLIST_ICON,
40
+ add_to_queue: ADD_TO_PLAYLIST_ICON,
41
+ add_all_to_queue: ADD_TO_PLAYLIST_ICON,
42
+ play_all: ADD_TO_PLAYLIST_ICON,
43
+ remove_item: REMOVE_ICON,
44
+ delete_collection: REMOVE_ICON,
45
+ edit: EDIT_ICON,
46
+ edit_name: EDIT_ICON,
47
+ };
48
+
49
+ /** Per-app overrides for the maps above. */
50
+ export type AliasPresentation = {
51
+ labels?: Record<string, string>;
52
+ assets?: Record<string, string>;
53
+ };
54
+
55
+ function formatAliasLabel(
56
+ alias: string,
57
+ overrides?: AliasPresentation
58
+ ): string {
59
+ const label = overrides?.labels?.[alias] ?? ALIAS_LABELS[alias];
60
+
61
+ if (label) {
62
+ return label;
63
+ }
64
+
65
+ const formatted = alias.replace(/_/g, " ");
66
+
67
+ return formatted.charAt(0).toUpperCase() + formatted.slice(1);
68
+ }
69
+
70
+ const nonEmptyString = (value: unknown): value is string =>
71
+ typeof value === "string" && value.length > 0;
72
+
73
+ /**
74
+ * Label the backend stated outright, if any. Distinct from
75
+ * {@link resolveButtonLabel} because an explicit label outranks the executor's
76
+ * action state, while the alias fallback does not.
77
+ */
78
+ export function resolveExplicitLabel(
79
+ button: EntryAction["button"]
80
+ ): string | undefined {
81
+ if (nonEmptyString(button?.title)) {
82
+ return button.title;
83
+ }
84
+
85
+ if (nonEmptyString(button?.label)) {
86
+ return button.label;
87
+ }
88
+
89
+ return undefined;
90
+ }
91
+
92
+ /** Label to show for an entry action: explicit title/label, else the alias. */
93
+ export function resolveButtonLabel(
94
+ button: EntryAction["button"],
95
+ overrides?: AliasPresentation
96
+ ): string {
97
+ const explicit = resolveExplicitLabel(button);
98
+
99
+ if (explicit) {
100
+ return explicit;
101
+ }
102
+
103
+ if (nonEmptyString(button?.alias)) {
104
+ return formatAliasLabel(button.alias, overrides);
105
+ }
106
+
107
+ return "";
108
+ }
109
+
110
+ /** Icon to show for an entry action: explicit iconURL, else the alias default. */
111
+ export function resolveButtonAsset(
112
+ button: EntryAction["button"],
113
+ overrides?: AliasPresentation
114
+ ): string | undefined {
115
+ if (button?.iconURL) {
116
+ return button.iconURL;
117
+ }
118
+
119
+ if (!button?.alias) {
120
+ return undefined;
121
+ }
122
+
123
+ return overrides?.assets?.[button.alias] ?? ALIAS_ASSETS[button.alias];
124
+ }
@@ -0,0 +1,166 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import { createLogger } from "../logger";
3
+ import { ActionExecutionContext } from "../actionsExecutor/types";
4
+ import { RegisteredAction } from "../uiActionsRegistrator";
5
+
6
+ import {
7
+ resolveButtonAsset,
8
+ resolveButtonLabel,
9
+ resolveExplicitLabel,
10
+ } from "./aliasPresentation";
11
+ import { EntryAction, EntryActionDeps } from "./types";
12
+
13
+ const { log_info, log_warning, log_error } = createLogger({
14
+ subsystem: "EntryActions",
15
+ category: "EntryAction",
16
+ });
17
+
18
+ const ENTRY_ACTION_IDENTIFIER_PREFIX = "entry_action";
19
+
20
+ /** True for actions inflated from `entry.extensions.entry_action`. */
21
+ export function isEntryAction(item: RegisteredAction): boolean {
22
+ return item?.source === "entry";
23
+ }
24
+
25
+ function isValidEntryAction(value: unknown): value is EntryAction {
26
+ if (typeof value !== "object" || value === null) {
27
+ return false;
28
+ }
29
+
30
+ const { button, actions } = value as EntryAction;
31
+
32
+ return (
33
+ (typeof button?.title === "string" ||
34
+ typeof button?.label === "string" ||
35
+ typeof button?.alias === "string") &&
36
+ Array.isArray(actions)
37
+ );
38
+ }
39
+
40
+ function createEntryAction(
41
+ entryAction: EntryAction,
42
+ index: number,
43
+ entry: ZappEntry | ZappFeed,
44
+ deps: EntryActionDeps
45
+ ): RegisteredAction {
46
+ const { button, actions, dismiss_on_action } = entryAction;
47
+
48
+ const identifier = `${ENTRY_ACTION_IDENTIFIER_PREFIX}_${index}`;
49
+ const primaryAction = actions.length > 0 ? actions[0] : null;
50
+
51
+ const actionState = primaryAction
52
+ ? deps.actionExecutor?.getActionState?.(primaryAction.type, entry)
53
+ : null;
54
+
55
+ // An explicit title/label outranks the executor's action state; the
56
+ // alias-derived defaults only fill in when neither produced anything.
57
+ const label: CellActionEntryState["label"] =
58
+ resolveExplicitLabel(button) ||
59
+ actionState?.label ||
60
+ resolveButtonLabel(button, deps.aliasPresentation);
61
+
62
+ const asset: CellActionEntryState["asset"] =
63
+ button?.iconURL ||
64
+ actionState?.asset ||
65
+ resolveButtonAsset(button, deps.aliasPresentation);
66
+
67
+ const initialState = { state: 0, label, asset };
68
+
69
+ return {
70
+ identifier,
71
+ source: "entry",
72
+ action: {
73
+ initialEntryState: () => initialState,
74
+ invokeAction: async (
75
+ invokedEntry: ZappEntry,
76
+ options: InvokeArgsOptions = {}
77
+ ) => {
78
+ if (dismiss_on_action === true) {
79
+ options.dismiss?.();
80
+ }
81
+
82
+ log_info(
83
+ `invokeAction: entry action "${identifier}" triggered for entry "${invokedEntry?.id}"`,
84
+ { identifier, entryId: invokedEntry?.id, actionCount: actions.length }
85
+ );
86
+
87
+ // Both of these leave the user with a button that does nothing when
88
+ // tapped, and neither throws, so they would otherwise be invisible.
89
+ if (actions.length === 0) {
90
+ log_warning(
91
+ `invokeAction: entry action "${identifier}" on entry "${invokedEntry?.id}" declares no actions - the tap does nothing`,
92
+ { identifier, entryId: invokedEntry?.id }
93
+ );
94
+ }
95
+
96
+ if (typeof deps.actionExecutor?.handleActions !== "function") {
97
+ log_warning(
98
+ `invokeAction: no action executor available for entry action "${identifier}" - the tap does nothing`,
99
+ { identifier, entryId: invokedEntry?.id }
100
+ );
101
+ }
102
+
103
+ try {
104
+ await deps.actionExecutor?.handleActions(actions, {
105
+ entry: invokedEntry,
106
+ entryContext: invokedEntry,
107
+ ...deps.actionContext,
108
+ } as ActionExecutionContext);
109
+ } catch (error) {
110
+ log_error(
111
+ `invokeAction: entry action "${identifier}" failed for entry "${invokedEntry?.id}"`,
112
+ {
113
+ identifier,
114
+ entryId: invokedEntry?.id,
115
+ // Types only - the action payloads are backend supplied and may
116
+ // carry user data.
117
+ actionTypes: actions.map((action) => action?.type),
118
+ error,
119
+ }
120
+ );
121
+ }
122
+ },
123
+ },
124
+ };
125
+ }
126
+
127
+ /**
128
+ * Builds the list of actions declared on an entry via
129
+ * `entry.extensions.entry_action`.
130
+ */
131
+ export function buildEntryActions(
132
+ entry: ZappEntry | ZappFeed,
133
+ deps: EntryActionDeps
134
+ ): RegisteredAction[] {
135
+ const entryId = (entry as ZappEntry)?.id;
136
+ const raw = (entry as any)?.extensions?.entry_action;
137
+
138
+ // Most entries simply declare no actions. This provider is resolved for
139
+ // every entry on every render, so saying so would drown everything else.
140
+ if (raw === undefined || raw === null) {
141
+ return [];
142
+ }
143
+
144
+ if (!Array.isArray(raw)) {
145
+ log_warning(
146
+ `buildEntryActions: entry "${entryId}" has extensions.entry_action of type ${typeof raw} instead of an array - no entry actions will be shown`,
147
+ { entryId, receivedType: typeof raw }
148
+ );
149
+
150
+ return [];
151
+ }
152
+
153
+ const valid = raw.filter(isValidEntryAction);
154
+ const invalid = raw.length - valid.length;
155
+
156
+ if (invalid > 0) {
157
+ log_warning(
158
+ `buildEntryActions: ${invalid} invalid entry action(s) skipped for entry "${entryId}"`,
159
+ { entryId, total: raw.length, invalid }
160
+ );
161
+ }
162
+
163
+ return valid.map((entryAction, index) =>
164
+ createEntryAction(entryAction, index, entry, deps)
165
+ );
166
+ }
@@ -0,0 +1,17 @@
1
+ export { buildEntryActions, isEntryAction } from "./buildEntryActions";
2
+
3
+ export {
4
+ ALIAS_ASSETS,
5
+ ALIAS_LABELS,
6
+ resolveButtonAsset,
7
+ resolveButtonLabel,
8
+ resolveExplicitLabel,
9
+ } from "./aliasPresentation";
10
+
11
+ export type {
12
+ EntryAction,
13
+ EntryActionDeps,
14
+ EntryActionExecutionContext,
15
+ } from "./types";
16
+
17
+ export type { AliasPresentation } from "./aliasPresentation";
@@ -0,0 +1,39 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ import type { ActionExecutorContextType } from "../actionsExecutor/ActionExecutorContext";
3
+ import type { AliasPresentation } from "./aliasPresentation";
4
+
5
+ /**
6
+ * A single action declared by the backend on an entry, under
7
+ * `entry.extensions.entry_action`.
8
+ */
9
+ export type EntryAction = {
10
+ button: {
11
+ title?: string;
12
+ label?: string;
13
+ alias?: string;
14
+ iconURL?: string;
15
+ };
16
+ actions: ZappActionType[];
17
+ dismiss_on_action?: boolean;
18
+ };
19
+
20
+ /**
21
+ * Everything `buildEntryActions` needs from the surrounding React tree in order
22
+ * to execute an entry action. Supplied lazily so the registered provider always
23
+ * reads the freshest screen context.
24
+ */
25
+ export type EntryActionDeps = {
26
+ actionExecutor: ActionExecutorContextType;
27
+ actionContext: EntryActionExecutionContext;
28
+ /** App-supplied labels/icons for backend aliases; defaults are used without it. */
29
+ aliasPresentation?: AliasPresentation;
30
+ };
31
+
32
+ /** The screen the action is executed against, spread into the execution context. */
33
+ export type EntryActionExecutionContext = {
34
+ screenData?: unknown;
35
+ screenState?: unknown;
36
+ screenRoute?: string;
37
+ screenStateStore?: unknown;
38
+ screenEntry?: unknown;
39
+ };
@@ -204,6 +204,20 @@ function getPlayerConfiguration({ platform, version }) {
204
204
  label_tooltip: "Label for close button accessibility",
205
205
  type: "text_input",
206
206
  },
207
+ {
208
+ key: "accessibility_overflow_label",
209
+ label: "Accessibility overflow label",
210
+ initial_value: "More actions",
211
+ label_tooltip: "Label for the overflow (…) button accessibility",
212
+ type: "text_input",
213
+ },
214
+ {
215
+ key: "accessibility_overflow_hint",
216
+ label: "Accessibility overflow hint",
217
+ initial_value: "Opens the remaining player actions",
218
+ label_tooltip: "Hint for the overflow (…) button accessibility",
219
+ type: "text_input",
220
+ },
207
221
  {
208
222
  key: "accessibility_close_hint",
209
223
  label: "Accessibility close hint",
@@ -791,7 +805,7 @@ function getPlayerConfiguration({ platform, version }) {
791
805
  label: "Player action buttons",
792
806
  initial_value: null,
793
807
  label_tooltip:
794
- "type here the identifiers of the action buttons you want to show on the player, separated by commas. Only 2 action buttons may be added at the same time",
808
+ "Comma-separated action identifiers. The entry_actions token expands from the playing entry's extensions.entry_action. When more than 2 actions resolve, the video and fullscreen audio players show Overflow (…) plus one companion - the first action that did not come from the entry, otherwise the first one - and the Overflow sheet lists every resolved action. A repeated identifier is counted once. No extra plugin is required.",
795
809
  type: "text_input",
796
810
  },
797
811
  {
@@ -1091,6 +1105,13 @@ function getPlayerConfiguration({ platform, version }) {
1091
1105
  type: "uploader",
1092
1106
  label_tooltip: "Override default close badge / icon",
1093
1107
  },
1108
+ {
1109
+ key: "overflow",
1110
+ label: "Overflow badge",
1111
+ type: "uploader",
1112
+ label_tooltip:
1113
+ "Override default overflow (…) badge / icon, shown when more action buttons resolve than fit on the player overlay",
1114
+ },
1094
1115
  {
1095
1116
  key: "lock",
1096
1117
  label: "Lock player badge",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "16.0.0-rc.70",
3
+ "version": "16.0.0-rc.72",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://github.com/applicaster/quickbrick#readme",
29
29
  "dependencies": {
30
- "@applicaster/applicaster-types": "16.0.0-rc.70",
30
+ "@applicaster/applicaster-types": "16.0.0-rc.72",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",
@@ -0,0 +1,138 @@
1
+ import { resolvePlayerActions } from "../resolvePlayerActions";
2
+ import { selectActionButtons } from "../../conf/player/selectors";
3
+ import { uiActionsRegistry } from "../../uiActionsRegistrator";
4
+
5
+ jest.mock("../../conf/player/selectors", () => ({
6
+ selectActionButtons: jest.fn(),
7
+ }));
8
+
9
+ const action = (identifier: string) =>
10
+ ({ identifier, action: { invokeAction: jest.fn() } }) as any;
11
+
12
+ describe("resolvePlayerActions", () => {
13
+ const entry = {
14
+ id: "e1",
15
+ extensions: {
16
+ entry_action: [
17
+ { button: { alias: "add_to_playlist" }, actions: [{ type: "test" }] },
18
+ { button: { alias: "add_to_queue" }, actions: [{ type: "test" }] },
19
+ ],
20
+ },
21
+ };
22
+
23
+ // The entry's own actions never reach the registry; the caller expands them.
24
+ const expandEntryActions = jest.fn(() => [
25
+ action("entry_action_0"),
26
+ action("entry_action_1"),
27
+ ]);
28
+
29
+ beforeEach(() => {
30
+ expandEntryActions.mockClear();
31
+
32
+ jest
33
+ .spyOn(uiActionsRegistry, "getActions")
34
+ .mockImplementation((name) => [action(name)]);
35
+ });
36
+
37
+ afterEach(() => {
38
+ jest.restoreAllMocks();
39
+ });
40
+
41
+ it("expands entry_actions through the caller and keeps config order", () => {
42
+ (selectActionButtons as jest.Mock).mockReturnValue(
43
+ "entry_actions,local_storage_favourites_action,offline-content-button"
44
+ );
45
+
46
+ const result = resolvePlayerActions({
47
+ configuration: {},
48
+ entry,
49
+ expandEntryActions,
50
+ });
51
+
52
+ expect(expandEntryActions).toHaveBeenCalledWith(entry);
53
+
54
+ expect(uiActionsRegistry.getActions).not.toHaveBeenCalledWith(
55
+ "entry_actions",
56
+ entry
57
+ );
58
+
59
+ expect(result.map((item) => item.identifier)).toEqual([
60
+ "entry_action_0",
61
+ "entry_action_1",
62
+ "local_storage_favourites_action",
63
+ "offline-content-button",
64
+ ]);
65
+ });
66
+
67
+ it.each([undefined, null, ""])(
68
+ "resolves nothing when the config is %p",
69
+ (configured) => {
70
+ (selectActionButtons as jest.Mock).mockReturnValue(configured);
71
+
72
+ expect(
73
+ resolvePlayerActions({ configuration: {}, entry, expandEntryActions })
74
+ ).toEqual([]);
75
+ }
76
+ );
77
+
78
+ it("does not cap the resolved list at two items", () => {
79
+ (selectActionButtons as jest.Mock).mockReturnValue("a,b,c");
80
+
81
+ expect(
82
+ resolvePlayerActions({
83
+ configuration: {},
84
+ entry,
85
+ expandEntryActions,
86
+ }).map((item) => item.identifier)
87
+ ).toEqual(["a", "b", "c"]);
88
+ });
89
+
90
+ it("has no special case for any plugin identifier", () => {
91
+ (selectActionButtons as jest.Mock).mockReturnValue(
92
+ "open-modal-bottom-sheet-cell-action,local_storage_favourites_action"
93
+ );
94
+
95
+ expect(
96
+ resolvePlayerActions({
97
+ configuration: {},
98
+ entry,
99
+ expandEntryActions,
100
+ }).map((item) => item.identifier)
101
+ ).toEqual([
102
+ "open-modal-bottom-sheet-cell-action",
103
+ "local_storage_favourites_action",
104
+ ]);
105
+ });
106
+
107
+ it("collapses a repeated identifier in the config string", () => {
108
+ (selectActionButtons as jest.Mock).mockReturnValue(
109
+ "favorites,favorites,share"
110
+ );
111
+
112
+ expect(
113
+ resolvePlayerActions({
114
+ configuration: {},
115
+ entry,
116
+ expandEntryActions,
117
+ }).map((item) => item.identifier)
118
+ ).toEqual(["favorites", "share"]);
119
+ });
120
+
121
+ it("drops resolved items that cannot be invoked", () => {
122
+ (selectActionButtons as jest.Mock).mockReturnValue("broken,share");
123
+
124
+ (uiActionsRegistry.getActions as jest.Mock).mockImplementation((name) =>
125
+ name === "broken"
126
+ ? [{ identifier: "broken" } as any]
127
+ : [action(name as string)]
128
+ );
129
+
130
+ expect(
131
+ resolvePlayerActions({
132
+ configuration: {},
133
+ entry,
134
+ expandEntryActions,
135
+ }).map((item) => item.identifier)
136
+ ).toEqual(["share"]);
137
+ });
138
+ });