The best way to control Claude Code, Codex and more from any computer or phone
| 1 | // @effect-diagnostics-next-line nodeBuiltinImport:off - one fixture page for the server's browser to load |
| 2 | import * as NodeHttp from "node:http"; |
| 3 | |
| 4 | import { expect } from "e2e"; |
| 5 | |
| 6 | import { test, WEB } from "./t3.ts"; |
| 7 | |
| 8 | // A page that renames itself on a click, with no navigation. |
| 9 | const PAGE = `<!doctype html> |
| 10 | <title>Original title</title> |
| 11 | <body style="margin:0;height:100vh" onpointerdown="document.title = 'Updated title'"> |
| 12 | Click to rename |
| 13 | </body>`; |
| 14 | |
| 15 | test( |
| 16 | "A Browser tab's label follows a title change that makes no navigation", |
| 17 | WEB, |
| 18 | async ({ t3, app, browser, screen }) => { |
| 19 | const server = NodeHttp.createServer((_request, response) => { |
| 20 | response.writeHead(200, { "content-type": "text/html" }); |
| 21 | response.end(PAGE); |
| 22 | }); |
| 23 | await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve)); |
| 24 | try { |
| 25 | const address = server.address(); |
| 26 | if (address === null || typeof address === "string") throw new Error("No page port."); |
| 27 | const project = await t3.project("demo"); |
| 28 | const thread = await t3.thread({ project, title: "Rename check", messages: ["first"] }); |
| 29 | await t3.open(thread); |
| 30 | |
| 31 | await screen.getByRole("button", "Toggle right panel").tap(); |
| 32 | await screen.getByRole("button", "Browser B").tap(); |
| 33 | await screen |
| 34 | .getByRole("textbox", "Search or enter URL") |
| 35 | .fill(`http://127.0.0.1:${address.port}/`); |
| 36 | await browser.keyboard.press("Enter"); |
| 37 | await expect(screen.getByText("Original title")).toBeVisible(); |
| 38 | |
| 39 | // The page draws on the canvas beside its input proxy. |
| 40 | await browser.locator('canvas:has(~ textarea[aria-label="Browser page"])').tap(); |
| 41 | await expect(screen.getByText("Updated title")).toBeVisible(); |
| 42 | await app.screenshot("after-title-change"); |
| 43 | } finally { |
| 44 | await new Promise((resolve) => server.close(resolve)); |
| 45 | } |
| 46 | }, |
| 47 | ); |