The best way to control Claude Code, Codex and more from any computer or phone

main
ts 69 lines 2.72 KB
Raw
1 /// <reference lib="dom" />
2 import { expect } from "e2e";
3 import * as Effect from "effect/Effect";
4 import * as FileSystem from "effect/FileSystem";
5
6 import { run } from "./shell.ts";
7 import { runPromise, test, WEB } from "./t3.ts";
8
9 test(
10 "A failed commit message stays in the repository it was written for",
11 WEB,
12 async ({ t3, app, browser, screen }) => {
13 const first = await t3.project("first-repository");
14 const second = await t3.project("second-repository");
15 const firstThread = await t3.thread({
16 project: first,
17 title: "First checkout",
18 messages: ["First"],
19 });
20 await t3.thread({ project: second, title: "Second checkout", messages: ["Second"] });
21
22 await runPromise(
23 Effect.gen(function* () {
24 const fs = yield* FileSystem.FileSystem;
25 const hook = `${first}/.git/hooks/pre-commit`;
26 yield* fs.writeFileString(
27 hook,
28 "#!/bin/sh\necho 'Scenario hook rejected the commit' >&2\nexit 1\n",
29 );
30 yield* fs.chmod(hook, 0o755);
31 yield* run("git", ["config", "core.hooksPath", ".git/hooks"], { cwd: first });
32 yield* run("git", ["config", "user.name", "Scenario"], { cwd: first });
33 yield* run("git", ["config", "user.email", "scenario@example.invalid"], { cwd: first });
34 yield* fs.writeFileString(`${first}/first.txt`, "A new change in the first repository\n");
35 yield* fs.writeFileString(
36 `${second}/second.txt`,
37 "A new change in the second repository\n",
38 );
39 }),
40 );
41
42 await browser.setViewport({ width: 1920, height: 1000 });
43 await t3.open(firstThread);
44 const openCommit = async (file: string) => {
45 await screen.getByRole("button", "Git action options").tap();
46 await screen.getByRole("menuitem", "Commit", { exact: true }).tap();
47 await screen.getByRole("button", `Open ${file} in editor`, { exact: true }).waitFor();
48 };
49 await openCommit("first.txt");
50 await screen
51 .getByPlaceholder("Leave empty to auto-generate")
52 .fill("Describe the first checkout");
53 await screen.getByRole("button", "Commit", { exact: true }).tap();
54 await screen.getByText("Action failed", { exact: true }).waitFor();
55
56 // Navigate in the running app so the shared thread view stays mounted.
57 await screen.getByRole("button", /^Second checkout(?:,|$)/).tap();
58 await openCommit("second.txt");
59 await app.screenshot("commit-message-in-second-repository");
60 const message = await browser.evaluate(
61 () =>
62 "" +
63 document.querySelector<HTMLTextAreaElement>(
64 'textarea[placeholder="Leave empty to auto-generate"]',
65 )?.value,
66 );
67 expect(message, "The second repository starts with a blank commit message").toBe("");
68 },
69 );