Public: anyone can read this; the crew can change it.
A preview that does not start shows its last start lines and the cause on the pull page #17904
Merged 21h 6m ago, live in production
scout/forge:scout/17892-a-preview-that-does-not-start-shows-its → main 0 commits fork 3 threads · 3 unresolved
7 files
changed +338
−5
docs/features/preview-start-failure.md added +16
| @@ -0,0 +1,16 @@ | ||
| 1 | --- | |
| 2 | topic: When something is wrong | |
| 3 | row: A preview that did not start shows its cause and last start lines on the pull | |
| 4 | --- | |
| 5 | # A preview that did not start | |
| 6 | ||
| 7 | When a pull's preview stopped before answering, the pull page shows, under its | |
| 8 | checks line, why in the app page's own words (the same sentence the proxy's | |
| 9 | page and the `preview` tool say), and a fold with the last 20 lines of the | |
| 10 | deploy's log, escaped. The log is redacted as it is written, so a variable's | |
| 11 | value never shows. The terminal's pull screen shows the cause and the last | |
| 12 | three lines in its checks line. Nothing shows for a preview that is running, | |
| 13 | starting or never deployed. | |
| 14 | ||
| 15 | Web: `src/web/pages/pull-start.ts` (on the pull page). Terminal: | |
| 16 | `src/tui/screens/pull.ts`. Both read `src/apps/start_output.ts`. |
src/apps/start_output.ts added +35
| @@ -0,0 +1,35 @@ | ||
| 1 | /** | |
| 2 | * Why a preview did not start, for the pull page and its terminal: the cause | |
| 3 | * in the words the app page and the proxy's page use (`servingWords`, whose | |
| 4 | * error already carries `run_command.ts`'s hint), and the last lines of the | |
| 5 | * deploy's log. The log is redacted as it is written and again as it is | |
| 6 | * read. Plain data in, plain data out. | |
| 7 | */ | |
| 8 | ||
| 9 | import type { App } from "../app.ts"; | |
| 10 | import { readRunLog } from "../runs/log.ts"; | |
| 11 | import { servingWords } from "./serving_words.ts"; | |
| 12 | import type { EnvStatus } from "./runtime.ts"; | |
| 13 | ||
| 14 | /** How many lines of the start the pull page shows. */ | |
| 15 | export const START_LINES = 20; | |
| 16 | ||
| 17 | export interface StartFailure { | |
| 18 | readonly says: string; | |
| 19 | readonly lines: readonly string[]; | |
| 20 | readonly runUrl: string | null; | |
| 21 | } | |
| 22 | ||
| 23 | /** The failure of an environment that stopped before answering, else null. */ | |
| 24 | export function startFailure(app: App, status: EnvStatus | undefined, forgeUrl: string | null): StartFailure | null { | |
| 25 | if (status === undefined || status.state !== "failed") return null; | |
| 26 | const words = servingWords(status, "open"); | |
| 27 | if (words.state !== "failed") return null; | |
| 28 | const lines = | |
| 29 | status.runId === undefined ? [] : readRunLog(app.config.dataDir, status.runId, 16 * 1024).lines.slice(-START_LINES); | |
| 30 | return { | |
| 31 | says: words.says, | |
| 32 | lines, | |
| 33 | runUrl: status.runId === undefined || forgeUrl === null ? null : `${forgeUrl}/runs/${status.runId}`, | |
| 34 | }; | |
| 35 | } |
src/tui/screens/pull.ts +18 −4
| @@ -64,6 +64,8 @@ import { pullLooksScreen } from "./pulllooks.ts"; | ||
| 64 | 64 | import { pullReviewScreen, setStepsPrompt } from "./pull_review.ts"; |
| 65 | 65 | import { combinedView, combinedWords, type CombinedView } from "../../core/combined_view.ts"; |
| 66 | 66 | import { previewEnv } from "../../apps/data.ts"; |
| 67 | import { startFailure } from "../../apps/start_output.ts"; | |
| 68 | import { appsRuntime } from "../../apps/runtime_registry.ts"; | |
| 67 | 69 | import { findingsWords, pullPreviewFindings } from "../../core/preview_findings.ts"; |
| 68 | 70 | import { pullSecrets, secretLine, secretsWords } from "../../checks/pushed_secrets.ts"; |
| 69 | 71 | import { envsFor } from "../../apps/runtime_registry.ts"; |
| @@ -87,7 +89,7 @@ import { nextOfPull, type Next } from "../../flow/next_actor.ts"; | ||
| 87 | 89 | import { landingLine } from "../../flow/landing_line.ts"; |
| 88 | 90 | import { pullPane, type Pane } from "../../flow/pull_pane.ts"; |
| 89 | 91 | import { fromKeptFork } from "../../core/landing_kind.ts"; |
| 90 | import { DRAFT_LINE, getPull, isDraft, isTalkDraft, pullDir, TALK_DRAFT_LINE, variantSiblings, type MergePullError, type Pull } from "../../core/pulls.ts"; | |
| 92 | import { changedSentences, DRAFT_LINE, getPull, isDraft, isTalkDraft, pullDir, TALK_DRAFT_LINE, variantSiblings, type MergePullError, type Pull } from "../../core/pulls.ts"; | |
| 91 | 93 | import { voteVariant } from "../../actions/variants.ts"; |
| 92 | 94 | import { costLineFor } from "../../core/ledger_rollup.ts"; |
| 93 | 95 | import { canAdmin, getRepoById, type Repo } from "../../core/repos.ts"; |
| @@ -95,7 +97,6 @@ import { canVerdict } from "../../core/verdict.ts"; | ||
| 95 | 97 | import { reviewWords } from "../../actions/review_words.ts"; |
| 96 | 98 | import { verdictOf, type Verdict } from "../../web/pages/pull-verdict.ts"; |
| 97 | 99 | import { wallOf, wallPlain, type Wall } from "../../contract/policy.ts"; |
| 98 | import { changedSentences } from "../../core/pulls.ts"; | |
| 99 | 100 | import { checkSummary, runnerSilent, type CheckSummary } from "../../core/runs.ts"; |
| 100 | 101 | import { placeAndOwn, queuePlace } from "../../checks/place.ts"; |
| 101 | 102 | import { err, ok } from "../../kernel/result.ts"; |
| @@ -347,6 +348,7 @@ export function pullScreen( | ||
| 347 | 348 | /** `findingsWords` of the preview's website-spec findings; empty when none were recorded. */ |
| 348 | 349 | let specWords = ""; |
| 349 | 350 | let redWords = ""; |
| 351 | let startWords = ""; | |
| 350 | 352 | /** The queued check's place in line, and that the owner's own pull goes ahead (`placeAndOwn`). */ |
| 351 | 353 | let placeText = ""; |
| 352 | 354 | /** The check's green was against a base that has since moved. */ |
| @@ -507,6 +509,15 @@ export function pullScreen( | ||
| 507 | 509 | repo === undefined || row === undefined |
| 508 | 510 | ? "" |
| 509 | 511 | : mainLineFor(() => redMain(f.db, repo.id), check, row.baseBranch).says; |
| 512 | const runtime = appsRuntime(f.app); | |
| 513 | const started = | |
| 514 | record === undefined || runtime === undefined || row?.state !== "open" | |
| 515 | ? null | |
| 516 | : startFailure(f.app, runtime.envStatus(record, previewEnv(number)), null); | |
| 517 | startWords = | |
| 518 | started === null | |
| 519 | ? "" | |
| 520 | : `The preview did not start: ${started.says}${started.lines.length === 0 ? "" : ` · ${started.lines.slice(-3).join(" | ")}`}`; | |
| 510 | 521 | const alone = mark === undefined ? "" : `red alone at ${redAloneAt(mark)}, ${RED_ALONE_WAIT}`; |
| 511 | 522 | redWords = [mainRed, alone].filter((w) => w !== "").join(" · "); |
| 512 | 523 | checkSteps = |
| @@ -1341,7 +1352,7 @@ export function pullScreen( | ||
| 1341 | 1352 | // The box is exactly as tall as what is in it: the state, then a row |
| 1342 | 1353 | // for the verdicts when there are any, then a row for the checks when |
| 1343 | 1354 | // a deploy has run or the gate demands one. |
| 1344 | const checksLine = checksText(check, requireChecks, isApp, checkBase, checkOld, checkProgress, checkSteps, specWords, redWords, placeText); | |
| 1355 | const checksLine = checksText(check, requireChecks, isApp, checkBase, checkOld, checkProgress, checkSteps, specWords, redWords, placeText, startWords); | |
| 1345 | 1356 | const boxH = |
| 1346 | 1357 | 3 + |
| 1347 | 1358 | (standingText(standing(), requireReview) === "" ? 0 : 1) + |
| @@ -2019,11 +2030,14 @@ export function checksText( | ||
| 2019 | 2030 | red = "", |
| 2020 | 2031 | /** `placeAndOwn` of a queued check: its place in line, and that an owner's own pull goes ahead. */ |
| 2021 | 2032 | place = "", |
| 2033 | /** A preview that did not start: its cause and last lines, apart from the red-main notes. */ | |
| 2034 | started = "", | |
| 2022 | 2035 | ): string { |
| 2023 | 2036 | const line = checksLine(check, required, isApp, baseBranch, stale, progress); |
| 2024 | 2037 | const withSteps = line === "" || steps === "" ? line : `${line} · ${steps}`; |
| 2025 | 2038 | const withSpec = withSteps === "" || spec === "" ? withSteps : `${withSteps} · ${spec}`; |
| 2026 | const withRed = withSpec === "" || red === "" ? `${withSpec}${red}` : `${withSpec} · ${red}`; | |
| 2039 | const withStart = withSpec === "" || started === "" ? `${withSpec}${started}` : `${withSpec} · ${started}`; | |
| 2040 | const withRed = withStart === "" || red === "" ? `${withStart}${red}` : `${withStart} · ${red}`; | |
| 2027 | 2041 | return withRed === "" || place === "" ? withRed : `${withRed} · ${place}`; |
| 2028 | 2042 | } |
| 2029 | 2043 |
src/web/pages/pull-start.ts added +19
| @@ -0,0 +1,19 @@ | ||
| 1 | /** | |
| 2 | * Why a pull's preview did not start (#17892), beside its checks line: the | |
| 3 | * cause in the app page's words, then the last lines of the start, escaped. | |
| 4 | */ | |
| 5 | ||
| 6 | import { html, type Html } from "../html.ts"; | |
| 7 | import type { StartFailure } from "../../apps/start_output.ts"; | |
| 8 | import { disclosure } from "../ui.ts"; | |
| 9 | ||
| 10 | export function startFailureStrip(found: StartFailure | null): Html | "" { | |
| 11 | if (found === null) return ""; | |
| 12 | const cause = html`<p data-preview-cause>The preview did not start: ${found.says}</p>`; | |
| 13 | if (found.lines.length === 0) return cause; | |
| 14 | const log = found.runUrl === null ? "" : html` <a href="${found.runUrl}">Whole log</a>`; | |
| 15 | return html`${cause}${disclosure( | |
| 16 | `Last ${found.lines.length} lines of its start`, | |
| 17 | html`<pre class="mono" data-preview-start tabindex="0">${found.lines.join("\n")}</pre>${log}`, | |
| 18 | )}`; | |
| 19 | } |
src/web/pages/pull.ts +9 −1
| @@ -130,6 +130,8 @@ import { | ||
| 130 | 130 | threadFragment, |
| 131 | 131 | } from "./thread.ts"; |
| 132 | 132 | import { previewEnv } from "../../apps/data.ts"; |
| 133 | import { startFailure } from "../../apps/start_output.ts"; | |
| 134 | import { startFailureStrip } from "./pull-start.ts"; | |
| 133 | 135 | import { specFindings } from "./pull-spec.ts"; |
| 134 | 136 | import { pushedSecretsNote } from "./findings.ts"; |
| 135 | 137 | import { pullSecrets } from "../../checks/pushed_secrets.ts"; |
| @@ -534,8 +536,14 @@ function pullChecksLine( | ||
| 534 | 536 | main.says === "" |
| 535 | 537 | ? html`` |
| 536 | 538 | : html`<p class="muted small">${main.waiting ? "" : icon("x")}${main.says}</p>`; |
| 539 | const runtime = pull.state === "open" && isApp ? appsRuntime(ctx.app) : undefined; | |
| 540 | const record = runtime === undefined ? undefined : getAppByRepo(ctx.app.db, repo.id); | |
| 541 | const started = | |
| 542 | runtime === undefined || record === undefined | |
| 543 | ? null | |
| 544 | : startFailure(ctx.app, runtime.envStatus(record, previewEnv(pull.number)), runtime.options.forgeUrl); | |
| 537 | 545 | const secrets = pull.state === "open" ? pushedSecretsNote(pullSecrets(ctx.app.db, repo, pull, ctx.auth.user)) : ""; |
| 538 | return html`${originCheckLine(ctx, repo, pull)}${header}${line}${red}${found === null ? "" : specFindings(found)}${secrets}`; | |
| 546 | return html`${originCheckLine(ctx, repo, pull)}${header}${line}${red}${found === null ? "" : specFindings(found)}${startFailureStrip(started)}${secrets}`; | |
| 539 | 547 | } |
| 540 | 548 | |
| 541 | 549 | /** |
test/preview-start-output.test.ts added +95
| @@ -0,0 +1,95 @@ | ||
| 1 | /** | |
| 2 | * #17892: a preview that stopped before answering shows its cause and the | |
| 3 | * last lines of its start on the pull page, escaped and redacted. | |
| 4 | */ | |
| 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 6 | import { mkdir, mkdtemp, rm } from "node:fs/promises"; | |
| 7 | import { tmpdir } from "node:os"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { createApp, type App } from "../src/app.ts"; | |
| 10 | import { startProcess } from "../src/apps/process.ts"; | |
| 11 | import { parseManifest } from "../src/apps/manifest.ts"; | |
| 12 | import type { EnvStatus } from "../src/apps/runtime.ts"; | |
| 13 | import { START_LINES, startFailure } from "../src/apps/start_output.ts"; | |
| 14 | import { servingWords } from "../src/apps/serving_words.ts"; | |
| 15 | import { appendRunLog } from "../src/runs/log.ts"; | |
| 16 | import { startFailureStrip } from "../src/web/pages/pull-start.ts"; | |
| 17 | ||
| 18 | let dataDir: string; | |
| 19 | let app: App; | |
| 20 | beforeAll(async () => { | |
| 21 | dataDir = await mkdtemp(join(tmpdir(), "forge-start-output-")); | |
| 22 | app = createApp({ dataDir, port: 0 }); | |
| 23 | }); | |
| 24 | afterAll(async () => { | |
| 25 | await rm(dataDir, { recursive: true, force: true }); | |
| 26 | }); | |
| 27 | ||
| 28 | const SECRET = "s3cret-value-for-the-test-1234"; | |
| 29 | ||
| 30 | /** Start the fixture for real, as a deploy does; its lines go to the run's log. */ | |
| 31 | async function deploy(run: string, ready: number, runId: string, dir: string): Promise<EnvStatus> { | |
| 32 | await mkdir(dir, { recursive: true }); | |
| 33 | const parsed = parseManifest(JSON.stringify({ app: { run, health: "/", ready } }), undefined); | |
| 34 | if (!parsed.ok) throw new Error(JSON.stringify(parsed.error)); | |
| 35 | const manifest = parsed.value; | |
| 36 | const started = await startProcess({ | |
| 37 | dir, | |
| 38 | dataDir: dir, | |
| 39 | manifest, | |
| 40 | env: "pull-1", | |
| 41 | url: "http://app.test", | |
| 42 | commitOid: "0".repeat(40), | |
| 43 | forgeUrl: "http://forge.test", | |
| 44 | identityKey: "key", | |
| 45 | vars: { TOKEN: SECRET }, | |
| 46 | log: (line) => appendRunLog(dataDir, runId, line), | |
| 47 | signal: new AbortController().signal, | |
| 48 | }); | |
| 49 | if (started.ok) { | |
| 50 | await started.value.handle.stop(); | |
| 51 | throw new Error("the fixture started"); | |
| 52 | } | |
| 53 | const error = `${started.error.stage}: ${started.error.message}`; | |
| 54 | return { env: "pull-1", state: "failed", commitOid: "", url: "http://p.test", runId, error }; | |
| 55 | } | |
| 56 | ||
| 57 | test("a start that exits at once shows its last lines, with an env value hidden", async () => { | |
| 58 | const status = await deploy(`echo "booting with $TOKEN"; echo "Error: cannot open config" >&2; exit 1`, 3, "run-exit", join(dataDir, "a")); | |
| 59 | const found = startFailure(app, status, "http://forge.test"); | |
| 60 | expect(found).not.toBeNull(); | |
| 61 | expect(found!.says).toContain("Error: cannot open config"); | |
| 62 | const page = startFailureStrip(found).toString(); | |
| 63 | expect(page).toContain("data-preview-cause"); | |
| 64 | expect(page).toContain("data-preview-start"); | |
| 65 | expect(page).toContain("cannot open config"); | |
| 66 | expect(page).toContain("http://forge.test/runs/run-exit"); | |
| 67 | expect(page).not.toContain(SECRET); | |
| 68 | expect(found!.says).toBe(servingWords(status, "open").says); | |
| 69 | }); | |
| 70 | ||
| 71 | test("a start that never listens shows the timeout words", async () => { | |
| 72 | const status = await deploy("sleep 30", 1, "run-quiet", join(dataDir, "b")); | |
| 73 | const found = startFailure(app, status, null); | |
| 74 | expect(found).not.toBeNull(); | |
| 75 | expect(found!.says).toBe("ready: no answer on / within 1s"); | |
| 76 | expect(found!.says).toBe(servingWords(status, "open").says); | |
| 77 | expect(startFailureStrip(found).toString()).toContain("The preview did not start"); | |
| 78 | }, 15_000); | |
| 79 | ||
| 80 | test("lines are escaped and only the last 20 are kept", () => { | |
| 81 | for (let i = 1; i <= 30; i++) appendRunLog(dataDir, "run-long", i === 30 ? `<script>alert(1)</script> ${i}` : `line ${i}`); | |
| 82 | const status: EnvStatus = { env: "pull-1", state: "failed", commitOid: "", url: "u", runId: "run-long", error: "boom" }; | |
| 83 | const found = startFailure(app, status, null)!; | |
| 84 | expect(found.lines.length).toBe(START_LINES); | |
| 85 | expect(found.lines[0]).toBe("line 11"); | |
| 86 | const page = startFailureStrip(found).toString(); | |
| 87 | expect(page).not.toContain("<script>"); | |
| 88 | expect(page).toContain("<script>"); | |
| 89 | }); | |
| 90 | ||
| 91 | test("a preview that is running, or unknown, shows nothing", () => { | |
| 92 | expect(startFailure(app, undefined, null)).toBeNull(); | |
| 93 | expect(startFailure(app, { env: "pull-1", state: "running", commitOid: "a", url: "u" }, null)).toBeNull(); | |
| 94 | expect(startFailureStrip(null)).toBe(""); | |
| 95 | }); |
test/preview-start-wiring.test.ts added +146
| @@ -0,0 +1,146 @@ | ||
| 1 | /** | |
| 2 | * #17892: the pull page and the terminal's pull screen show a failed | |
| 3 | * preview's cause and start lines, and nothing for one that runs. | |
| 4 | */ | |
| 5 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 6 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 7 | import { tmpdir } from "node:os"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { newApp } from "../src/actions/apps.ts"; | |
| 10 | import { openPull } from "../src/actions/pulls.ts"; | |
| 11 | import { commitToBranch } from "../src/actions/repos.ts"; | |
| 12 | import { createApp, type App } from "../src/app.ts"; | |
| 13 | import type { AppsRuntime, EnvStatus } from "../src/apps/runtime.ts"; | |
| 14 | import { registerRuntime, unregisterRuntime } from "../src/apps/runtime_registry.ts"; | |
| 15 | import type { Repo } from "../src/core/repos.ts"; | |
| 16 | import { createUser, type User } from "../src/core/users.ts"; | |
| 17 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 18 | import { appendRunLog } from "../src/runs/log.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 | import { quietLogs } from "./helpers/globals.ts"; | |
| 24 | import { settleApp } from "./helpers/tui.ts"; | |
| 25 | ||
| 26 | quietLogs(); | |
| 27 | ||
| 28 | describe("a failed preview on the pull page and in the terminal", () => { | |
| 29 | let dataDir: string; | |
| 30 | let app: App; | |
| 31 | let servers: Servers; | |
| 32 | let alice: User; | |
| 33 | let repo: Repo; | |
| 34 | let number = 0; | |
| 35 | let status: EnvStatus; | |
| 36 | ||
| 37 | const failed: EnvStatus = { | |
| 38 | env: "pull-1", | |
| 39 | state: "failed", | |
| 40 | commitOid: "", | |
| 41 | url: "http://p.test", | |
| 42 | runId: "run-wired", | |
| 43 | error: "ready: no answer on / within 1s", | |
| 44 | }; | |
| 45 | const running: EnvStatus = { env: "pull-1", state: "running", commitOid: "a", url: "http://p.test" }; | |
| 46 | ||
| 47 | const put = async (branch: string, content: string) => { | |
| 48 | const done = await commitToBranch(app, alice, repo, { | |
| 49 | branch, | |
| 50 | message: `edit ${branch}`, | |
| 51 | files: [{ path: "code.txt", content }], | |
| 52 | }); | |
| 53 | if (!done.ok) throw new Error(JSON.stringify(done.error)); | |
| 54 | }; | |
| 55 | ||
| 56 | beforeAll(async () => { | |
| 57 | dataDir = await mkdtemp(join(tmpdir(), "forge-start-wiring-")); | |
| 58 | app = createApp({ dataDir, port: 0, host: "forge.test" }); | |
| 59 | servers = await serve(app); | |
| 60 | const made = await createUser(app.db, { | |
| 61 | origin: "seed", | |
| 62 | trusted: true, | |
| 63 | username: "alice", | |
| 64 | email: "[email protected]", | |
| 65 | password: "a-good-passphrase", | |
| 66 | adminIfFirst: true, | |
| 67 | }); | |
| 68 | if (!made.ok) throw new Error(made.error); | |
| 69 | alice = made.value; | |
| 70 | const site = await newApp(app, alice, { name: "site", description: "x", visibility: "public" }); | |
| 71 | if (!site.ok) throw new Error(String(site.error)); | |
| 72 | repo = site.value.repo; | |
| 73 | await put("main", "top\nbase\n"); | |
| 74 | await put("feat", "top\nbase\nmore\n"); | |
| 75 | const opened = await openPull(app, alice, repo, { title: "Feat", baseBranch: "main", headBranch: "feat" }); | |
| 76 | if (!opened.ok) throw new Error(String(opened.error)); | |
| 77 | number = opened.value.number; | |
| 78 | appendRunLog(dataDir, "run-wired", "Error: cannot open <config>"); | |
| 79 | registerRuntime(app, { | |
| 80 | app, | |
| 81 | options: { forgeUrl: "http://forge.test", domain: "apps.forge.test" }, | |
| 82 | envStatus: () => status, | |
| 83 | status: () => [], | |
| 84 | statusMany: () => new Map(), | |
| 85 | } as unknown as AppsRuntime); | |
| 86 | }, 120_000); | |
| 87 | ||
| 88 | afterAll(async () => { | |
| 89 | unregisterRuntime(app); | |
| 90 | servers.stop(); | |
| 91 | app.close(); | |
| 92 | await rm(dataDir, { recursive: true, force: true }); | |
| 93 | }); | |
| 94 | ||
| 95 | const page = async () => (await fetch(`${servers.url}/alice/site/pulls/${number}`)).text(); | |
| 96 | ||
| 97 | const screen = async (wanted: string | null): Promise<string> => { | |
| 98 | const { app: tui, session } = createForgeApp( | |
| 99 | app, | |
| 100 | { sshUsername: "alice", remoteAddress: "127.0.0.1", fingerprint: "SHA256:alice", user: alice }, | |
| 101 | { terminal: headlessTerminal(200, 44), exitHooks: false }, | |
| 102 | ); | |
| 103 | tui.start(); | |
| 104 | try { | |
| 105 | tui.ctx.push(pullScreen(session, tui.ctx, local(session, repo), number)); | |
| 106 | const end = Date.now() + 20_000; | |
| 107 | for (;;) { | |
| 108 | await settleApp(tui); | |
| 109 | const text = tui.screen.toText(); | |
| 110 | if (wanted === null ? text.includes("Feat") && Date.now() > end - 18_500 : text.includes(wanted)) return text; | |
| 111 | if (Date.now() > end) throw new Error(text); | |
| 112 | } | |
| 113 | } finally { | |
| 114 | tui.stop(); | |
| 115 | } | |
| 116 | }; | |
| 117 | ||
| 118 | test("the page shows the cause and the start lines of a failed preview, escaped", async () => { | |
| 119 | status = failed; | |
| 120 | const html = await page(); | |
| 121 | expect(html).toContain("data-preview-cause"); | |
| 122 | expect(html).toContain("ready: no answer on / within 1s"); | |
| 123 | expect(html).toContain("data-preview-start"); | |
| 124 | expect(html).toContain("cannot open <config>"); | |
| 125 | expect(html).toContain("http://forge.test/runs/run-wired"); | |
| 126 | }); | |
| 127 | ||
| 128 | test("the page shows nothing for a running preview", async () => { | |
| 129 | status = running; | |
| 130 | const html = await page(); | |
| 131 | expect(html).not.toContain("data-preview-cause"); | |
| 132 | expect(html).not.toContain("data-preview-start"); | |
| 133 | }); | |
| 134 | ||
| 135 | test("the terminal's checks line says the preview did not start, with the cause", async () => { | |
| 136 | status = failed; | |
| 137 | const text = await screen("The preview did not start"); | |
| 138 | expect(text).toContain("ready: no answer on / within 1s"); | |
| 139 | }, 60_000); | |
| 140 | ||
| 141 | test("the terminal says nothing of a start for a running preview", async () => { | |
| 142 | status = running; | |
| 143 | const text = await screen(null); | |
| 144 | expect(text).not.toContain("did not start"); | |
| 145 | }, 60_000); | |
| 146 | }); |
new above
offline
startWords is joined into redWords, which holds the red-main and red-alone notes. A preview that failed to start is a different fact; give it its own line so it is not read as a main-is-red note.