Old-tab chunk recovery in the default configuration only had jsdom tests, and the old-asset test checked its own hosting fixture. A spec now serves two real builds: the old tab reloads once into the new one and not a second time. The fixture test and the acceptance row now say what they cover. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
2.3 KiB
TypeScript
51 lines
2.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { CACHE_POLICY, createReleaseFixture } from "./release-fixture.ts";
|
|
|
|
/**
|
|
* 11-05. A contract of the in-memory hosting model in `release-fixture.ts`
|
|
* against `config/hosting/cache-policy.json`: no product code, deploy script or
|
|
* browser runs here. Keeping old assets reachable is the hosting provider's
|
|
* job (`docs/operations/release-cache-rollback.md`). What an old tab does when
|
|
* an asset is gone anyway is checked in a real browser by
|
|
* `tests/e2e/old-tab-chunk-recovery.spec.ts`.
|
|
*/
|
|
describe("old hashed-asset reachability (hosting fixture contract)", () => {
|
|
it("keeps R10 hashed assets reachable after R11 becomes active", async () => {
|
|
const deployment = createReleaseFixture(["R10", "R11"]);
|
|
deployment.activate("R11");
|
|
|
|
expect(await deployment.fetch("/releases/R10/assets/app.aaaa.js"))
|
|
.toMatchObject({ status: 200 });
|
|
expect(await deployment.fetch("/assets/app.aaaa.js")).toMatchObject({
|
|
status: 200,
|
|
release: "R10",
|
|
});
|
|
});
|
|
|
|
it("serves distinct, never-overwritten hashed names per release", async () => {
|
|
const deployment = createReleaseFixture(["R10", "R11"]);
|
|
const old = await deployment.fetch("/assets/app.aaaa.js");
|
|
const current = await deployment.fetch("/assets/app.bbbb.js");
|
|
expect(old.body).toContain('"R10"');
|
|
expect(current.body).toContain('"R11"');
|
|
expect(old.headers["cache-control"]).toBe(CACHE_POLICY.surfaces.hashedAsset.cacheControl);
|
|
});
|
|
|
|
it("switches mutable surfaces to the active release only", async () => {
|
|
const deployment = createReleaseFixture(["R10", "R11"]);
|
|
deployment.activate("R11");
|
|
expect((await deployment.fetch("/")).release).toBe("R11");
|
|
expect((await deployment.fetch("/config.json")).release).toBe("R11");
|
|
expect((await deployment.fetch("/release-manifest.json")).release).toBe("R11");
|
|
expect((await deployment.fetch("/config.json")).headers["cache-control"]).toBe("no-store");
|
|
});
|
|
|
|
it("detects an unsafe deploy that removed old assets inside the rolling window", async () => {
|
|
const deployment = createReleaseFixture(["R10", "R11"]);
|
|
deployment.activate("R11");
|
|
deployment.retireAssets("R10");
|
|
expect(await deployment.fetch("/assets/app.aaaa.js")).toMatchObject({ status: 404 });
|
|
});
|
|
});
|