import { test, expect } from "@playwright/test"; // The downloads page has to be correct in BOTH states — with a snapshot // attached and without — because the tarball is a gitignored build artefact // that a fresh checkout does not have. The rule it must never break: no link // to a file that isn't there. test("says plainly that this is a snapshot, not a repository", async ({ page, }) => { await page.goto("/downloads/"); await expect(page.getByRole("heading", { level: 1 })).toContainText( "Downloads", ); await expect( page.getByText(/this is a snapshot, not a repository/i), ).toBeVisible(); await expect(page.getByText(/nothing to/i)).toBeVisible(); }); test("the download link and its facts agree, or there is no link at all", async ({ page, }) => { await page.goto("/downloads/"); const link = page.getByRole("link", { name: /archilyzer-source\.tar\.gz/i }); if ((await link.count()) === 0) { // No snapshot in this build: explain, don't link. await expect( page.getByText(/no source snapshot attached/i), ).toBeVisible(); return; } const href = await link.getAttribute("href"); expect(href).toBe("/downloads/archilyzer-source.tar.gz"); // The advertised file must actually be served. A stale sidecar beside a // missing tarball is the exact failure the loader is written to prevent. const res = await page.request.get(href!); expect(res.status()).toBe(200); // The sidecar's facts are rendered, not hardcoded: a checksum and a commit. await expect(page.getByText("SHA-256")).toBeVisible(); const sha = await page .locator("text=/^[0-9a-f]{64}$/") .first() .textContent(); expect(sha?.trim()).toMatch(/^[0-9a-f]{64}$/); }); test("names what the tarball does not contain", async ({ page }) => { await page.goto("/downloads/"); await expect(page.getByText(/The archive itself/)).toBeVisible(); await expect(page.getByText(/Any operator’s configuration/)).toBeVisible(); await expect(page.getByRole("heading", { name: "License" })).toBeVisible(); });