Files
pleno-vue/tests/unit/release-verify-upload.spec.js
T

30 lines
1.1 KiB
JavaScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { containsVueAppRoot, verifyCachePolicy } from "../../scripts/release/verify-upload.mjs";
afterEach(() => {
vi.unstubAllEnvs();
});
describe("release upload app-shell verification", () => {
it("accepts the branded loader rendered inside the Vue app root", () => {
expect(containsVueAppRoot('<div class="loading-shell" id="app"><span>Loading</span></div>')).toBe(true);
});
it("accepts an empty Vue app root", () => {
expect(containsVueAppRoot('<div id="app"></div>')).toBe(true);
});
it("rejects a shell without the Vue app root", () => {
expect(containsVueAppRoot('<main id="application"></main>')).toBe(false);
});
it("keeps mutable release manifests out of immutable cache validation", () => {
vi.stubEnv("RELEASE_REQUIRE_CACHE_HEADERS", "true");
const response = new Response(null, { headers: { "Cache-Control": "no-cache, must-revalidate" } });
expect(() => verifyCachePolicy("release-manifest.json", response)).not.toThrow();
expect(() => verifyCachePolicy("assets/main-12345678.js", response)).toThrow("immutable caching");
});
});