diff --git a/tests/integration/headplane/machines.test.ts b/tests/integration/headplane/machines.test.ts index 35308f5b..577bcb8e 100644 --- a/tests/integration/headplane/machines.test.ts +++ b/tests/integration/headplane/machines.test.ts @@ -26,7 +26,7 @@ describe("machines on a real tailnet", () => { }); function machine(form: Record) { - return app.call(machineAction as never, "/machines", { as: owner, form }); + return app.call(machineAction, "/machines", { as: owner, form }); } test("a waiting machine registered from its URL comes online for that user", async () => { @@ -110,7 +110,7 @@ describe("DNS on a real tailnet", () => { const node = await tailnet.node({ name: "dns-client", user: "alice@" }); const { cookie } = await app.signIn("owner"); - const result = await app.call(dnsAction as never, "/dns", { + const result = await app.call(dnsAction, "/dns", { as: cookie, form: { intent: "add_record", diff --git a/tests/support/app.ts b/tests/support/app.ts index e649df52..525e6ad4 100644 --- a/tests/support/app.ts +++ b/tests/support/app.ts @@ -21,7 +21,8 @@ export interface TestAppOptions { export type TestApp = Awaited>; -type RouteFunction = (args: LoaderFunctionArgs & ActionFunctionArgs) => unknown; +// Any loader or action, whatever its generated argument types. +type RouteFunction = (args: never) => unknown; export interface CallOptions { as?: string; @@ -120,7 +121,9 @@ export async function createTestApp(options: TestAppOptions = {}) { }; try { - return await fn(args as unknown as LoaderFunctionArgs & ActionFunctionArgs); + return await (fn as (args: LoaderFunctionArgs & ActionFunctionArgs) => unknown)( + args as unknown as LoaderFunctionArgs & ActionFunctionArgs, + ); } catch (error) { return error; } diff --git a/tests/unit/routes/auth-keys.test.ts b/tests/unit/routes/auth-keys.test.ts index db7043af..358b87c5 100644 --- a/tests/unit/routes/auth-keys.test.ts +++ b/tests/unit/routes/auth-keys.test.ts @@ -20,7 +20,7 @@ afterEach(async () => { }); function create(as: string, form: Record) { - return app.call(action as never, "/settings/auth-keys", { + return app.call(action, "/settings/auth-keys", { as, form: { intent: "create", expiry: "90", ...form }, }); @@ -90,7 +90,7 @@ describe("self-service auth keys", () => { await create(admin, { user_id: bob.id }); await create(admin, { tags: "tag:prod" }); - const data = (await app.call(loader as never, "/settings/auth-keys", { + const data = (await app.call(loader, "/settings/auth-keys", { as: await signInAsAlice(), })) as Awaited>; @@ -104,7 +104,7 @@ describe("self-service auth keys", () => { await create(cookie, { user_id: bob.id }); await create(cookie, { tags: "tag:prod" }); - const data = (await app.call(loader as never, "/settings/auth-keys", { + const data = (await app.call(loader, "/settings/auth-keys", { as: cookie, })) as Awaited>; diff --git a/tests/unit/routes/login.test.ts b/tests/unit/routes/login.test.ts index 214d19ea..0c99b3bc 100644 --- a/tests/unit/routes/login.test.ts +++ b/tests/unit/routes/login.test.ts @@ -6,7 +6,7 @@ import { HEADSCALE_VERSIONS } from "../../harness/versions"; import { createTestApp, type TestApp } from "../../support/app"; async function signIn(app: TestApp, form: Record) { - return app.call(action as never, "/login", { form }); + return app.call(action, "/login", { form }); } describe.for(HEADSCALE_VERSIONS)("API key sign-in on Headscale %s", (version) => { diff --git a/tests/unit/routes/permissions.test.ts b/tests/unit/routes/permissions.test.ts index 5dcd6af8..cc7bbf20 100644 --- a/tests/unit/routes/permissions.test.ts +++ b/tests/unit/routes/permissions.test.ts @@ -112,7 +112,7 @@ describe("route permissions", () => { }); function callAction(entry: Entry, as?: string) { - return app.call(entry.module.action! as never, entry.path, { + return app.call(entry.module.action!, entry.path, { as, form: { ...form, ...(entry.intent ? { intent: entry.intent } : {}) }, params: { id: form.node_id }, @@ -129,7 +129,7 @@ describe("route permissions", () => { async ([, entry]) => { const callers = MEMBER_VISIBLE.has(entry.file) ? [undefined] : [undefined, "member" as const]; for (const role of callers) { - const result = await app.call(entry.module.loader! as never, entry.path, { + const result = await app.call(entry.module.loader!, entry.path, { as: role && cookies.get(role), params: { id: form.node_id }, });