@applicaster/zapp-react-native-ui-components 16.0.0-alpha.1740103407 → 16.0.0-alpha.1745039402

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 (35) hide show
  1. package/Components/CellRendererResolver/index.ts +1 -1
  2. package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +39 -0
  3. package/Components/GeneralContentScreen/__tests__/GeneralContentScreenHookAdapter.test.tsx +64 -0
  4. package/Components/GeneralContentScreen/__tests__/HookContentFocusGroup.web.test.tsx +91 -0
  5. package/Components/GeneralContentScreen/hookAdapter/__tests__/networkService.test.ts +74 -0
  6. package/Components/GeneralContentScreen/hookAdapter/__tests__/runInBackground.test.ts +139 -0
  7. package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +124 -0
  8. package/Components/GeneralContentScreen/hookAdapter/logger.ts +6 -0
  9. package/Components/GeneralContentScreen/hookAdapter/networkService.ts +53 -0
  10. package/Components/GeneralContentScreen/hookAdapter/runInBackground.ts +48 -0
  11. package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +72 -0
  12. package/Components/GeneralContentScreen/hookFocus/index.tsx +13 -0
  13. package/Components/GeneralContentScreen/hookFocus/index.web.tsx +69 -0
  14. package/Components/GeneralContentScreen/index.ts +2 -0
  15. package/Components/MasterCell/dataAdapter.ts +15 -5
  16. package/Components/MasterCell/index.tsx +30 -5
  17. package/Components/MasterCell/utils/__tests__/resolveColor.test.js +169 -132
  18. package/Components/MasterCell/utils/__tests__/resolveColorForProp.test.js +92 -0
  19. package/Components/MasterCell/utils/index.ts +85 -46
  20. package/Components/PlayerContainer/PlayerContainer.tsx +7 -3
  21. package/Components/River/ComponentsMap/ComponentsMap.tsx +105 -188
  22. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +10 -1
  23. package/Components/Screen/index.tsx +8 -4
  24. package/Components/ZappFrameworkComponents/BarView/BarView.tsx +12 -5
  25. package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
  26. package/Contexts/CachedDimensionsContext/__tests__/index.test.ts +154 -0
  27. package/Contexts/CachedDimensionsContext/index.ts +17 -2
  28. package/Helpers/ComponentCellSelectionHelper/index.js +0 -6
  29. package/Helpers/index.js +0 -39
  30. package/package.json +5 -5
  31. package/Components/Screen/utils.ts +0 -16
  32. package/Helpers/Analytics/index.js +0 -95
  33. /package/Components/BackgroundImage/{BackgroundImage.tv.android.tsx → BackgroundImage.android.tv.tsx} +0 -0
  34. /package/Components/BackgroundImage/{BackgroundImage.tv.ios.tsx → BackgroundImage.ios.tv.tsx} +0 -0
  35. /package/Components/MasterCell/DefaultComponents/ButtonContainerView/{index.tv.android.tsx → index.android.tv.tsx} +0 -0
@@ -0,0 +1,72 @@
1
+ import { getNamespaceAndKey } from "@applicaster/zapp-react-native-utils/appUtils/contextKeysManager/utils";
2
+ import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
3
+ import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
4
+ import { log_error, log_info } from "./logger";
5
+
6
+ type ParseKey = { key: string; namespace?: string };
7
+
8
+ export function parseKeyEntries(input: string): ParseKey[] {
9
+ return input.split(",").flatMap((item) => {
10
+ const trimmed = item.trim();
11
+
12
+ return trimmed ? getNamespaceAndKey(trimmed) : [];
13
+ });
14
+ }
15
+
16
+ export const getKeyToSkipHook = async (key: string, namespace?: string) => {
17
+ const value = await sessionStorage.getItem(key, namespace);
18
+
19
+ if (value) {
20
+ return value;
21
+ }
22
+
23
+ return await localStorage.getItem(key, namespace);
24
+ };
25
+
26
+ export const shouldSkipHook = async (
27
+ skipHookIfKeysExist?: string
28
+ ): Promise<boolean> => {
29
+ if (!skipHookIfKeysExist?.trim()) {
30
+ log_info("shouldSkipHook: No skipping condition provided");
31
+
32
+ return false;
33
+ }
34
+
35
+ const keyEntries = parseKeyEntries(skipHookIfKeysExist);
36
+
37
+ if (keyEntries.length === 0) {
38
+ log_info("shouldSkipHook: No valid keys provided");
39
+
40
+ return false;
41
+ }
42
+
43
+ for (const entry of keyEntries) {
44
+ try {
45
+ const value = await getKeyToSkipHook(entry.key, entry.namespace);
46
+
47
+ if (value) {
48
+ log_info(
49
+ `shouldSkipHook: Hook will be skipped due to: ${
50
+ entry.namespace ?? ""
51
+ } ${entry.key}. Finishing hook flow`
52
+ );
53
+
54
+ return true;
55
+ }
56
+ } catch (error) {
57
+ log_error(
58
+ `shouldSkipHook: Error: ${error.message} checking key: ${
59
+ entry.namespace ?? ""
60
+ } ${entry.key}`,
61
+ { error }
62
+ );
63
+ }
64
+ }
65
+
66
+ log_info(
67
+ // eslint-disable-next-line max-len
68
+ "shouldSkipHook: No skipping condition met, none of the provided keys found in storage, proceeding with hook"
69
+ );
70
+
71
+ return false;
72
+ };
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+
3
+ type Props = {
4
+ children: React.ReactElement;
5
+ };
6
+
7
+ /**
8
+ * On native platforms the river `ComponentsMap` registers its own initial focus,
9
+ * so a hook-presented general content screen needs no extra focus wrapper here.
10
+ * The web counterpart (`index.web.tsx`) recreates the content focus group that
11
+ * the `River` wrapper would normally provide.
12
+ */
13
+ export const HookContentFocusGroup = ({ children }: Props) => <>{children}</>;
@@ -0,0 +1,69 @@
1
+ import * as React from "react";
2
+ import { StyleSheet } from "react-native";
3
+ import { shallow } from "zustand/shallow";
4
+
5
+ import { FocusableGroup } from "../../FocusableGroup";
6
+ import {
7
+ useContentId,
8
+ useNavbarId,
9
+ usePathname,
10
+ } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
11
+ import { useZappHookModalStore } from "../../../Contexts/ZappHookModalContext";
12
+
13
+ import { useInitialFocus } from "../../Screen/TV/hooks";
14
+
15
+ const styles = StyleSheet.create({
16
+ container: { flex: 1 },
17
+ });
18
+
19
+ type Props = {
20
+ children: React.ReactElement;
21
+ };
22
+
23
+ /**
24
+ * A general content screen presented as a full-screen hook is rendered straight
25
+ * through `ComponentsMap`, bypassing the web `River` wrapper. That wrapper is what
26
+ * normally creates the `quick-brick-content` FocusableGroup (with `preferredFocus`)
27
+ * the focus manager relies on and what lets initial focus land on the content.
28
+ *
29
+ * Without it the hook screen renders but nothing is focusable on web TV. This
30
+ * recreates that content group and triggers initial focus, mirroring `River`.
31
+ */
32
+ const FocusedHookContent = ({ children }: Props) => {
33
+ const contentId = useContentId();
34
+ const navbarId = useNavbarId();
35
+ const pathname = usePathname();
36
+
37
+ useInitialFocus();
38
+
39
+ return (
40
+ <FocusableGroup
41
+ id={contentId}
42
+ // Nest under the hook-modal route so the focus manager treats this as the
43
+ // active screen's content node; `useInitialFocus` targets the same route.
44
+ groupId={pathname}
45
+ nextFocusUp={navbarId}
46
+ preferredFocus
47
+ shouldUsePreferredFocus
48
+ style={styles.container}
49
+ >
50
+ {React.cloneElement(children, { groupId: contentId })}
51
+ </FocusableGroup>
52
+ );
53
+ };
54
+
55
+ export const HookContentFocusGroup = ({ children }: Props) => {
56
+ const isRunningInBackground = useZappHookModalStore(
57
+ (state) => state.isRunningInBackground,
58
+ shallow
59
+ );
60
+
61
+ // A hook presented full screen (either as a `/hooks/<id>` screen or a
62
+ // full-screen modal) needs the content focus group. Only background runs,
63
+ // which render invisibly, must be left alone so they don't steal focus.
64
+ if (isRunningInBackground) {
65
+ return <>{children}</>;
66
+ }
67
+
68
+ return <FocusedHookContent>{children}</FocusedHookContent>;
69
+ };
@@ -1 +1,3 @@
1
1
  export { GeneralContentScreen } from "./GeneralContentScreen";
2
+
3
+ export { GeneralContentScreenHookAdapter } from "./GeneralContentScreenHookAdapter";
@@ -1,5 +1,6 @@
1
1
  import * as R from "ramda";
2
2
  import { isFunction } from "@applicaster/zapp-react-native-utils/functionUtils";
3
+ import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
3
4
 
4
5
  import { functionForName } from "./MappingFunctions";
5
6
  import { resolveColor } from "./utils";
@@ -52,7 +53,8 @@ export function configInflater(
52
53
  additionalProps?: Record<string, any>;
53
54
  data?: Array<{ propName: string; func: Function; args: any[] }>;
54
55
  elements?: any[];
55
- }
56
+ },
57
+ allowDynamicColorsOutsideExtensions: boolean
56
58
  ) {
57
59
  const props = data.reduce(
58
60
  (acc, curr) => {
@@ -68,13 +70,13 @@ export function configInflater(
68
70
 
69
71
  if (Array.isArray(elements)) {
70
72
  adjustedElements = elements.map((element) =>
71
- configInflater(entry, element as any)
73
+ configInflater(entry, element as any, allowDynamicColorsOutsideExtensions)
72
74
  );
73
75
  }
74
76
 
75
77
  return {
76
78
  type,
77
- style: resolveColor(entry, style),
79
+ style: resolveColor(entry, style, allowDynamicColorsOutsideExtensions),
78
80
  props,
79
81
  elements: adjustedElements,
80
82
  };
@@ -98,9 +100,17 @@ function resolveElementsNode(entry, state, elements) {
98
100
  }
99
101
 
100
102
  export function defaultDataAdapter(elements) {
101
- return function elementsBuilder({ entry, state = "default" }) {
103
+ return function elementsBuilder({
104
+ entry,
105
+ state = "default",
106
+ allowDynamicColorsOutsideExtensions,
107
+ }) {
102
108
  return resolveElementsNode(entry, state, elements).map((element) =>
103
- configInflater(entry, element)
109
+ configInflater(
110
+ entry,
111
+ element,
112
+ toBooleanWithDefaultFalse(allowDynamicColorsOutsideExtensions)
113
+ )
104
114
  );
105
115
  };
106
116
  }
@@ -2,7 +2,10 @@ import * as R from "ramda";
2
2
  import * as React from "react";
3
3
  import { v4 as uuid } from "uuid";
4
4
 
5
+ import { isHorizontalList } from "@applicaster/zapp-react-native-utils/componentsUtils";
6
+ import { isVideoPreviewEnabled } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/utils";
5
7
  import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
8
+ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
6
9
  import { useScreenState } from "@applicaster/zapp-react-native-utils/screenState";
7
10
  import { defaultComponents } from "./DefaultComponents";
8
11
  import { defaultDataAdapter } from "./dataAdapter";
@@ -34,8 +37,8 @@ type MasterCellBuilderOptions = {
34
37
  containerStyle: any;
35
38
  cellOptions?: {
36
39
  isRTL?: boolean;
37
- generateId?: () => string;
38
40
  skipButtons?: boolean;
41
+ component?: ZappComponent;
39
42
  };
40
43
  };
41
44
 
@@ -46,7 +49,7 @@ export function masterCellBuilder({
46
49
  containerStyle = defaultContainerStyle,
47
50
  cellOptions = {},
48
51
  }: MasterCellBuilderOptions) {
49
- const { generateId = uuid, skipButtons = false } = cellOptions;
52
+ const { skipButtons = false, component } = cellOptions;
50
53
 
51
54
  const componentsMap = R.merge(defaultComponents, components);
52
55
  const { View } = componentsMap;
@@ -65,6 +68,7 @@ export function masterCellBuilder({
65
68
  */
66
69
  function MasterCell({ item, state, ...otherProps }: Props) {
67
70
  const { screenData } = useRoute();
71
+ const theme = useTheme();
68
72
 
69
73
  const screenId =
70
74
  screenData && "targetScreen" in screenData
@@ -85,14 +89,35 @@ export function masterCellBuilder({
85
89
  elementsBuilder({
86
90
  entry: item,
87
91
  state: getEntryState(state, entryIsSelected),
92
+ allowDynamicColorsOutsideExtensions:
93
+ theme?.allow_dynamic_colors_outside_extensions,
88
94
  }),
89
- [state, item, entryIsSelected] // Assuming that item won't mutate
95
+ [
96
+ state,
97
+ item,
98
+ entryIsSelected,
99
+ theme?.allow_dynamic_colors_outside_extensions,
100
+ ] // Assuming that item won't mutate
90
101
  );
91
102
 
92
103
  const wrapperRef = React.useRef(null);
93
104
 
94
- const cellUUID = React.useMemo<string>(generateId, [
95
- generateId,
105
+ const cellUUID = React.useMemo<string>(() => {
106
+ const isLiveImage = isVideoPreviewEnabled({
107
+ enable_video_preview: component?.rules?.enable_video_preview,
108
+ player_screen_id: component?.rules?.player_screen_id,
109
+ });
110
+
111
+ const isHL = isHorizontalList(component);
112
+
113
+ return isHL && isLiveImage
114
+ ? `${component?.id}-${component?.styles?.cell_plugin_configuration_id}`
115
+ : uuid();
116
+ }, [
117
+ component?.id,
118
+ component?.styles?.cell_plugin_configuration_id,
119
+ component?.rules?.enable_video_preview,
120
+ component?.rules?.player_screen_id,
96
121
  screenId,
97
122
  item?.id,
98
123
  ]);
@@ -1,194 +1,231 @@
1
1
  import { resolveColor } from "..";
2
- import { masterCellLogger } from "../../logger";
3
-
4
- const loggerSpy = jest
5
- .spyOn(masterCellLogger, "warn")
6
- .mockImplementation(() => {});
7
2
 
8
3
  describe("resolveColor", () => {
9
4
  const entry = {
10
5
  extensions: {
11
6
  color: "red",
12
7
  green_color: "green",
8
+ float_alpha_color: "rgba(239,239,239,1.0)",
9
+ invalid_color: "not_a_color",
13
10
  },
11
+ background_color: "#123456",
14
12
  };
15
13
 
16
- beforeEach(() => {
17
- loggerSpy.mockClear();
18
- });
19
-
20
- it("resolve color with path", () => {
21
- const style = {
22
- color: "extensions.color",
23
- };
14
+ describe("default behavior (resolves extensions paths via pathOr, passes through literals)", () => {
15
+ it("resolves color from extensions data mapping path", () => {
16
+ const style = {
17
+ color: "extensions.color",
18
+ };
24
19
 
25
- expect(resolveColor(entry, style)).toEqual({
26
- color: entry.extensions.color,
20
+ expect(resolveColor(entry, style)).toEqual({
21
+ color: entry.extensions.color,
22
+ });
27
23
  });
28
- });
29
24
 
30
- it("logs a warning when path is undefined", () => {
31
- const style = {
32
- color: "invalid_path",
33
- };
25
+ it("passes through non-extensions values as raw color strings", () => {
26
+ const style = {
27
+ color: "invalid_path",
28
+ };
34
29
 
35
- expect(resolveColor(entry, style)).toEqual({
36
- color: undefined,
30
+ expect(resolveColor(entry, style)).toEqual({
31
+ color: "invalid_path",
32
+ });
37
33
  });
38
34
 
39
- expect(loggerSpy).toHaveBeenCalledWith(
40
- expect.objectContaining({
41
- message: "Cannot resolve property invalid_path from the entry.",
42
- data: {
43
- colorFromProp: "invalid_path",
44
- configurationValue: "invalid_path",
45
- },
46
- })
47
- );
48
- });
49
-
50
- it("resolves any style prop with containing color", () => {
51
- const style = {
52
- backgroundColor: "extensions.color",
53
- width: "100%",
54
- borderColor: "extensions.green_color",
55
- };
35
+ it("passes through entry path keys outside extensions prefix as raw color strings", () => {
36
+ const style = {
37
+ color: "background_color",
38
+ };
56
39
 
57
- expect(resolveColor(entry, style)).toEqual({
58
- backgroundColor: "red",
59
- borderColor: "green",
60
- width: "100%",
40
+ expect(resolveColor(entry, style)).toEqual({
41
+ color: "background_color",
42
+ });
61
43
  });
62
- });
63
44
 
64
- it("not replace color with in hex format", () => {
65
- const style = {
66
- color: "#000000",
67
- };
45
+ it("resolves all color-related style props from extensions paths", () => {
46
+ const style = {
47
+ backgroundColor: "extensions.color",
48
+ width: "100%",
49
+ borderColor: "extensions.green_color",
50
+ };
68
51
 
69
- expect(resolveColor(entry, style)).toEqual(style);
70
- });
52
+ expect(resolveColor(entry, style)).toEqual({
53
+ backgroundColor: "red",
54
+ borderColor: "green",
55
+ width: "100%",
56
+ });
57
+ });
71
58
 
72
- it("not replace color with in rgda format", () => {
73
- const style = {
74
- color: "rgba(0,0,0,0)",
75
- };
59
+ it("passes through literal hex color values unchanged", () => {
60
+ const style = {
61
+ color: "#000000",
62
+ };
76
63
 
77
- expect(resolveColor(entry, style)).toEqual(style);
78
- });
64
+ expect(resolveColor(entry, style)).toEqual(style);
65
+ });
79
66
 
80
- it("doesn't replace transparent as a color", () => {
81
- const style = {
82
- color: "transparent",
83
- };
67
+ it("passes through literal rgba color values unchanged", () => {
68
+ const style = {
69
+ color: "rgba(0,0,0,0)",
70
+ };
84
71
 
85
- expect(resolveColor(entry, style)).toEqual(style);
86
- });
72
+ expect(resolveColor(entry, style)).toEqual(style);
73
+ });
87
74
 
88
- it("return nil if style is nil", () => {
89
- const style = undefined;
75
+ it("passes through literal rgba values with float alpha unchanged", () => {
76
+ const style = {
77
+ color: "rgba(239,239,239,1.0)",
78
+ };
90
79
 
91
- expect(resolveColor(entry, style)).toBeUndefined();
92
- });
80
+ expect(resolveColor(entry, style)).toEqual(style);
81
+ });
82
+
83
+ it("passes through transparent as a literal color value", () => {
84
+ const style = {
85
+ color: "transparent",
86
+ };
93
87
 
94
- it("not modify style without color prop", () => {
95
- const style = {
96
- test: 1,
97
- };
88
+ expect(resolveColor(entry, style)).toEqual(style);
89
+ });
98
90
 
99
- expect(resolveColor(entry, style)).toEqual(style);
100
- });
91
+ it("passes through named color values as literal colors", () => {
92
+ const style = {
93
+ color: "black",
94
+ };
101
95
 
102
- it("not modify style with not existing path", () => {
103
- const style = {
104
- color: "not.exist.path",
105
- };
96
+ expect(resolveColor(entry, style)).toEqual(style);
97
+ });
106
98
 
107
- expect(resolveColor(entry, style)).toEqual({
108
- color: undefined,
99
+ it("returns style unchanged when style is undefined", () => {
100
+ expect(resolveColor(entry, undefined)).toBeUndefined();
109
101
  });
110
- });
111
102
 
112
- it("not modify style with empty path", () => {
113
- const style = {
114
- color: "",
115
- };
103
+ it("returns style unchanged when style is null", () => {
104
+ expect(resolveColor(entry, null)).toBeNull();
105
+ });
116
106
 
117
- expect(resolveColor(entry, style)).toEqual(style);
118
- });
107
+ it("returns style unchanged when it has no color-related props", () => {
108
+ const style = {
109
+ test: 1,
110
+ };
119
111
 
120
- describe("memoization", () => {
121
- beforeEach(() => {
122
- // Clear memoization cache before each test
123
- resolveColor.clear && resolveColor.clear();
112
+ expect(resolveColor(entry, style)).toEqual(style);
124
113
  });
125
114
 
126
- it("hits cache with same entry and style references", () => {
127
- const style = { color: "extensions.color" };
115
+ it("returns null when extensions path is missing from entry", () => {
116
+ const style = {
117
+ color: "extensions.missing.path",
118
+ };
128
119
 
129
- const result1 = resolveColor(entry, style);
130
- const result2 = resolveColor(entry, style);
120
+ expect(resolveColor(entry, style)).toEqual({
121
+ color: null,
122
+ });
123
+ });
124
+
125
+ it("returns resolved extensions path value without validating color", () => {
126
+ const style = {
127
+ color: "extensions.invalid_color",
128
+ };
131
129
 
132
- expect(result1).toBe(result2); // Same object reference
130
+ expect(resolveColor(entry, style)).toEqual({
131
+ color: "not_a_color",
132
+ });
133
133
  });
134
134
 
135
- it("hits cache with new references but equal entry/style values", () => {
136
- const entryClone = {
137
- extensions: {
138
- color: "red",
139
- green_color: "green",
140
- },
135
+ it("passes through empty string color values unchanged", () => {
136
+ const style = {
137
+ color: "",
141
138
  };
142
139
 
143
- const style = { color: "extensions.color" };
144
- const styleClone = { color: "extensions.color" };
140
+ expect(resolveColor(entry, style)).toEqual({
141
+ color: "",
142
+ });
143
+ });
145
144
 
146
- const result1 = resolveColor(entry, style);
147
- const result2 = resolveColor(entryClone, styleClone);
145
+ it("resolves rgba color values with float alpha from extensions path", () => {
146
+ const style = {
147
+ color: "extensions.float_alpha_color",
148
+ };
148
149
 
149
- expect(result1).toBe(result2);
150
+ expect(resolveColor(entry, style)).toEqual({
151
+ color: "rgba(239,239,239,1.0)",
152
+ });
150
153
  });
154
+ });
151
155
 
152
- it("misses cache when entry is new object", () => {
153
- const entry2 = { extensions: { color: "blue" } }; // Same values, different object
154
- const style = { color: "extensions.color" };
156
+ describe("when allowDynamicColorsOutsideExtensions is enabled (resolves via resolveColorForProp with validation)", () => {
157
+ it("resolves entry paths outside the extensions prefix", () => {
158
+ const style = {
159
+ color: "background_color",
160
+ };
161
+
162
+ expect(resolveColor(entry, style, true)).toEqual({
163
+ color: "#123456",
164
+ });
165
+ });
155
166
 
156
- const result1 = resolveColor(entry, style);
157
- const result2 = resolveColor(entry2, style);
167
+ it("resolves extensions paths through resolveColorForProp", () => {
168
+ const style = {
169
+ color: "extensions.color",
170
+ };
158
171
 
159
- expect(result1).not.toBe(result2); // Different object references
172
+ expect(resolveColor(entry, style, true)).toEqual({
173
+ color: "red",
174
+ });
160
175
  });
161
176
 
162
- it("misses cache when entry property changes", () => {
163
- const myEntry = {
164
- extensions: {
165
- color: "red",
166
- green_color: "green",
167
- },
177
+ it("returns null for invalid entry paths that cannot be resolved", () => {
178
+ const style = {
179
+ color: "invalid_path",
168
180
  };
169
181
 
170
- const style = { color: "extensions.color" };
182
+ expect(resolveColor(entry, style, true)).toEqual({
183
+ color: null,
184
+ });
185
+ });
171
186
 
172
- const result1 = resolveColor(myEntry, style);
187
+ it("returns null when extensions path cannot be resolved to a valid color", () => {
188
+ const style = {
189
+ color: "extensions.missing.path",
190
+ };
173
191
 
174
- myEntry.extensions.color = "blue"; // Change property
175
- const result2 = resolveColor(myEntry, style);
192
+ expect(resolveColor(entry, style, true)).toEqual({
193
+ color: null,
194
+ });
195
+ });
176
196
 
177
- expect(result1).toEqual({ color: "red" });
178
- expect(result2).toEqual({ color: "blue" });
179
- expect(result1).not.toBe(result2);
197
+ it("passes through literal color values unchanged", () => {
198
+ const style = {
199
+ color: "#000000",
200
+ backgroundColor: "rgba(239,239,239,1.0)",
201
+ borderColor: "transparent",
202
+ };
203
+
204
+ expect(resolveColor(entry, style, true)).toEqual(style);
180
205
  });
181
206
 
182
- it("misses cache when style changes", () => {
183
- const style1 = { color: "extensions.color" };
184
- const style2 = { backgroundColor: "extensions.color" };
207
+ it("passes through empty string color values unchanged", () => {
208
+ const style = {
209
+ color: "",
210
+ };
211
+
212
+ expect(resolveColor(entry, style, true)).toEqual({
213
+ color: "",
214
+ });
215
+ });
185
216
 
186
- const result1 = resolveColor(entry, style1);
187
- const result2 = resolveColor(entry, style2);
217
+ it("resolves multiple color-related style props from entry paths", () => {
218
+ const style = {
219
+ backgroundColor: "background_color",
220
+ borderColor: "extensions.green_color",
221
+ width: "100%",
222
+ };
188
223
 
189
- expect(result1).toEqual({ color: "red" });
190
- expect(result2).toEqual({ backgroundColor: "red" });
191
- expect(result1).not.toBe(result2);
224
+ expect(resolveColor(entry, style, true)).toEqual({
225
+ backgroundColor: "#123456",
226
+ borderColor: "green",
227
+ width: "100%",
228
+ });
192
229
  });
193
230
  });
194
231
  });