The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { expect } from "e2e"; |
| 2 | import { test, WEB } from "./t3.ts"; |
| 3 | |
| 4 | test( |
| 5 | "Moving the caret onto /mod leaves editing keys with the text", |
| 6 | WEB, |
| 7 | async ({ t3, app, screen, browser }) => { |
| 8 | const project = await t3.project("demo"); |
| 9 | const thread = await t3.thread({ project, title: "Caret control", messages: ["Hello"] }); |
| 10 | await t3.open(thread); |
| 11 | const composer = screen.getByRole("textbox"); |
| 12 | |
| 13 | await composer.pressSequentially("/mod ab"); |
| 14 | await composer.press("ArrowLeft"); |
| 15 | await composer.press("ArrowLeft"); |
| 16 | await composer.press("ArrowLeft"); |
| 17 | await app.screenshot("caret-on-command"); |
| 18 | await composer.press("ArrowDown"); |
| 19 | await composer.pressSequentially("!"); |
| 20 | await expect(composer).toHaveText("/mod ab!"); |
| 21 | |
| 22 | await composer.press("ControlOrMeta+a"); |
| 23 | await composer.press("Backspace"); |
| 24 | await composer.pressSequentially("/mod ab"); |
| 25 | await composer.press("ArrowLeft"); |
| 26 | await composer.press("ArrowLeft"); |
| 27 | await composer.press("ArrowLeft"); |
| 28 | await expect(screen.getByRole("listbox")).toBeHidden(); |
| 29 | await composer.press("Shift+Enter"); |
| 30 | await composer.pressSequentially("next"); |
| 31 | await app.screenshot("shift-enter-with-closed-list"); |
| 32 | await expect(composer).toHaveText("/mod next ab"); |
| 33 | await expect(browser.locator('[role="textbox"] > p')).toHaveCount(2); |
| 34 | |
| 35 | // A typed trigger opens its list, but Shift+Enter still adds a line. |
| 36 | await composer.press("ControlOrMeta+a"); |
| 37 | await composer.press("Backspace"); |
| 38 | await composer.pressSequentially("hi @READ"); |
| 39 | await expect(screen.getByRole("option").first()).toBeVisible(); |
| 40 | await composer.press("Shift+Enter"); |
| 41 | await composer.pressSequentially("next"); |
| 42 | await app.screenshot("shift-enter-with-open-list"); |
| 43 | await expect(composer).toHaveText("hi @READ next"); |
| 44 | await expect(browser.locator('[role="textbox"] > p')).toHaveCount(2); |
| 45 | |
| 46 | for (const key of ["Enter", "Tab"]) { |
| 47 | await composer.press("ControlOrMeta+a"); |
| 48 | await composer.press("Backspace"); |
| 49 | await composer.pressSequentially("hi @READ"); |
| 50 | await expect(screen.getByRole("option").first()).toBeVisible(); |
| 51 | await composer.press(key); |
| 52 | await expect(screen.getByRole("listbox")).toBeHidden(); |
| 53 | await expect(composer).not.toContainText("@READ"); |
| 54 | } |
| 55 | |
| 56 | await composer.press("ControlOrMeta+a"); |
| 57 | await composer.press("Backspace"); |
| 58 | await composer.pressSequentially("hi /m"); |
| 59 | await expect(screen.getByRole("option").first()).toBeVisible(); |
| 60 | await composer.press("Escape"); |
| 61 | await composer.pressSequentially("o"); |
| 62 | await expect(screen.getByRole("listbox")).toBeHidden(); |
| 63 | await composer.press("ArrowLeft"); |
| 64 | await composer.press("ArrowRight"); |
| 65 | await composer.pressSequentially("d"); |
| 66 | await expect(screen.getByRole("listbox")).toBeHidden(); |
| 67 | await composer.press("Home"); |
| 68 | await composer.press("End"); |
| 69 | await expect(screen.getByRole("listbox")).toBeHidden(); |
| 70 | await composer.pressSequentially("e"); |
| 71 | await app.screenshot("escape-leave-return-edit"); |
| 72 | await expect(screen.getByRole("option").first()).toBeVisible(); |
| 73 | }, |
| 74 | ); |