Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

failed-commit-keeps-excluded-files.e2e.ts

51 lines2.3 KB

1import { expect } from "e2e";
2import * as Effect from "effect/Effect";
3import * as FileSystem from "effect/FileSystem";
4​
5import { run } from "./shell.ts";
6import { runPromise, test, WEB } from "./t3.ts";
7​
8test(
9 "A failed partial commit keeps excluded files out of the retry",
10 WEB,
11 async ({ t3, app, screen }) => {
12 const project = await t3.project("demo");
13 const thread = await t3.thread({ project, title: "Partial commit", messages: ["Start"] });
14​
15 await runPromise(
16 Effect.gen(function* () {
17 const fs = yield* FileSystem.FileSystem;
18 const hook = `${project}/.git/hooks/pre-commit`;
19 yield* fs.writeFileString(hook, "#!/bin/sh\necho 'Commit rejected by hook' >&2\nexit 1\n");
20 yield* fs.chmod(hook, 0o755);
21 yield* run("git", ["config", "core.hooksPath", ".git/hooks"], { cwd: project });
22 yield* run("git", ["config", "user.name", "Scenario"], { cwd: project });
23 yield* run("git", ["config", "user.email", "scenario@example.invalid"], { cwd: project });
24 yield* fs.writeFileString(`${project}/include.txt`, "Include this change\n");
25 yield* fs.writeFileString(`${project}/later.txt`, "Save this change for later\n");
26 }),
27 );
28​
29 await t3.open(thread);
30 const openCommit = async () => {
31 await screen.getByRole("button", "Git action options").tap();
32 await screen.getByRole("menuitem", "Commit", { exact: true }).tap();
33 await screen.getByRole("button", "Open later.txt in editor").waitFor();
34 };
35 const laterFile = screen.getByRole("button", "Open later.txt in editor");
36 await openCommit();
37 await screen.getByRole("button", "Edit", { exact: true }).tap();
38 await screen.getByRole("checkbox", "Include later.txt").tap();
39 await laterFile.getByText("Excluded", { exact: true }).waitFor();
40 await screen.getByPlaceholder("Leave empty to auto-generate").fill("Commit the first change");
41 await screen.getByRole("button", "Commit", { exact: true }).tap();
42 const failure = screen.getByText("Action failed", { exact: true });
43 await failure.waitFor();
44 await screen.getByRole("button", "Dismiss notification", { exact: true }).tap();
45 await failure.waitFor({ state: "detached" });
46​
47 await openCommit();
48 await app.screenshot("file-selection-after-failed-commit");
49 await expect(laterFile).toHaveText(/Excluded/);
50 },
51);