@applicaster/zapp-react-native-ui-components 16.0.0-alpha.1042942411 → 16.0.0-alpha.1054344748

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 (112) hide show
  1. package/Components/AudioPlayer/tv/__tests__/audioPlayer.test.js +19 -0
  2. package/Components/AudioPlayer/tv/__tests__/index.test.tsx +120 -0
  3. package/Components/AudioPlayer/tv/index.tsx +5 -1
  4. package/Components/Cell/Cell.tsx +3 -6
  5. package/Components/Cell/TvOSCellComponent.tsx +0 -1
  6. package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +15 -0
  7. package/Components/GeneralContentScreen/hookAdapter/__tests__/skipExpression.test.ts +294 -0
  8. package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +64 -0
  9. package/Components/GeneralContentScreen/hookAdapter/skipExpression.ts +252 -0
  10. package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +18 -0
  11. package/Components/LinkHandler/LinkHandler.tsx +2 -7
  12. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +64 -28
  13. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/ActionButtonController.tsx +19 -4
  14. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/__tests__/ActionButtonController.test.tsx +43 -1
  15. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +46 -217
  16. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +109 -46
  17. package/Components/MasterCell/DefaultComponents/Button.tsx +44 -50
  18. package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +14 -13
  19. package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +420 -125
  20. package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +114 -19
  21. package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +19 -8
  22. package/Components/MasterCell/DefaultComponents/LiveImage/executePreloadHooks.ts +2 -4
  23. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -3
  24. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +50 -46
  25. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +39 -47
  26. package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +6 -19
  27. package/Components/MasterCell/DefaultComponents/Text/index.tsx +15 -45
  28. package/Components/MasterCell/DefaultComponents/Toggle.tsx +36 -14
  29. package/Components/MasterCell/DefaultComponents/__tests__/Toggle.test.tsx +167 -0
  30. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +67 -196
  31. package/Components/MasterCell/DefaultComponents/index.ts +0 -4
  32. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +6 -4
  33. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/factory.test.ts +32 -0
  34. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -2
  35. package/Components/MasterCell/elementMapper.tsx +0 -2
  36. package/Components/ModalComponent/ActionsBottomSheet/ActionButton.tsx +56 -0
  37. package/Components/ModalComponent/ActionsBottomSheet/__tests__/openActionsBottomSheet.test.ts +38 -0
  38. package/Components/ModalComponent/ActionsBottomSheet/boundActionButton.tsx +24 -0
  39. package/Components/ModalComponent/ActionsBottomSheet/index.ts +9 -0
  40. package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +61 -0
  41. package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +87 -97
  42. package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +87 -126
  43. package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +140 -83
  44. package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +252 -123
  45. package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +205 -0
  46. package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +113 -0
  47. package/Components/ModalComponent/AudioPlayer/Components/__tests__/NowPlayingHeaderSection.test.tsx +36 -0
  48. package/Components/ModalComponent/AudioPlayer/Components/index.ts +3 -3
  49. package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +356 -0
  50. package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +521 -0
  51. package/Components/ModalComponent/BottomSheetModalContent.tsx +498 -66
  52. package/Components/ModalComponent/Button/index.tsx +5 -3
  53. package/Components/ModalComponent/Header/CloseButton.tsx +12 -0
  54. package/Components/ModalComponent/Header/__tests__/CloseButton.test.tsx +72 -0
  55. package/Components/ModalComponent/Header/index.tsx +20 -7
  56. package/Components/ModalComponent/Header/utils.ts +1 -1
  57. package/Components/ModalComponent/ModalBlocksStyleContext.tsx +10 -0
  58. package/Components/ModalComponent/SortableList.tsx +156 -0
  59. package/Components/ModalComponent/SortableList.web.tsx +34 -0
  60. package/Components/ModalComponent/TextInputContent.tsx +135 -0
  61. package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +343 -0
  62. package/Components/ModalComponent/__tests__/SortableList.web.test.tsx +16 -0
  63. package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +169 -0
  64. package/Components/ModalComponent/__tests__/showTextInput.test.ts +95 -0
  65. package/Components/ModalComponent/index.tsx +18 -9
  66. package/Components/ModalComponent/presets/__tests__/getCell.test.ts +90 -0
  67. package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +78 -0
  68. package/Components/ModalComponent/presets/index.ts +27 -0
  69. package/Components/ModalComponent/presets/selectableCell.tsx +28 -0
  70. package/Components/ModalComponent/presets/standardCell.tsx +41 -0
  71. package/Components/ModalComponent/presets/types.ts +35 -0
  72. package/Components/ModalComponent/showTextInput.ts +52 -0
  73. package/Components/ModalComponent/utils.ts +82 -21
  74. package/Components/OfflineHandler/__tests__/index.test.tsx +109 -0
  75. package/Components/OfflineHandler/hooks.ts +0 -12
  76. package/Components/OfflineHandler/index.tsx +42 -4
  77. package/Components/PlayerContainer/PlayerContainer.tsx +19 -8
  78. package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -4
  79. package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +66 -13
  80. package/Components/River/ComponentsMap/ComponentsMap.tsx +85 -59
  81. package/Components/River/River.tsx +4 -0
  82. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +138 -75
  83. package/Components/River/__tests__/componentsMap.test.js +8 -3
  84. package/Components/River/__tests__/resultCallback.test.tsx +47 -0
  85. package/Components/Screen/__tests__/Screen.test.tsx +24 -0
  86. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
  87. package/Components/Screen/index.tsx +5 -0
  88. package/Components/Screen/navigationHandler.ts +8 -8
  89. package/Components/ScreenRevealManager/ScreenRevealManager.ts +18 -2
  90. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +36 -0
  91. package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +56 -0
  92. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +21 -4
  93. package/Components/Transitioner/AnimationManager.js +1 -1
  94. package/Components/Transitioner/Scene.tsx +4 -3
  95. package/Components/Transitioner/Transitioner.tsx +71 -33
  96. package/Components/Transitioner/__tests__/transitioner.test.js +372 -3
  97. package/Components/VideoLive/LiveImageManager.ts +9 -3
  98. package/Components/VideoLive/__tests__/LiveImageManager.test.ts +59 -0
  99. package/Contexts/ModalNavigationContext/__tests__/index.test.tsx +15 -0
  100. package/Contexts/ModalNavigationContext/index.tsx +2 -2
  101. package/Hooks/useEntryActionsExpander.ts +63 -0
  102. package/assets/empty-Info.png +0 -0
  103. package/package.json +6 -5
  104. package/Components/MasterCell/DefaultComponents/CellBadge/__tests__/__snapshots__/index.test.tsx.snap +0 -18
  105. package/Components/MasterCell/DefaultComponents/CellBadge/__tests__/index.test.tsx +0 -90
  106. package/Components/MasterCell/DefaultComponents/UIKitAdapters/Badge.tsx +0 -49
  107. package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.test.tsx +0 -122
  108. package/Components/MasterCell/DefaultComponents/__tests__/Button.test.tsx +0 -186
  109. package/Components/MasterCell/DefaultComponents/__tests__/DynamicBadge.test.tsx +0 -156
  110. package/Components/MasterCell/DefaultComponents/__tests__/__snapshots__/ActionButton.test.tsx.snap +0 -60
  111. package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +0 -332
  112. /package/Decorators/ZappPipesDataConnector/__tests__/{Hero.js → Hero.tsx} +0 -0
@@ -1,6 +1,7 @@
1
- import React, { useState, useCallback } from "react";
1
+ import React, { useCallback, useState } from "react";
2
2
  import { Switch } from "react-native";
3
3
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
4
+ import { useCellClick } from "@applicaster/zapp-react-native-utils/reactHooks/cell-click";
4
5
 
5
6
  type Props = {
6
7
  item: ZappEntry | ZappFeed;
@@ -15,36 +16,57 @@ type Props = {
15
16
  export const Toggle = (props: Props) => {
16
17
  const { style, item, action, cellState } = props;
17
18
 
18
- const {
19
- trackColor,
20
- trackColorActive,
21
- thumbColor,
22
- thumbColorActive,
23
- iosBackgroundColor,
24
- } = style;
19
+ const { trackColor, trackColorActive, thumbColor, thumbColorActive } = style;
25
20
 
21
+ // `focused_selected` is the selected state with a finger on the row, so the
22
+ // switch has to read as on for both. Leaving it out reads a pressed selected
23
+ // row as off, which flips the thumb for the duration of the press.
26
24
  const isSelected = React.useMemo(
27
- () => cellState === "selected",
25
+ () => cellState === "selected" || cellState === "focused_selected",
28
26
  [item?.id, cellState]
29
27
  );
30
28
 
31
29
  const actionContext = useActions(action?.identifier);
30
+ const onCellClick = useCellClick({ item: item as ZappEntry });
32
31
 
33
- const [actionState, setActionState] = useState(
34
- actionContext.initialEntryState(item)
32
+ // A form toggle has no action plugin behind the switch: it reflects the cell
33
+ // selection state and writes through the entry's tap actions, the same path a
34
+ // tap on the row takes.
35
+ //
36
+ // An empty identifier is the way to ask for that, which is why the cell
37
+ // manifest declares no initial_value for `toggle_action_identifier`:
38
+ // `castOrDefault` substitutes the default whenever the configured value is
39
+ // empty - and an empty string counts as empty - so any default there would be
40
+ // uncleanable and would force every toggle onto that plugin.
41
+ //
42
+ // The route is still decided on whether the identifier resolves to an
43
+ // installed action plugin rather than on the string being non-empty. App
44
+ // configurations saved while the old default was in the manifest still carry
45
+ // it, and a mistyped plugin id has to fall back the same way.
46
+ const hasActionPlugin = Boolean(
47
+ action?.identifier && actionContext?.invokeAction
48
+ );
49
+
50
+ const [actionState, setActionState] = useState(() =>
51
+ hasActionPlugin ? actionContext?.initialEntryState?.(item) : undefined
35
52
  );
36
53
 
37
54
  const onPress = useCallback(() => {
38
- actionContext.invokeAction(item, {
55
+ if (!hasActionPlugin) {
56
+ onCellClick();
57
+
58
+ return;
59
+ }
60
+
61
+ actionContext?.invokeAction?.(item, {
39
62
  updateState: setActionState,
40
63
  });
41
- }, [actionState, actionContext?.state]);
64
+ }, [hasActionPlugin, onCellClick, actionState, actionContext?.state]);
42
65
 
43
66
  return (
44
67
  <Switch
45
68
  trackColor={{ false: trackColor, true: trackColorActive }}
46
69
  thumbColor={isSelected ? thumbColorActive : thumbColor}
47
- ios_backgroundColor={iosBackgroundColor}
48
70
  onValueChange={onPress}
49
71
  value={isSelected}
50
72
  />
@@ -0,0 +1,167 @@
1
+ import React from "react";
2
+ import { fireEvent, render } from "@testing-library/react-native";
3
+ import { Switch } from "react-native";
4
+ import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
5
+
6
+ import { Toggle } from "../Toggle";
7
+
8
+ const mockOnCellClick = jest.fn();
9
+ const mockInvokeAction = jest.fn();
10
+ const mockInitialEntryState = jest.fn().mockReturnValue({ state: 0 });
11
+
12
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/cell-click", () => ({
13
+ useCellClick: jest.fn(() => mockOnCellClick),
14
+ }));
15
+
16
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/actions", () => ({
17
+ useActions: jest.fn(() => ({
18
+ invokeAction: mockInvokeAction,
19
+ initialEntryState: mockInitialEntryState,
20
+ })),
21
+ }));
22
+
23
+ const style = {
24
+ trackColor: "rgba(0,0,0,1)",
25
+ trackColorActive: "rgba(4,207,153,1)",
26
+ thumbColor: "rgba(255,255,255,1)",
27
+ thumbColorActive: "rgba(255,255,255,1)",
28
+ } as any;
29
+
30
+ const item = { id: "true", title: "I agree" } as any;
31
+
32
+ const renderToggle = (identifier: string, cellState) =>
33
+ render(
34
+ <Toggle
35
+ item={item}
36
+ action={{ identifier }}
37
+ style={style}
38
+ cellState={cellState}
39
+ />
40
+ );
41
+
42
+ describe("Toggle with an empty action identifier", () => {
43
+ beforeEach(() => {
44
+ jest.clearAllMocks();
45
+ });
46
+
47
+ it("is on when the cell is selected", () => {
48
+ const { getByRole } = renderToggle("", "selected");
49
+
50
+ expect(getByRole("switch").props.value).toBe(true);
51
+ });
52
+
53
+ it("is off when the cell is not selected", () => {
54
+ const { getByRole } = renderToggle("", "default");
55
+
56
+ expect(getByRole("switch").props.value).toBe(false);
57
+ });
58
+
59
+ // A finger on a selected row resolves the cell to focused_selected. Reading
60
+ // that as unselected flipped the thumb for the duration of the press and let
61
+ // it jump back on release, which reads as a second tap.
62
+ it("stays on while a selected cell is pressed", () => {
63
+ const { getByRole } = renderToggle("", "focused_selected");
64
+
65
+ expect(getByRole("switch").props.value).toBe(true);
66
+ });
67
+
68
+ it("is off while an unselected cell is pressed", () => {
69
+ const { getByRole } = renderToggle("", "focused");
70
+
71
+ expect(getByRole("switch").props.value).toBe(false);
72
+ });
73
+
74
+ it("routes a change through the cell click path", () => {
75
+ const { getByRole } = renderToggle("", "default");
76
+
77
+ fireEvent(getByRole("switch"), "valueChange", true);
78
+
79
+ expect(mockOnCellClick).toHaveBeenCalledTimes(1);
80
+ expect(mockInvokeAction).not.toHaveBeenCalled();
81
+ });
82
+
83
+ it("does not read the action plugin state", () => {
84
+ renderToggle("", "default");
85
+
86
+ expect(mockInitialEntryState).not.toHaveBeenCalled();
87
+ });
88
+
89
+ // Asserted on the Switch element rather than the rendered host component:
90
+ // what Toggle owns is the props it hands to Switch, and React Native rewrites
91
+ // them into platform-specific ones (tintColor, a style entry) underneath.
92
+ it("forwards every configured color to the switch", () => {
93
+ const { UNSAFE_getByType } = renderToggle("", "default");
94
+
95
+ expect(UNSAFE_getByType(Switch).props).toMatchObject({
96
+ trackColor: { false: style.trackColor, true: style.trackColorActive },
97
+ thumbColor: style.thumbColor,
98
+ });
99
+ });
100
+
101
+ // ios_backgroundColor paints an opaque layer behind the track that the track
102
+ // color cannot cover, which on iOS reads as a halo around the switch. The
103
+ // switch is left on its platform default instead, so the prop must stay
104
+ // unset even if a style happens to carry a color for it.
105
+ it("does not set an iOS background color on the switch", () => {
106
+ const { UNSAFE_getByType } = renderToggle("", "default");
107
+
108
+ expect(UNSAFE_getByType(Switch).props.ios_backgroundColor).toBeUndefined();
109
+ });
110
+ });
111
+
112
+ describe("Toggle with an action plugin identifier", () => {
113
+ beforeEach(() => {
114
+ jest.clearAllMocks();
115
+ });
116
+
117
+ it("routes a change through the action plugin", () => {
118
+ const { getByRole } = renderToggle("firebase-push-topic-action", "default");
119
+
120
+ fireEvent(getByRole("switch"), "valueChange", true);
121
+
122
+ expect(mockInvokeAction).toHaveBeenCalledWith(
123
+ item,
124
+ expect.objectContaining({ updateState: expect.any(Function) })
125
+ );
126
+
127
+ expect(mockOnCellClick).not.toHaveBeenCalled();
128
+ });
129
+ });
130
+
131
+ describe("Toggle with an identifier whose action plugin is not installed", () => {
132
+ // The cell manifest no longer defaults toggle_action_identifier, but app
133
+ // configurations saved while it did still carry "firebase-push-topic-action",
134
+ // and a mistyped id is always possible. A toggle can therefore still arrive
135
+ // with a non-empty identifier it never asked for - the presence of a real
136
+ // action context, not the identifier string, is what decides the route.
137
+ beforeEach(() => {
138
+ jest.clearAllMocks();
139
+
140
+ (useActions as jest.Mock).mockReturnValue(undefined);
141
+ });
142
+
143
+ afterEach(() => {
144
+ (useActions as jest.Mock).mockReturnValue({
145
+ invokeAction: mockInvokeAction,
146
+ initialEntryState: mockInitialEntryState,
147
+ });
148
+ });
149
+
150
+ it("routes a change through the cell click path", () => {
151
+ const { getByRole } = renderToggle("firebase-push-topic-action", "default");
152
+
153
+ fireEvent(getByRole("switch"), "valueChange", true);
154
+
155
+ expect(mockOnCellClick).toHaveBeenCalledTimes(1);
156
+ expect(mockInvokeAction).not.toHaveBeenCalled();
157
+ });
158
+
159
+ it("still reflects the cell selection state", () => {
160
+ const { getByRole } = renderToggle(
161
+ "firebase-push-topic-action",
162
+ "selected"
163
+ );
164
+
165
+ expect(getByRole("switch").props.value).toBe(true);
166
+ });
167
+ });
@@ -1,221 +1,92 @@
1
- import * as React from "react";
2
- import { render, waitFor } from "@testing-library/react-native";
3
- import { StyleSheet } from "react-native";
1
+ import React from "react";
2
+ import RN from "react-native";
3
+ import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
4
4
 
5
- import Text from "../Text";
6
- import { MeasurementPortalContext } from "../../../MeasurmentsPortal";
7
- import { CellFocusedStateContext } from "@applicaster/zapp-react-native-ui-components/Contexts/CellFocusedStateContext";
8
-
9
- const mockAddHeading = jest.fn();
10
-
11
- jest.mock(
12
- "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks",
13
- () => ({
14
- useAccessibilityManager: jest.fn(() => ({
15
- addHeading: mockAddHeading,
16
- })),
17
- })
18
- );
5
+ const mockUseIsRTL = jest.fn(() => true);
6
+ const mockGetIsRTL = jest.fn(() => true);
7
+ const mockUseLocalizedStrings = jest.fn(() => ({}));
8
+ const mockGetUILanguage = jest.fn(() => "he-HE");
19
9
 
20
10
  jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
21
- useIsRTL: jest.fn(() => false),
22
- }));
23
-
24
- jest.mock("@applicaster/uikit/lib/components/uikit/text", () => ({
25
- Text: ({
26
- style,
27
- focusedStyle,
28
- normalStyles,
29
- focusedState,
30
- children,
31
- ...props
32
- }) => {
33
- const React = require("react");
34
- const { Text } = require("react-native");
35
-
36
- const resolvedStyle = focusedState
37
- ? [focusedState === "focused" ? focusedStyle : normalStyles, style]
38
- : style;
39
-
40
- return (
41
- <Text {...props} allowFontScaling={false} style={resolvedStyle}>
42
- {children}
43
- </Text>
44
- );
45
- },
11
+ useIsRTL: mockUseIsRTL,
12
+ getIsRTL: mockGetIsRTL,
13
+ useLocalizedStrings: mockUseLocalizedStrings,
14
+ getUILanguage: mockGetUILanguage,
46
15
  }));
47
16
 
48
- const renderText = ({
49
- props = {},
50
- measurementValue = null,
51
- cellFocused = false,
52
- }: {
53
- props?: Partial<React.ComponentProps<typeof Text>>;
54
- measurementValue?: React.ContextType<typeof MeasurementPortalContext>;
55
- cellFocused?: boolean;
56
- } = {}) => {
57
- const defaultProps = {
58
- label: "Hero title",
59
- style: {
60
- color: "navy",
61
- fontSize: 18,
62
- lineHeight: 24,
63
- },
64
- };
17
+ const CustomText = require("../Text").default;
65
18
 
66
- return render(
67
- <MeasurementPortalContext.Provider value={measurementValue}>
68
- <CellFocusedStateContext.Provider value={cellFocused}>
69
- <Text {...defaultProps} {...props} />
70
- </CellFocusedStateContext.Provider>
71
- </MeasurementPortalContext.Provider>
72
- );
19
+ const defaultProps = {
20
+ entry: {},
21
+ style: {},
22
+ transformText: "default",
73
23
  };
74
24
 
75
- describe("MasterCell Text", () => {
76
- beforeEach(() => {
77
- jest.clearAllMocks();
78
- });
25
+ const getRenderedText = (label: string, storeConfig: any) => {
26
+ const props = { ...{ ...defaultProps, label } };
79
27
 
80
- it("renders the resolved text content with the explicit UI props preserved", () => {
81
- const { getByText } = renderText({
82
- props: {
83
- transformText: "uppercase",
84
- numberOfLines: 2,
85
- ellipsizeMode: "tail",
86
- testID: "mastercell-text",
87
- accessibilityLabel: "MasterCell title",
88
- accessibilityHint: "Opens details",
89
- nativeID: "text-native-id",
90
- selectable: true,
91
- },
92
- });
93
-
94
- const text = getByText("HERO TITLE");
95
-
96
- expect(text.props.numberOfLines).toBe(2);
97
- expect(text.props.ellipsizeMode).toBe("tail");
98
- expect(text.props.testID).toBe("mastercell-text");
99
- expect(text.props.accessibilityLabel).toBe("MasterCell title");
100
- expect(text.props.accessibilityHint).toBe("Opens details");
101
- expect(text.props.nativeID).toBe("text-native-id");
102
- expect(text.props.selectable).toBe(true);
103
- expect(text.props.allowFontScaling).toBe(false);
104
- });
28
+ const { UNSAFE_getByType } = renderWithProviders(
29
+ <CustomText {...props} />,
30
+ storeConfig
31
+ );
105
32
 
106
- it("applies the focused visual styles to the rendered text node", () => {
107
- const { getByText } = renderText({
108
- props: {
109
- state: "focused",
110
- focusedStyles: {
111
- color: "gold",
112
- fontWeight: "700",
113
- },
114
- },
115
- });
116
-
117
- const text = getByText("Hero title");
118
- const flattenedStyle = StyleSheet.flatten(text.props.style);
119
-
120
- expect(flattenedStyle).toEqual(
121
- expect.objectContaining({
122
- color: "gold",
123
- fontWeight: "700",
124
- fontSize: 18,
125
- })
126
- );
127
- });
33
+ return UNSAFE_getByType(RN.Text).props.children;
34
+ };
128
35
 
129
- it("applies the normal visual styles when the text is not focused", () => {
130
- const { getByText } = renderText({
131
- props: {
132
- state: "default",
133
- normalStyles: {
134
- color: "gray",
135
- opacity: 0.7,
136
- },
137
- },
138
- });
139
-
140
- const text = getByText("Hero title");
141
- const flattenedStyle = StyleSheet.flatten(text.props.style);
142
-
143
- expect(flattenedStyle).toEqual(
144
- expect.objectContaining({
145
- color: "gray",
146
- opacity: 0.7,
147
- fontSize: 18,
148
- })
149
- );
150
- });
36
+ describe("RTL app: Hebrew text contains english word", () => {
37
+ const textWithFirstEnglishWord = "Word השיר של נועה נועה קירל באירוויזיון";
38
+ const textWithNotFirstEnglishWord = "השיר של נועה נועה קירל באירוויזיון Word";
39
+ const textWithoutEnglishWord = "השיר של נועה נועה קירל באירוויזיון";
151
40
 
152
- it("adds a capped height during measurement when lineHeight and numberOfLines are available", () => {
153
- const { getByText } = renderText({
154
- measurementValue: { measuringInProgress: true } as any,
155
- props: {
156
- numberOfLines: 3,
157
- },
158
- });
41
+ const storeConfig = {
42
+ remoteConfigurations: { localizations: { he: {} } },
43
+ appData: {
44
+ languageCode: "he",
45
+ countryCode: "IL",
46
+ },
47
+ };
159
48
 
160
- const text = getByText("Hero title");
161
- const flattenedStyle = StyleSheet.flatten(text.props.style);
49
+ it("Hebrew text contains first english word", () => {
50
+ const renderedText = getRenderedText(textWithFirstEnglishWord, storeConfig);
51
+ const desiredText = "\u200fWord\u202c השיר של נועה נועה קירל באירוויזיון";
162
52
 
163
- expect(flattenedStyle.height).toBe(72);
53
+ expect(renderedText).toEqual(desiredText);
164
54
  });
165
55
 
166
- it("returns null when the resolved label is empty", () => {
167
- const wrapper = renderText({
168
- props: {
169
- label: "",
170
- },
171
- });
56
+ it("Hebrew text contains not first english word", () => {
57
+ const renderedText = getRenderedText(
58
+ textWithNotFirstEnglishWord,
59
+ storeConfig
60
+ );
172
61
 
173
- expect(wrapper.toJSON()).toBeNull();
62
+ expect(renderedText).toEqual(textWithNotFirstEnglishWord);
174
63
  });
175
64
 
176
- it("announces the heading for a focused text label", async () => {
177
- renderText({
178
- cellFocused: true,
179
- props: {
180
- state: "focused",
181
- },
182
- });
183
-
184
- await waitFor(() => {
185
- expect(mockAddHeading).toHaveBeenCalledWith("Hero title");
186
- });
65
+ it("Hebrew text doesn't contain english word", () => {
66
+ const renderedText = getRenderedText(textWithoutEnglishWord, storeConfig);
67
+ expect(renderedText).toEqual(textWithoutEnglishWord);
187
68
  });
69
+ });
188
70
 
189
- it("announces the selected heading for a focused selected text label", async () => {
190
- renderText({
191
- cellFocused: true,
192
- props: {
193
- state: "focused_selected",
194
- },
195
- });
196
-
197
- await waitFor(() => {
198
- expect(mockAddHeading).toHaveBeenCalledWith("Hero title, Selected");
199
- });
71
+ describe("LTR app: English text", () => {
72
+ beforeAll(() => {
73
+ mockUseIsRTL.mockReturnValue(false);
74
+ mockGetIsRTL.mockReturnValue(false);
75
+ mockGetUILanguage.mockReturnValue("en-US");
200
76
  });
201
77
 
202
- it("does not leak internal control props onto the rendered text node", () => {
203
- const { getByText } = renderText({
204
- props: {
205
- state: "focused",
206
- focusedStyles: {
207
- color: "gold",
208
- },
209
- normalStyles: {
210
- color: "gray",
211
- },
212
- },
213
- });
214
-
215
- const text = getByText("Hero title");
216
-
217
- expect(text.props.state).toBeUndefined();
218
- expect(text.props.focusedStyles).toBeUndefined();
219
- expect(text.props.normalStyles).toBeUndefined();
78
+ const englishText = "Test sentence";
79
+
80
+ const storeConfig = {
81
+ remoteConfigurations: { localizations: { en: {} } },
82
+ appData: {
83
+ languageCode: "en",
84
+ countryCode: "US",
85
+ },
86
+ };
87
+
88
+ it("English text", () => {
89
+ const renderedText = getRenderedText(englishText, storeConfig);
90
+ expect(renderedText).toEqual(englishText);
220
91
  });
221
92
  });
@@ -20,11 +20,7 @@ import { ImageBorderContainer } from "./ImageBorderContainer";
20
20
  import { PressableView } from "./PressableView";
21
21
  import { ActionButton as MobileActionButton } from "./mobile/MobileActionButtons/ActionButton";
22
22
 
23
- // UIKIT adapters
24
- import { UIKitBadge } from "./UIKitAdapters/Badge";
25
-
26
23
  export const defaultComponents = {
27
- UIKitBadge,
28
24
  View,
29
25
  CollapsibleTextContainer,
30
26
  Text,
@@ -231,9 +231,11 @@ describe("MobileActionButton", () => {
231
231
  getByTestId("mobile-action-button").props.style[2].backgroundColor
232
232
  ).toBe("rgba(3,3,3,1)");
233
233
 
234
- expect(getByText("Play").props.style).toMatchObject({
235
- color: "rgba(20,20,20,1)",
236
- });
234
+ expect(getByText("Play").props.style).toEqual(
235
+ expect.arrayContaining([
236
+ expect.objectContaining({ color: "rgba(20,20,20,1)" }),
237
+ ])
238
+ );
237
239
  });
238
240
 
239
241
  it("invokes action on press", () => {
@@ -291,7 +293,7 @@ describe("MobileActionButton", () => {
291
293
  height: 24,
292
294
  });
293
295
 
294
- expect(label.props.style).toMatchObject({
296
+ expect(label.props.style[0]).toMatchObject({
295
297
  color: "rgba(10,10,10,1)",
296
298
  fontSize: 15,
297
299
  lineHeight: 24,
@@ -0,0 +1,32 @@
1
+ import { CollapsibleTextContainer } from "../index";
2
+
3
+ const getValue = (key: string) => {
4
+ const values: Record<string, unknown> = {
5
+ text_alignment: "left",
6
+ margin_top: 0,
7
+ margin_right: 0,
8
+ margin_bottom: 0,
9
+ margin_left: 0,
10
+ padding_top: 0,
11
+ padding_right: 0,
12
+ padding_bottom: 0,
13
+ padding_left: 0,
14
+ corner_radius: 0,
15
+ data_key: "title",
16
+ custom_data_key: undefined,
17
+ };
18
+
19
+ return values[key];
20
+ };
21
+
22
+ describe("CollapsibleTextContainer view tree", () => {
23
+ it("stretches to the parent width so labels wrap using the cell width", () => {
24
+ const result = CollapsibleTextContainer({
25
+ getValue,
26
+ elements: [],
27
+ additionalStyles: { backgroundColor: "transparent" },
28
+ });
29
+
30
+ expect(result.style.alignSelf).toBe("stretch");
31
+ });
32
+ });
@@ -3,7 +3,6 @@ import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/he
3
3
  import {
4
4
  getColorFromData,
5
5
  getKeyForLabel,
6
- mapSelfAlignment,
7
6
  } from "@applicaster/zapp-react-native-utils/cellUtils";
8
7
  import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
9
8
 
@@ -23,7 +22,7 @@ export const CollapsibleTextContainer = ({
23
22
  return {
24
23
  type: "CollapsibleTextContainer", // Collapsible Text Container,
25
24
  style: {
26
- alignSelf: mapSelfAlignment(getValue("text_alignment")),
25
+ alignSelf: "stretch",
27
26
  marginTop: toNumberWithDefaultZero(getValue("margin_top")),
28
27
  marginRight: toNumberWithDefaultZero(getValue("margin_right")),
29
28
  marginBottom: toNumberWithDefaultZero(getValue("margin_bottom")),
@@ -24,7 +24,6 @@ const focusableTypes = new Set([
24
24
  "PressableView",
25
25
  "CollapsibleTextContainer",
26
26
  "BorderContainerView",
27
- "UIKitBadge",
28
27
  ]);
29
28
 
30
29
  const childrenRenderingTypes = new Set([
@@ -36,7 +35,6 @@ const childrenRenderingTypes = new Set([
36
35
  "DataProvider",
37
36
  "TvActionButton",
38
37
  "MobileActionButton",
39
- "UIKitBadge",
40
38
  ]);
41
39
 
42
40
  const cellPlayerTypes = new Set([