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 | /// <reference lib="dom" /> |
| 2 | // The DOM lib types the function this scenario runs in the page. |
| 3 | import { expect } from "e2e"; |
| 4 | |
| 5 | import { test, WEB } from "./t3.ts"; |
| 6 | |
| 7 | const FILE = "reports/100% #1? draft.md"; |
| 8 | |
| 9 | test( |
| 10 | "A relative Codex citation whose name has % # ? opens its file", |
| 11 | WEB, |
| 12 | async ({ t3, app, browser, screen }) => { |
| 13 | // The editor renders in a shadow root that locators do not reach. |
| 14 | const editorText = () => |
| 15 | browser.evaluate(() => { |
| 16 | for (const host of document.querySelectorAll("*")) { |
| 17 | const content = host.shadowRoot?.querySelector("[data-content]"); |
| 18 | if (content) return content.textContent ?? ""; |
| 19 | } |
| 20 | return null; |
| 21 | }); |
| 22 | |
| 23 | const project = await t3.project("demo", { [FILE]: "Title\nQuarterly draft body\n" }); |
| 24 | // User messages render Codex directives through the same Markdown pipeline as replies. |
| 25 | const thread = await t3.thread({ |
| 26 | project, |
| 27 | title: "Citation", |
| 28 | messages: [`See :codex-file-citation{path="${FILE}" line_range_start="2"}`], |
| 29 | }); |
| 30 | await t3.open(thread); |
| 31 | // A message sent through the CLI shows collapsed under its sender. |
| 32 | await screen.getByRole("button", /^Agent See/).tap(); |
| 33 | |
| 34 | const citation = screen.getByRole("link", /^100% #1\? draft\.md/); |
| 35 | await expect(citation).toBeVisible(); |
| 36 | await citation.tap(); |
| 37 | await expect.poll(editorText).toContain("Quarterly draft body"); |
| 38 | // The file opens at its workspace path, so the tree selects it and no `.` crumb appears. |
| 39 | await expect |
| 40 | .poll(() => |
| 41 | browser.evaluate((path) => { |
| 42 | for (const host of document.querySelectorAll("*")) { |
| 43 | const row = host.shadowRoot?.querySelector(`[data-item-path="${path}"]`); |
| 44 | if (row) return row.getAttribute("aria-selected"); |
| 45 | } |
| 46 | return null; |
| 47 | }, FILE), |
| 48 | ) |
| 49 | .toBe("true"); |
| 50 | const crumbs = await browser.evaluate(() => |
| 51 | [...document.querySelectorAll("[data-file-crumb]")].map((crumb) => crumb.textContent?.trim()), |
| 52 | ); |
| 53 | expect(crumbs).not.toContain("."); |
| 54 | await app.screenshot("citation-opened"); |
| 55 | }, |
| 56 | ); |