@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 07:15 UTC

main
ts 56 lines 2.49 KB
Raw
1 import * as Playwright from "@alchemy.run/cloudflare-test-tools/e2e/Playwright";
2 import { expect, test } from "@playwright/test";
3
4 for (const mode of Playwright.SERVER_METHODS) {
5 test.describe(mode, () => {
6 const it = Playwright.make(mode);
7
8 it("SSRs the homepage with the docs sidebar", async ({ page, server }) => {
9 const response = await page.goto(server.url.toString());
10 expect(response?.status()).toBe(200);
11 await expect(page.getByRole("heading", { name: "Vocs Fixture Home" })).toBeVisible();
12 await expect(page.getByTestId("home-marker")).toHaveText("HOME_MARKER");
13 // The docs shell (sidebar) is rendered by the worker at request time.
14 const sidebar = page.getByRole("complementary");
15 await expect(sidebar.getByRole("link", { name: "Guide" })).toBeVisible();
16 await expect(sidebar.getByRole("link", { name: "Counter" })).toBeVisible();
17 });
18
19 it("navigates to a second page from the sidebar", async ({ page, server }) => {
20 await page.goto(server.url.toString());
21 await page.getByRole("complementary").getByRole("link", { name: "Guide" }).click();
22 await page.waitForURL("**/guide");
23 await expect(page.getByTestId("guide-marker")).toHaveText("GUIDE_MARKER");
24 });
25
26 it("hydrates the custom MDX React component", async ({ page, server }) => {
27 await page.goto(new URL("/counter", server.url).toString());
28 await expect(page.getByTestId("counter-page-marker")).toHaveText("COUNTER_PAGE_MARKER");
29 const counter = page.getByTestId("counter");
30 await expect(counter).toHaveText("count: 0");
31 // The first click can land before hydration attaches the listener;
32 // retry until the click observably increments.
33 await expect(async () => {
34 await counter.click();
35 await expect(counter).toHaveText(/count: [1-9]\d*/, { timeout: 500 });
36 }).toPass();
37 });
38
39 it("serves the static asset", async ({ server }) => {
40 const response = await server.fetch("/hello.txt");
41 expect(response.status).toBe(200);
42 expect(await response.text()).toContain("hello from public/");
43 });
44 });
45 }
46
47 // Build-time artifacts only exist in the production build: vocs prerenders
48 // llms.txt / llms-full.txt into dist/public, served by the assets layer.
49 test.describe("live artifacts", () => {
50 const it = Playwright.make("live");
51
52 it("serves the generated llms.txt from assets", async ({ server }) => {
53 const response = await server.fetch("/llms.txt");
54 expect(response.status).toBe(200);
55 });
56 });