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

main
ts 55 lines 2.24 KB
Raw
1 import * as Playwright from "@alchemy.run/cloudflare-test-tools/e2e/Playwright";
2 import { expect, test } from "@playwright/test";
3
4 const SECRET = "s3cret-from-binding";
5
6 // Both modes run the shared contract. Live serves the adapter-emitted
7 // `dist/server/worker.js` under miniflare (asset-first, SSR on miss); dev is
8 // Octane's own Vite dev server (the plugin's in-process SSR middleware).
9 for (const mode of Playwright.SERVER_METHODS) {
10 test.describe(mode, () => {
11 const it = Playwright.make(mode);
12
13 it("server-renders the home page", async ({ page, server }) => {
14 const response = await page.goto(server.url.toString());
15 expect(response?.status()).toBe(200);
16 await expect(page.getByTestId("page-marker")).toHaveText("OCTANE_FIXTURE");
17 });
18
19 it("hydrates the client-interactive counter", async ({ page, server }) => {
20 await page.goto(server.url.toString());
21 await expect(page.locator("#count")).toHaveText("count:0");
22 // wait for hydration before interacting (useEffect flips the marker)
23 await expect(page.locator("#increment")).toHaveAttribute("data-hydrated", "true");
24 await page.click("#increment");
25 await expect(page.locator("#count")).toHaveText("count:1");
26 await page.click("#increment");
27 await expect(page.locator("#count")).toHaveText("count:2");
28 });
29
30 it("serves static assets asset-first", async ({ server }) => {
31 const response = await server.fetch("/robots.txt");
32 expect(response.status).toBe(200);
33 expect(await response.text()).toContain("User-agent: *");
34 });
35
36 it("runs the server route", async ({ server }) => {
37 const body = await server.fetchJson<{
38 marker: string;
39 secret: string | null;
40 hasWaitUntil: boolean;
41 }>("/api/hello");
42 expect(body.marker).toBe("api-route-ok");
43 if (mode === "live") {
44 // `context.platform` is the adapter-forwarded `{ env, ctx }`.
45 expect(body.secret).toBe(SECRET);
46 expect(body.hasWaitUntil).toBe(true);
47 } else {
48 // Octane's dev middleware supplies no platform (upstream
49 // limitation) — the handler degrades to null/false.
50 expect(body.secret).toBeNull();
51 expect(body.hasWaitUntil).toBe(false);
52 }
53 });
54 });
55 }