subpath feature

This commit is contained in:
Lucas Winther
2026-07-10 10:13:37 +02:00
parent 2d668b3fb8
commit 076efc2101
11 changed files with 32 additions and 31 deletions
+4 -4
View File
@@ -69,7 +69,7 @@ describe("fetchAuthStatus (fail-silent /me)", () => {
const { fetch, calls } = mockFetch(jsonResponse(200, { user: USER }));
expect(await fetchAuthStatus(fetch)).toEqual({ enabled: true, user: USER });
// The cookie is HttpOnly — it must ride along via same-origin credentials.
expect(calls[0]?.input).toBe("/api/auth/me");
expect(calls[0]?.input).toBe("api/auth/me");
expect(calls[0]?.init?.credentials).toBe("same-origin");
});
@@ -105,7 +105,7 @@ describe("login", () => {
expect(await login("alice", "hunter22", fetch)).toEqual(USER);
const call = calls[0];
expect(call?.input).toBe("/api/auth/login");
expect(call?.input).toBe("api/auth/login");
expect(call?.init?.method).toBe("POST");
expect(call?.init?.credentials).toBe("same-origin");
expect(
@@ -145,7 +145,7 @@ describe("register", () => {
test("returns the user on 201", async () => {
const { fetch, calls } = mockFetch(jsonResponse(201, { user: USER }));
expect(await register("alice", "hunter22", fetch)).toEqual(USER);
expect(calls[0]?.input).toBe("/api/auth/register");
expect(calls[0]?.input).toBe("api/auth/register");
});
test("surfaces {error} on 409 (username taken)", async () => {
@@ -172,7 +172,7 @@ describe("logout", () => {
test("POSTs to /api/auth/logout with credentials", async () => {
const { fetch, calls } = mockFetch(new Response(null, { status: 204 }));
await logout(fetch);
expect(calls[0]?.input).toBe("/api/auth/logout");
expect(calls[0]?.input).toBe("api/auth/logout");
expect(calls[0]?.init?.method).toBe("POST");
expect(calls[0]?.init?.credentials).toBe("same-origin");
});
+5 -5
View File
@@ -11,15 +11,15 @@ describe("precachePathsFromOutputs", () => {
expect(
precachePathsFromOutputs(
["index.html", "chunk-abc123.js", "chunk-abc123.js.map", "./index-def456.css"],
["/inference.worker.js"],
["inference.worker.js"],
),
).toEqual(["/", "/chunk-abc123.js", "/index-def456.css", "/inference.worker.js"]);
).toEqual(["./", "chunk-abc123.js", "index-def456.css", "inference.worker.js"]);
});
test("deduplicates and sorts", () => {
expect(precachePathsFromOutputs(["a.js", "a.js"], ["/a.js", "/"])).toEqual([
"/",
"/a.js",
expect(precachePathsFromOutputs(["a.js", "a.js"], ["a.js", "./"])).toEqual([
"./",
"a.js",
]);
});
});