@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 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, fireEvent} from "../../ui/node_modules/@testing-library/react-native";
8
+ import type {AdminApi} from "./types";
6
9
 
7
10
  interface ListState {
8
- data: any;
11
+ data: unknown;
9
12
  isLoading: boolean;
10
13
  error: unknown;
11
14
  }
@@ -32,19 +35,25 @@ describe("ConsentFormList", () => {
32
35
 
33
36
  it("renders loading state", () => {
34
37
  listState.isLoading = true;
35
- const {toJSON} = renderWithTheme(<ConsentFormList api={{} as any} baseUrl="/admin" />);
38
+ const {toJSON} = renderWithTheme(
39
+ <ConsentFormList api={{} as unknown as AdminApi} baseUrl="/admin" />
40
+ );
36
41
  expect(toJSON()).toBeDefined();
37
42
  });
38
43
 
39
44
  it("renders error state", () => {
40
45
  listState.error = new Error("x");
41
- const {getByText} = renderWithTheme(<ConsentFormList api={{} as any} baseUrl="/admin" />);
46
+ const {getByText} = renderWithTheme(
47
+ <ConsentFormList api={{} as unknown as AdminApi} baseUrl="/admin" />
48
+ );
42
49
  expect(getByText(/Failed to load consent forms/)).toBeDefined();
43
50
  });
44
51
 
45
52
  it("renders empty state", () => {
46
53
  listState.data = {data: [], total: 0};
47
- const {getByText} = renderWithTheme(<ConsentFormList api={{} as any} baseUrl="/admin" />);
54
+ const {getByText} = renderWithTheme(
55
+ <ConsentFormList api={{} as unknown as AdminApi} baseUrl="/admin" />
56
+ );
48
57
  expect(getByText(/No consent forms found/)).toBeDefined();
49
58
  });
50
59
 
@@ -54,7 +63,9 @@ describe("ConsentFormList", () => {
54
63
  total: 1,
55
64
  };
56
65
  // No onRowClick is provided. The ActionsCell edit-button path should be hidden.
57
- const {toJSON} = renderWithTheme(<ConsentFormList api={{} as any} baseUrl="/admin" />);
66
+ const {toJSON} = renderWithTheme(
67
+ <ConsentFormList api={{} as unknown as AdminApi} baseUrl="/admin" />
68
+ );
58
69
  expect(toJSON()).toBeDefined();
59
70
  });
60
71
 
@@ -77,7 +88,7 @@ describe("ConsentFormList", () => {
77
88
  const onRowClick = mock((_: string) => undefined);
78
89
  const {getByTestId} = renderWithTheme(
79
90
  <ConsentFormList
80
- api={{} as any}
91
+ api={{} as unknown as AdminApi}
81
92
  baseUrl="/admin"
82
93
  onCreateNew={onCreateNew}
83
94
  onRowClick={onRowClick}
@@ -96,19 +107,25 @@ describe("ConsentFormList", () => {
96
107
  total: 1,
97
108
  };
98
109
  const {UNSAFE_root, toJSON} = renderWithTheme(
99
- <ConsentFormList api={{} as any} baseUrl="/admin" onRowClick={() => undefined} />
110
+ <ConsentFormList
111
+ api={{} as unknown as AdminApi}
112
+ baseUrl="/admin"
113
+ onRowClick={() => undefined}
114
+ />
115
+ );
116
+ const tables = UNSAFE_root.findAll(
117
+ (n: ReactTestInstance) => typeof n.props?.setSortColumn === "function"
100
118
  );
101
- const tables = UNSAFE_root.findAll((n: any) => typeof n.props?.setSortColumn === "function");
102
119
  expect(tables.length).toBeGreaterThan(0);
103
120
  await act(async () => {
104
121
  // Column 99 is out of range, so buildSortString returns undefined and
105
122
  // the default "-created" sort should be used.
106
- (tables[0] as any).props.setSortColumn({column: 99, direction: "asc"});
123
+ (tables[0] as ReactTestInstance).props.setSortColumn({column: 99, direction: "asc"});
107
124
  await new Promise((r) => setTimeout(r, 10));
108
125
  });
109
126
  // Also exercise the desc branch on a valid column.
110
127
  await act(async () => {
111
- (tables[0] as any).props.setSortColumn({column: 0, direction: "desc"});
128
+ (tables[0] as ReactTestInstance).props.setSortColumn({column: 0, direction: "desc"});
112
129
  await new Promise((r) => setTimeout(r, 10));
113
130
  });
114
131
  expect(toJSON()).toBeDefined();
@@ -1,11 +1,13 @@
1
+ // noExplicitAny: test mocks use type-erased RTK Query API doubles and dynamic mock returns
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";
7
+ import type {AdminApi} from "./types";
6
8
 
7
9
  interface ReadState {
8
- data: any;
10
+ data: unknown;
9
11
  isLoading: boolean;
10
12
  }
11
13
  const readState: ReadState = {data: undefined, isLoading: false};
@@ -21,10 +23,10 @@ mock.module("./useAdminApi", () => ({
21
23
  }),
22
24
  }));
23
25
 
24
- const pdfCalls: any[] = [];
25
- let pdfImpl: (r: any) => Promise<void> = async () => {};
26
+ const pdfCalls: unknown[] = [];
27
+ let pdfImpl: (r: unknown) => Promise<void> = async () => {};
26
28
  mock.module("./generateConsentPdf", () => ({
27
- generateConsentPdf: async (r: any) => {
29
+ generateConsentPdf: async (r: unknown) => {
28
30
  pdfCalls.push(r);
29
31
  return pdfImpl(r);
30
32
  },
@@ -43,7 +45,7 @@ describe("ConsentResponseViewer", () => {
43
45
  it("renders loading state", () => {
44
46
  readState.isLoading = true;
45
47
  const {toJSON} = renderWithTheme(
46
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r1" />
48
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r1" />
47
49
  );
48
50
  expect(toJSON()).toBeDefined();
49
51
  });
@@ -55,19 +57,19 @@ describe("ConsentResponseViewer", () => {
55
57
  it("survives the loading → loaded transition without a hook-order error", async () => {
56
58
  readState.isLoading = true;
57
59
  const {rerender, getByText} = renderWithTheme(
58
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r1" />
60
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r1" />
59
61
  );
60
62
  await act(async () => {
61
63
  readState.isLoading = false;
62
64
  readState.data = {agreed: true, consentFormId: "raw-id", userId: "u1"};
63
- rerender(<ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r1" />);
65
+ rerender(<ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r1" />);
64
66
  });
65
67
  expect(getByText("Download PDF")).toBeDefined();
66
68
  });
67
69
 
68
70
  it("shows not-found state when there is no id / data", () => {
69
71
  const {getByText} = renderWithTheme(
70
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="" />
72
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="" />
71
73
  );
72
74
  expect(getByText(/Response not found\./)).toBeDefined();
73
75
  });
@@ -87,7 +89,7 @@ describe("ConsentResponseViewer", () => {
87
89
  userId: {_id: "u1"},
88
90
  };
89
91
  const {getByText} = renderWithTheme(
90
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r1" />
92
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r1" />
91
93
  );
92
94
  await act(async () => {
93
95
  fireEvent.press(getByText("Download PDF"));
@@ -103,7 +105,7 @@ describe("ConsentResponseViewer", () => {
103
105
  userId: "u2",
104
106
  };
105
107
  const {toJSON} = renderWithTheme(
106
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r2" />
108
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r2" />
107
109
  );
108
110
  expect(toJSON()).toBeDefined();
109
111
  });
@@ -114,7 +116,7 @@ describe("ConsentResponseViewer", () => {
114
116
  throw new Error("broken");
115
117
  };
116
118
  const {getByText} = renderWithTheme(
117
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r1" />
119
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r1" />
118
120
  );
119
121
  await act(async () => {
120
122
  fireEvent.press(getByText("Download PDF"));
@@ -126,7 +128,7 @@ describe("ConsentResponseViewer", () => {
126
128
  it("formats invalid dates gracefully", () => {
127
129
  readState.data = {agreed: true, agreedAt: "not-a-date"};
128
130
  const {toJSON} = renderWithTheme(
129
- <ConsentResponseViewer api={{} as any} baseUrl="/admin" id="r1" />
131
+ <ConsentResponseViewer api={{} as unknown as AdminApi} baseUrl="/admin" id="r1" />
130
132
  );
131
133
  expect(toJSON()).toBeDefined();
132
134
  });
@@ -1,37 +1,41 @@
1
+ // noExplicitAny: test mocks use type-erased RTK Query API doubles and dynamic mock returns
1
2
  // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
2
3
  import {afterEach, 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 {Platform} from "react-native";
7
+ import type {ReactTestInstance} from "react-test-renderer";
6
8
  import {act, fireEvent} from "../../ui/node_modules/@testing-library/react-native";
9
+ import type {AdminApi} from "./types";
7
10
 
8
11
  mock.module("react-native-webview", () => ({
9
- WebView: (props: any) => React.createElement("WebView", {...props, testID: "mock-webview"}),
12
+ WebView: (props: Record<string, unknown>) =>
13
+ React.createElement("WebView", {...props, testID: "mock-webview"}),
10
14
  }));
11
15
 
12
16
  interface ListState {
13
- data: any;
17
+ data: unknown;
14
18
  isLoading: boolean;
15
19
  isError: boolean;
16
- error: any;
20
+ error: unknown;
17
21
  }
18
22
  const listState: ListState = {data: undefined, error: null, isError: false, isLoading: false};
19
23
  const refetchMock = mock(() => {});
20
- const uploadCalls: any[] = [];
24
+ const uploadCalls: unknown[] = [];
21
25
  const deleteCalls: string[] = [];
22
26
  const deleteFolderCalls: string[] = [];
23
- const createFolderCalls: any[] = [];
27
+ const createFolderCalls: unknown[] = [];
24
28
  const downloadCalls: string[] = [];
25
- let uploadImpl: (body: any) => Promise<any> = async () => ({});
26
- let deleteImpl: (p: string) => Promise<any> = async () => ({});
27
- let deleteFolderImpl: (p: string) => Promise<any> = async () => ({});
28
- let createFolderImpl: (body: any) => Promise<any> = async () => ({});
29
- let downloadImpl: (p: string) => Promise<any> = async () => new Blob(["hi"]);
29
+ let uploadImpl: (body: unknown) => Promise<unknown> = async () => ({});
30
+ let deleteImpl: (p: string) => Promise<unknown> = async () => ({});
31
+ let deleteFolderImpl: (p: string) => Promise<unknown> = async () => ({});
32
+ let createFolderImpl: (body: unknown) => Promise<unknown> = async () => ({});
33
+ let downloadImpl: (p: string) => Promise<unknown> = async () => new Blob(["hi"]);
30
34
 
31
35
  mock.module("./useDocumentStorageApi", () => ({
32
36
  useDocumentStorageApi: () => ({
33
37
  useCreateFolderMutation: () => [
34
- (body: any) => ({
38
+ (body: unknown) => ({
35
39
  unwrap: async () => {
36
40
  createFolderCalls.push(body);
37
41
  return createFolderImpl(body);
@@ -75,7 +79,7 @@ mock.module("./useDocumentStorageApi", () => ({
75
79
  return {...listState, refetch: refetchMock};
76
80
  },
77
81
  useUploadMutation: () => [
78
- (body: any) => ({
82
+ (body: unknown) => ({
79
83
  unwrap: async () => {
80
84
  uploadCalls.push(body);
81
85
  return uploadImpl(body);
@@ -88,7 +92,7 @@ mock.module("./useDocumentStorageApi", () => ({
88
92
 
89
93
  import {DocumentStorageBrowser} from "./DocumentStorageBrowser";
90
94
 
91
- const press = async (el: any): Promise<void> => {
95
+ const press = async (el: ReactTestInstance): Promise<void> => {
92
96
  await act(async () => {
93
97
  fireEvent.press(el);
94
98
  await new Promise((r) => setTimeout(r, 150));
@@ -123,7 +127,7 @@ describe("DocumentStorageBrowser", () => {
123
127
  it("renders loading state", () => {
124
128
  listState.isLoading = true;
125
129
  const {toJSON} = renderWithTheme(
126
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
130
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
127
131
  );
128
132
  expect(toJSON()).toBeDefined();
129
133
  });
@@ -132,7 +136,7 @@ describe("DocumentStorageBrowser", () => {
132
136
  listState.isError = true;
133
137
  listState.error = {status: 500};
134
138
  const {getByText} = renderWithTheme(
135
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
139
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
136
140
  );
137
141
  expect(getByText(/Failed to load files/)).toBeDefined();
138
142
  });
@@ -143,7 +147,7 @@ describe("DocumentStorageBrowser", () => {
143
147
  const onSettingsPress = mock(() => undefined);
144
148
  const {getByText} = renderWithTheme(
145
149
  <DocumentStorageBrowser
146
- api={{} as any}
150
+ api={{} as unknown as AdminApi}
147
151
  basePath="/documents"
148
152
  onSettingsPress={onSettingsPress}
149
153
  />
@@ -154,7 +158,7 @@ describe("DocumentStorageBrowser", () => {
154
158
  it("renders empty state when no files or folders", () => {
155
159
  listState.data = {files: [], folders: []};
156
160
  const {getByText} = renderWithTheme(
157
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
161
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
158
162
  );
159
163
  expect(getByText(/No files found/)).toBeDefined();
160
164
  });
@@ -180,7 +184,7 @@ describe("DocumentStorageBrowser", () => {
180
184
  folders: ["sub/"],
181
185
  };
182
186
  const {toJSON} = renderWithTheme(
183
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
187
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
184
188
  );
185
189
  expect(toJSON()).toBeDefined();
186
190
  });
@@ -188,7 +192,7 @@ describe("DocumentStorageBrowser", () => {
188
192
  it("refreshes the list when refresh is pressed", async () => {
189
193
  listState.data = {files: [], folders: []};
190
194
  const {getByTestId} = renderWithTheme(
191
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
195
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
192
196
  );
193
197
  await press(getByTestId("document-refresh-button"));
194
198
  expect(refetchMock).toHaveBeenCalled();
@@ -197,7 +201,7 @@ describe("DocumentStorageBrowser", () => {
197
201
  it("opens the new-folder modal when pressed", async () => {
198
202
  listState.data = {files: [], folders: []};
199
203
  const {getByTestId, toJSON} = renderWithTheme(
200
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
204
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
201
205
  );
202
206
  await press(getByTestId("document-new-folder-button"));
203
207
  expect(toJSON()).toBeDefined();
@@ -206,7 +210,11 @@ describe("DocumentStorageBrowser", () => {
206
210
  it("does not show upload/new folder when allowUpload is false", () => {
207
211
  listState.data = {files: [], folders: []};
208
212
  const {queryByTestId} = renderWithTheme(
209
- <DocumentStorageBrowser allowUpload={false} api={{} as any} basePath="/documents" />
213
+ <DocumentStorageBrowser
214
+ allowUpload={false}
215
+ api={{} as unknown as AdminApi}
216
+ basePath="/documents"
217
+ />
210
218
  );
211
219
  expect(queryByTestId("document-upload-button")).toBeNull();
212
220
  expect(queryByTestId("document-new-folder-button")).toBeNull();
@@ -219,7 +227,11 @@ describe("DocumentStorageBrowser", () => {
219
227
  };
220
228
  const onFileSelect = mock(() => undefined);
221
229
  const {toJSON} = renderWithTheme(
222
- <DocumentStorageBrowser api={{} as any} basePath="/documents" onFileSelect={onFileSelect} />
230
+ <DocumentStorageBrowser
231
+ api={{} as unknown as AdminApi}
232
+ basePath="/documents"
233
+ onFileSelect={onFileSelect}
234
+ />
223
235
  );
224
236
  expect(toJSON()).toBeDefined();
225
237
  });
@@ -229,7 +241,7 @@ describe("DocumentStorageBrowser", () => {
229
241
  const onSettingsPress = mock(() => undefined);
230
242
  const {toJSON} = renderWithTheme(
231
243
  <DocumentStorageBrowser
232
- api={{} as any}
244
+ api={{} as unknown as AdminApi}
233
245
  basePath="/documents"
234
246
  onSettingsPress={onSettingsPress}
235
247
  />
@@ -240,7 +252,11 @@ describe("DocumentStorageBrowser", () => {
240
252
  it("does not render when allowDelete is false (folder actions return null)", () => {
241
253
  listState.data = {files: [], folders: ["sub/"]};
242
254
  const {toJSON} = renderWithTheme(
243
- <DocumentStorageBrowser allowDelete={false} api={{} as any} basePath="/documents" />
255
+ <DocumentStorageBrowser
256
+ allowDelete={false}
257
+ api={{} as unknown as AdminApi}
258
+ basePath="/documents"
259
+ />
244
260
  );
245
261
  expect(toJSON()).toBeDefined();
246
262
  });
@@ -248,7 +264,11 @@ describe("DocumentStorageBrowser", () => {
248
264
  it("uses custom title when provided", () => {
249
265
  listState.data = {files: [], folders: []};
250
266
  const {getByText} = renderWithTheme(
251
- <DocumentStorageBrowser api={{} as any} basePath="/documents" title="Custom Storage" />
267
+ <DocumentStorageBrowser
268
+ api={{} as unknown as AdminApi}
269
+ basePath="/documents"
270
+ title="Custom Storage"
271
+ />
252
272
  );
253
273
  expect(getByText("Custom Storage")).toBeDefined();
254
274
  });
@@ -257,7 +277,7 @@ describe("DocumentStorageBrowser", () => {
257
277
  listState.isError = true;
258
278
  listState.error = {status: 503};
259
279
  const {getByTestId, rerender} = renderWithTheme(
260
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
280
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
261
281
  );
262
282
  await act(async () => {
263
283
  await new Promise((r) => setTimeout(r, 50));
@@ -266,7 +286,7 @@ describe("DocumentStorageBrowser", () => {
266
286
  listState.isError = false;
267
287
  listState.error = null;
268
288
  listState.data = {files: [], folders: []};
269
- rerender(<DocumentStorageBrowser api={{} as any} basePath="/documents" />);
289
+ rerender(<DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />);
270
290
  expect(true).toBe(true);
271
291
  });
272
292
 
@@ -274,7 +294,7 @@ describe("DocumentStorageBrowser", () => {
274
294
  listState.isError = true;
275
295
  listState.error = {originalStatus: 503};
276
296
  const {getByText} = renderWithTheme(
277
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
297
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
278
298
  );
279
299
  expect(getByText(/Storage is not configured/)).toBeDefined();
280
300
  });
@@ -282,7 +302,7 @@ describe("DocumentStorageBrowser", () => {
282
302
  it("renders breadcrumbs that can be clicked", () => {
283
303
  listState.data = {files: [], folders: []};
284
304
  const {toJSON} = renderWithTheme(
285
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
305
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
286
306
  );
287
307
  // No current prefix, only root crumb
288
308
  expect(toJSON()).toBeDefined();
@@ -291,7 +311,7 @@ describe("DocumentStorageBrowser", () => {
291
311
  it("renders new folder modal markup when opened", async () => {
292
312
  listState.data = {files: [], folders: []};
293
313
  const {getByTestId, toJSON} = renderWithTheme(
294
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
314
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
295
315
  );
296
316
  await press(getByTestId("document-new-folder-button"));
297
317
  expect(toJSON()).toBeDefined();
@@ -301,10 +321,12 @@ describe("DocumentStorageBrowser", () => {
301
321
  Object.defineProperty(Platform, "OS", {configurable: true, value: "web"});
302
322
  listState.data = {files: [], folders: []};
303
323
  const {UNSAFE_getAllByType} = renderWithTheme(
304
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
324
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
305
325
  );
306
- const hostInputs = UNSAFE_getAllByType("input" as any);
307
- const fileInput = hostInputs.find((node: any) => node.props?.type === "file") as any;
326
+ const hostInputs = UNSAFE_getAllByType("input" as unknown as React.ComponentType);
327
+ const fileInput = hostInputs.find(
328
+ (node: ReactTestInstance) => node.props?.type === "file"
329
+ ) as ReactTestInstance;
308
330
  expect(fileInput).toBeDefined();
309
331
  const fakeFile = new File(["x"], "x.txt", {type: "text/plain"});
310
332
  await act(async () => {
@@ -312,17 +334,19 @@ describe("DocumentStorageBrowser", () => {
312
334
  await new Promise((r) => setTimeout(r, 30));
313
335
  });
314
336
  expect(uploadCalls.length).toBe(1);
315
- expect(uploadCalls[0].prefix).toBeUndefined();
337
+ expect((uploadCalls[0] as Record<string, unknown>).prefix).toBeUndefined();
316
338
  });
317
339
 
318
340
  it("ignores upload change when no file selected", async () => {
319
341
  Object.defineProperty(Platform, "OS", {configurable: true, value: "web"});
320
342
  listState.data = {files: [], folders: []};
321
343
  const {UNSAFE_getAllByType} = renderWithTheme(
322
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
344
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
323
345
  );
324
- const hostInputs = UNSAFE_getAllByType("input" as any);
325
- const fileInput = hostInputs.find((node: any) => node.props?.type === "file") as any;
346
+ const hostInputs = UNSAFE_getAllByType("input" as unknown as React.ComponentType);
347
+ const fileInput = hostInputs.find(
348
+ (node: ReactTestInstance) => node.props?.type === "file"
349
+ ) as ReactTestInstance;
326
350
  await act(async () => {
327
351
  fileInput.props.onChange({target: {files: []}});
328
352
  await new Promise((r) => setTimeout(r, 10));
@@ -337,10 +361,12 @@ describe("DocumentStorageBrowser", () => {
337
361
  throw new Error("upload failed");
338
362
  };
339
363
  const {UNSAFE_getAllByType} = renderWithTheme(
340
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
364
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
341
365
  );
342
- const hostInputs = UNSAFE_getAllByType("input" as any);
343
- const fileInput = hostInputs.find((node: any) => node.props?.type === "file") as any;
366
+ const hostInputs = UNSAFE_getAllByType("input" as unknown as React.ComponentType);
367
+ const fileInput = hostInputs.find(
368
+ (node: ReactTestInstance) => node.props?.type === "file"
369
+ ) as ReactTestInstance;
344
370
  const fakeFile = new File(["x"], "y.txt", {type: "text/plain"});
345
371
  await act(async () => {
346
372
  fileInput.props.onChange({target: {files: [fakeFile], value: ""}});
@@ -363,7 +389,7 @@ describe("DocumentStorageBrowser", () => {
363
389
  folders: ["sub-folder/"],
364
390
  };
365
391
  const {toJSON} = renderWithTheme(
366
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
392
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
367
393
  );
368
394
  expect(toJSON()).toBeDefined();
369
395
  });
@@ -392,7 +418,7 @@ describe("DocumentStorageBrowser", () => {
392
418
  folders: [],
393
419
  };
394
420
  const {toJSON} = renderWithTheme(
395
- <DocumentStorageBrowser api={{} as any} basePath="/documents" />
421
+ <DocumentStorageBrowser api={{} as unknown as AdminApi} basePath="/documents" />
396
422
  );
397
423
  expect(toJSON()).toBeDefined();
398
424
  });
@@ -1,11 +1,13 @@
1
+ // noExplicitAny: test mocks use UNSAFE_root traversal and mock.calls access for assertions
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 {act, fireEvent} from "../../ui/node_modules/@testing-library/react-native";
6
8
  import {LocaleContentEditor} from "./LocaleContentEditor";
7
9
 
8
- const press = async (el: any): Promise<void> => {
10
+ const press = async (el: ReactTestInstance): Promise<void> => {
9
11
  await act(async () => {
10
12
  fireEvent.press(el);
11
13
  await new Promise((r) => setTimeout(r, 150));
@@ -51,12 +53,14 @@ describe("LocaleContentEditor", () => {
51
53
 
52
54
  await press(getByText(/Remove /));
53
55
  expect(onChange).toHaveBeenCalled();
54
- 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"]);
55
59
  });
56
60
 
57
61
  it("falls back to empty object when value is not an object", () => {
58
62
  const {toJSON} = renderWithTheme(
59
- <LocaleContentEditor onChange={() => {}} value={null as any} />
63
+ <LocaleContentEditor onChange={() => {}} value={null as unknown as Record<string, string>} />
60
64
  );
61
65
  expect(toJSON()).toBeDefined();
62
66
  });
@@ -68,20 +72,23 @@ describe("LocaleContentEditor", () => {
68
72
  );
69
73
  // Find the SelectField and invoke its onChange prop directly.
70
74
  const selects = UNSAFE_root.findAll(
71
- (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)
72
77
  );
73
78
  expect(selects.length).toBeGreaterThan(0);
74
79
  await act(async () => {
75
- (selects[0] as any).props.onChange("en");
80
+ (selects[0] as ReactTestInstance).props.onChange("en");
76
81
  });
77
82
  // Find the Add Locale button (may be nested)
78
- 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");
79
84
  expect(addBtns.length).toBeGreaterThan(0);
80
85
  await act(async () => {
81
- (addBtns[0] as any).props.onClick?.();
86
+ (addBtns[0] as ReactTestInstance).props.onClick?.();
82
87
  });
83
88
  expect(onChange).toHaveBeenCalled();
84
- 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");
85
92
  expect(toJSON()).toBeDefined();
86
93
  });
87
94
 
@@ -91,14 +98,15 @@ describe("LocaleContentEditor", () => {
91
98
  <LocaleContentEditor onChange={onChange} value={{en: "Hi"}} />
92
99
  );
93
100
  const selects = UNSAFE_root.findAll(
94
- (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)
95
103
  );
96
104
  await act(async () => {
97
- (selects[0] as any).props.onChange("en");
105
+ (selects[0] as ReactTestInstance).props.onChange("en");
98
106
  });
99
- 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");
100
108
  await act(async () => {
101
- (addBtns[0] as any).props.onClick?.();
109
+ (addBtns[0] as ReactTestInstance).props.onClick?.();
102
110
  });
103
111
  // Should NOT have called onChange with an add because "en" already exists.
104
112
  expect(onChange).not.toHaveBeenCalled();
@@ -107,9 +115,9 @@ describe("LocaleContentEditor", () => {
107
115
  it("does not add when no new locale selected", async () => {
108
116
  const onChange = mock((_: Record<string, string>) => undefined);
109
117
  const {UNSAFE_root} = renderWithTheme(<LocaleContentEditor onChange={onChange} value={{}} />);
110
- 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");
111
119
  await act(async () => {
112
- (addBtns[0] as any).props.onClick?.();
120
+ (addBtns[0] as ReactTestInstance).props.onClick?.();
113
121
  });
114
122
  expect(onChange).not.toHaveBeenCalled();
115
123
  });
@@ -120,15 +128,16 @@ describe("LocaleContentEditor", () => {
120
128
  <LocaleContentEditor onChange={onChange} value={{en: "Hi", es: "Hola"}} />
121
129
  );
122
130
  const editors = UNSAFE_root.findAll(
123
- (n: any) =>
124
- 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-")
125
134
  );
126
135
  expect(editors.length).toBeGreaterThan(0);
127
136
  await act(async () => {
128
- (editors[0] as any).props.onChange("new content");
137
+ (editors[0] as ReactTestInstance).props.onChange("new content");
129
138
  });
130
139
  expect(onChange).toHaveBeenCalled();
131
- const arg = (onChange.mock.calls[0] as any)[0];
140
+ const arg = (onChange.mock.calls[0] as unknown[])[0] as Record<string, string>;
132
141
  expect(arg.en).toBe("new content");
133
142
  expect(arg.es).toBe("Hola");
134
143
  });
@@ -1,3 +1,4 @@
1
+ // noExplicitAny: test mocks use type-erased UI component stubs and field config literals
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";
@@ -21,8 +22,9 @@ mock.module("../LocaleContentEditor", () => ({
21
22
  }));
22
23
 
23
24
  import {AdminFieldRenderer} from "../AdminFieldRenderer";
25
+ import type {AdminApi, AdminFieldConfig} from "../types";
24
26
 
25
- const api = {} as any;
27
+ const api = {} as unknown as AdminApi;
26
28
  const base = {api, baseUrl: "/admin", onChange: () => {}};
27
29
 
28
30
  describe("AdminFieldRenderer", () => {
@@ -78,7 +80,7 @@ describe("AdminFieldRenderer", () => {
78
80
  const {toJSON} = renderWithTheme(
79
81
  <AdminFieldRenderer
80
82
  {...base}
81
- fieldConfig={fieldConfig as any}
83
+ fieldConfig={fieldConfig as unknown as AdminFieldConfig}
82
84
  fieldKey={fieldKey}
83
85
  value={value}
84
86
  />