import { expect, test, type Locator, type Route } from "@playwright/test"; import { AI_DOC_URL } from "../../common/lib/project"; // Release 16 slice DX, on the hub: no /use-with-ai page; the header's, the // footer's and Ask AI's "Use with AI" go to the homepage's AI and MCP doc // (AI_DOC_URL), in the same tab, as plain anchors — the same links a site has. async function fulfillJson(route: Route, body: unknown) { await route.fulfill({ status: 200, contentType: "application/json", headers: { "access-control-allow-origin": "*" }, body: JSON.stringify(body), }); } async function expectDocLink(link: Locator) { await expect(link).toHaveAttribute("href", AI_DOC_URL); await expect(link).not.toHaveAttribute("target", /./); } test.beforeEach(async ({ page }) => { // No members: the shelf stays empty and nothing reaches a real origin. await page.route("**/hub-sites.json", (r) => fulfillJson(r, [])); await page.route("**/hub-summary.json", (r) => r.fulfill({ status: 404, body: "" })); }); test("the hub's header and footer Use with AI go to the homepage doc", async ({ page }) => { await page.goto("/"); await expectDocLink( page.getByRole("banner").getByRole("link", { name: "Use with AI", exact: true }), ); await expectDocLink( page.getByRole("contentinfo").getByRole("link", { name: "Use with AI", exact: true }), ); }); test("the hub's Ask AI links Use with AI to the homepage doc", async ({ page }) => { await page.goto("/ask/"); await expectDocLink( page.getByRole("main").getByRole("link", { name: "Use with AI", exact: true }), ); }); test("the hub has no /use-with-ai page", async ({ page }) => { const res = await page.request.get("/use-with-ai/"); expect(res.status()).toBe(404); });