Public: anyone can read this; the crew can change it.
Full suite red: test/flow-alarm-drift.test.ts #12894
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/12883-full-suite-red-test-flow-alarm-drift-tes → main 2 commits fork
1 file
changed +20
−7
test/flow-alarm-drift.test.ts +20 −7
| @@ -114,12 +114,24 @@ test("read from git: landings past a pull's base, open pulls only", async () => | ||
| 114 | 114 | setIssueState(app.db, open.id, "closed"); |
| 115 | 115 | }); |
| 116 | 116 | |
| 117 | test("a rebased head stops counting; a merged pull never counts", async () => { | |
| 117 | /** | |
| 118 | * A repository `name` of user `username` with one open pull from `work`, as the drift tests below | |
| 119 | * start. | |
| 120 | */ | |
| 121 | async function pullFixture(username: string, name: string) { | |
| 118 | 122 | const ada = ok( |
| 119 | await createUser(app.db, { origin: "seed", trusted: true, username: "bo", email: "bo@forge.local", password: "a-good-passphrase" }), | |
| 123 | await createUser(app.db, { origin: "seed", trusted: true, username, email: `${username}@forge.local`, password: "a-good-passphrase" }), | |
| 120 | 124 | ); |
| 121 | const repo = ok(await createRepo(app.db, app.reposRoot, { ownerId: ada.id, name: "rb", visibility: "public" })); | |
| 125 | const repo = ok(await createRepo(app.db, app.reposRoot, { ownerId: ada.id, name, visibility: "public" })); | |
| 122 | 126 | const dir = repoDir(app.reposRoot, ada.username, repo.name); |
| 127 | ok(await commitToBranch(app, ada, repo, { message: "seed", files: [{ path: "a.txt", content: "a\n" }] })); | |
| 128 | ok(await commitToBranch(app, ada, repo, { message: "w", branch: "work", files: [{ path: "w.txt", content: "w\n" }] } as any)); | |
| 129 | const pull = ok(await createPull(app.db, dir, { repoId: repo.id, authorId: ada.id, title: "w", baseBranch: "main", headBranch: "work" })); | |
| 130 | return { dir, pull }; | |
| 131 | } | |
| 132 | ||
| 133 | test("a rebased head stops counting", async () => { | |
| 134 | const { dir, pull } = await pullFixture("bo", "rb"); | |
| 123 | 135 | const git = async (...args: string[]) => { |
| 124 | 136 | const p = Bun.spawn(["git", ...args], { |
| 125 | 137 | cwd: dir, |
| @@ -129,9 +141,6 @@ test("a rebased head stops counting; a merged pull never counts", async () => { | ||
| 129 | 141 | }); |
| 130 | 142 | return (await new Response(p.stdout).text()).trim(); |
| 131 | 143 | }; |
| 132 | ok(await commitToBranch(app, ada, repo, { message: "seed", files: [{ path: "a.txt", content: "a\n" }] })); | |
| 133 | ok(await commitToBranch(app, ada, repo, { message: "w", branch: "work", files: [{ path: "w.txt", content: "w\n" }] } as any)); | |
| 134 | const pull = ok(await createPull(app.db, dir, { repoId: repo.id, authorId: ada.id, title: "w", baseBranch: "main", headBranch: "work" })); | |
| 135 | 144 | await landMany(dir, 26, "g"); |
| 136 | 145 | expect((await alarmDrift(app, new Date())).fired).toBe(true); |
| 137 | 146 | // Merge main into the head and tell the pull, as a push does. |
| @@ -140,7 +149,11 @@ test("a rebased head stops counting; a merged pull never counts", async () => { | ||
| 140 | 149 | await git("update-ref", "refs/heads/work", merged); |
| 141 | 150 | app.db.query("UPDATE pull SET head_oid = ?1 WHERE issue_id = ?2").run(merged, pull.id); |
| 142 | 151 | expect((await alarmDrift(app, new Date())).fired).toBe(false); |
| 143 | // Behind again, but merged: never counts. | |
| 152 | setIssueState(app.db, pull.id, "closed"); | |
| 153 | }); | |
| 154 | ||
| 155 | test("a merged pull never counts", async () => { | |
| 156 | const { dir, pull } = await pullFixture("bp", "mg"); | |
| 144 | 157 | await landMany(dir, 26, "h"); |
| 145 | 158 | expect((await alarmDrift(app, new Date())).fired).toBe(true); |
| 146 | 159 | app.db.query("UPDATE pull SET merged_at = ?1 WHERE issue_id = ?2").run(new Date().toISOString(), pull.id); |
new above
offline