@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 60 lines 2.22 KB
Raw
1 /// <reference lib="dom" />
2 import { expect } from "e2e";
3
4 import { test, WEB } from "./t3.ts";
5
6 test(
7 "Copying two items within a numbered list keeps their numbers",
8 WEB,
9 async ({ t3, app, browser, screen }) => {
10 const project = await t3.project("demo");
11 const thread = await t3.thread({
12 project,
13 title: "Steps",
14 messages: ["Steps:\n\n1. Install\n2. Configure\n3. Deploy\n\nThen report back."],
15 });
16 await t3.open(thread);
17 await screen.getByRole("button", /^Agent Steps/).tap();
18 await screen.getByText("Configure", { exact: true }).waitFor();
19
20 await browser.evaluate(() => {
21 const items = [...document.querySelectorAll("[data-user-message-body] ol > li")];
22 const start = items.find((item) => item.textContent === "Configure")?.firstChild;
23 const end = items.find((item) => item.textContent === "Deploy")?.firstChild;
24 if (!start || !end) throw new Error("Could not find the two list items");
25 const range = document.createRange();
26 range.setStart(start, 0);
27 range.setEnd(end, end.textContent?.length ?? 0);
28 const selection = window.getSelection();
29 selection?.removeAllRanges();
30 selection?.addRange(range);
31 return null;
32 });
33 await browser.keyboard.press("ControlOrMeta+C");
34 await screen.getByRole("textbox").tap();
35 await browser.keyboard.press("ControlOrMeta+V");
36
37 const numberedItems = await browser.evaluate(() => {
38 const list = document.querySelector<HTMLOListElement>('[role="textbox"] ol');
39 if (!list) return null;
40 return [...list.querySelectorAll(":scope > li")].map(
41 (item, index) => `${list.start + index}. ${item.textContent?.trim()}`,
42 );
43 });
44 await app.screenshot("pasted-list-items");
45 expect(numberedItems, "The pasted items keep their displayed list numbers").toEqual([
46 "2. Configure",
47 "3. Deploy",
48 ]);
49
50 const renderedItems = await browser.evaluate(() =>
51 [...document.querySelectorAll('[role="textbox"] ol > li')].map(
52 (item) => `${item.getAttribute("data-marker")} ${item.textContent?.trim()}`,
53 ),
54 );
55 expect(renderedItems, "The composer renders both pasted markers").toEqual([
56 "2. Configure",
57 "3. Deploy",
58 ]);
59 },
60 );