Public: anyone can read this; the crew can change it.
Full suite red: 2 files in check run 01m7xz5phbyvnpznpn06050y10 #15057
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15049-full-suite-red-2-files-in-check-run-01m7 → main 3 commits fork 3 threads · 3 unresolved
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-billing-links.test.ts +2 −2
| @@ -62,7 +62,7 @@ test("an admin reads the sizes, a bad address is refused, a good one is saved", | ||
| 62 | 62 | expect(h.text()).toContain("small"); |
| 63 | 63 | expect(h.text()).toContain("no link"); |
| 64 | 64 | await h.press("enter"); |
| 65 | for (const ch of "http://insecure.test") await h.press(ch); | |
| 65 | await h.press(..."http://insecure.test"); | |
| 66 | 66 | await h.press("enter"); |
| 67 | 67 | expect(h.text()).toContain("https address"); |
| 68 | 68 | expect(getBillingLinks(forge.db)).toEqual({}); |
| @@ -71,7 +71,7 @@ test("an admin reads the sizes, a bad address is refused, a good one is saved", | ||
| 71 | 71 | const again = boot("alice"); |
| 72 | 72 | await again.open(); |
| 73 | 73 | await again.press("j", "enter"); |
| 74 | for (const ch of "https://buy.test/medium") await again.press(ch); | |
| 74 | await again.press(..."https://buy.test/medium"); | |
| 75 | 75 | await again.press("enter"); |
| 76 | 76 | expect(getBillingLinks(forge.db)).toEqual({ medium: "https://buy.test/medium" }); |
| 77 | 77 | expect(again.text()).toContain("https://buy.test/medium"); |
test/tui-pull-hold.test.ts +2 −26
| @@ -15,12 +15,8 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 15 | 15 | import { getHold, WHY_MAX } from "../src/core/holds.ts"; |
| 16 | 16 | import { getPull } from "../src/core/pulls.ts"; |
| 17 | 17 | 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"; | |
| 22 | 18 | import { quietLogs } from "./helpers/globals.ts"; |
| 23 | import { settleApp } from "./helpers/tui.ts"; | |
| 19 | import { openPullScreen } from "./helpers/tui-pull.ts"; | |
| 24 | 20 | |
| 25 | 21 | quietLogs(); |
| 26 | 22 | |
| @@ -71,27 +67,7 @@ test("h holds with a reason, the header says held, h again releases; an agent ha | ||
| 71 | 67 | const number = o.value.number; |
| 72 | 68 | const pullId = getPull(app.db, repo.id, number)!.id; |
| 73 | 69 | |
| 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); | |
| 95 | 71 | |
| 96 | 72 | const h = await open(alice); |
| 97 | 73 | try { |
test/tui-pull-slice.test.ts +27 −30
| @@ -16,13 +16,9 @@ import { getRepoById, type Repo } from "../src/core/repos.ts"; | ||
| 16 | 16 | import { createUser, getUserByName, type User } from "../src/core/users.ts"; |
| 17 | 17 | import { resolveOid } from "../src/git/merge.ts"; |
| 18 | 18 | 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"; | |
| 23 | 19 | import { quietLogs } from "./helpers/globals.ts"; |
| 24 | import { settleApp } from "./helpers/tui.ts"; | |
| 25 | 20 | import { promote } from "./helpers/members.ts"; |
| 21 | import { openPullScreen } from "./helpers/tui-pull.ts"; | |
| 26 | 22 | |
| 27 | 23 | quietLogs(); |
| 28 | 24 | |
| @@ -62,18 +58,26 @@ async function commit(user: User, repo: Repo, branch: string, path: string): Pro | ||
| 62 | 58 | return (await resolveOid(repoDir(app.reposRoot, repo.ownerName, repo.name), `refs/heads/${branch}`))!; |
| 63 | 59 | } |
| 64 | 60 | |
| 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"); | |
| 68 | 72 | promote(app.db, bob); |
| 69 | 73 | const r = await createRepo(app, alice, { name: "lib", visibility: "public" }); |
| 70 | 74 | if (!r.ok) throw new Error(String(r.error)); |
| 71 | let repo = r.value; | |
| 75 | repo = r.value; | |
| 72 | 76 | await commit(alice, repo, "main", "seed.md"); |
| 73 | 77 | const forked = await forkRepo(app, bob, repo); |
| 74 | 78 | if (!forked.ok) throw new Error(String(forked.error)); |
| 75 | 79 | 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")]; | |
| 77 | 81 | const fromFork = await openPull(app, bob, repo, { |
| 78 | 82 | title: "Bob's work", |
| 79 | 83 | body: "", |
| @@ -93,31 +97,20 @@ test("S is offered to a writer on an open fork pull, to no agent, reader or bran | ||
| 93 | 97 | const agent = await createAgent(app, alice, { username: "bot" }); |
| 94 | 98 | if (!agent.ok) throw new Error(String(agent.error)); |
| 95 | 99 | repo = getRepoById(app.db, repo.id)!; |
| 100 | number = fromFork.value.number; | |
| 101 | ownNumber = own.value.number; | |
| 102 | }, 60_000); | |
| 96 | 103 | |
| 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); | |
| 115 | 105 | |
| 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 () => { | |
| 116 | 109 | // Not an agent, not the author who cannot write here, not a branch of the repository. |
| 117 | 110 | for (const [who, n] of [ |
| 118 | 111 | [getUserByName(app.db, "bot")!, number], |
| 119 | 112 | [bob, number], |
| 120 | [alice, own.value.number], | |
| 113 | [alice, ownNumber], | |
| 121 | 114 | ] as const) { |
| 122 | 115 | const s = await open(who, n); |
| 123 | 116 | try { |
| @@ -127,7 +120,11 @@ test("S is offered to a writer on an open fork pull, to no agent, reader or bran | ||
| 127 | 120 | s.tui.stop(); |
| 128 | 121 | } |
| 129 | 122 | } |
| 123 | }); | |
| 130 | 124 | |
| 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 () => { | |
| 131 | 128 | const s = await open(alice, number); |
| 132 | 129 | try { |
| 133 | 130 | 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 | ||
| 145 | 142 | const parents = (await Bun.$`git -C ${dir} log -1 --format=%P ${tip}`.text()).trim().split(" "); |
| 146 | 143 | expect(parents[1]).toBe(mine[0]!); |
outdated
Stray blank line before the closing |
||
| 147 | 144 | 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. |
new above
offline
Body of open() is indented one level too deep after the hoist. Re-indent it to match the module style.