@applicaster/zapp-react-native-ui-components 16.0.0-rc.99 → 17.0.0-alpha.1102403272
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.
- package/Components/AudioPlayer/index.web.tsx +10 -0
- package/Components/Cell/PlatformCellComponent.ts +9 -0
- package/Components/Cell/PlatformCellComponent.web.ts +3 -0
- package/Components/Cell/index.js +2 -9
- package/Components/CellRendererResolver/index.ts +22 -3
- package/Components/ComponentResolver/ComponentResolver.ts +6 -2
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +13 -5
- package/Components/ContentScreen/index.js +2 -2
- package/Components/Focusable/index.web.tsx +3 -0
- package/Components/FocusableList/hooks/useCheckItemIdsForUnique.ts +2 -7
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +1 -1
- package/Components/GeneralContentScreen/hookAdapter/logger.ts +1 -1
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +158 -1
- package/Components/GeneralContentScreen/utils/index.ts +2 -2
- package/Components/GeneralContentScreen/utils/logger.ts +3 -4
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +32 -10
- package/Components/HandlePlayable/utils.ts +2 -7
- package/Components/HookRenderer/HookRenderer.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +42 -4
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.android.tv.tsx +7 -4
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/types.ts +1 -0
- package/Components/MasterCell/DefaultComponents/FocusableView/index.android.tsx +10 -4
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +1 -1
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +2 -4
- package/Components/MasterCell/DefaultComponents/Image/hooks/checkTooBigImageSize.ts +2 -7
- package/Components/MasterCell/DefaultComponents/Image/index.web.ts +7 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/__tests__/prepareEntry.test.ts +30 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +34 -7
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +3 -0
- package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +2 -7
- package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.missingPlugin.test.tsx +66 -0
- package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.test.tsx +288 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +2 -1
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +4 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/factory.test.ts +2 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +2 -1
- package/Components/MasterCell/__tests__/masterCell.test.js +116 -0
- package/Components/MasterCell/index.tsx +45 -6
- package/Components/MasterCell/logger.ts +2 -2
- package/Components/MasterCell/utils/__tests__/getFocusableElementId.test.ts +38 -0
- package/Components/MasterCell/utils/__tests__/useIsCellSelected.test.ts +91 -0
- package/Components/MasterCell/utils/__tests__/withoutFocusedState.test.js +20 -0
- package/Components/MasterCell/utils/behaviorProvider.ts +57 -38
- package/Components/MasterCell/utils/index.ts +60 -19
- package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +1 -1
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +7 -3
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +22 -1
- package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +52 -1
- package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +77 -0
- package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +58 -16
- package/Components/ModalComponent/BottomSheetDragArea.web.tsx +15 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +51 -82
- package/Components/ModalComponent/Button/index.tsx +3 -1
- package/Components/ModalComponent/SortableList.tsx +2 -3
- package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +30 -0
- package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +237 -17
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +25 -0
- package/Components/ModalComponent/presets/__tests__/getCell.test.ts +29 -2
- package/Components/ModalComponent/presets/index.ts +2 -3
- package/Components/ModalComponent/showTextInput.ts +2 -0
- package/Components/OfflineHandler/__tests__/index.test.tsx +136 -0
- package/Components/OfflineHandler/index.tsx +45 -6
- package/Components/PlayerContainer/PlayerContainer.tsx +30 -6
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +51 -0
- package/Components/PlayerContainer/logger.ts +9 -5
- package/Components/River/ComponentsMap/ComponentsMap.tsx +4 -1
- package/Components/River/ComponentsMap/index.web.tsx +3 -0
- package/Components/River/RiverItem.tsx +4 -0
- package/Components/River/TV/River.tsx +7 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
- package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +2 -2
- package/Components/ScreenResolver/index.tsx +6 -4
- package/Components/Tabs/TV/index.web.tsx +5 -0
- package/Components/TopCutoffOverlay/__tests__/TopCutoffOverlay.test.tsx +56 -10
- package/Components/TopCutoffOverlay/index.tsx +41 -10
- package/Components/Transitioner/AnimationManager.js +1 -1
- package/Components/Transitioner/Scene.tsx +4 -3
- package/Components/Transitioner/Transitioner.tsx +71 -33
- package/Components/Transitioner/__tests__/transitioner.test.js +372 -3
- package/Components/VideoLive/LiveImageManager.ts +126 -12
- package/Components/VideoLive/MuteUnmuteController.ts +135 -0
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +15 -19
- package/Components/VideoLive/__tests__/LiveImageManager.test.ts +30 -0
- package/Components/VideoLive/__tests__/LiveImageMuteState.test.ts +311 -0
- package/Components/VideoLive/__tests__/MuteUnmuteController.test.ts +135 -0
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -1
- package/Components/VideoLive/loggerHelper.ts +2 -2
- package/Components/VideoModal/PlayerDetails.tsx +27 -2
- package/Components/VideoModal/PlayerWrapper.tsx +9 -2
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +84 -0
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
- package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +263 -0
- package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +125 -0
- package/Components/VideoModal/hooks/useModalSize.ts +2 -7
- package/Components/VideoModal/playerWrapperStyle.ts +62 -23
- package/Components/VideoModal/playerWrapperUtils.ts +141 -1
- package/Components/__tests__/webVariants.test.js +73 -0
- package/Components/default-cell-renderer/containerStyles/index.web.ts +6 -0
- package/Components/default-cell-renderer/viewTrees/index.web.ts +10 -0
- package/Contexts/ZappPipesContext/ZappPipesContextFactory.tsx +3 -5
- package/Decorators/RiverResolver/__tests__/riverResolver.missingRiver.test.tsx +52 -0
- package/Decorators/RiverResolver/index.tsx +25 -0
- package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +4 -3
- package/Decorators/ZappPipesDataConnector/__tests__/screenToolbox.test.ts +347 -0
- package/Decorators/ZappPipesDataConnector/__tests__/screenToolboxUnavailable.test.ts +53 -0
- package/Decorators/ZappPipesDataConnector/index.tsx +19 -4
- package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +2 -21
- package/Decorators/ZappPipesDataConnector/screenToolbox.ts +384 -0
- package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +1 -1
- package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +1 -1
- package/Helpers/logger.js +2 -2
- package/package.json +5 -5
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { render, screen } from "@testing-library/react-native";
|
|
3
3
|
import { BottomSheetModalContent } from "../BottomSheetModalContent";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
ContentViewModel,
|
|
6
|
+
OPERATIONS,
|
|
7
|
+
} from "@applicaster/zapp-react-native-utils/modalState";
|
|
8
|
+
import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
|
|
9
|
+
import { Image, StyleSheet } from "react-native";
|
|
10
|
+
import {
|
|
11
|
+
AudioPlayerButton,
|
|
12
|
+
VARIANT_TEXT_ONLY,
|
|
13
|
+
} from "../AudioPlayer/Components/Button";
|
|
14
|
+
import { ModalBlocksStyleContext } from "../ModalBlocksStyleContext";
|
|
5
15
|
|
|
6
16
|
jest.mock("react-native-sortables", () => {
|
|
7
17
|
const { View } = require("react-native");
|
|
@@ -45,11 +55,11 @@ jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
|
45
55
|
}));
|
|
46
56
|
|
|
47
57
|
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
48
|
-
usePlugins: () => [],
|
|
58
|
+
usePlugins: jest.fn(() => []),
|
|
49
59
|
}));
|
|
50
60
|
|
|
51
61
|
jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
|
|
52
|
-
useLocalizedStrings: () =>
|
|
62
|
+
useLocalizedStrings: ({ localizations }: any) => localizations || {},
|
|
53
63
|
}));
|
|
54
64
|
|
|
55
65
|
jest.mock("react-native-safe-area-context", () => ({
|
|
@@ -92,15 +102,13 @@ jest.mock("../AudioPlayer/Components", () => ({
|
|
|
92
102
|
return null;
|
|
93
103
|
},
|
|
94
104
|
AudioPlayerButton: (props: any) => {
|
|
95
|
-
const {
|
|
105
|
+
const { AudioPlayerButton } = jest.requireActual(
|
|
106
|
+
"../AudioPlayer/Components/Button"
|
|
107
|
+
);
|
|
96
108
|
|
|
97
109
|
mockAudioPlayerButtonProps.push(props);
|
|
98
110
|
|
|
99
|
-
return
|
|
100
|
-
<Text testID="create-playlist-button" onPress={props.onPress}>
|
|
101
|
-
{props.data?.title}
|
|
102
|
-
</Text>
|
|
103
|
-
);
|
|
111
|
+
return <AudioPlayerButton {...props} />;
|
|
104
112
|
},
|
|
105
113
|
}));
|
|
106
114
|
|
|
@@ -115,6 +123,10 @@ const baseProps = {
|
|
|
115
123
|
};
|
|
116
124
|
|
|
117
125
|
describe("BottomSheetModalContent role/behavior cells", () => {
|
|
126
|
+
beforeEach(() => {
|
|
127
|
+
jest.mocked(usePlugins).mockReturnValue([]);
|
|
128
|
+
});
|
|
129
|
+
|
|
118
130
|
it("renders standard Button rows and default header when no viewModel/role", () => {
|
|
119
131
|
render(<BottomSheetModalContent {...baseProps} />);
|
|
120
132
|
|
|
@@ -199,26 +211,234 @@ describe("BottomSheetModalContent role/behavior cells", () => {
|
|
|
199
211
|
|
|
200
212
|
render(<BottomSheetModalContent {...baseProps} viewModel={viewModel} />);
|
|
201
213
|
|
|
202
|
-
const createBtn = screen.
|
|
214
|
+
const createBtn = screen.getByText("Create New");
|
|
203
215
|
expect(createBtn).toBeTruthy();
|
|
204
216
|
|
|
205
|
-
// The button is rendered bare: styling comes from the modal blocks theme
|
|
206
|
-
// and the title from the button block, so no configuration/data is passed.
|
|
207
217
|
expect(mockAudioPlayerButtonProps.length).toBeGreaterThan(0);
|
|
208
218
|
|
|
209
219
|
for (const props of mockAudioPlayerButtonProps) {
|
|
210
|
-
expect(props.configuration).
|
|
211
|
-
expect(props.data).
|
|
220
|
+
expect(props.configuration.icons.leadingIcon.enabled).toBe(false);
|
|
221
|
+
expect(props.data).toEqual({ title: "Create New" });
|
|
212
222
|
expect(typeof props.onPress).toBe("function");
|
|
213
223
|
}
|
|
214
224
|
|
|
215
225
|
const { fireEvent } = require("@testing-library/react-native");
|
|
216
226
|
fireEvent.press(createBtn);
|
|
217
227
|
|
|
218
|
-
expect(addMock).toHaveBeenCalledWith(
|
|
219
|
-
|
|
220
|
-
|
|
228
|
+
expect(addMock).toHaveBeenCalledWith();
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it.each([["add"], ["add", "reorder"]])(
|
|
232
|
+
"renders operationButtons.add.title with plugin typography and icon for %j",
|
|
233
|
+
(...operations: string[]) => {
|
|
234
|
+
const { BehaviorSubject } = require("rxjs");
|
|
235
|
+
|
|
236
|
+
const configuration = {
|
|
237
|
+
"button.title.font_color": "#123456",
|
|
238
|
+
"button.title.font_size": 19,
|
|
239
|
+
"button.title.line_height": 27,
|
|
240
|
+
"button.background.background_color": "#ff9900",
|
|
241
|
+
"button.leading_icon.asset": "https://example.com/create.png",
|
|
242
|
+
localizations: {
|
|
243
|
+
playlist_experience_button_create_new: "Plugin key label",
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
jest
|
|
248
|
+
.mocked(usePlugins)
|
|
249
|
+
.mockReturnValue([
|
|
250
|
+
{ identifier: "playlist-experience", configuration },
|
|
251
|
+
]);
|
|
252
|
+
|
|
253
|
+
const viewModel = new ContentViewModel({
|
|
254
|
+
title: "Playlists",
|
|
255
|
+
items: [],
|
|
256
|
+
role: "collection_selector",
|
|
257
|
+
themePluginId: "playlist-experience",
|
|
258
|
+
dynamicCollection: { operations },
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
viewModel.editableCollection = {
|
|
262
|
+
items$: new BehaviorSubject([]),
|
|
263
|
+
operations,
|
|
264
|
+
add: jest.fn(),
|
|
265
|
+
move: jest.fn(),
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const styleOverrides = {
|
|
269
|
+
button: {
|
|
270
|
+
title: { default: "Wrong decorator label" },
|
|
271
|
+
leadingIcon: { default: { asset: "https://example.com/wrong.png" } },
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
render(
|
|
276
|
+
<BottomSheetModalContent
|
|
277
|
+
{...baseProps}
|
|
278
|
+
viewModel={viewModel}
|
|
279
|
+
styleOverrides={styleOverrides}
|
|
280
|
+
operationButtons={{ add: { title: "Neue Playlist" } }}
|
|
281
|
+
/>
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
expect(
|
|
285
|
+
StyleSheet.flatten(screen.getByText("Neue Playlist").props.style)
|
|
286
|
+
).toMatchObject({ color: "#123456", fontSize: 19, lineHeight: 27 });
|
|
287
|
+
|
|
288
|
+
expect(screen.UNSAFE_getByType(Image).props.source).toEqual({
|
|
289
|
+
uri: "https://example.com/create.png",
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
expect(screen.queryByText("Wrong decorator label")).toBeNull();
|
|
293
|
+
expect(screen.queryByText("Plugin key label")).toBeNull();
|
|
294
|
+
expect(styleOverrides.button.title.default).toBe("Wrong decorator label");
|
|
295
|
+
expect(configuration["button.title.font_size"]).toBe(19);
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
it("does not read the playlist-specific Add icon key", () => {
|
|
300
|
+
const { BehaviorSubject } = require("rxjs");
|
|
301
|
+
|
|
302
|
+
jest.mocked(usePlugins).mockReturnValue([
|
|
303
|
+
{
|
|
304
|
+
identifier: "playlist-experience",
|
|
305
|
+
configuration: {
|
|
306
|
+
"button.create_new_playlist_asset": "https://example.com/legacy.png",
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
]);
|
|
310
|
+
|
|
311
|
+
const viewModel = new ContentViewModel({
|
|
312
|
+
title: "Playlists",
|
|
313
|
+
items: [],
|
|
314
|
+
role: "collection_selector",
|
|
315
|
+
themePluginId: "playlist-experience",
|
|
316
|
+
dynamicCollection: { operations: ["add"] },
|
|
221
317
|
});
|
|
318
|
+
|
|
319
|
+
viewModel.editableCollection = {
|
|
320
|
+
items$: new BehaviorSubject([]),
|
|
321
|
+
operations: ["add"],
|
|
322
|
+
add: jest.fn(),
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
render(<BottomSheetModalContent {...baseProps} viewModel={viewModel} />);
|
|
326
|
+
|
|
327
|
+
expect(screen.UNSAFE_queryAllByType(Image)).toHaveLength(0);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it.each(
|
|
331
|
+
[false, true].flatMap((sortable) =>
|
|
332
|
+
[
|
|
333
|
+
{ iconURL: undefined, themeIcon: undefined, expected: undefined },
|
|
334
|
+
{
|
|
335
|
+
iconURL: "file:///bundled-add.png",
|
|
336
|
+
themeIcon: undefined,
|
|
337
|
+
expected: "file:///bundled-add.png",
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
iconURL: "https://example.com/upload.png",
|
|
341
|
+
themeIcon: undefined,
|
|
342
|
+
expected: "https://example.com/upload.png",
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
iconURL: undefined,
|
|
346
|
+
themeIcon: "https://example.com/theme.png",
|
|
347
|
+
expected: "https://example.com/theme.png",
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
iconURL: "file:///bundled-add.png",
|
|
351
|
+
themeIcon: "https://example.com/theme.png",
|
|
352
|
+
expected: "https://example.com/theme.png",
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
iconURL: "file:///bundled-add.png",
|
|
356
|
+
themeIcon: "https://example.com/theme.png",
|
|
357
|
+
themeEnabled: false,
|
|
358
|
+
expected: undefined,
|
|
359
|
+
},
|
|
360
|
+
].map((scenario) => ({ ...scenario, sortable }))
|
|
361
|
+
)
|
|
362
|
+
)(
|
|
363
|
+
"resolves Add icon presentation for %j",
|
|
364
|
+
({ sortable, iconURL, themeIcon, themeEnabled, expected }) => {
|
|
365
|
+
const { BehaviorSubject } = require("rxjs");
|
|
366
|
+
|
|
367
|
+
const operations = sortable
|
|
368
|
+
? [OPERATIONS.ADD, OPERATIONS.REORDER]
|
|
369
|
+
: [OPERATIONS.ADD];
|
|
370
|
+
|
|
371
|
+
jest.mocked(usePlugins).mockReturnValue([
|
|
372
|
+
{
|
|
373
|
+
identifier: "generic-theme",
|
|
374
|
+
configuration: themeIcon
|
|
375
|
+
? {
|
|
376
|
+
"button.leading_icon.asset": themeIcon,
|
|
377
|
+
"button.leading_icon.enabled": themeEnabled,
|
|
378
|
+
}
|
|
379
|
+
: {},
|
|
380
|
+
},
|
|
381
|
+
]);
|
|
382
|
+
|
|
383
|
+
const viewModel = new ContentViewModel({
|
|
384
|
+
title: "Collections",
|
|
385
|
+
items: [],
|
|
386
|
+
themePluginId: "generic-theme",
|
|
387
|
+
dynamicCollection: { operations },
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
viewModel.editableCollection = {
|
|
391
|
+
items$: new BehaviorSubject([]),
|
|
392
|
+
operations,
|
|
393
|
+
add: jest.fn(),
|
|
394
|
+
move: jest.fn(),
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
render(
|
|
398
|
+
<BottomSheetModalContent
|
|
399
|
+
{...baseProps}
|
|
400
|
+
viewModel={viewModel}
|
|
401
|
+
operationButtons={{ add: { iconURL } }}
|
|
402
|
+
/>
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
if (expected) {
|
|
406
|
+
expect(screen.UNSAFE_getByType(Image).props.source).toEqual({
|
|
407
|
+
uri: expected,
|
|
408
|
+
});
|
|
409
|
+
} else {
|
|
410
|
+
expect(screen.UNSAFE_queryAllByType(Image)).toHaveLength(0);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
it("does not render a typography object as a button label", () => {
|
|
416
|
+
render(
|
|
417
|
+
<ModalBlocksStyleContext.Provider
|
|
418
|
+
value={{ button: { title: { default: { fontSize: 19 } } } }}
|
|
419
|
+
>
|
|
420
|
+
<AudioPlayerButton configuration={VARIANT_TEXT_ONLY} />
|
|
421
|
+
</ModalBlocksStyleContext.Provider>
|
|
422
|
+
);
|
|
423
|
+
|
|
424
|
+
expect(screen.toJSON()).toBeTruthy();
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
it("renders explicit button data separately from typography", () => {
|
|
428
|
+
render(
|
|
429
|
+
<ModalBlocksStyleContext.Provider
|
|
430
|
+
value={{ button: { title: { default: { fontSize: 19 } } } }}
|
|
431
|
+
>
|
|
432
|
+
<AudioPlayerButton
|
|
433
|
+
configuration={VARIANT_TEXT_ONLY}
|
|
434
|
+
data={{ title: "Create Playlist" }}
|
|
435
|
+
/>
|
|
436
|
+
</ModalBlocksStyleContext.Provider>
|
|
437
|
+
);
|
|
438
|
+
|
|
439
|
+
expect(
|
|
440
|
+
StyleSheet.flatten(screen.getByText("Create Playlist").props.style)
|
|
441
|
+
).toMatchObject({ fontSize: 19 });
|
|
222
442
|
});
|
|
223
443
|
|
|
224
444
|
it("shows the empty Next Up message only when now playing is on and the list is empty", () => {
|
|
@@ -92,4 +92,29 @@ describe("showTextInputAction", () => {
|
|
|
92
92
|
expect(result).toBe(ActionResult.Error);
|
|
93
93
|
expect(actionExecutor.handleAction).not.toHaveBeenCalled();
|
|
94
94
|
});
|
|
95
|
+
|
|
96
|
+
it("forwards themePluginId so the sheet can read plugin button styles", async () => {
|
|
97
|
+
const action = {
|
|
98
|
+
type: "showTextInput",
|
|
99
|
+
options: {
|
|
100
|
+
headerTitle: "Create New Playlist",
|
|
101
|
+
inputLabel: "Name your playlist",
|
|
102
|
+
buttonLabel: "Create",
|
|
103
|
+
themePluginId: "playlist-experience",
|
|
104
|
+
actions: [{ type: "sendCloudEvent", options: {} }],
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
await showTextInputAction(action as any);
|
|
109
|
+
|
|
110
|
+
expect(actionExecutor.handleAction).toHaveBeenCalledWith(
|
|
111
|
+
expect.objectContaining({
|
|
112
|
+
type: "openBottomSheet",
|
|
113
|
+
options: expect.objectContaining({
|
|
114
|
+
themePluginId: "playlist-experience",
|
|
115
|
+
}),
|
|
116
|
+
}),
|
|
117
|
+
undefined
|
|
118
|
+
);
|
|
119
|
+
});
|
|
95
120
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Pressable } from "react-native";
|
|
3
3
|
import { fireEvent, render, screen } from "@testing-library/react-native";
|
|
4
|
+
import { Button } from "../../Button";
|
|
4
5
|
import { getCell } from "../index";
|
|
5
6
|
import { standardCell } from "../standardCell";
|
|
6
7
|
import { selectableCell } from "../selectableCell";
|
|
@@ -12,8 +13,8 @@ describe("getCell", () => {
|
|
|
12
13
|
expect(getCell("collection_selector")).toBe(selectableCell);
|
|
13
14
|
});
|
|
14
15
|
|
|
15
|
-
it("returns
|
|
16
|
-
expect(getCell("preference_editor")).toBe(
|
|
16
|
+
it("returns standard cell for preference_editor", () => {
|
|
17
|
+
expect(getCell("preference_editor")).toBe(standardCell);
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
it("returns standard cell when role is undefined", () => {
|
|
@@ -88,3 +89,29 @@ describe("selectableCell checkbox press", () => {
|
|
|
88
89
|
expect(onPress).toHaveBeenCalledWith(item);
|
|
89
90
|
});
|
|
90
91
|
});
|
|
92
|
+
|
|
93
|
+
describe("standardCell selection via item.isSelected", () => {
|
|
94
|
+
it("highlights row and renders selected icon when item.isSelected is true", () => {
|
|
95
|
+
render(
|
|
96
|
+
standardCell.renderItem({
|
|
97
|
+
item: { id: "1", title: "1x", isSelected: true },
|
|
98
|
+
index: 0,
|
|
99
|
+
onPress: jest.fn(),
|
|
100
|
+
context: {
|
|
101
|
+
theme: {},
|
|
102
|
+
ButtonComponent: Button,
|
|
103
|
+
current_selection: null,
|
|
104
|
+
iconBaseProps: { width: 16, height: 16 },
|
|
105
|
+
itemBaseProps: { selectedBackgroundColor: "#3E3E3E" } as any,
|
|
106
|
+
labelBaseProps: { selectedColor: "#EFEFEF" } as any,
|
|
107
|
+
getSelectedItemIcon: () => "https://example.com/check.png",
|
|
108
|
+
getDefaultItemIcon: () => null,
|
|
109
|
+
} as any,
|
|
110
|
+
}) as React.ReactElement
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
expect(screen.getByText("1x").props.style).toMatchObject({
|
|
114
|
+
color: "#EFEFEF",
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -11,8 +11,6 @@ export { selectableCell } from "./selectableCell";
|
|
|
11
11
|
|
|
12
12
|
import { dynamicCollectionCell } from "./dynamicCollectionCell";
|
|
13
13
|
|
|
14
|
-
const SELECTION_ROLES = new Set(["collection_selector", "preference_editor"]);
|
|
15
|
-
|
|
16
14
|
/**
|
|
17
15
|
* Resolve the row cell from feed role (+ behavior for future config only).
|
|
18
16
|
* Unknown / none -> standard Button cell.
|
|
@@ -22,6 +20,7 @@ export const getCell = (
|
|
|
22
20
|
_behavior?: SelectionBehavior
|
|
23
21
|
): CellRenderer => {
|
|
24
22
|
if (role === "dynamic_collection") return dynamicCollectionCell;
|
|
23
|
+
if (role === "collection_selector") return selectableCell;
|
|
25
24
|
|
|
26
|
-
return
|
|
25
|
+
return standardCell;
|
|
27
26
|
};
|
|
@@ -21,6 +21,7 @@ export async function showTextInputAction(
|
|
|
21
21
|
validationLabel,
|
|
22
22
|
actions,
|
|
23
23
|
maxLength,
|
|
24
|
+
themePluginId,
|
|
24
25
|
} = action.options || {};
|
|
25
26
|
|
|
26
27
|
if (!headerTitle || !buttonLabel || !actions || !actions.length) {
|
|
@@ -34,6 +35,7 @@ export async function showTextInputAction(
|
|
|
34
35
|
header: {
|
|
35
36
|
title: headerTitle,
|
|
36
37
|
},
|
|
38
|
+
...(themePluginId ? { themePluginId } : {}),
|
|
37
39
|
content: {
|
|
38
40
|
component: TextInputContent,
|
|
39
41
|
props: {
|
|
@@ -10,6 +10,55 @@ jest.useFakeTimers({ legacyFakeTimers: true });
|
|
|
10
10
|
// isConnected/isInternetReachable/details fields, so the mock has to mirror
|
|
11
11
|
// that shape for online/offline to actually be distinguishable.
|
|
12
12
|
let mockConnectionStatus = false;
|
|
13
|
+
let mockStillOfflineAfterResumeCount = 0;
|
|
14
|
+
|
|
15
|
+
const mockComponentsLogger = {
|
|
16
|
+
log: jest.fn(),
|
|
17
|
+
debug: jest.fn(),
|
|
18
|
+
info: jest.fn(),
|
|
19
|
+
warning: jest.fn(),
|
|
20
|
+
error: jest.fn(),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
jest.mock("@applicaster/zapp-react-native-utils/logger", () => {
|
|
24
|
+
const actual = jest.requireActual(
|
|
25
|
+
"@applicaster/zapp-react-native-utils/logger"
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
...actual,
|
|
30
|
+
// Only the logger of this subsystem is replaced; every other module keeps its real one.
|
|
31
|
+
subsystemLogger: (subsystem: string) => {
|
|
32
|
+
if (subsystem !== "offline") {
|
|
33
|
+
return actual.subsystemLogger(subsystem);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const logger = {
|
|
37
|
+
log: (event) => mockComponentsLogger.log(event),
|
|
38
|
+
debug: (event) => mockComponentsLogger.debug(event),
|
|
39
|
+
info: (event) => mockComponentsLogger.info(event),
|
|
40
|
+
warning: (event) => mockComponentsLogger.warning(event),
|
|
41
|
+
error: (event) => mockComponentsLogger.error(event),
|
|
42
|
+
addSubsystem: () => logger,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return logger;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
jest.mock("../../../Helpers/logger", () => {
|
|
51
|
+
const proxy = {
|
|
52
|
+
log: (event) => mockComponentsLogger.log(event),
|
|
53
|
+
debug: (event) => mockComponentsLogger.debug(event),
|
|
54
|
+
info: (event) => mockComponentsLogger.info(event),
|
|
55
|
+
warning: (event) => mockComponentsLogger.warning(event),
|
|
56
|
+
error: (event) => mockComponentsLogger.error(event),
|
|
57
|
+
addSubsystem: () => proxy,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return { componentsLogger: proxy };
|
|
61
|
+
});
|
|
13
62
|
|
|
14
63
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/connection", () => {
|
|
15
64
|
return {
|
|
@@ -20,6 +69,7 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/connection", () => {
|
|
|
20
69
|
details: {},
|
|
21
70
|
isConnected: mockConnectionStatus,
|
|
22
71
|
isInternetReachable: mockConnectionStatus,
|
|
72
|
+
stillOfflineAfterResumeCount: mockStillOfflineAfterResumeCount,
|
|
23
73
|
})),
|
|
24
74
|
};
|
|
25
75
|
});
|
|
@@ -58,6 +108,7 @@ describe("OfflineHandler", () => {
|
|
|
58
108
|
|
|
59
109
|
beforeEach(() => {
|
|
60
110
|
mockConnectionStatus = false;
|
|
111
|
+
mockStillOfflineAfterResumeCount = 0;
|
|
61
112
|
});
|
|
62
113
|
|
|
63
114
|
it("renders its children without wrapping them in a notification view", () => {
|
|
@@ -131,4 +182,89 @@ describe("OfflineHandler", () => {
|
|
|
131
182
|
|
|
132
183
|
unsubscribe();
|
|
133
184
|
});
|
|
185
|
+
|
|
186
|
+
it("re-shows the offline toast when still offline after app resume", () => {
|
|
187
|
+
mockConnectionStatus = false;
|
|
188
|
+
|
|
189
|
+
const handleShowToast = jest.fn();
|
|
190
|
+
const unsubscribe = subscriberFor("showToast", handleShowToast);
|
|
191
|
+
|
|
192
|
+
const { rerender } = render(<OfflineHandler />);
|
|
193
|
+
handleShowToast.mockClear();
|
|
194
|
+
|
|
195
|
+
mockStillOfflineAfterResumeCount = 1;
|
|
196
|
+
rerender(<OfflineHandler />);
|
|
197
|
+
|
|
198
|
+
expect(handleShowToast).toHaveBeenCalledTimes(1);
|
|
199
|
+
|
|
200
|
+
expect(handleShowToast).toHaveBeenCalledWith(
|
|
201
|
+
expect.objectContaining({
|
|
202
|
+
id: "offline-status",
|
|
203
|
+
message: "No internet connection",
|
|
204
|
+
timeout: 5000,
|
|
205
|
+
}),
|
|
206
|
+
expect.any(Function)
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
// further renders with the same counter must not re-emit
|
|
210
|
+
rerender(<OfflineHandler />);
|
|
211
|
+
expect(handleShowToast).toHaveBeenCalledTimes(1);
|
|
212
|
+
|
|
213
|
+
unsubscribe();
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it("does not re-show the offline toast for a counter bump while online", () => {
|
|
217
|
+
mockConnectionStatus = true;
|
|
218
|
+
|
|
219
|
+
const handleShowToast = jest.fn();
|
|
220
|
+
const unsubscribe = subscriberFor("showToast", handleShowToast);
|
|
221
|
+
|
|
222
|
+
const { rerender } = render(<OfflineHandler />);
|
|
223
|
+
|
|
224
|
+
mockStillOfflineAfterResumeCount = 1;
|
|
225
|
+
rerender(<OfflineHandler />);
|
|
226
|
+
|
|
227
|
+
expect(handleShowToast).not.toHaveBeenCalled();
|
|
228
|
+
|
|
229
|
+
unsubscribe();
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("does not emit on mount just because the counter is already > 0", () => {
|
|
233
|
+
mockConnectionStatus = true;
|
|
234
|
+
mockStillOfflineAfterResumeCount = 3;
|
|
235
|
+
|
|
236
|
+
const handleShowToast = jest.fn();
|
|
237
|
+
const unsubscribe = subscriberFor("showToast", handleShowToast);
|
|
238
|
+
|
|
239
|
+
render(<OfflineHandler />);
|
|
240
|
+
|
|
241
|
+
expect(handleShowToast).not.toHaveBeenCalled();
|
|
242
|
+
|
|
243
|
+
unsubscribe();
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it("logs toast emissions at info level", () => {
|
|
247
|
+
mockConnectionStatus = false;
|
|
248
|
+
mockComponentsLogger.info.mockClear();
|
|
249
|
+
mockComponentsLogger.warning.mockClear();
|
|
250
|
+
|
|
251
|
+
const { rerender } = render(<OfflineHandler />);
|
|
252
|
+
|
|
253
|
+
mockConnectionStatus = true;
|
|
254
|
+
rerender(<OfflineHandler />);
|
|
255
|
+
|
|
256
|
+
expect(mockComponentsLogger.info).toHaveBeenCalledWith(
|
|
257
|
+
expect.objectContaining({
|
|
258
|
+
message: "OfflineHandler: device is offline, emit toast",
|
|
259
|
+
})
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
expect(mockComponentsLogger.info).toHaveBeenCalledWith(
|
|
263
|
+
expect.objectContaining({
|
|
264
|
+
message: "OfflineHandler: device is back online, emit toast",
|
|
265
|
+
})
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
expect(mockComponentsLogger.warning).not.toHaveBeenCalled();
|
|
269
|
+
});
|
|
134
270
|
});
|
|
@@ -4,10 +4,11 @@ import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/uti
|
|
|
4
4
|
import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
|
|
5
5
|
|
|
6
6
|
import { useOfflineHandlerProps } from "./hooks";
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
import { parseConnectionInfo } from "./utils";
|
|
9
|
+
import { subsystemLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
9
10
|
|
|
10
|
-
const logger =
|
|
11
|
+
const logger = subsystemLogger("offline", "OfflineHandler");
|
|
11
12
|
|
|
12
13
|
// mirrors NOTIFICATION_TOAST_EVENTS.SHOW_TOAST in
|
|
13
14
|
// @applicaster/quick-brick-core/App/NotificationToastRenderer/NotificationToastManager
|
|
@@ -29,12 +30,22 @@ export const OfflineHandler = ({ children }: Props) => {
|
|
|
29
30
|
const { online } = parseConnectionInfo(connectionInfo);
|
|
30
31
|
const prevOnline = usePrevious(online);
|
|
31
32
|
|
|
33
|
+
const stillOfflineAfterResumeCount =
|
|
34
|
+
connectionInfo?.stillOfflineAfterResumeCount ?? 0;
|
|
35
|
+
|
|
36
|
+
const prevStillOfflineAfterResumeCount = usePrevious(
|
|
37
|
+
stillOfflineAfterResumeCount
|
|
38
|
+
);
|
|
39
|
+
|
|
32
40
|
const emitShowToast = useSubscriberFor(SHOW_TOAST_EVENT);
|
|
33
41
|
|
|
34
42
|
const { message, extraMessage, style } = useOfflineHandlerProps(online);
|
|
35
43
|
|
|
36
44
|
const showOnlineToast = useCallback(() => {
|
|
37
|
-
logger.
|
|
45
|
+
logger.info({
|
|
46
|
+
message: "OfflineHandler: device is back online, emit toast",
|
|
47
|
+
data: { online, prevOnline },
|
|
48
|
+
});
|
|
38
49
|
|
|
39
50
|
emitShowToast({
|
|
40
51
|
id: OFFLINE_STATUS_TOAST_ID,
|
|
@@ -43,10 +54,13 @@ export const OfflineHandler = ({ children }: Props) => {
|
|
|
43
54
|
style,
|
|
44
55
|
timeout: timers.goingOnline,
|
|
45
56
|
});
|
|
46
|
-
}, [emitShowToast, message, extraMessage, style]);
|
|
57
|
+
}, [emitShowToast, message, extraMessage, style, online, prevOnline]);
|
|
47
58
|
|
|
48
59
|
const showOfflineToast = useCallback(() => {
|
|
49
|
-
logger.
|
|
60
|
+
logger.info({
|
|
61
|
+
message: "OfflineHandler: device is offline, emit toast",
|
|
62
|
+
data: { online, prevOnline, stillOfflineAfterResumeCount },
|
|
63
|
+
});
|
|
50
64
|
|
|
51
65
|
emitShowToast({
|
|
52
66
|
id: OFFLINE_STATUS_TOAST_ID,
|
|
@@ -55,7 +69,15 @@ export const OfflineHandler = ({ children }: Props) => {
|
|
|
55
69
|
style,
|
|
56
70
|
timeout: timers.goingOffline,
|
|
57
71
|
});
|
|
58
|
-
}, [
|
|
72
|
+
}, [
|
|
73
|
+
emitShowToast,
|
|
74
|
+
message,
|
|
75
|
+
extraMessage,
|
|
76
|
+
style,
|
|
77
|
+
online,
|
|
78
|
+
prevOnline,
|
|
79
|
+
stillOfflineAfterResumeCount,
|
|
80
|
+
]);
|
|
59
81
|
|
|
60
82
|
useEffect(() => {
|
|
61
83
|
// On mount there is no previous state yet: only surface the offline toast
|
|
@@ -79,5 +101,22 @@ export const OfflineHandler = ({ children }: Props) => {
|
|
|
79
101
|
}
|
|
80
102
|
}, [online, prevOnline, showOfflineToast, showOnlineToast]);
|
|
81
103
|
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
// NetworkStatusProvider bumps this counter when the app resumed while offline
|
|
106
|
+
// and is still offline after the verification delay: remind the user.
|
|
107
|
+
if (
|
|
108
|
+
prevStillOfflineAfterResumeCount !== undefined &&
|
|
109
|
+
stillOfflineAfterResumeCount > prevStillOfflineAfterResumeCount &&
|
|
110
|
+
!online
|
|
111
|
+
) {
|
|
112
|
+
showOfflineToast();
|
|
113
|
+
}
|
|
114
|
+
}, [
|
|
115
|
+
stillOfflineAfterResumeCount,
|
|
116
|
+
prevStillOfflineAfterResumeCount,
|
|
117
|
+
online,
|
|
118
|
+
showOfflineToast,
|
|
119
|
+
]);
|
|
120
|
+
|
|
82
121
|
return children;
|
|
83
122
|
};
|