@terreno/admin-frontend 0.13.3 → 0.14.1

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 (101) hide show
  1. package/dist/AdminFieldRenderer.d.ts +5 -53
  2. package/dist/AdminFieldRenderer.js +6 -168
  3. package/dist/AdminFieldRenderer.js.map +1 -1
  4. package/dist/AdminFieldRendererCore.d.ts +26 -0
  5. package/dist/AdminFieldRendererCore.js +138 -0
  6. package/dist/AdminFieldRendererCore.js.map +1 -0
  7. package/dist/AdminModelForm.d.ts +6 -7
  8. package/dist/AdminModelForm.js.map +1 -1
  9. package/dist/AdminModelList.d.ts +2 -3
  10. package/dist/AdminModelList.js.map +1 -1
  11. package/dist/AdminModelTable.d.ts +2 -2
  12. package/dist/AdminModelTable.js +2 -1
  13. package/dist/AdminModelTable.js.map +1 -1
  14. package/dist/AdminNestedArrayField.d.ts +6 -7
  15. package/dist/AdminNestedArrayField.js +26 -2
  16. package/dist/AdminNestedArrayField.js.map +1 -1
  17. package/dist/AdminObjectPicker.d.ts +2 -2
  18. package/dist/AdminObjectPicker.js +13 -7
  19. package/dist/AdminObjectPicker.js.map +1 -1
  20. package/dist/AdminPrimitiveArrayField.d.ts +2 -3
  21. package/dist/AdminPrimitiveArrayField.js.map +1 -1
  22. package/dist/AdminScriptList.d.ts +2 -2
  23. package/dist/AdminScriptList.js.map +1 -1
  24. package/dist/AdminScriptRunModal.d.ts +2 -2
  25. package/dist/AdminScriptRunModal.js.map +1 -1
  26. package/dist/AdminVersionConfig.d.ts +2 -2
  27. package/dist/AdminVersionConfig.js +16 -10
  28. package/dist/AdminVersionConfig.js.map +1 -1
  29. package/dist/ConfigurationScreen.d.ts +2 -2
  30. package/dist/ConfigurationScreen.js +18 -9
  31. package/dist/ConfigurationScreen.js.map +1 -1
  32. package/dist/ConsentFormEditor.d.ts +27 -2
  33. package/dist/ConsentFormEditor.js +48 -32
  34. package/dist/ConsentFormEditor.js.map +1 -1
  35. package/dist/ConsentFormList.d.ts +2 -1
  36. package/dist/ConsentFormList.js.map +1 -1
  37. package/dist/ConsentResponseViewer.d.ts +2 -1
  38. package/dist/ConsentResponseViewer.js.map +1 -1
  39. package/dist/DocumentStorageBrowser.js.map +1 -1
  40. package/dist/types.d.ts +29 -4
  41. package/dist/types.js.map +1 -1
  42. package/dist/useAdminApi.d.ts +2 -2
  43. package/dist/useAdminApi.js +8 -5
  44. package/dist/useAdminApi.js.map +1 -1
  45. package/dist/useAdminConfig.d.ts +2 -3
  46. package/dist/useAdminConfig.js +2 -0
  47. package/dist/useAdminConfig.js.map +1 -1
  48. package/dist/useAdminScripts.d.ts +2 -3
  49. package/dist/useAdminScripts.js +6 -3
  50. package/dist/useAdminScripts.js.map +1 -1
  51. package/dist/useConfigurationApi.d.ts +11 -8
  52. package/dist/useConfigurationApi.js +7 -4
  53. package/dist/useConfigurationApi.js.map +1 -1
  54. package/dist/useDocumentStorageApi.d.ts +2 -2
  55. package/dist/useDocumentStorageApi.js +9 -6
  56. package/dist/useDocumentStorageApi.js.map +1 -1
  57. package/package.json +2 -2
  58. package/src/AdminFieldRenderer.test.tsx +48 -22
  59. package/src/AdminFieldRenderer.tsx +18 -371
  60. package/src/AdminFieldRendererCore.tsx +356 -0
  61. package/src/AdminModelForm.test.tsx +146 -40
  62. package/src/AdminModelForm.tsx +22 -17
  63. package/src/AdminModelList.test.tsx +14 -5
  64. package/src/AdminModelList.tsx +5 -5
  65. package/src/AdminModelTable.test.tsx +58 -31
  66. package/src/AdminModelTable.tsx +11 -10
  67. package/src/AdminNestedArrayField.tsx +91 -26
  68. package/src/AdminObjectPicker.tsx +33 -16
  69. package/src/AdminPrimitiveArrayField.test.tsx +14 -10
  70. package/src/AdminPrimitiveArrayField.tsx +2 -3
  71. package/src/AdminScriptList.test.tsx +7 -4
  72. package/src/AdminScriptList.tsx +2 -3
  73. package/src/AdminScriptRunModal.test.tsx +5 -2
  74. package/src/AdminScriptRunModal.tsx +2 -3
  75. package/src/AdminVersionConfig.test.tsx +47 -21
  76. package/src/AdminVersionConfig.tsx +29 -5
  77. package/src/CheckboxListEditor.test.tsx +9 -6
  78. package/src/ConfigurationScreen.test.tsx +16 -11
  79. package/src/ConfigurationScreen.tsx +43 -29
  80. package/src/ConsentFormEditor.test.tsx +95 -75
  81. package/src/ConsentFormEditor.tsx +76 -49
  82. package/src/ConsentFormList.test.tsx +28 -10
  83. package/src/ConsentFormList.tsx +14 -2
  84. package/src/ConsentResponseViewer.test.tsx +15 -12
  85. package/src/ConsentResponseViewer.tsx +3 -2
  86. package/src/DocumentStorageBrowser.test.tsx +69 -42
  87. package/src/DocumentStorageBrowser.tsx +4 -4
  88. package/src/LocaleContentEditor.test.tsx +28 -18
  89. package/src/isolated/AdminFieldRenderer.isolated.tsx +5 -2
  90. package/src/isolated/AdminNestedArrayField.isolated.tsx +49 -36
  91. package/src/isolated/AdminObjectPicker.isolated.tsx +31 -26
  92. package/src/isolated/AdminRefField.isolated.tsx +4 -1
  93. package/src/isolated/AdminScriptRunModal.isolated.tsx +24 -17
  94. package/src/isolated/DocumentStorageBrowser.isolated.tsx +80 -63
  95. package/src/isolated/hooks.isolated.tsx +40 -33
  96. package/src/types.ts +34 -4
  97. package/src/useAdminApi.ts +21 -13
  98. package/src/useAdminConfig.ts +5 -4
  99. package/src/useAdminScripts.ts +9 -7
  100. package/src/useConfigurationApi.ts +26 -12
  101. package/src/useDocumentStorageApi.ts +12 -9
@@ -1,10 +1,13 @@
1
+ // noExplicitAny: test mocks use UNSAFE_root traversal and mock.calls access for assertions
2
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
3
  import {describe, expect, it, mock} from "bun:test";
2
4
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
5
  import React from "react";
6
+ import type {ReactTestInstance} from "react-test-renderer";
4
7
  import {act, fireEvent} from "../../ui/node_modules/@testing-library/react-native";
5
8
  import {LocaleContentEditor} from "./LocaleContentEditor";
6
9
 
7
- const press = async (el: any): Promise<void> => {
10
+ const press = async (el: ReactTestInstance): Promise<void> => {
8
11
  await act(async () => {
9
12
  fireEvent.press(el);
10
13
  await new Promise((r) => setTimeout(r, 150));
@@ -50,12 +53,14 @@ describe("LocaleContentEditor", () => {
50
53
 
51
54
  await press(getByText(/Remove /));
52
55
  expect(onChange).toHaveBeenCalled();
53
- expect(Object.keys((onChange.mock.calls[0] as any)[0])).toEqual(["es"]);
56
+ expect(
57
+ Object.keys((onChange.mock.calls[0] as unknown[])[0] as Record<string, unknown>)
58
+ ).toEqual(["es"]);
54
59
  });
55
60
 
56
61
  it("falls back to empty object when value is not an object", () => {
57
62
  const {toJSON} = renderWithTheme(
58
- <LocaleContentEditor onChange={() => {}} value={null as any} />
63
+ <LocaleContentEditor onChange={() => {}} value={null as unknown as Record<string, string>} />
59
64
  );
60
65
  expect(toJSON()).toBeDefined();
61
66
  });
@@ -67,20 +72,23 @@ describe("LocaleContentEditor", () => {
67
72
  );
68
73
  // Find the SelectField and invoke its onChange prop directly.
69
74
  const selects = UNSAFE_root.findAll(
70
- (n: any) => typeof n.props?.onChange === "function" && Array.isArray(n.props?.options)
75
+ (n: ReactTestInstance) =>
76
+ typeof n.props?.onChange === "function" && Array.isArray(n.props?.options)
71
77
  );
72
78
  expect(selects.length).toBeGreaterThan(0);
73
79
  await act(async () => {
74
- (selects[0] as any).props.onChange("en");
80
+ (selects[0] as ReactTestInstance).props.onChange("en");
75
81
  });
76
82
  // Find the Add Locale button (may be nested)
77
- const addBtns = UNSAFE_root.findAll((n: any) => n.props?.text === "Add Locale");
83
+ const addBtns = UNSAFE_root.findAll((n: ReactTestInstance) => n.props?.text === "Add Locale");
78
84
  expect(addBtns.length).toBeGreaterThan(0);
79
85
  await act(async () => {
80
- (addBtns[0] as any).props.onClick?.();
86
+ (addBtns[0] as ReactTestInstance).props.onClick?.();
81
87
  });
82
88
  expect(onChange).toHaveBeenCalled();
83
- expect(Object.keys((onChange.mock.calls[0] as any)[0])).toContain("en");
89
+ expect(
90
+ Object.keys((onChange.mock.calls[0] as unknown[])[0] as Record<string, unknown>)
91
+ ).toContain("en");
84
92
  expect(toJSON()).toBeDefined();
85
93
  });
86
94
 
@@ -90,14 +98,15 @@ describe("LocaleContentEditor", () => {
90
98
  <LocaleContentEditor onChange={onChange} value={{en: "Hi"}} />
91
99
  );
92
100
  const selects = UNSAFE_root.findAll(
93
- (n: any) => typeof n.props?.onChange === "function" && Array.isArray(n.props?.options)
101
+ (n: ReactTestInstance) =>
102
+ typeof n.props?.onChange === "function" && Array.isArray(n.props?.options)
94
103
  );
95
104
  await act(async () => {
96
- (selects[0] as any).props.onChange("en");
105
+ (selects[0] as ReactTestInstance).props.onChange("en");
97
106
  });
98
- const addBtns = UNSAFE_root.findAll((n: any) => n.props?.text === "Add Locale");
107
+ const addBtns = UNSAFE_root.findAll((n: ReactTestInstance) => n.props?.text === "Add Locale");
99
108
  await act(async () => {
100
- (addBtns[0] as any).props.onClick?.();
109
+ (addBtns[0] as ReactTestInstance).props.onClick?.();
101
110
  });
102
111
  // Should NOT have called onChange with an add because "en" already exists.
103
112
  expect(onChange).not.toHaveBeenCalled();
@@ -106,9 +115,9 @@ describe("LocaleContentEditor", () => {
106
115
  it("does not add when no new locale selected", async () => {
107
116
  const onChange = mock((_: Record<string, string>) => undefined);
108
117
  const {UNSAFE_root} = renderWithTheme(<LocaleContentEditor onChange={onChange} value={{}} />);
109
- const addBtns = UNSAFE_root.findAll((n: any) => n.props?.text === "Add Locale");
118
+ const addBtns = UNSAFE_root.findAll((n: ReactTestInstance) => n.props?.text === "Add Locale");
110
119
  await act(async () => {
111
- (addBtns[0] as any).props.onClick?.();
120
+ (addBtns[0] as ReactTestInstance).props.onClick?.();
112
121
  });
113
122
  expect(onChange).not.toHaveBeenCalled();
114
123
  });
@@ -119,15 +128,16 @@ describe("LocaleContentEditor", () => {
119
128
  <LocaleContentEditor onChange={onChange} value={{en: "Hi", es: "Hola"}} />
120
129
  );
121
130
  const editors = UNSAFE_root.findAll(
122
- (n: any) =>
123
- typeof n.props?.testID === "string" && n.props.testID.startsWith("locale-content-")
131
+ (n: ReactTestInstance) =>
132
+ typeof n.props?.testID === "string" &&
133
+ (n.props.testID as string).startsWith("locale-content-")
124
134
  );
125
135
  expect(editors.length).toBeGreaterThan(0);
126
136
  await act(async () => {
127
- (editors[0] as any).props.onChange("new content");
137
+ (editors[0] as ReactTestInstance).props.onChange("new content");
128
138
  });
129
139
  expect(onChange).toHaveBeenCalled();
130
- const arg = (onChange.mock.calls[0] as any)[0];
140
+ const arg = (onChange.mock.calls[0] as unknown[])[0] as Record<string, string>;
131
141
  expect(arg.en).toBe("new content");
132
142
  expect(arg.es).toBe("Hola");
133
143
  });
@@ -1,3 +1,5 @@
1
+ // noExplicitAny: test mocks use type-erased UI component stubs and field config literals
2
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
3
  import {describe, expect, it, mock} from "bun:test";
2
4
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
5
  import React from "react";
@@ -20,8 +22,9 @@ mock.module("../LocaleContentEditor", () => ({
20
22
  }));
21
23
 
22
24
  import {AdminFieldRenderer} from "../AdminFieldRenderer";
25
+ import type {AdminApi, AdminFieldConfig} from "../types";
23
26
 
24
- const api = {} as any;
27
+ const api = {} as unknown as AdminApi;
25
28
  const base = {api, baseUrl: "/admin", onChange: () => {}};
26
29
 
27
30
  describe("AdminFieldRenderer", () => {
@@ -77,7 +80,7 @@ describe("AdminFieldRenderer", () => {
77
80
  const {toJSON} = renderWithTheme(
78
81
  <AdminFieldRenderer
79
82
  {...base}
80
- fieldConfig={fieldConfig as any}
83
+ fieldConfig={fieldConfig as unknown as AdminFieldConfig}
81
84
  fieldKey={fieldKey}
82
85
  value={value}
83
86
  />
@@ -1,10 +1,14 @@
1
+ // noExplicitAny: test mocks use type-erased UI component stubs and mock field renderers
2
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
3
  import {describe, expect, it, mock} from "bun:test";
2
4
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
5
  import React from "react";
6
+ import type {ReactTestInstance} from "react-test-renderer";
4
7
  import {fireEvent} from "../../../ui/node_modules/@testing-library/react-native";
8
+ import type {AdminApi, AdminFieldConfig} from "../types";
5
9
 
6
10
  mock.module("../AdminFieldRenderer", () => ({
7
- AdminFieldRenderer: ({fieldKey, onChange}: {fieldKey: string; onChange: (v: any) => void}) =>
11
+ AdminFieldRenderer: ({fieldKey, onChange}: {fieldKey: string; onChange: (v: unknown) => void}) =>
8
12
  React.createElement("AdminFieldRenderer", {
9
13
  fieldKey,
10
14
  onChange,
@@ -33,17 +37,21 @@ mock.module("@terreno/ui", () => {
33
37
  }),
34
38
  ]);
35
39
  };
36
- const Box = ({children, ...rest}: any) => ReactMod.createElement(RN.View, rest, children);
37
- const Button = ({text, onClick, iconName}: any) =>
40
+ const Box = ({children, ...rest}: Record<string, unknown>) =>
41
+ ReactMod.createElement(RN.View, rest, children);
42
+ const Button = ({text, onClick, iconName}: Record<string, unknown>) =>
38
43
  ReactMod.createElement(
39
44
  RN.Pressable,
40
45
  {onPress: onClick, testID: `btn-${iconName ?? text}`},
41
46
  ReactMod.createElement(RN.Text, {}, text)
42
47
  );
43
- const Card = ({children}: any) => ReactMod.createElement(RN.View, {testID: "card"}, children);
44
- const Heading = ({children}: any) => ReactMod.createElement(RN.Text, {}, children);
45
- const Text = ({children, ...rest}: any) => ReactMod.createElement(RN.Text, rest, children);
46
- const IconButton = ({onClick, accessibilityLabel}: any) =>
48
+ const Card = ({children}: Record<string, unknown>) =>
49
+ ReactMod.createElement(RN.View, {testID: "card"}, children);
50
+ const Heading = ({children}: Record<string, unknown>) =>
51
+ ReactMod.createElement(RN.Text, {}, children);
52
+ const Text = ({children, ...rest}: Record<string, unknown>) =>
53
+ ReactMod.createElement(RN.Text, rest, children);
54
+ const IconButton = ({onClick, accessibilityLabel}: Record<string, unknown>) =>
47
55
  ReactMod.createElement(RN.Pressable, {
48
56
  onPress: onClick,
49
57
  testID: `icon-${accessibilityLabel}`,
@@ -64,10 +72,10 @@ describe("AdminNestedArrayField", () => {
64
72
  it("renders empty state when no items", () => {
65
73
  const {toJSON, getByText} = renderWithTheme(
66
74
  <AdminNestedArrayField
67
- api={{} as any}
75
+ api={{} as unknown as AdminApi}
68
76
  baseUrl="/admin"
69
77
  helperText="help"
70
- items={baseItems as any}
78
+ items={baseItems as unknown as Record<string, AdminFieldConfig>}
71
79
  onChange={() => {}}
72
80
  title="Items"
73
81
  value={[]}
@@ -80,10 +88,10 @@ describe("AdminNestedArrayField", () => {
80
88
  it("renders items with error text", () => {
81
89
  const {toJSON} = renderWithTheme(
82
90
  <AdminNestedArrayField
83
- api={{} as any}
91
+ api={{} as unknown as AdminApi}
84
92
  baseUrl="/admin"
85
93
  errorText="oops"
86
- items={baseItems as any}
94
+ items={baseItems as unknown as Record<string, AdminFieldConfig>}
87
95
  onChange={() => {}}
88
96
  title="Items"
89
97
  value={[
@@ -98,12 +106,12 @@ describe("AdminNestedArrayField", () => {
98
106
  it("handles non-array incoming value gracefully", () => {
99
107
  const {toJSON} = renderWithTheme(
100
108
  <AdminNestedArrayField
101
- api={{} as any}
109
+ api={{} as unknown as AdminApi}
102
110
  baseUrl="/admin"
103
- items={baseItems as any}
111
+ items={baseItems as unknown as Record<string, AdminFieldConfig>}
104
112
  onChange={() => {}}
105
113
  title="Items"
106
- value={null as any}
114
+ value={null as unknown as Record<string, unknown>[]}
107
115
  />
108
116
  );
109
117
  expect(toJSON()).toBeDefined();
@@ -113,9 +121,9 @@ describe("AdminNestedArrayField", () => {
113
121
  const onChange = mock(() => {});
114
122
  const {getByTestId} = renderWithTheme(
115
123
  <AdminNestedArrayField
116
- api={{} as any}
124
+ api={{} as unknown as AdminApi}
117
125
  baseUrl="/admin"
118
- items={baseItems as any}
126
+ items={baseItems as unknown as Record<string, AdminFieldConfig>}
119
127
  onChange={onChange}
120
128
  title="Items"
121
129
  value={[]}
@@ -135,9 +143,14 @@ describe("AdminNestedArrayField", () => {
135
143
  const onChange = mock(() => {});
136
144
  const {getByTestId} = renderWithTheme(
137
145
  <AdminNestedArrayField
138
- api={{} as any}
146
+ api={{} as unknown as AdminApi}
139
147
  baseUrl="/admin"
140
- items={{description: {required: false, type: "string"}} as any}
148
+ items={
149
+ {description: {required: false, type: "string"}} as unknown as Record<
150
+ string,
151
+ AdminFieldConfig
152
+ >
153
+ }
141
154
  onChange={onChange}
142
155
  title="Items"
143
156
  value={[]}
@@ -156,9 +169,9 @@ describe("AdminNestedArrayField", () => {
156
169
  };
157
170
  const {getByTestId} = renderWithTheme(
158
171
  <AdminNestedArrayField
159
- api={{} as any}
172
+ api={{} as unknown as AdminApi}
160
173
  baseUrl="/admin"
161
- items={items as any}
174
+ items={items as unknown as Record<string, AdminFieldConfig>}
162
175
  onChange={onChange}
163
176
  title="Items"
164
177
  value={[]}
@@ -176,9 +189,9 @@ describe("AdminNestedArrayField", () => {
176
189
  const onChange = mock(() => {});
177
190
  const {getAllByTestId} = renderWithTheme(
178
191
  <AdminNestedArrayField
179
- api={{} as any}
192
+ api={{} as unknown as AdminApi}
180
193
  baseUrl="/admin"
181
- items={baseItems as any}
194
+ items={baseItems as unknown as Record<string, AdminFieldConfig>}
182
195
  onChange={onChange}
183
196
  title="Items"
184
197
  value={[
@@ -199,9 +212,9 @@ describe("AdminNestedArrayField", () => {
199
212
  const onChange = mock(() => {});
200
213
  const {getAllByTestId} = renderWithTheme(
201
214
  <AdminNestedArrayField
202
- api={{} as any}
215
+ api={{} as unknown as AdminApi}
203
216
  baseUrl="/admin"
204
- items={baseItems as any}
217
+ items={baseItems as unknown as Record<string, AdminFieldConfig>}
205
218
  onChange={onChange}
206
219
  title="Items"
207
220
  value={[
@@ -211,7 +224,7 @@ describe("AdminNestedArrayField", () => {
211
224
  />
212
225
  );
213
226
  const nameFields = getAllByTestId("admin-field-renderer-name");
214
- (nameFields[1] as any).props.onChange("new name");
227
+ (nameFields[1] as ReactTestInstance).props.onChange("new name");
215
228
  expect(onChange).toHaveBeenCalled();
216
229
  const next = onChange.mock.calls[0][0];
217
230
  expect(next[1].name).toBe("new name");
@@ -222,9 +235,9 @@ describe("AdminNestedArrayField", () => {
222
235
  const onChange = mock(() => {});
223
236
  const {getByTestId} = renderWithTheme(
224
237
  <AdminNestedArrayField
225
- api={{} as any}
238
+ api={{} as unknown as AdminApi}
226
239
  baseUrl="/admin"
227
- items={baseItems as any}
240
+ items={baseItems as unknown as Record<string, AdminFieldConfig>}
228
241
  onChange={onChange}
229
242
  title="Items"
230
243
  value={[
@@ -237,16 +250,16 @@ describe("AdminNestedArrayField", () => {
237
250
  fireEvent.press(getByTestId("mock-reorder"));
238
251
  expect(onChange).toHaveBeenCalled();
239
252
  const next = onChange.mock.calls[0][0];
240
- expect(next.map((i: any) => i.name)).toEqual(["c", "b", "a"]);
253
+ expect(next.map((i: Record<string, unknown>) => i.name)).toEqual(["c", "b", "a"]);
241
254
  });
242
255
 
243
256
  it("supports re-render with longer value array (grows itemIds)", () => {
244
257
  const onChange = mock(() => {});
245
258
  const {rerender, toJSON} = renderWithTheme(
246
259
  <AdminNestedArrayField
247
- api={{} as any}
260
+ api={{} as unknown as AdminApi}
248
261
  baseUrl="/admin"
249
- items={baseItems as any}
262
+ items={baseItems as unknown as Record<string, AdminFieldConfig>}
250
263
  onChange={onChange}
251
264
  title="Items"
252
265
  value={[{active: true, count: 1, name: "a", tags: []}]}
@@ -254,9 +267,9 @@ describe("AdminNestedArrayField", () => {
254
267
  );
255
268
  rerender(
256
269
  <AdminNestedArrayField
257
- api={{} as any}
270
+ api={{} as unknown as AdminApi}
258
271
  baseUrl="/admin"
259
- items={baseItems as any}
272
+ items={baseItems as unknown as Record<string, AdminFieldConfig>}
260
273
  onChange={onChange}
261
274
  title="Items"
262
275
  value={[
@@ -271,9 +284,9 @@ describe("AdminNestedArrayField", () => {
271
284
  it("supports re-render with shorter value array (shrinks itemIds)", () => {
272
285
  const {rerender, toJSON} = renderWithTheme(
273
286
  <AdminNestedArrayField
274
- api={{} as any}
287
+ api={{} as unknown as AdminApi}
275
288
  baseUrl="/admin"
276
- items={baseItems as any}
289
+ items={baseItems as unknown as Record<string, AdminFieldConfig>}
277
290
  onChange={() => {}}
278
291
  title="Items"
279
292
  value={[
@@ -284,9 +297,9 @@ describe("AdminNestedArrayField", () => {
284
297
  );
285
298
  rerender(
286
299
  <AdminNestedArrayField
287
- api={{} as any}
300
+ api={{} as unknown as AdminApi}
288
301
  baseUrl="/admin"
289
- items={baseItems as any}
302
+ items={baseItems as unknown as Record<string, AdminFieldConfig>}
290
303
  onChange={() => {}}
291
304
  title="Items"
292
305
  value={[{active: true, count: 1, name: "a", tags: []}]}
@@ -1,13 +1,16 @@
1
+ // noExplicitAny: test mocks use type-erased RTK Query API doubles and dynamic endpoint injection
2
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
3
  import {beforeEach, describe, expect, it, mock} from "bun:test";
2
4
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
5
  import React from "react";
4
6
  import {act, fireEvent} from "../../../ui/node_modules/@testing-library/react-native";
5
7
  import {AdminObjectPicker} from "../AdminObjectPicker";
8
+ import type {AdminApi} from "../types";
6
9
 
7
10
  interface ApiState {
8
- searchData: any;
11
+ searchData: unknown;
9
12
  isSearching: boolean;
10
- selectedItem: any;
13
+ selectedItem: Record<string, unknown> | undefined;
11
14
  }
12
15
 
13
16
  const apiState: ApiState = {
@@ -16,11 +19,11 @@ const apiState: ApiState = {
16
19
  selectedItem: undefined,
17
20
  };
18
21
 
19
- const querySpecs: any[] = [];
22
+ const querySpecs: unknown[] = [];
20
23
  const makeApi = () => ({
21
- injectEndpoints: ({endpoints}: {endpoints: (b: any) => Record<string, any>}) => {
24
+ injectEndpoints: ({endpoints}: {endpoints: (b: unknown) => Record<string, unknown>}) => {
22
25
  const build = {
23
- query: (spec: any) => {
26
+ query: (spec: Record<string, unknown>) => {
24
27
  // Invoke the query lambda so the URL/params builders run.
25
28
  if (typeof spec?.query === "function") {
26
29
  querySpecs.push(spec.query("some-id"));
@@ -33,9 +36,9 @@ const makeApi = () => ({
33
36
  const cap = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
34
37
  const searchKey = keys.find((k) => k.startsWith("adminSearch_"));
35
38
  const readKey = keys.find((k) => k.startsWith("adminSearchRead_"));
36
- const enhanced: any = {};
39
+ const enhanced: Record<string, unknown> = {};
37
40
  if (searchKey) {
38
- enhanced[`use${cap(searchKey)}Query`] = (_q: string, opts: any) => {
41
+ enhanced[`use${cap(searchKey)}Query`] = (_q: string, opts: Record<string, unknown>) => {
39
42
  if (opts?.skip) {
40
43
  return {data: undefined, isFetching: false};
41
44
  }
@@ -43,7 +46,7 @@ const makeApi = () => ({
43
46
  };
44
47
  }
45
48
  if (readKey) {
46
- enhanced[`use${cap(readKey)}Query`] = (_id: string, opts: any) => {
49
+ enhanced[`use${cap(readKey)}Query`] = (_id: string, opts: Record<string, unknown>) => {
47
50
  if (opts?.skip) {
48
51
  return {data: undefined};
49
52
  }
@@ -65,7 +68,7 @@ describe("AdminObjectPicker", () => {
65
68
  it("wires the search and read query endpoints to the right URLs", () => {
66
69
  renderWithTheme(
67
70
  <AdminObjectPicker
68
- api={makeApi() as any}
71
+ api={makeApi() as unknown as AdminApi}
69
72
  onChange={() => {}}
70
73
  refModelName="User"
71
74
  routePath="/admin/users"
@@ -76,7 +79,9 @@ describe("AdminObjectPicker", () => {
76
79
  const urls = querySpecs.map((s) => s.url).sort();
77
80
  expect(urls).toContain("/admin/users/search");
78
81
  expect(urls).toContain("/admin/users/some-id");
79
- const searchSpec = querySpecs.find((s: any) => s.url === "/admin/users/search");
82
+ const searchSpec = querySpecs.find(
83
+ (s: unknown) => (s as Record<string, unknown>).url === "/admin/users/search"
84
+ );
80
85
  expect(searchSpec.params).toEqual({q: "some-id"});
81
86
  });
82
87
 
@@ -85,7 +90,7 @@ describe("AdminObjectPicker", () => {
85
90
  apiState.selectedItem = {_id: "abc123"};
86
91
  const {toJSON} = renderWithTheme(
87
92
  <AdminObjectPicker
88
- api={makeApi() as any}
93
+ api={makeApi() as unknown as AdminApi}
89
94
  onChange={() => {}}
90
95
  refModelName="Foo"
91
96
  routePath="/admin/foo"
@@ -99,7 +104,7 @@ describe("AdminObjectPicker", () => {
99
104
  it("clears the pending debounce timeout on rapid input (line 120)", async () => {
100
105
  const {getByTestId} = renderWithTheme(
101
106
  <AdminObjectPicker
102
- api={makeApi() as any}
107
+ api={makeApi() as unknown as AdminApi}
103
108
  onChange={() => {}}
104
109
  refModelName="User"
105
110
  routePath="/admin/users"
@@ -122,7 +127,7 @@ describe("AdminObjectPicker", () => {
122
127
  it("renders a search field when there is no selected value", () => {
123
128
  const {toJSON} = renderWithTheme(
124
129
  <AdminObjectPicker
125
- api={makeApi() as any}
130
+ api={makeApi() as unknown as AdminApi}
126
131
  errorText="bad"
127
132
  helperText="helper"
128
133
  onChange={() => {}}
@@ -139,7 +144,7 @@ describe("AdminObjectPicker", () => {
139
144
  apiState.selectedItem = {_id: "u1", email: "e@x.com", name: "Alice"};
140
145
  const {toJSON, getByTestId} = renderWithTheme(
141
146
  <AdminObjectPicker
142
- api={makeApi() as any}
147
+ api={makeApi() as unknown as AdminApi}
143
148
  onChange={() => {}}
144
149
  refModelName="User"
145
150
  routePath="/admin/users"
@@ -156,7 +161,7 @@ describe("AdminObjectPicker", () => {
156
161
  const onChange = mock((_: string) => undefined);
157
162
  const {getByTestId} = renderWithTheme(
158
163
  <AdminObjectPicker
159
- api={makeApi() as any}
164
+ api={makeApi() as unknown as AdminApi}
160
165
  onChange={onChange}
161
166
  refModelName="User"
162
167
  routePath="/admin/users"
@@ -175,7 +180,7 @@ describe("AdminObjectPicker", () => {
175
180
  apiState.selectedItem = {_id: "u1", name: "Alice"};
176
181
  const {getByTestId, queryByTestId} = renderWithTheme(
177
182
  <AdminObjectPicker
178
- api={makeApi() as any}
183
+ api={makeApi() as unknown as AdminApi}
179
184
  onChange={() => {}}
180
185
  refModelName="User"
181
186
  routePath="/admin/users"
@@ -197,7 +202,7 @@ describe("AdminObjectPicker", () => {
197
202
  ];
198
203
  const {getByTestId} = renderWithTheme(
199
204
  <AdminObjectPicker
200
- api={makeApi() as any}
205
+ api={makeApi() as unknown as AdminApi}
201
206
  onChange={() => {}}
202
207
  refModelName="User"
203
208
  routePath="/admin/users"
@@ -216,7 +221,7 @@ describe("AdminObjectPicker", () => {
216
221
  apiState.searchData = undefined;
217
222
  const {toJSON} = renderWithTheme(
218
223
  <AdminObjectPicker
219
- api={makeApi() as any}
224
+ api={makeApi() as unknown as AdminApi}
220
225
  onChange={() => {}}
221
226
  refModelName="User"
222
227
  routePath="/admin/users"
@@ -231,7 +236,7 @@ describe("AdminObjectPicker", () => {
231
236
  apiState.selectedItem = {_id: "raw-id"};
232
237
  const {toJSON} = renderWithTheme(
233
238
  <AdminObjectPicker
234
- api={makeApi() as any}
239
+ api={makeApi() as unknown as AdminApi}
235
240
  onChange={() => {}}
236
241
  refModelName="User"
237
242
  routePath="/admin/users"
@@ -249,7 +254,7 @@ describe("AdminObjectPicker", () => {
249
254
  ];
250
255
  const {getByTestId} = renderWithTheme(
251
256
  <AdminObjectPicker
252
- api={makeApi() as any}
257
+ api={makeApi() as unknown as AdminApi}
253
258
  onChange={() => {}}
254
259
  refModelName="User"
255
260
  routePath="/admin/users"
@@ -269,7 +274,7 @@ describe("AdminObjectPicker", () => {
269
274
  const onChange = mock((_: string) => undefined);
270
275
  const {getByTestId} = renderWithTheme(
271
276
  <AdminObjectPicker
272
- api={makeApi() as any}
277
+ api={makeApi() as unknown as AdminApi}
273
278
  onChange={onChange}
274
279
  refModelName="User"
275
280
  routePath="/admin/users"
@@ -293,7 +298,7 @@ describe("AdminObjectPicker", () => {
293
298
  apiState.searchData = [];
294
299
  const {getByTestId, getByText} = renderWithTheme(
295
300
  <AdminObjectPicker
296
- api={makeApi() as any}
301
+ api={makeApi() as unknown as AdminApi}
297
302
  onChange={() => {}}
298
303
  refModelName="User"
299
304
  routePath="/admin/users"
@@ -312,7 +317,7 @@ describe("AdminObjectPicker", () => {
312
317
  apiState.searchData = {data: [{_id: "p1", name: "Paginated"}]};
313
318
  const {getByTestId} = renderWithTheme(
314
319
  <AdminObjectPicker
315
- api={makeApi() as any}
320
+ api={makeApi() as unknown as AdminApi}
316
321
  onChange={() => {}}
317
322
  refModelName="User"
318
323
  routePath="/admin/users"
@@ -330,7 +335,7 @@ describe("AdminObjectPicker", () => {
330
335
  it("cleans up the debounce timer on unmount", async () => {
331
336
  const {getByTestId, unmount} = renderWithTheme(
332
337
  <AdminObjectPicker
333
- api={makeApi() as any}
338
+ api={makeApi() as unknown as AdminApi}
334
339
  onChange={() => {}}
335
340
  refModelName="User"
336
341
  routePath="/admin/users"
@@ -350,7 +355,7 @@ describe("AdminObjectPicker", () => {
350
355
  it("opens results dropdown on focus and shows 'Start typing to search'", async () => {
351
356
  const {getByTestId, getByText} = renderWithTheme(
352
357
  <AdminObjectPicker
353
- api={makeApi() as any}
358
+ api={makeApi() as unknown as AdminApi}
354
359
  onChange={() => {}}
355
360
  refModelName="User"
356
361
  routePath="/admin/users"
@@ -369,7 +374,7 @@ describe("AdminObjectPicker", () => {
369
374
  apiState.selectedItem = {_id: "x", label: "Label", title: "Title"};
370
375
  const {getByTestId} = renderWithTheme(
371
376
  <AdminObjectPicker
372
- api={makeApi() as any}
377
+ api={makeApi() as unknown as AdminApi}
373
378
  onChange={() => {}}
374
379
  refModelName="User"
375
380
  routePath="/admin/users"
@@ -1,3 +1,5 @@
1
+ // noExplicitAny: test mocks use type-erased RTK Query API doubles
2
+ // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
1
3
  import {describe, expect, it, mock} from "bun:test";
2
4
  import {renderWithTheme} from "@terreno/ui/src/test-utils";
3
5
  import React from "react";
@@ -8,12 +10,13 @@ mock.module("../AdminObjectPicker", () => ({
8
10
  }));
9
11
 
10
12
  import {AdminRefField} from "../AdminRefField";
13
+ import type {AdminApi} from "../types";
11
14
 
12
15
  describe("AdminRefField", () => {
13
16
  it("renders an AdminObjectPicker passing through key props", () => {
14
17
  const {getByTestId} = renderWithTheme(
15
18
  <AdminRefField
16
- api={{} as any}
19
+ api={{} as unknown as AdminApi}
17
20
  baseUrl="/admin"
18
21
  errorText="e"
19
22
  helperText="h"