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