@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 50 lines 2.01 KB
Raw
1 import { expect } from "e2e";
2 import * as Effect from "effect/Effect";
3 import * as FileSystem from "effect/FileSystem";
4
5 import { runPromise, test, WEB } from "./t3.ts";
6
7 test(
8 "Expanding visible diffs keeps a hidden test file folded",
9 WEB,
10 async ({ t3, app, screen }) => {
11 const project = await t3.project("demo", {
12 "notes.txt": "Old implementation notes\n",
13 "notes.test.ts": "const expected = 1;\n",
14 });
15 await runPromise(
16 Effect.gen(function* () {
17 const fs = yield* FileSystem.FileSystem;
18 yield* fs.writeFileString(`${project}/notes.txt`, "New implementation notes\n");
19 yield* fs.writeFileString(`${project}/notes.test.ts`, "const expected = 2;\n");
20 }),
21 );
22 const thread = await t3.thread({ project, title: "Diff folds", messages: ["first"] });
23
24 await t3.open(thread);
25 await screen.getByText("first fixture turn complete", { exact: false }).waitFor();
26 await screen.getByRole("button", "Toggle right panel").tap();
27 await screen.getByText("Diff").tap();
28
29 const fileToggle = (path: string, expanded: boolean) =>
30 screen.getByRole("button", `${expanded ? "Collapse" : "Expand"} ${path}`, { exact: true });
31 for (const path of ["notes.test.ts", "notes.txt"]) {
32 // Open each file once to load its patch before testing the saved folds.
33 await fileToggle(path, false).tap();
34 await fileToggle(path, true).tap();
35 await fileToggle(path, false).waitFor();
36 }
37
38 const filter = screen.getByRole("button", "Hide test files", { exact: true });
39 await filter.tap();
40 await fileToggle("notes.test.ts", false).waitFor({ state: "hidden" });
41 await screen.getByRole("button", "Expand all files", { exact: true }).tap();
42 await fileToggle("notes.txt", true).waitFor();
43 await filter.tap();
44
45 const testFile = screen.getByRole("button", /^(Collapse|Expand) notes\.test\.ts$/);
46 await testFile.waitFor();
47 await app.screenshot("test-file-shown-again");
48 await expect(testFile).toHaveAttribute("aria-expanded", "false");
49 },
50 );