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
| 1 | import { expect } from "e2e"; |
| 2 | |
| 3 | import { T3_HOME } from "../e2e.config.ts"; |
| 4 | import { SECOND_HOME, startSecondServer } from "./second-server.ts"; |
| 5 | import { makeState, runPromise, test, WEB } from "./t3.ts"; |
| 6 | |
| 7 | test( |
| 8 | "Removing an environment closes the in-app notifications it raised", |
| 9 | WEB, |
| 10 | async ({ t3, app, screen, browser }) => { |
| 11 | const project = await t3.project("demo"); |
| 12 | const primaryThread = await t3.thread({ |
| 13 | project, |
| 14 | title: "Finished here", |
| 15 | messages: ["first"], |
| 16 | }); |
| 17 | const primary = makeState(T3_HOME); |
| 18 | const second = makeState(SECOND_HOME); |
| 19 | const server = startSecondServer(app.baseUrl ?? ""); |
| 20 | try { |
| 21 | const { host, token } = await server.ready; |
| 22 | const project = await second.state.project("remote-demo"); |
| 23 | const thread = await second.state.thread({ |
| 24 | project, |
| 25 | title: "Finished elsewhere", |
| 26 | messages: ["first"], |
| 27 | }); |
| 28 | |
| 29 | await t3.open("/settings/general"); |
| 30 | await screen.getByRole("switch", "In-app notifications").check(); |
| 31 | await app.open("/settings/connections"); |
| 32 | await screen.getByRole("button", "Add environment").tap(); |
| 33 | const dialog = screen.getByRole("dialog"); |
| 34 | await dialog.getByPlaceholder("backend.example.com").fill(host); |
| 35 | await dialog.getByPlaceholder("PAIRCODE").fill(token); |
| 36 | await dialog.getByRole("button", "Add environment").tap(); |
| 37 | const moreActions = screen.getByRole("button", "More actions for Scenario"); |
| 38 | await expect(moreActions).toBeVisible({ timeout: 60_000 }); |
| 39 | |
| 40 | // The client announces only a change it saw happen, so it must hold the thread first. |
| 41 | await expect(screen.getByText("Finished elsewhere").first()).toBeVisible({ timeout: 60_000 }); |
| 42 | await runPromise( |
| 43 | primary.cli(["thread", "send", primaryThread.threadId, "second", "--wait", "--json"]), |
| 44 | ); |
| 45 | const primaryToast = browser.locator( |
| 46 | '[data-slot="toast-description"]:has-text("Finished here")', |
| 47 | ); |
| 48 | await expect(primaryToast).toBeVisible({ timeout: 60_000 }); |
| 49 | await primaryToast.hover(); |
| 50 | await runPromise( |
| 51 | second.cli(["thread", "send", thread.threadId, "second", "--wait", "--json"]), |
| 52 | ); |
| 53 | const toast = browser.locator( |
| 54 | '[data-slot="toast-description"]:has-text("Finished elsewhere")', |
| 55 | ); |
| 56 | await expect(toast).toBeVisible({ timeout: 60_000 }); |
| 57 | |
| 58 | // A hovered toast does not time out. The removal goes by keyboard so the pointer stays. |
| 59 | await toast.hover(); |
| 60 | await moreActions.press("Enter"); |
| 61 | await screen.getByRole("menuitem", "Remove from this device…").press("Enter"); |
| 62 | await expect(toast).toBeVisible(); |
| 63 | await screen.getByRole("button", "Confirm").press("Enter"); |
| 64 | try { |
| 65 | await expect(toast).toBeHidden(); |
| 66 | // Both timers pause together; an older surviving toast rules out auto-dismissal. |
| 67 | await expect(primaryToast).toBeVisible(); |
| 68 | } finally { |
| 69 | await app.screenshot("after-removal"); |
| 70 | } |
| 71 | await expect(moreActions).toBeHidden({ timeout: 30_000 }); |
| 72 | } finally { |
| 73 | await server.stop(); |
| 74 | } |
| 75 | }, |
| 76 | ); |