Skip to content

Commit 3080a68

Browse files
committed
test(app-shell): type the narrowed trigger calls; the installed-row double gains headers in its one stub
Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5e2d177 commit 3080a68

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

‎ui/packages/app-shell/src/views/RecordDetailView.headerApiInterpolation.test.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,11 @@ describe("RecordDetailView api handler — `{field}` target interpolation (objec
287287

288288
// Exactly one trigger goes out. The page's own reads after it (they share the
289289
// authenticated fetch) are not this handler's calls.
290-
const triggers = authFetchSpy.mock.calls.filter(([u]) => String(u).includes('/trigger'));
290+
const triggers = (authFetchSpy.mock.calls as unknown as Array<[string, RequestInit]>).filter(([u]) =>
291+
String(u).includes('/trigger'),
292+
);
291293
expect(triggers).toHaveLength(1);
292-
const [url, init] = triggers[0] as unknown as [string, RequestInit];
294+
const [url, init] = triggers[0];
293295
expect(url).toContain('/api/v1/automation/copy_plan_flow/trigger');
294296
const body = JSON.parse(String(init.body));
295297
expect(body.params).toEqual({ comment: 'hi' });

‎ui/packages/app-shell/src/views/studio-design/fetchInstalledPackageRow-7881.test.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ const MARKED = 'Publishing is temporarily unavailable. Nothing was changed.';
3131
function answer(response: { ok: boolean; status: number; json: () => Promise<unknown> }): void {
3232
vi.stubGlobal(
3333
'fetch',
34-
vi.fn(async () => response),
34+
// With the headers a real Response carries: the list read goes through the authenticated fetch.
35+
vi.fn(async () => ({ headers: new Headers(), ...response })),
3536
);
3637
}
3738
const listOk = (packages: unknown[]) =>
38-
answer({ headers: new Headers(), ok: true, status: 200, json: async () => ({ success: true, data: { packages, total: packages.length } }) });
39+
answer({ ok: true, status: 200, json: async () => ({ success: true, data: { packages, total: packages.length } }) });
3940
const listFailure = (status: number, error: Record<string, unknown>) =>
40-
answer({ headers: new Headers(), ok: false, status, json: async () => ({ success: false, error }) });
41+
answer({ ok: false, status, json: async () => ({ success: false, error }) });
4142

4243
/** The message the read throws with, for a failed answer. */
4344
async function thrownFor(status: number, error: Record<string, unknown>): Promise<string> {
@@ -78,7 +79,7 @@ describe('a failed read is not an empty result (objectui#7881)', () => {
7879

7980
it('a non-JSON error body names the status, not a JSON syntax error', async () => {
8081
answer({
81-
headers: new Headers(), ok: false,
82+
ok: false,
8283
status: 502,
8384
json: async () => {
8485
throw new SyntaxError("Unexpected token '<', \"<html>\"... is not valid JSON");
@@ -98,7 +99,7 @@ describe('a failed read is not an empty result (objectui#7881)', () => {
9899
});
99100

100101
it('CONTROL — the bare-array body the endpoint also serves reads the same', async () => {
101-
answer({ headers: new Headers(), ok: true, status: 200, json: async () => [{ manifest: { id: PACKAGE_ID, name: PACKAGE_ID } }] });
102+
answer({ ok: true, status: 200, json: async () => [{ manifest: { id: PACKAGE_ID, name: PACKAGE_ID } }] });
102103
await expect(fetchInstalledPackageRow(PACKAGE_ID)).resolves.toMatchObject({ manifest: { id: PACKAGE_ID } });
103104
});
104105
});

0 commit comments

Comments
 (0)