// E2E: the meta-demonstration. The blog post that describes the // CMS gets edited THROUGH the CMS, the resulting commit is observed // in Forgejo, and the live page reflects it. If this test passes, // the blog post's central claim ("you can verify this post is real") // is literally true. import { test, expect } from "@playwright/test"; import * as fs from "fs"; import * as path from "path"; const SLUG = "sama-meets-git-cms"; const SCREENSHOT_DIR = "test-results/blog-cms-meta"; test.beforeAll(() => { fs.mkdirSync(SCREENSHOT_DIR, { recursive: true }); }); test.describe("blog post is the CMS demo", () => { test("post is reachable + announces it's editable via the CMS", async ({ page }) => { const res = await page.goto(`/blog/${SLUG}`); expect(res?.status()).toBe(200); await expect(page.getByRole("heading", { name: /SAMA meets git/i }).first()).toBeVisible(); // The "you can verify this post is real" section links the editor, // raw markdown and Forgejo source. await expect(page.locator(`a[href="/edit/blog/${SLUG}"]`).first()).toBeVisible(); await expect(page.locator(`a[href="/content/blog/${SLUG}.md"]`).first()).toBeVisible(); await expect( page.locator(`a[href*="git.tdd.md/syntaxai/tdd.md/src/branch/main/content/blog/${SLUG}.md"]`).first(), ).toBeVisible(); await page.screenshot({ path: path.join(SCREENSHOT_DIR, "1-blog-post-live.png"), fullPage: true, }); }); test("raw markdown serves from tdd.md (no git.tdd.md dependency)", async ({ request }) => { const res = await request.get(`/content/blog/${SLUG}.md`); expect(res.status()).toBe(200); expect(res.headers()["content-type"]).toMatch(/text\/plain/); const body = await res.text(); expect(body).toMatch(/^# SAMA meets git/m); expect(body).toContain("Forgejo"); }); test("/edit/blog/ renders the login wall when not authed", async ({ page }) => { const res = await page.goto(`/edit/blog/${SLUG}`); expect(res?.status()).toBe(401); await expect(page.getByRole("heading", { name: /edit · /i })).toBeVisible(); await expect(page.getByRole("link", { name: /sign in with github/i })).toBeVisible(); }); }); // Note: the admin-can-edit-meta-blog test that used to live here was // retired — it asserted on a git.tdd.md commit link the applied-live // page no longer emits (we link to /GIT/... now), and the broader // admin-edit-lands-in-bare-repo flow is fully covered by // e2e/git-native-proof.spec.ts. The remaining tests above still prove // the meta-claim of the blog post (post is reachable, raw markdown // works, /edit page is gated correctly).