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

When the included credit runs out mid-change, the app page and the pull say so and offer a way on #13806

Merged opened this in answer to

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

Merged

scout/forge:scout/13797-when-the-included-credit-runs-out-mid-ch → main 9 commits fork 3 threads · 3 unresolved

  • Merged. scout/13797-when-the-included-credit-runs-out-mid-ch was merged into main as a229cfa.

Review

Sign in to review this change.
10 files changed +189 −27
docs/features/land-as-is.md +15 −7
@@ -1,10 +1,18 @@
1 # Land it as it is
1 # Ship it as it is
22
3 When the crew cannot go on (its included credit is spent, or it has no model key) a green pull still goes live.
3 When the crew cannot go on, a green pull still goes live.
44
5 - The pull page and the app's page each say so in one sentence, and offer **Land it as it is** with the preview link beside it, and **Add a key**.
6 - The button is the pull's own ship action (`POST /:owner/:name/pulls/:n/ship`, same-origin checked, `mergePull` behind it). It is offered only for a pull whose check is green and whose verdict is "Ready to land"; a red pull never shows it.
7 - MCP: the existing `merge` tool takes `action: "land"` (squash, only while the check is green); its plan carries `crew` with the same sentence.
5 The crew cannot go on when its included credit is spent or it has no model key.
6
7 - The pull page and the app's page say why, in one sentence.
8 - Beside it: **Ship it as it is**, the preview link and **Add your key**.
9 - Only an admin sees **Add your key**. Anyone else is told only an admin can add one.
10 - The button is the pull's own ship action: `POST /:owner/:name/pulls/:n/ship`, same-origin checked, `mergePull` behind it.
11 - It shows only for a pull whose check is green. A red pull never shows it.
12 - It shows on a pull a reviewer asked changes of, for an admin only: nobody can answer the changes without credit.
13 - A repository that requires review keeps its rule, so there it does not show.
14 - A conflict, a mirror or a review still waited for never shows it.
15 - Before the credit runs out, the app page says "About one more change left".
16 - MCP: the `merge` tool takes `action: "land"` (squash, only while the check is green). Its plan carries `crew`, the same sentence.
17 - Terminal: the palette's "<owner>/<name> — Ship it as it is" (`src/tui/screens/landasis.ts`) while a pull waits. Enter ships the pull under the cursor, squashed. `landable` gives page, terminal and MCP the same rows.
818 - Code: `src/web/studio/land_as_is.ts`. Test: `test/land-as-is.test.ts`.
9 - Terminal: the palette's "<owner>/<name> — Land it as it is" (`src/tui/screens/landasis.ts`) while an open app has a pull to land; Enter lands the pull under the cursor, squashed, as the page's button does. `landable` gives the page, the terminal and MCP the same rows (a writer's, the crew stopped, the check green).
10 - Only an admin is shown **Add a key**; anyone else is told only the admin can.
src/http/mcp/tools/merge.ts +4 −3
@@ -5,7 +5,7 @@ import { checkSummary } from "../../../core/runs.ts";
55 import { canVerdict } from "../../../core/verdict.ts";
66 import { reviewWords } from "../../../actions/review_words.ts";
77 import { mergeFailure } from "../../../web/pages/pull.ts";
8 import { LAND_AS_IS, stalledWords } from "../../../web/studio/land_as_is.ts";
8 import { LAND_AS_IS, shipsPastReviews, stalledWords } from "../../../web/studio/land_as_is.ts";
99 import { good, bad, type Tool, REPO_ARG, repoArg, isAnswer } from "../shared.ts";
1010
1111 /**
@@ -16,7 +16,7 @@ import { good, bad, type Tool, REPO_ARG, repoArg, isAnswer } from "../shared.ts"
1616 */
1717 export const tool: Tool = {
1818 name: "merge",
19 doc: "`{ repo, number, strategy?, action?, dryRun? }` (a person, never an agent: a person merges): land a pull as its page's Merge button does, `merge` (default) or `squash`; `action: \"land\"` is the page's Land it as it is (squash, and only while the check is green); plans carry `crew` when the crew cannot go on; planned unless `dryRun` is false: the plan is the pull's `head`, `base`, `mergeable`, `conflicts` and `check` as `pull` reads them; landing is `mergePull`'s, with its refusals (conflict, review or check required, not a writer) in the page's words, and takes an rw token",
19 doc: "`{ repo, number, strategy?, action?, dryRun? }` (a person, never an agent: a person merges): land a pull as its page's Merge button does, `merge` (default) or `squash`; `action: \"land\"` is the page's Ship it as it is (squash, and only while the check is green); plans carry `crew` when the crew cannot go on; planned unless `dryRun` is false: the plan is the pull's `head`, `base`, `mergeable`, `conflicts` and `check` as `pull` reads them; landing is `mergePull`'s, with its refusals (conflict, review or check required, not a writer) in the page's words, and takes an rw token",
2020 description: "Land a pull, as its page's Merge button does; a person's only.",
2121 inputSchema: {
2222 type: "object",
@@ -73,7 +73,8 @@ export const tool: Tool = {
7373 }
7474 if (act === "land" && checkSummary(ctx.app.db, pull.id, pull.headOid).state !== "ok")
7575 return bad("check_required", `${LAND_AS_IS} waits for a green check`);
76 const merged = await mergePull(ctx.app, user, repo, pull, strategy);
76 const merged = await mergePull(ctx.app, user, repo, pull, strategy, undefined,
77 act === "land" && shipsPastReviews(ctx.app, repo, pull, user) ? { pastReviews: true } : {});
7778 if (!merged.ok) {
7879 const error = merged.error;
7980 const code =
src/tui/screens/landasis.ts +2 −2
@@ -9,7 +9,7 @@
99 import { mergePull } from "../../actions/pulls.ts";
1010 import type { Repo } from "../../core/repos.ts";
1111 import { mergeFailure } from "../../web/pages/pull.ts";
12 import { LAND_AS_IS, landable, stalledWords } from "../../web/studio/land_as_is.ts";
12 import { LAND_AS_IS, landable, shipsPastReviews, stalledWords } from "../../web/studio/land_as_is.ts";
1313 import type { Ctx, Screen } from "../app/app.ts";
1414 import { binding } from "../app/keys.ts";
1515 import type { Command } from "../app/palette.ts";
@@ -40,7 +40,7 @@ export function landScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
4040 const at = all[state.index];
4141 if (at === undefined || busy) return true;
4242 busy = true;
43 void mergePull(f.app, f.user, repo, at, "squash")
43 void mergePull(f.app, f.user, repo, at, "squash", undefined, shipsPastReviews(f.app, repo, at, f.user) ? { pastReviews: true } : {})
4444 .then((done) => ctx.toast(done.ok ? `Landed #${at.number} as it is.` : mergeFailure(done.error), done.ok ? undefined : "danger"))
4545 .finally(() => {
4646 busy = false;
src/web/pages/pull-verdict.ts +3
@@ -37,6 +37,8 @@ export interface Verdict {
3737 readonly tone: Tone | undefined;
3838 /** A fixed phrase of ours, never a person's text. */
3939 readonly words: string;
40 /** Set when a reviewer's asked-for changes hold the pull: callers read this, never the words. */
41 readonly kind?: "changes_requested";
4042 readonly action: { readonly label: string; readonly href: string } | null;
4143 }
4244
@@ -63,6 +65,7 @@ export function verdictOf(v: VerdictInput, thread: string, page = ""): Verdict {
6365 return {
6466 tone: "attn",
6567 words: v.changesRequested ? "A reviewer asked for changes" : "Waiting for a review",
68 ...(v.changesRequested ? { kind: "changes_requested" as const } : {}),
6669 action: { label: "Review", href: `${page}#review-body` },
6770 };
6871 if (v.teamsHolding > 0)
src/web/pages/pull.ts +2 −2
@@ -36,7 +36,7 @@ import { tierLine, type TierState } from "../../checks/tiers.ts";
3636 import { fromKeptFork } from "../../core/landing_kind.ts";
3737 import { combinedCard } from "./pull-combined.ts";
3838 import { verdictLine, verdictOf, type VerdictInput } from "./pull-verdict.ts";
39 import { landAsIs } from "../studio/land_as_is.ts";
39 import { landAsIs, shipsOn } from "../studio/land_as_is.ts";
4040 import { getAppByRepo } from "../../core/apps.ts";
4141 import { labelsFor, listLabels } from "../../core/issues.ts";
4242 import { marksByName } from "../../core/marks.ts";
@@ -1146,7 +1146,7 @@ export async function pullFilesPage(ctx: Ctx): Promise<Response> {
11461146 ${changeHead(ctx, repo, pull, { headOid: status.headOid, conflicts: status.conflicts.length })}
11471147 ${changeTabs(repo, pull, "files")}
11481148 ${verdictLine(verdict)}
1149 ${verdict.tone === "success" && mayMerge && check.state === "ok" && !stale
1149 ${shipsOn(verdict, ctx.app, repo, pull, ctx.auth.user) && mayMerge && check.state === "ok" && !stale
11501150 ? landAsIs(ctx, repo, pull)
11511151 : null}
11521152 <p class="files-where muted small" id="files">
src/web/studio/actions.ts +7 −1
@@ -11,6 +11,7 @@
1111 import type { Routed } from "../../crew/route.ts";
1212 import { COMPOSER_FIELDS, claimShare, refuseTell, releaseShare } from "../share_target.ts";
1313 import { mayView } from "../../core/sealed.ts";
14 import { shipsPastReviews } from "./land_as_is.ts";
1415 import { holdPull, releasePull } from "../../actions/holds.ts";
1516 import { addComment } from "../../actions/issues.ts";
1617 import { parseFrom } from "../../actions/tell_from.ts";
@@ -308,7 +309,12 @@ export async function shipSubmit(ctx: Ctx): Promise<Response> {
308309 return notFoundPage(ctx);
309310 // The inbox and the feed say where they were; the pull page does not.
310311 const back = backTo(form, changeHref(base, pull.number));
311 const merged = await mergePull(ctx.app, ctx.auth.user, repo, pull, "squash");
312 const merged = await mergePull(
313 ctx.app, ctx.auth.user, repo, pull, "squash", undefined,
314 // The crew cannot answer a reviewer's changes without credit: an admin's press lands the
315 // green change (#13797).
316 shipsPastReviews(ctx.app, repo, pull, ctx.auth.user) ? { pastReviews: true } : {},
outdated

Overrides a reviewer for any writer; restrict to the owner as the comment claims, and test it.

317 );
312318 // A conflict is never the person's to fix: the pull's agent brings the
313319 // branch up to date, and the pull comes back green, or lands on its own.
314320 if (
src/web/studio/change.ts +2 −2
@@ -68,7 +68,7 @@ import { previewBlock } from "../pages/apps.ts";
6868 import { filmstrip, filmstripJs } from "../pages/filmstrip.ts";
6969 import { lookCard } from "../pages/looks.ts";
7070 import { approveHereCard, keptChange, pullChecksLineFor, reachLine, teamsCard, verdictFacts } from "../pages/pull.ts";
71 import { landAsIs } from "./land_as_is.ts";
71 import { landAsIs, shipsOn } from "./land_as_is.ts";
7272 import { changeSummary, verdictLine, verdictOf } from "../pages/pull-verdict.ts";
7373 import { guestWalls, strangerCard } from "../pages/pull-guest.ts";
7474 import { combinedCard } from "../pages/pull-combined.ts";
@@ -807,7 +807,7 @@ async function changeConversation(
807807 )}
808808 <div id="pull-check">${checkLine}</div>
809809 ${when(runLine, (l) => l)} ${gate} ${decisionSection}
810 ${verdict.tone === "success" && writer && word === "look"
810 ${shipsOn(verdict, ctx.app, repo, pull, ctx.auth.user) && writer && word === "look"
811811 ? landAsIs(ctx, repo, pull)
812812 : null}
813813 ${when(visionPreview, (v) => visionPreviewCard(v))}
src/web/studio/crew_key.ts +11 −1
@@ -92,6 +92,16 @@ function payingCard(app: App, compact: boolean): Html | null {
9292 return html`<p class="small muted" id="crew-key-note" role="status">${icon("key")} ${OWN_KEY_NOTE}</p>`;
9393 }
9494
95 /** What one change costs at most, from what the host's credit paid for (#13797: $0.33 to $0.80). */
96 const CHANGE_USD = 0.8;
97
98 /** Said on the app page before the credit runs out: when about one more change is left. */
99 function runningLow(app: App): Html | null {
100 const credit = crewHasCredential(app.db) ? undefined : includedCredit(app);
101 if (credit === undefined || credit.leftUsd <= 0 || credit.leftUsd > CHANGE_USD) return null;
102 return html`<p class="small muted" id="crew-key-note" role="status">${icon("alert")} About one more change left on the included credit (${usdWords(credit.leftUsd)}). A key of your own keeps it building.</p>`;
103 }
104
95105 /** What the crew runs on, said once, with the field when a key would change anything (`compact`: a line and a link, no field). */
96106 export function crewKeyCard(ctx: Ctx, compact = false): Html | null {
97107 // Credit left is something to run on: the card never asks for a key then, in any form (#11508).
@@ -99,7 +109,7 @@ export function crewKeyCard(ctx: Ctx, compact = false): Html | null {
99109 const admin = ctx.auth.user?.isAdmin === true;
100110 // On a repository page: one line and a link, the field lives on the feed page.
101111 if (compact) {
102 if (crewCanRun(ctx.app)) return null;
112 if (crewCanRun(ctx.app)) return runningLow(ctx.app);
103113 return html`<p class="small muted" id="crew-key-note" role="status">${icon("alert")} The crew needs a model key to start.
104114 ${blockedWay(noKeyBlocked(ctx.app, ctx.auth.user))}</p>`;
105115 }
src/web/studio/land_as_is.ts +34 −4
@@ -15,7 +15,7 @@ import type { App } from "../../app.ts";
1515 import { requireWriter } from "../../actions/access.ts";
1616 import { getAppByRepo } from "../../core/apps.ts";
1717 import { listOpenPulls, type Pull } from "../../core/pulls.ts";
18 import type { Repo } from "../../core/repos.ts";
18 import { canAdmin, type Repo } from "../../core/repos.ts";
1919 import { checkSummary } from "../../core/runs.ts";
2020 import type { User } from "../../core/users.ts";
2121 import type { Ctx } from "../../http/context.ts";
@@ -26,7 +26,7 @@ import { crewCanRun, hasCrew, includedCredit } from "./crew_key.ts";
2626 import { changeHref } from "./nouns.ts";
2727
2828 /** The one label, on the page, in the terminal and in the MCP tool's `action`. */
29 export const LAND_AS_IS = "Land it as it is";
29 export const LAND_AS_IS = "Ship it as it is";
3030 export const ADD_KEY_HREF = "/settings/subscriptions";
3131
3232 /**
@@ -36,10 +36,40 @@ export const ADD_KEY_HREF = "/settings/subscriptions";
3636 export function stalledWords(app: App): string | null {
3737 if (!hasCrew(app) || crewCanRun(app)) return null;
3838 return includedCredit(app) !== undefined
39 ? "The crew cannot go on: the included credit is spent."
39 ? "The included credit is spent; this change is waiting."
4040 : "The crew cannot go on: it has no model key.";
4141 }
4242
43 /**
44 * Whether this person's press lands past a reviewer's verdict: they administer the repository,
45 * the crew is stopped so nobody can answer the changes asked (#13797), and the check is green.
46 * A repository that requires review keeps it.
47 */
48 export function shipsPastReviews(app: App, repo: Repo, pull: Pull, user: User | undefined): boolean {
49 return (
50 user !== undefined &&
51 canAdmin(app.db, repo, user) &&
outdated

Bypass applies to any writer; no owner check (finding 1). Also the requireReview rule is untested.

52 stalledWords(app) !== null &&
53 !pull.mergedAt &&
54 !repo.requireReview &&
55 checkSummary(app.db, pull.id, pull.headOid).state === "ok"
56 );
57 }
58
59 /**

Matches on display text; use the verdict's state, not its words (finding 2). Should also agree with shipsPastReviews (finding 3).

60 * Whether the verdict leaves the button on offer: ready to land, or held only by a reviewer's ask
61 * this person may land past. A conflict, a mirror or a review still waited for offers none.
62 */
63 export function shipsOn(
64 v: { readonly tone: string | undefined; readonly kind?: string },
65 app: App,
66 repo: Repo,
67 pull: Pull,
68 user: User | undefined,
69 ): boolean {
70 return v.tone === "success" || (v.kind === "changes_requested" && shipsPastReviews(app, repo, pull, user));
71 }
72
4373 /**
4474 * The open pulls of this repository the viewer may land as they are: a writer's, the crew
4575 * stopped, the check green.
@@ -59,7 +89,7 @@ const landForm = (repo: Repo, pull: Pull): Html =>
5989 /** Who may add a key gets the link; anyone else is told why there is none. */
6090 const keyOffer = (ctx: Ctx): Html =>
6191 ctx.auth.user?.isAdmin === true
62 ? btn("Add a key", { href: ADD_KEY_HREF, size: "sm" })
92 ? btn("Add your key", { href: ADD_KEY_HREF, size: "sm" })
6393 : html`<span class="muted small">${blockedWay(noKeyBlocked(ctx.app, ctx.auth.user))}</span>`;
6494
6595 /** The pull's own page: the sentence, the button, the preview beside it, the key. */
test/land-as-is.test.ts +109 −5
@@ -15,12 +15,14 @@ import { openPull } from "../src/actions/pulls.ts";
1515 import { commitToBranch, createRepo } from "../src/actions/repos.ts";
1616 import { getPull, type Pull } from "../src/core/pulls.ts";
1717 import type { Repo } from "../src/core/repos.ts";
18 import { submitReview } from "../src/core/reviews.ts";
1819 import { claimRun, createRun, finishRun } from "../src/core/runs.ts";
1920 import { createUser, type User } from "../src/core/users.ts";
2021 import { createToken } from "../src/core/tokens.ts";
2122 import { promote } from "./helpers/members.ts";
22 import { landable } from "../src/web/studio/land_as_is.ts";
23 import { landCommands } from "../src/tui/screens/landasis.ts";
23 import { landable, shipsPastReviews } from "../src/web/studio/land_as_is.ts";
24 import { landCommands, landScreen } from "../src/tui/screens/landasis.ts";
25 import { updateRepoSettings } from "../src/core/repos.ts";
2426 import { serve, type Servers } from "../src/http/server.ts";
2527 import { STRANGER_NEVER_SEES } from "../src/design/first_five_minutes.ts";
2628 import { LAND_AS_IS } from "../src/web/studio/land_as_is.ts";
@@ -142,7 +144,7 @@ describe("land it as it is", () => {
142144 test("credit runs out after a green pull: the sentence, the button, the preview and the key on both pages; pressing it lands", async () => {
143145 const pull = await pullWith("ok");
144146 spendCredit();
145 const sentence = "The crew cannot go on: the included credit is spent.";
147 const sentence = "The included credit is spent; this change is waiting.";
146148 for (const path of [`/alice/garden/pulls/${pull.number}`, `/alice/garden/pulls/${pull.number}/files`, "/alice/garden"]) {
147149 const page = await get(path);
148150 expect(page).toContain(sentence);
@@ -183,7 +185,7 @@ describe("land it as it is", () => {
183185 const rw = createToken(app.db, alice.id, "rw", "rw").token;
184186 const green = await pullWith("ok");
185187 const plan = await mcp(rw, { repo: "alice/garden", number: green.number, action: "land" });
186 expect(plan.value.crew).toBe("The crew cannot go on: the included credit is spent.");
188 expect(plan.value.crew).toBe("The included credit is spent; this change is waiting.");
187189 expect(getPull(app.db, repo.id, green.number)?.mergedAt).toBeNull();
188190 const landed = await mcp(rw, { repo: "alice/garden", number: green.number, action: "land", dryRun: false });
189191 expect(landed.value.strategy).toBe("squash");
@@ -200,7 +202,7 @@ describe("land it as it is", () => {
200202 const a = await pullWith("ok");
201203 const b = await pullWith("ok");
202204 const page = await get("/alice/garden");
203 expect(page.split("The crew cannot go on").length - 1).toBe(1);
205 expect(page.split("this change is waiting").length - 1).toBe(1);
204206 expect(page).toContain(`action="/alice/garden/pulls/${a.number}/ship"`);
205207 expect(page).toContain(`action="/alice/garden/pulls/${b.number}/ship"`);
206208 const rows = landable(app, alice, repo).map((p) => p.number);
@@ -235,4 +237,106 @@ describe("land it as it is", () => {
235237 // Signed out, nothing is offered.
236238 expect(landable(app, undefined, made.value)).toEqual([]);
237239 });
240
241 test("a reviewer asked for changes and the credit is spent: the page names the credit and both ways, and shipping lands it", async () => {
242 spendCredit();
243 const rev = await createUser(app.db, { origin: "seed", trusted: true, username: "rev", email: "[email protected]", password: "a-good-passphrase" });
244 if (!rev.ok) throw new Error(rev.error);
245 const pull = await pullWith("ok");
246 const asked = submitReview(app.db, { issueId: pull.id, authorId: rev.value.id, state: "changes_requested", commitOid: pull.headOid });
247 if (!asked.ok) throw new Error(asked.error);
248 for (const path of [`/alice/garden/pulls/${pull.number}`, `/alice/garden/pulls/${pull.number}/files`, "/alice/garden"]) {
249 const page = await get(path);
250 expect(page).toContain("The included credit is spent; this change is waiting.");
251 expect(page).toContain("Ship it as it is");
252 expect(page).toContain("Add your key");
253 }
254 const landed = await fetch(`${base}/alice/garden/pulls/${pull.number}/ship`, { method: "POST", headers: { cookie, origin: base }, redirect: "manual" });
255 expect(landed.status).toBe(303);
256 expect(getPull(app.db, repo.id, pull.number)?.mergedAt).not.toBeNull();
257 });
258
259 const askedChanges = async (): Promise<Pull> => {
260 let rev = getUserByName("rev");
261 const pull = await pullWith("ok");
262 const asked = submitReview(app.db, { issueId: pull.id, authorId: rev.id, state: "changes_requested", commitOid: pull.headOid });
263 if (!asked.ok) throw new Error(asked.error);
264 return pull;
265 };
266 const getUserByName = (name: string): User => app.db.query<any, [string]>("SELECT * FROM user WHERE username = ?1").get(name) as User;
267 const ship = (pull: Pull) =>
268 fetch(`${base}/alice/garden/pulls/${pull.number}/ship`, { method: "POST", headers: { cookie, origin: base }, redirect: "manual" });
269 const mergedAt = (pull: Pull) => getPull(app.db, repo.id, pull.number)?.mergedAt;
270
271 test("a repository that requires review keeps its rule: no card, and shipping does not land", async () => {
272 spendCredit();
273 const pull = await askedChanges();
274 updateRepoSettings(app.db, repo, { ...repo, requireReview: true });
275 try {
276 const live = { ...repo, requireReview: true };
277 expect(shipsPastReviews(app, live, pull, alice)).toBe(false);
278 expect(await get(`/alice/garden/pulls/${pull.number}`)).not.toContain("data-land-as-is");
279 await ship(pull);
280 expect(mergedAt(pull)).toBeNull();
281 } finally {
282 updateRepoSettings(app.db, repo, { ...repo, requireReview: false });
283 }
284 });
285
286 test("only an admin lands past a reviewer: a person who does not administer the repository is not let", async () => {
287 spendCredit();
288 const pull = await askedChanges();
289 expect(shipsPastReviews(app, repo, pull, alice)).toBe(true);
290 const bob = getUserByName("bob");
291 expect(shipsPastReviews(app, repo, pull, bob)).toBe(false);
292 expect(shipsPastReviews(app, repo, pull, undefined)).toBe(false);
293 const rw = createToken(app.db, bob.id, "bobrw", "rw").token;
294 const refused = await mcp(rw, { repo: "alice/garden", number: pull.number, action: "land", dryRun: false });
295 expect(refused.error).toBeDefined();
296 expect(mergedAt(pull)).toBeNull();
297 });
298
299 test("MCP land goes past a reviewer's ask for the admin", async () => {
300 spendCredit();
301 const pull = await askedChanges();
302 const rw = createToken(app.db, alice.id, "rw2", "rw").token;
303 const landed = await mcp(rw, { repo: "alice/garden", number: pull.number, action: "land", dryRun: false });
304 expect(landed.value?.strategy).toBe("squash");
305 expect(mergedAt(pull)).not.toBeNull();
306 });
307
308 test("a pull that conflicts is not offered the card", async () => {
309 spendCredit();
310 const pull = await pullWith("ok");
311 const moved = await commitToBranch(app, alice, repo, { branch: "main", message: "Clash", files: [{ path: `F${n}.md`, content: "other\n" }] });
312 if (!moved.ok) throw new Error(JSON.stringify(moved.error));
313 const page = await get(`/alice/garden/pulls/${pull.number}`);
314 expect(page).toContain("Conflicts with main");
315 expect(page).not.toContain("data-land-as-is");
316 });
317
318 test("the terminal lands a reviewer-held pull for the admin, under the same label", async () => {
319 spendCredit();
320 const pull = await askedChanges();
321 // The land runs detached and ends in a toast: wait on that, not on a timer.
322 let toasted!: () => void;
323 const landed = new Promise<void>((r) => (toasted = r));
324 const ctx = { push() {}, toast: () => toasted(), invalidate() {}, theme: {} } as any;
325 const screen = landScreen({ app, user: alice } as any, ctx, repo);
326 expect(screen.title).toContain(LAND_AS_IS);
327 expect(landable(app, alice, repo).map((p) => p.number)).toContain(pull.number);
328 // Rows are in listing order: move to the pull, then Enter.
329 const rows = landable(app, alice, repo);
330 for (let i = 0; i < rows.findIndex((p) => p.id === pull.id); i++) screen.key({ key: "j", ctrl: false, alt: false } as any);
331 screen.key({ key: "enter", ctrl: false, alt: false } as any);
332 await landed;
333 expect(mergedAt(pull)).not.toBeNull();
334 });
335
336 test("before the credit runs out the app page says about one more change is left", async () => {
337 writeFileSync(join(dataDir, "parent.json"), JSON.stringify({ credit: { token: "bearer-token-123", capUsd: 2, spentUsd: 1.5 } }));
338 expect(await get("/alice/garden")).toContain("About one more change left");
339 writeFileSync(join(dataDir, "parent.json"), JSON.stringify({ credit: { token: "bearer-token-123", capUsd: 2, spentUsd: 0.2 } }));
340 expect(await get("/alice/garden")).not.toContain("About one more change left");
341 });
238342 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs