Public: anyone can read this; the crew can change it.

Full suite red: 2 files in check run 01m7xz5phbyvnpznpn06050y10 #15057

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/15049-full-suite-red-2-files-in-check-run-01m7 → main 3 commits fork 3 threads · 3 unresolved

  • Merged. scout/15049-full-suite-red-2-files-in-check-run-01m7 was merged into main as 82bde22.

Review

Sign in to review this change.
4 files changed +60 −58
test/helpers/tui-pull.ts added +29
@@ -0,0 +1,29 @@
1 /**
2 * A terminal session opened on one pull's screen, for the tests of what that
3 * screen offers to whom: the forge, the person, the repository, the number.
4 */
5 import type { App } from "../../src/app.ts";
6 import type { Repo } from "../../src/core/repos.ts";
7 import type { User } from "../../src/core/users.ts";
8 import { createForgeApp } from "../../src/tui/forge.ts";
9 import { pullScreen } from "../../src/tui/screens/pull.ts";
10 import { local } from "../../src/tui/screens/where.ts";
11 import { headlessTerminal } from "../../src/tui/term/terminal.ts";
12 import { settleApp } from "./tui.ts";
13
14 export async function openPullScreen(app: App, user: User, repo: Repo, number: number) {
15 const { app: tui, session } = createForgeApp(
16 app,
17 { sshUsername: user.username, remoteAddress: "127.0.0.1", fingerprint: "SHA256:t", user },
18 { terminal: headlessTerminal(160, 44), exitHooks: false },
19 );
20 tui.start();
21 tui.ctx.push(pullScreen(session, tui.ctx, local(session, repo), number));
22 await settleApp(tui);
23 const press = async (...keys: string[]) => {
24 for (const key of keys)
25 tui.dispatch({ type: "key", key, ctrl: false, alt: false, shift: false });
26 await settleApp(tui);
27 };
28 return { tui, press, text: () => tui.screen.toText() };
29 }
test/tui-pull-hold.test.ts +2 −26
@@ -15,12 +15,8 @@ import { createApp, type App } from "../src/app.ts";
1515 import { getHold, WHY_MAX } from "../src/core/holds.ts";
1616 import { getPull } from "../src/core/pulls.ts";
1717 import { createUser, getUserByName, type User } from "../src/core/users.ts";
18 import { createForgeApp } from "../src/tui/forge.ts";
19 import { pullScreen } from "../src/tui/screens/pull.ts";
20 import { local } from "../src/tui/screens/where.ts";
21 import { headlessTerminal } from "../src/tui/term/terminal.ts";
2218 import { quietLogs } from "./helpers/globals.ts";
23 import { settleApp } from "./helpers/tui.ts";
19 import { openPullScreen } from "./helpers/tui-pull.ts";
2420
2521 quietLogs();
2622
@@ -71,27 +67,7 @@ test("h holds with a reason, the header says held, h again releases; an agent ha
7167 const number = o.value.number;
7268 const pullId = getPull(app.db, repo.id, number)!.id;
7369
74 const open = async (user: User) => {
75 const { app: tui, session } = createForgeApp(
76 app,
77 {
78 sshUsername: user.username,
79 remoteAddress: "127.0.0.1",
80 fingerprint: "SHA256:t",
81 user,
82 },
83 { terminal: headlessTerminal(160, 44), exitHooks: false },
84 );
85 tui.start();
86 tui.ctx.push(pullScreen(session, tui.ctx, local(session, repo), number));
87 await settleApp(tui);
88 const press = async (...keys: string[]) => {
89 for (const key of keys)
90 tui.dispatch({ type: "key", key, ctrl: false, alt: false, shift: false });
91 await settleApp(tui);
92 };
93 return { tui, press, text: () => tui.screen.toText() };
94 };
70 const open = (user: User) => openPullScreen(app, user, repo, number);
9571
9672 const h = await open(alice);
9773 try {
test/tui-pull-slice.test.ts +27 −30
@@ -16,13 +16,9 @@ import { getRepoById, type Repo } from "../src/core/repos.ts";
1616 import { createUser, getUserByName, type User } from "../src/core/users.ts";
1717 import { resolveOid } from "../src/git/merge.ts";
1818 import { repoDir } from "../src/git/repos.ts";
19 import { createForgeApp } from "../src/tui/forge.ts";
20 import { pullScreen } from "../src/tui/screens/pull.ts";
21 import { local } from "../src/tui/screens/where.ts";
22 import { headlessTerminal } from "../src/tui/term/terminal.ts";
2319 import { quietLogs } from "./helpers/globals.ts";
24 import { settleApp } from "./helpers/tui.ts";
2520 import { promote } from "./helpers/members.ts";
21 import { openPullScreen } from "./helpers/tui-pull.ts";
2622
2723 quietLogs();
2824
@@ -62,18 +58,26 @@ async function commit(user: User, repo: Repo, branch: string, path: string): Pro
6258 return (await resolveOid(repoDir(app.reposRoot, repo.ownerName, repo.name), `refs/heads/${branch}`))!;
6359 }
6460
65 test("S is offered to a writer on an open fork pull, to no agent, reader or branch pull; a pick lands the slice", async () => {
66 const alice = await person("alice", true);
67 const bob = await person("bob");
61 let alice: User;
62 let bob: User;
63 let repo: Repo;
64 let mine: string[];
65 let number: number;
66 let ownNumber: number;
67
68 // The fixture is built once, outside any test's budget: both tests read it.
69 beforeAll(async () => {
70 alice = await person("alice", true);
71 bob = await person("bob");
6872 promote(app.db, bob);
6973 const r = await createRepo(app, alice, { name: "lib", visibility: "public" });
7074 if (!r.ok) throw new Error(String(r.error));
71 let repo = r.value;
75 repo = r.value;
7276 await commit(alice, repo, "main", "seed.md");
7377 const forked = await forkRepo(app, bob, repo);
7478 if (!forked.ok) throw new Error(String(forked.error));
7579 const fork = forked.value;
76 const mine = [await commit(bob, fork, "main", "x.md"), await commit(bob, fork, "main", "y.md")];
80 mine = [await commit(bob, fork, "main", "x.md"), await commit(bob, fork, "main", "y.md")];
7781 const fromFork = await openPull(app, bob, repo, {
7882 title: "Bob's work",
7983 body: "",
@@ -93,31 +97,20 @@ test("S is offered to a writer on an open fork pull, to no agent, reader or bran
9397 const agent = await createAgent(app, alice, { username: "bot" });
9498 if (!agent.ok) throw new Error(String(agent.error));
9599 repo = getRepoById(app.db, repo.id)!;
100 number = fromFork.value.number;
101 ownNumber = own.value.number;
102 }, 60_000);
96103
97 const open = async (user: User, number: number) => {
98 const { app: tui, session } = createForgeApp(
99 app,
100 { sshUsername: user.username, remoteAddress: "127.0.0.1", fingerprint: "SHA256:t", user },
101 { terminal: headlessTerminal(160, 44), exitHooks: false },
102 );
103 tui.start();
104 tui.ctx.push(pullScreen(session, tui.ctx, local(session, repo), number));
105 await settleApp(tui);
106 const press = async (...keys: string[]) => {
107 for (const key of keys)
108 tui.dispatch({ type: "key", key, ctrl: false, alt: false, shift: false });
109 await settleApp(tui);
110 };
111 return { tui, press, text: () => tui.screen.toText() };
112 };
113 const picker = (n: number) => `Land #${n} up to`;
114 const number = fromFork.value.number;
104 const open = (user: User, n: number) => openPullScreen(app, user, repo, n);
115105
106 const picker = (n: number) => `Land #${n} up to`;
107
108 test("S is offered to no agent, no author who cannot write here, and no branch pull", async () => {
116109 // Not an agent, not the author who cannot write here, not a branch of the repository.
outdated

Body of open() is indented one level too deep after the hoist. Re-indent it to match the module style.

117110 for (const [who, n] of [
118111 [getUserByName(app.db, "bot")!, number],
119112 [bob, number],
120 [alice, own.value.number],
113 [alice, ownNumber],
121114 ] as const) {
122115 const s = await open(who, n);
123116 try {
@@ -127,7 +120,11 @@ test("S is offered to a writer on an open fork pull, to no agent, reader or bran
127120 s.tui.stop();
128121 }
129122 }
123 });
130124
125 // Lands a slice into the repository shared through beforeAll: it must stay the
126 // last test in this file, or the tests after it read a changed main.
127 test("S is offered to a writer on an open fork pull; a pick lands the slice", async () => {
131128 const s = await open(alice, number);
132129 try {
133130 await s.press("S");
@@ -145,4 +142,4 @@ test("S is offered to a writer on an open fork pull, to no agent, reader or bran
145142 const parents = (await Bun.$`git -C ${dir} log -1 --format=%P ${tip}`.text()).trim().split(" ");
146143 expect(parents[1]).toBe(mine[0]!);
outdated

Stray blank line before the closing });. Remove it.

147144 expect(getPull(app.db, repo.id, number)!.mergedAt).toBeNull();
148 }, 60_000);
145 });
outdated

This test lands a slice into the repo shared through beforeAll. Add a one-line note that it depends on running last, so a reorder does not make it flaky.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs