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

An app host's /__forge/ door lists the open pulls on the app with their check state, so you can jump to any preview #5988

Closed opened this
Closed without merging

scout/forge:scout/5984-an-app-host-s-forge-door-lists-the-open → main 7 commits fork 3 threads · 3 unresolved

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
8 files changed +323 −5
README.md +2
@@ -278,6 +278,8 @@ An app's repository home wears the pace on its app strip, the terminal's **Deplo
278278
279279 An app made from the template ships the same beacon as `static/beacon.js`, posting to `POST /__forge/measure` on the app's own host. The forge answers that door itself (`src/apps/measure.ts`), before the app is woken: same-origin only, 30 reports a minute per client and 600 per app (429), a body over the cap is a 413, and a private app or a sealed pull's preview refuses anyone its gate refuses. The app is the host's, never the body's. Production reports are kept in `app_vital` (`src/apps/vitals.ts`, TTFB, load, LCP, INP and CLS, a visitor hashed under the day's salt, no address, kept 90 days and removed with the app, at most 20,000 rows per app a day); previews store nothing. Only Do-Not-Track opts a visitor out on an app's host: the `forge_measure=off` cookie is set on the forge's host and never reaches an app's. Read the numbers (visitors today and over 7 days, p75 TTFB, load, LCP, INP and CLS) on the app's settings page under **Visitors and speed**, or as `vitals` in an admin's `GET /api/v1/repos/:owner/:name/app`. Both doors show them only to people who administer the repository (`appVisitors` in `src/actions/apps.ts`), so a reader or an anonymous caller sees no `vitals`. The page also draws p75 load for each of the last 30 days as a sparkline (server-rendered, no script); a day with no reports is a gap in the line, not a zero, and an app with none in 30 days says so in words. The same 30 values, oldest first with `null` for a silent day, are `vitals.loadDays` in the API. In the terminal all five are on the second line of the app's **Deploys** screen over ssh, and a third line there shows the 30 days as block characters with `·` for a silent day, then the range.
280280
281 An app's `/__forge/` door on its own host (production or a preview) lists up to five open pulls, newest first, each with its head's check as `green`, `red` or `running`, read as the pull's own verdict is (the newest run of each kind at the head: red if any failed, running if any is queued or running, green when all are ok); a head with no run, or a cancelled one, shows no check word. A pull whose preview is up links to the preview; any other links to its page on the forge. Only what the viewer may see is listed: a guest, or anyone who may not read the repository, gets none of a private repository's pulls, and a sealed pull shows only to who may see it (`src/apps/door_pulls.ts`). The terminal's **Deploys** screen (`d` on the repository) lists the same pulls under its title, numbered `1` to `5`: press the number to open that pull.
282
281283 The `app_vital` board source (`src/boards/sources.ts`) charts those reports: one row per app per day with `app` (the app's id), `day`, `load_p75`, `inp_p75` (ms) and `reports` (rows kept that day), the percentiles nearest-rank per app per day as `reach` does. `max` or `avg` over several days summarises daily percentiles, not the percentile of the whole range. Its rows belong to the app's repository, so a query sees only the repos in its scope. Today boards query with `repoIds: "all"` (`src/web/pages/boards.ts`) and only a site admin reaches them; no non-admin scope exists, so nothing yet applies the settings page's `canAdmin` gate per repository, and whoever builds one must. Days older than the 90-day trim are gone, not zero. The slug and the visitor hash are not columns. No dependency was added. Left out: a starting board for it; pick `app_vital` in the `/boards` source picker.
282284
283285 ## The board's notes
src/apps/door.ts +8 −1
@@ -5,6 +5,7 @@
55 */
66
77 import { createHash } from "node:crypto";
8 import { checkText, type DoorCheck } from "./door_pulls.ts";
89 import { escapeAttr, type PillWhere } from "./toolbar.ts";
910 import type { Served, Serving } from "./serving.ts";
1011
@@ -15,6 +16,8 @@ export type DoorFacts = {
1516 tell?: string;
1617 /** This host's own sign-in door, offered when nobody is signed in. */
outdated

Orphaned doc comment: this describes pulls, but it now sits above the timing field. Move it onto pulls (and drop timing if the Server-Timing work goes).

1718 signin?: string;
19 /** Open pulls the viewer may see, each with where to go. */
20 pulls?: { number: number; title: string; check: DoorCheck; href: string }[];
1821 /** What the host is serving, read from the deploy record. */
1922 serving?: Serving | undefined;
2023 /**
@@ -85,6 +88,10 @@ export function doorPage(facts: DoorFacts, head: boolean): Response {
8588 if (facts.tell !== undefined) links.push(link(facts.tell, "Tell the crew"));
8689 else if (facts.signin !== undefined)
8790 links.push(link(facts.signin, "Sign in to tell the crew"));
91 const pulls = (facts.pulls ?? []).map((p) =>
92 link(p.href, `#${p.number} ${p.title}${checkText(p.check)}`),
93 );
94 const open = pulls.length === 0 ? "" : `<h2>Open pulls</h2><ul>${pulls.join("")}</ul>`;
8895 const terminal =
8996 facts.ssh === undefined
9097 ? ""
@@ -93,7 +100,7 @@ export function doorPage(facts: DoorFacts, head: boolean): Response {
93100 : `<p>Terminal:</p><pre><code>${escapeAttr(facts.ssh)}</code></pre>`;
94101 const html = `<!doctype html>
95102 <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>${escapeAttr(where.app)}, ${escapeAttr(doorWhere(where))}</title><style>${STYLE}</style></head>
96 <body><main><h1>${escapeAttr(where.app)}</h1><p>${escapeAttr(doorWhere(where))}</p>${servingHtml(facts)}<ul>${links.join("")}</ul>${terminal}</main></body></html>
103 <body><main><h1>${escapeAttr(where.app)}</h1><p>${escapeAttr(doorWhere(where))}</p>${servingHtml(facts)}<ul>${links.join("")}</ul>${terminal}${open}</main></body></html>
97104 `;
98105 return new Response(head ? null : html, {
99106 headers: {
src/apps/door_pulls.ts added +85
@@ -0,0 +1,85 @@
1 /**
2 * The open pulls the app's door lists: up to five, newest first, each with
3 * the state of its head's check, read in one query. Only what the viewer
4 * may see: nothing for a repository they may not read (a stranger is never
5 * told a private pull exists), and no sealed pull unless it is theirs to see.
6 */
7
8 import type { Database } from "bun:sqlite";
9 import { canRead, type Repo } from "../core/repos.ts";
10 import { verdictForHead, type Run } from "../core/runs.ts";
11 import { sealedScope } from "../core/sealed.ts";
12 import { getUserById, isActive, type User } from "../core/users.ts";
13
14 export const DOOR_PULLS = 5;
15
16 export type DoorCheck = "green" | "red" | "running" | "none";
17
18 export type OpenPull = { number: number; title: string; check: DoorCheck };
19
20 interface Row {
21 id: string;
22 number: number;
23 title: string;
24 head: string | null;
25 }
outdated

With no run at the head, or a cancelled one, this falls through to running, so the door says check running when nothing is running. Map queued/running to running, and give no run and cancelled their own word, e.g. none. The test "no check yet" → "running" asserts the wrong thing and should change with this.

26
27 /**
28 * The head's verdict in a word, from the newest run of each kind (the
29 * forge's own `verdictForHead`): red if any failed, running if any is
30 * queued or running, green when every one is ok, else none (no run, or a
31 * cancelled one).
32 */
33 export function checkWord(runs: readonly Pick<Run, "state">[]): DoorCheck {
34 if (runs.some((r) => r.state === "failed")) return "red";
35 if (runs.some((r) => r.state === "queued" || r.state === "running")) return "running";
36 return runs.length > 0 && runs.every((r) => r.state === "ok") ? "green" : "none";
37 }
outdated

High (correctness): ORDER BY run.id DESC LIMIT 1 across both kinds means a later ok deploy hides a failed check at the same head. The door says green while the pull is red. Use verdictForHead: newest per kind and env, green only when all of them are ok.

38
39 /** `check green`, or nothing when no check speaks for the head. */
40 export const checkText = (check: DoorCheck): string =>
41 check === "none" ? "" : ` · check ${check}`;
42
43 export function openPulls(
44 db: Database,
45 repo: Repo,
46 viewer: User | undefined,
47 ): OpenPull[] {
48 if (!canRead(db, repo, viewer)) return [];
49 const scope = sealedScope(db, repo, viewer);
50 const rows = db
51 .query<Row, [string, number, string | null]>(
52 `SELECT issue.id, issue.number, issue.title, pull.head_oid AS head
53 FROM issue LEFT JOIN pull ON pull.issue_id = issue.id
54 WHERE issue.repo_id = ?1 AND issue.kind = 'pull' AND issue.state = 'open'
55 AND (?2 = 1 OR issue.sealed = 0 OR issue.author_id = ?3)
56 ORDER BY issue.number DESC LIMIT ${DOOR_PULLS}`,
57 )
58 .all(repo.id, scope.sealed === true ? 1 : 0, scope.sealedBy ?? null);
59 return rows.map((r) => ({
60 number: r.number,
61 title: r.title,
62 check: r.head === null ? "none" : checkWord(verdictForHead(db, r.id, r.head)),
63 }));
64 }
65
66 /** The signed-in viewer behind a grant, or nobody: a gone or inactive account is a guest. */
67 export function doorViewer(db: Database, id: string | undefined): User | undefined {
68 const user = id === undefined ? undefined : getUserById(db, id);
69 return user !== undefined && isActive(user) ? user : undefined;
70 }
71
72 /**
73 * Where a listed pull leads: its live preview when one is up, else the
74 * pull's page on the forge.
75 */
76 export function pullHref(
77 pull: { number: number },
78 repo: Pick<Repo, "ownerName" | "name">,
79 forgeUrl: string,
80 preview: string | undefined,
81 ): string {
82 return preview !== undefined
83 ? `${preview}/`
84 : new URL(`/${repo.ownerName}/${repo.name}/pulls/${pull.number}`, forgeUrl).href;
85 }
src/apps/proxy.ts +19
@@ -40,6 +40,7 @@ import { crewNow, tellLink } from "./crew.ts";
4040 import { feedback, mintProof } from "./feedback.ts";
4141 import { clientBucket } from "../http/peer.ts";
4242 import { doorPage } from "./door.ts";
43 import { doorViewer, openPulls, pullHref } from "./door_pulls.ts";
4344 import { takePhases, timePhase } from "../core/route_timing.ts";
4445 import { readServing } from "./serving.ts";
4546 import { notFound, securityFloor } from "../http/respond.ts";
@@ -682,6 +683,23 @@ export async function proxyApp(
682683 const where = timePhase(request, "pull", () =>
683684 pillWhere(runtime, target, signed?.who),
684685 );
686 const repo = getRepoById(runtime.app.db, target.app.repoId);
687 const viewer = doorViewer(runtime.app.db, signed?.who?.id);
688 const pulls = repo === undefined ? [] : openPulls(runtime.app.db, repo, viewer);
689 const doorPulls = pulls.map((p) => {
690 const env = previewEnv(p.number);
691 const status = runtime.envStatus(target.app, env);
692 const live = status?.state === "running" || status?.state === "asleep";
693 return {
694 ...p,
695 href: pullHref(
696 p,
697 repo!,
698 runtime.options.forgeUrl,
699 live ? runtime.urlFor(target.app, env) : undefined,
700 ),
701 };
702 });
685703 const serving = timePhase(request, "serving", () =>
686704 readServing(runtime.app.db, target.app.repoId, target.env),
687705 );
@@ -689,6 +707,7 @@ export async function proxyApp(
689707 doorPage(
690708 {
691709 where,
710 pulls: doorPulls,
692711 ...(serving === undefined ? {} : { serving }),
693712 forgeUrl: runtime.options.forgeUrl,
694713 ...(ssh === undefined ? {} : { ssh }),
src/tui/screens/deploys.ts +19 −4
@@ -8,6 +8,7 @@
88 */
99
1010 import { appPace, appVisitors } from "../../actions/apps.ts";
11 import { checkText, openPulls, type OpenPull } from "../../apps/door_pulls.ts";
1112 import { trendLine, visitorsLine } from "../../apps/vitals.ts";
1213 import { listRepoRuns } from "../../actions/runs.ts";
1314 import { carriedByRuns, carriesText } from "../../core/carried.ts";
@@ -21,7 +22,9 @@ import { truncate } from "../term/width.ts";
2122 import { fill, len, split } from "../ui/layout.ts";
2223 import { emptyState } from "../ui/widgets.ts";
2324 import { drawList, hitList } from "./common.ts";
25 import { pullScreen } from "./pull.ts";
2426 import { RunList, openRunLog, runRows } from "./runlist.ts";
27 import { local } from "./where.ts";
2528
2629 const LIMIT = 50;
2730
@@ -42,6 +45,7 @@ export function deploysScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
4245 let visitors = "";
4346 let trend = "";
4447 let pace = "";
48 let pulls: OpenPull[] = [];
4549
4650 const read = (): void => {
4751 const runs = readDeploys(f, repo);
@@ -54,6 +58,7 @@ export function deploysScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
5458 visitors = seen === undefined ? "" : visitorsLine(seen);
5559 trend = seen === undefined ? "" : trendLine(seen.loadDays);
5660 pace = appPace(f.app, f.user, repo);
61 pulls = openPulls(f.db, repo, f.user);
5762 loaded = true;
5863 ctx.invalidate();
5964 };
@@ -65,12 +70,19 @@ export function deploysScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
6570 keys: [
6671 binding(["j", "k"], "move"),
6772 binding(["enter"], "open the log"),
73 binding(["1-5"], "open a pull"),
6874 binding(["r"], "refresh"),
6975 ],
7076 load: async () => read(),
7177 render(area, s) {
7278 const c = ctx.theme.c;
73 const [head, body] = split(area, "v", [len(1 + (visitors === "" ? 0 : 1) + (trend === "" ? 0 : 1) + (pace === "" ? 0 : 1)), fill(1)]);
79 const lines = [
80 visitors,
81 trend,
82 pace,
83 ...pulls.map((p, i) => `${i + 1} #${p.number} ${p.title}${checkText(p.check)}`),
84 ].filter((line) => line !== "");
85 const [head, body] = split(area, "v", [len(1 + lines.length), fill(1)]);
7486 s.text(
7587 head!.x,
7688 head!.y,
@@ -78,9 +90,7 @@ export function deploysScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
7890 style(c.mutedFg, c.bg),
7991 head!.x + head!.w,
8092 );
81 [visitors, trend, pace]
82 .filter((line) => line !== "")
83 .forEach((line, i) =>
93 lines.forEach((line, i) =>
8494 s.text(head!.x, head!.y + 1 + i, truncate(line, head!.w), style(c.mutedFg, c.bg), head!.x + head!.w),
8595 );
8696 if (list.runs.length === 0) {
@@ -113,6 +123,11 @@ export function deploysScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
113123 if (run !== undefined) open(run);
114124 return true;
115125 }
126 const nth = /^[1-5]$/.test(e.key) ? pulls[Number(e.key) - 1] : undefined;
127 if (nth !== undefined) {
128 ctx.push(pullScreen(f, ctx, local(f, repo), nth.number));
129 return true;
130 }
116131 if (e.key === "r") {
117132 read();
118133 return true;
test/apps-door-pulls.test.ts added +158
@@ -0,0 +1,158 @@
1 /**
2 * The app's /__forge/ door lists its open pulls (#5988): newest first, with
3 * the check at the head, a link to the preview or else the pull, and nothing
4 * about a private repository's pulls to a stranger.
5 */
6
7 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
8 import { mkdtemp, rm } from "node:fs/promises";
9 import { tmpdir } from "node:os";
10 import { join } from "node:path";
11 import { createApp, type App } from "../src/app.ts";
12 import type { Repo } from "../src/core/repos.ts";
13 import { newApp } from "../src/actions/apps.ts";
14 import { doorPage } from "../src/apps/door.ts";
15 import { doorViewer, openPulls, pullHref } from "../src/apps/door_pulls.ts";
16 import { createIssue } from "../src/core/issues.ts";
17 import { createRun, finishRun, claimRun } from "../src/core/runs.ts";
18 import { createUser, type User } from "../src/core/users.ts";
19 import { quietLogs } from "./helpers/globals.ts";
20
21 quietLogs();
22
23 describe("the door's open pulls", () => {
24 let dataDir: string;
25 let app: App;
26 let alice: User;
27 let stranger: User;
28 const repos = {} as { pub: Repo; priv: Repo; mix: Repo };
29
30 const make = async (name: string, visibility: "public" | "private") => {
31 const made = await newApp(app, alice, { name, description: "x", visibility });
32 if (!made.ok) throw new Error(String(made.error));
33 return made.value.repo;
34 };
35 const runAt = (repoId: string, issueId: string, kind: "check" | "deploy", state: "ok" | "failed" | "running" | "cancelled") => {
36 const run = createRun(app.db, { repoId, kind, issueId, commitOid: "h" });
37 claimRun(app.db, run.id);
38 if (state === "cancelled") app.db.query("UPDATE run SET state = 'cancelled' WHERE id = ?1").run(run.id);
39 else if (state !== "running") finishRun(app.db, run.id, { state, summary: "" });
40 };
41 const pull = (repoId: string, title: string, check?: "ok" | "failed" | "running") => {
42 const p = createIssue(app.db, { repoId, authorId: alice.id, title, kind: "pull" });
43 if (!p.ok) throw new Error(p.error);
44 app.db.query("INSERT OR REPLACE INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid) VALUES (?1,'main','b','a','h')").run(p.value.id);
45 if (check !== undefined) {
46 runAt(repoId, p.value.id, "check", check);
47 }
48 return p.value;
49 };
50
51 beforeAll(async () => {
52 dataDir = await mkdtemp(join(tmpdir(), "forge-door-"));
53 app = createApp({ dataDir, port: 0, host: "forge.test" });
54 const person = async (username: string, adminIfFirst?: boolean) => {
55 const u = await createUser(app.db, {
56 origin: "seed", trusted: true, username, email: `${username}@forge.local`,
57 password: "a-good-passphrase", ...(adminIfFirst ? { adminIfFirst } : {}),
58 });
59 if (!u.ok) throw new Error(u.error);
60 return u.value;
61 };
62 alice = await person("alice", true);
63 stranger = await person("stranger");
64 repos.pub = await make("pubapp", "public");
65 repos.priv = await make("privapp", "private");
66 repos.mix = await make("mixapp", "public");
67 pull(repos.pub.id, "green one", "ok");
68 pull(repos.pub.id, "red <b>two</b>", "failed");
69 pull(repos.pub.id, "no check yet");
70 pull(repos.priv.id, "secret work", "ok");
71 }, 120_000);
72
73 afterAll(async () => {
74 app.close();
75 await rm(dataDir, { recursive: true, force: true });
76 });
77
78 test("three pulls in mixed states, newest first", () => {
79 const got = openPulls(app.db, repos.pub, alice);
80 expect(got.map((p) => [p.title, p.check])).toEqual([
81 ["no check yet", "none"],
82 ["red <b>two</b>", "red"],
83 ["green one", "green"],
84 ]);
85 });
86
87 test("a failed check is red though a later deploy at the same head is ok", () => {
88 const p = pull(repos.mix.id, "red then deployed", "failed");
89 runAt(repos.mix.id, p.id, "deploy", "ok");
90 const got = openPulls(app.db, repos.mix, alice).find((x) => x.number === p.number);
91 expect(got?.check).toBe("red");
92 });
93
94 test("running only while a run is queued or running; a cancelled one says nothing", () => {
95 const live = pull(repos.mix.id, "live", "running");
96 const gone = pull(repos.mix.id, "gone");
97 runAt(repos.mix.id, gone.id, "check", "cancelled");
98 const by = new Map(openPulls(app.db, repos.mix, alice).map((x) => [x.number, x.check]));
99 expect(by.get(live.number)).toBe("running");
100 expect(by.get(gone.number)).toBe("none");
101 });
102
103 test("at most five", () => {
104 for (let i = 0; i < 4; i++) pull(repos.pub.id, `extra ${i}`, "ok");
105 expect(openPulls(app.db, repos.pub, alice)).toHaveLength(5);
106 });
107
108 test("a pull with no verdict has no check word on the page", async () => {
109 const html = await doorPage(
110 { where: { app: "a", env: "production" }, forgeUrl: "http://f.test", pulls: [{ number: 1, title: "t", check: "none", href: "http://f.test/x" }] },
111 false,
112 ).text();
113 expect(html).toContain(">#1 t</a>");
114 });
115
116 test("a stranger sees none of a private repository's pulls, a public one's all", () => {
117 expect(openPulls(app.db, repos.priv, undefined)).toEqual([]);
118 expect(openPulls(app.db, repos.priv, stranger)).toEqual([]);
119 expect(openPulls(app.db, repos.priv, alice)).toHaveLength(1);
120 expect(openPulls(app.db, repos.pub, undefined).length).toBeGreaterThan(0);
121 });
122
123 test("the page words each pull, and escapes it", async () => {
124 const res = doorPage(
125 {
126 where: { app: "pubapp", env: "production" },
127 forgeUrl: "http://forge.test",
128 pulls: [
129 { number: 9, title: "red <b>two</b>", check: "red", href: "http://pubapp--9.apps.test/" },
130 { number: 8, title: "plain", check: "running", href: "http://forge.test/alice/pubapp/pulls/8" },
131 ],
132 },
133 false,
134 );
135 const html = await res.text();
136 expect(html).toContain('<a href="http://pubapp--9.apps.test/">#9 red &lt;b&gt;two&lt;/b&gt; · check red</a>');
137 expect(html).toContain('href="http://forge.test/alice/pubapp/pulls/8">#8 plain · check running');
138 expect(html).not.toContain("<b>two");
139 });
140
141 test("a pull links to its live preview, else to its page on the forge", () => {
142 const repo = { ownerName: "alice", name: "pubapp" };
143 expect(pullHref({ number: 9 }, repo, "http://forge.test", "http://pubapp--9.apps.test")).toBe(
144 "http://pubapp--9.apps.test/",
145 );
146 expect(pullHref({ number: 9 }, repo, "http://forge.test", undefined)).toBe(
147 "http://forge.test/alice/pubapp/pulls/9",
148 );
149 });
150
151 test("only an active account is a viewer", () => {
152 expect(doorViewer(app.db, undefined)).toBeUndefined();
153 expect(doorViewer(app.db, "nobody")).toBeUndefined();
154 expect(doorViewer(app.db, alice.id)?.id).toBe(alice.id);
155 app.db.query("UPDATE user SET suspended_at = 1 WHERE id = ?1").run(stranger.id);
156 expect(doorViewer(app.db, stranger.id)).toBeUndefined();
157 });
158 });
test/apps-door.test.ts +9
@@ -132,6 +132,13 @@ test("a private repository is linked only to who may read it", async () => {
132132 password: "a-good-passphrase",
133133 });
134134 if (!b.ok) throw new Error(b.error);
135 const secret = createIssue(app.db, {
136 repoId: made.value.repo.id,
137 authorId: alice,
138 title: "SECRET-PULL",
139 kind: "pull",
140 });
141 if (!secret.ok) throw new Error(secret.error);
135142 const target = { app: vault, env: "production" } as AppTarget;
136143 const cookie = `forge_grant_${vault.id.slice(-8)}`;
137144 const as = (id: string, name: string, role: "admin" | "user") =>
@@ -157,6 +164,8 @@ test("a private repository is linked only to who may read it", async () => {
157164 const mine = await (await door(host, as(alice, "alice", "admin"))).text();
158165 expect(mine).toContain(`href="${servers.url}/alice/vault"`);
159166 expect(mine).toContain("alice/vault");
167 expect(mine).toContain("SECRET-PULL");
168 expect(mine).toContain(`href="${servers.url}/alice/vault/pulls/${secret.value.number}"`);
160169 });
161170
162171 test("HEAD answers the headers with no body; POST is a 405 that says what is allowed", async () => {
test/tui-deploys.test.ts +23
@@ -9,6 +9,7 @@ import { signUp } from "../src/actions/users.ts";
99 import { createApp, type App as Forge } from "../src/app.ts";
1010 import { createApp as createAppRecord } from "../src/core/apps.ts";
1111 import { recordAppVital } from "../src/apps/vitals.ts";
12 import { createIssue } from "../src/core/issues.ts";
1213 import { createRun } from "../src/core/runs.ts";
1314 import type { Repo } from "../src/core/repos.ts";
1415 import type { User } from "../src/core/users.ts";
@@ -141,3 +142,25 @@ test("an admin sees the app's visitors and speed above the deploys, and a reader
141142 if (!c.ok) throw new Error("signup failed");
142143 expect(await screenText(c.value, r.value)).not.toContain("visitors");
143144 });
145
146 test("the screen lists open pulls with their check, and a number opens one", async () => {
147 const p = createIssue(forge.db, { repoId: repo.id, authorId: alice.id, title: "OPEN-PULL-MARKER", kind: "pull" });
148 if (!p.ok) throw new Error(p.error);
149 forge.db
150 .query("INSERT OR REPLACE INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid) VALUES (?1,'main','b','a','h')")
151 .run(p.value.id);
152 const { app, session } = createForgeApp(
153 forge,
154 { sshUsername: alice.username, remoteAddress: "127.0.0.1", user: alice },
155 { terminal: headlessTerminal(120, 30), exitHooks: false },
156 );
157 app.start();
158 await settleApp(app);
159 app.push(deploysScreen(session, app.ctx, repo));
160 await settleApp(app);
161 expect(app.screen.toText()).toContain(`1 #${p.value.number} OPEN-PULL-MARKER`);
162 app.dispatch({ type: "key", key: "1", ctrl: false, alt: false, shift: false });
163 await settleApp(app);
164 expect(app.screen.toText()).not.toContain("production deploys");
165 app.stop();
166 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs