@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, 03:37 UTC

main
ts 48 lines 1.81 KB
Raw
1 import { expect } from "e2e";
2
3 import { test, WEB } from "./t3.ts";
4
5 test(
6 "Finishing a pairing link leaves a reopened Create link dialog open",
7 WEB,
8 async ({ t3, app, browser, screen }) => {
9 await t3.project("demo");
10 const pairingToken = "**/api/auth/pairing-token";
11 const requested = Promise.withResolvers<void>();
12 const release = Promise.withResolvers<void>();
13 await browser.route(pairingToken, async (route) => {
14 if (route.request.method !== "POST") return route.fallback();
15 requested.resolve();
16 await release.promise;
17 await route.continue();
18 });
19
20 await t3.open("/settings/access");
21 const authorizedClients = browser.locator("#authorized-clients");
22 const open = authorizedClients.getByRole("button", "Create link", { exact: true });
23 const dialog = screen.getByRole("dialog", "Create pairing link", { exact: true });
24 // A closing popup keeps its role until its exit animation ends; only an open one has data-open.
25 const openDialog = browser
26 .locator('[data-slot="dialog-popup"][data-open]')
27 .getByRole("heading", "Create pairing link", { exact: true });
28 const label = "Waiting tablet";
29 try {
30 await open.tap();
31 await dialog.getByPlaceholder("e.g. Living room iPad").fill(label);
32 await dialog.getByRole("button", "Create link", { exact: true }).tap();
33 await requested.promise;
34 await browser.keyboard.press("Escape");
35 await dialog.waitFor({ state: "hidden" });
36 await open.tap();
37 await openDialog.waitFor();
38
39 release.resolve();
40 await authorizedClients.getByText(label, { exact: true }).waitFor();
41 await app.screenshot("after-first-link-finishes");
42 await expect(openDialog).toBeVisible();
43 } finally {
44 release.resolve();
45 await browser.unroute(pairingToken);
46 }
47 },
48 );