Skip to content
Myr

answer.test.tsx

This file

Path

apps/web/test/answer.test.tsx

740 lines · 23.9 KiB · TypeScript

Last changed by

Merge redesign into mainoscabrielbefore adoptioncaedd21

History of this file

Take it

The walk stopped after 200 commits: lines older than 678c8b8 point at it.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 1–3why, one step back
1import { describe, expect, it } from "@effect/vitest";
2import { Brand } from "@repo/brand";3import { Client, Contracts } from "@repo/protocol/contracts";

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 4–5why, one step back
4import type { Verdict } from "@repo/protocol/domain/answer";
5import type { Ask } from "@repo/protocol/domain/ask";

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 6why, one step back
6import { Outcome } from "@repo/protocol/domain/outcome";

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 7–8why, one step back
7import type { StageName } from "@repo/protocol/domain/outcome";
8import { AreaName, AskId, CommitSha, DecisionId } from "@repo/protocol/ids";

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 9–17why, one step back
9import {
10 ChecksFailed,11 HeldBackFailed,12 UnknownAsk,13 UnknownCommit,14} from "@repo/protocol/refusal";15import { explain } from "@repo/protocol/render";16import { asTester, unanswered } from "@repo/protocol/testing";17import { isNotFound } from "@tanstack/react-router";

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 18why, one step back
18import { Effect, Layer, Ref, Schema, Stream } from "effect";

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 19–22why, one step back
19import { RpcTest } from "effect/rpc";
2021import {22 AnswerView,

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 23why, one step back
23 durationText,

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 24–25why, one step back
24 HeldBackBits,
25} from "../src/features/answer/answer-page.tsx";

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 26–27why, one step back
26import { readAnswer } from "../src/features/answer/reads.ts";
27import { askStates } from "../src/features/shared/ask-progress.ts";

Fold every page's project events once, keep Markdown off the first load, and cache what never changesoscabrielbefore adoption38e5215

line 28why, one step back
28import { Refusals } from "../src/features/shared/refusals.ts";

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 29why, one step back
29import {

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 30why, one step back
30 ask,

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 31why, one step back
31 askId,

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 32–35why, one step back
32 brief,
33 claimedEvent,34 decidedLanding,35 family,

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 36why, one step back
36 inOrder,

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 37why, one step back
37 judgedEvent,

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 38–41why, one step back
38 landedSha,
39 landing,40 markupOf,41 now,

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 42why, one step back
42 plainLanding,

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 43–48why, one step back
43 plainText,
44 project,45 suite,46 textOf,47 verdictOf,48} from "./ask-fixtures.ts";

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 49why, one step back
49import { textIn } from "./markup.ts";

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 50why, one step back
50import { elementWith } from "./records.ts";

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 51–72why, one step back
51
52const checksFailed = new ChecksFailed({53 lane: "unit",54 logRef: "logs/datekit/parse-iso-week/unit",55 next: `${Brand.cli} evidence logs/datekit/parse-iso-week/unit`,56});5758const heldBackFailed = new HeldBackFailed({ area: "export", suite });5960const refused = verdictOf(61 Outcome.cases.Refused.make({ refusals: [checksFailed, heldBackFailed] })62);6364const stagesOf = (markup: string) =>65 [...markup.matchAll(/<li\b[^>]*>/gu)].flatMap(([tag]) => {66 const stage = /data-stage="(?<value>[^"]+)"/u.exec(tag)?.groups?.value;67 const state = /data-state="(?<value>[^"]+)"/u.exec(tag)?.groups?.value;6869 return stage === undefined || state === undefined ? [] : [[stage, state]];70 });7172const lanesOf = (markup: string) =>

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 73–76why, one step back
73 [...markup.matchAll(/<[a-z]+\b[^>]*data-lane="[^"]*"[^>]*>/gu)].flatMap(
74 ([tag]) => {75 const lane = /data-lane="(?<value>[^"]+)"/u.exec(tag)?.groups?.value;76 const result = /data-result="(?<value>[^"]+)"/u.exec(tag)?.groups?.value;

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 77why, one step back
77

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 78–80why, one step back
78 return lane === undefined || result === undefined ? [] : [[lane, result]];
79 }80 );

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 81why, one step back
81

Merge build/1109 into mainoscabrielbefore adoption1a26053

lines 82–92why, one step back
82const commitLinksOf = (markup: string) =>
83 [84 ...markup.matchAll(85 /<a\b[^>]*href="(?<href>[^"]*\/commit\/[^"]*)"[^>]*>(?<inner>.*?)<\/a>/gu86 ),87 ].flatMap(({ groups }) =>88 groups?.href === undefined || groups.inner === undefined89 ? []90 : [[groups.href, plainText(groups.inner).trim()]]91 );92

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 93–95why, one step back
93const heroOf = (markup: string) =>
94 /<section aria-label="Outcome"[^>]*>(?<inner>.*?)<\/section>/su.exec(markup)95 ?.groups?.inner ?? "";

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 96why, one step back
96

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 97–102why, one step back
97const runOf = (markup: string) =>
98 markup.slice(markup.indexOf('id="answer-gate"'), markup.indexOf("</main>"));99100const mainOf = (markup: string) =>101 /<main\b[^>]*>(?<inner>.*)<\/main>/su.exec(markup)?.groups?.inner ?? "";102

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 103why, one step back
103const factsOf = (markup: string) => elementWith(markup, 'data-facts="inline"');

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 104–130why, one step back
104
105const page = (106 props: Partial<Parameters<typeof AnswerView>[0]> & {107 readonly verdict: Verdict | undefined;108 }109) => <AnswerView ask={ask} now={now} {...props} />;110111const landedAt = (stage: StageName, heldBack: boolean) => ({112 ...verdictOf(Outcome.cases.Landed.make({ sha: landedSha })),113 heldBack: heldBack114 ? verdictOf(Outcome.cases.Landed.make({ sha: landedSha })).heldBack115 : [],116 stage,117});118119describe("the answer page", () => {120 const refusedPage = page({ verdict: refused });121122 it("titles the page with the ask's want, and names the project, the ask and the answer in its trail", () => {123 const markup = markupOf(refusedPage);124125 expect(markup).toMatch(126 /<h1\b[^>]*>Parse ISO week dates like 2026-W41-3<\/h1>/u127 );128 expect(129 inOrder(textOf(refusedPage), ["datekit", "Asks", askId, "Answer"])130 ).toBeTruthy();

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

lines 131–132why, one step back
131 expect(markup).toContain('href="/oscabriel/datekit"');
132 expect(markup).toContain(`href="/oscabriel/datekit/asks/${askId}"`);

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 133–150why, one step back
133 });
134135 it("leads with the outcome: the first heading after the title is the hero, and a landing links its commit", () => {136 const landed = landedAt("human", true);137 const markup = markupOf(page({ landing: decidedLanding, verdict: landed }));138 const afterTitle = markup.slice(markup.indexOf("</h1>"));139140 const hero =141 /<section aria-label="Outcome"[^>]*>(?<inner>.*?)<\/section>/su.exec(142 afterTitle143 );144145 expect(hero).not.toBeNull();146 expect(afterTitle.indexOf('<section aria-label="Outcome"')).toBeLessThan(147 afterTitle.indexOf("<h2")148 );149 expect(plainText(hero?.groups?.inner ?? "")).toContain("Landed as 9b1c3e5");150 expect(hero?.groups?.inner).toContain(

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 151why, one step back
151 `href="/oscabriel/datekit/commit/${landedSha}"`

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 152–154why, one step back
152 );
153 });154

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 155why, one step back
155 it("puts what was judged last in main, after the outcome and the gate, and only there", () => {

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 156why, one step back
156 const markup = markupOf(refusedPage);

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 157–158why, one step back
157 const main = mainOf(markup);
158 const strip = main.indexOf('data-stage="human"');

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 159why, one step back
159

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 160–163why, one step back
160 expect(strip).toBeGreaterThan(main.indexOf('aria-label="Outcome"'));
161 expect(main.lastIndexOf("Patch id")).toBeGreaterThan(strip);162 expect(main.lastIndexOf("Merged tree")).toBeGreaterThan(strip);163 expect(factsOf(markup)).not.toContain("Patch id");

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 164–165why, one step back
164 });
165

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 166why, one step back
166 it("shows the stages the answer passed, the one that refused it, and the ones it never reached", () => {

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 167why, one step back
167 expect(stagesOf(mainOf(markupOf(refusedPage)))).toStrictEqual([

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 168–177why, one step back
168 ["parse", "passed"],
169 ["shape", "passed"],170 ["merge", "passed"],171 ["cheap", "passed"],172 ["checks", "refused"],173 ["heldBack", "pending"],174 ["human", "pending"],175 ]);176 });177

Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571

line 178why, one step back
178 it("reads the maintainer and held-back stages as not needed for a landing that needed neither", () => {

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 179–191why, one step back
179 const markup = markupOf(
180 page({ landing: plainLanding, verdict: landedAt("human", false) })181 );182183 expect(stagesOf(mainOf(markup)).slice(5)).toStrictEqual([184 ["heldBack", "skipped"],185 ["human", "skipped"],186 ]);187 expect(188 textOf(page({ landing: plainLanding, verdict: landedAt("human", false) }))189 ).toContain("not needed");190 });191

Merge build/maintainer-wording into mainoscabrielbefore adoption4c1a571

line 192why, one step back
192 it("reads them passed for a landing a maintainer finished and held-back checks judged", () => {

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 193–207why, one step back
193 const markup = markupOf(
194 page({ landing: decidedLanding, verdict: landedAt("human", true) })195 );196197 expect(stagesOf(mainOf(markup)).slice(5)).toStrictEqual([198 ["heldBack", "passed"],199 ["human", "passed"],200 ]);201 });202203 it("opens failed lanes first, each with the command that reads its log, and folds the passed ones into a line", () => {204 const markup = markupOf(refusedPage);205 const text = textOf(refusedPage);206207 expect(lanesOf(mainOf(markup))).toStrictEqual([

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 208why, one step back
208 ["unit", "failed"],

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 209why, one step back
209 ["lint", "passed"],

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 210why, one step back
210 ]);

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 211why, one step back
211 expect(text).toContain(

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 212why, one step back
212 `${Brand.cli} evidence logs/datekit/parse-iso-week/unit --project oscabriel/datekit`

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 213–214why, one step back
213 );
214 expect(text).toContain("1 lane passed in 1.2 s");

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 215why, one step back
215 expect(

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 216why, one step back
216 /<details\b[^>]*>.*data-lane="lint".*<\/details>/su.test(mainOf(markup))

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 217why, one step back
217 ).toBeTruthy();

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 218why, one step back
218 expect(inOrder(text, ["unit", "bun test", "failed", "8.3 s"])).toBeTruthy();

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 219–220why, one step back
219 });
220

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 221–268why, one step back
221 it("keeps each passed lane's command and how long it ran inside the folded line", () => {
222 const folded =223 /<details\b[^>]*>(?<inner>.*)<\/details>/su.exec(224 mainOf(markupOf(refusedPage))225 )?.groups?.inner ?? "";226227 expect(228 inOrder(plainText(folded), ["lint", "bun run lint", "passed", "1.2 s"])229 ).toBeTruthy();230 });231232 it("says no lane has run yet while the answer is checking, and that none ran once it was refused before them", () => {233 const checking = {234 ...verdictOf(Outcome.cases.Checking.make({ stage: "cheap" })),235 lanes: [],236 stage: "cheap" as const,237 };238239 const refusedEarly = { ...refused, lanes: [], stage: "shape" as const };240241 expect(textOf(page({ verdict: checking }))).toContain(242 "No lane has run yet."243 );244 expect(textOf(page({ verdict: checking }))).not.toContain("No lane ran");245 expect(textOf(page({ verdict: refusedEarly }))).toContain(246 "No lane ran on this answer."247 );248 });249250 it("names the ask and the round right under the title, before the outcome", () => {251 const states = askStates([252 claimedEvent(1, "okafor"),253 judgedEvent(2, refused.outcome),254 ]);255256 const markup = mainOf(markupOf(page({ states, verdict: refused })));257 const round = markup.indexOf("round 1 of 1");258259 expect(round).toBeGreaterThan(markup.indexOf("</h1>"));260 expect(round).toBeLessThan(markup.indexOf('aria-label="Outcome"'));261 });262263 it("gives no claim command for an ask that still waits on others to land", () => {264 const blocked = { ...ask, blockedBy: [AskId.make("split-format")] };265 const markup = mainOf(markupOf(page({ ask: blocked, verdict: undefined })));266267 expect(textIn(markup)).not.toContain(`${Brand.cli} claim`);268 expect(textIn(markup)).toContain("waits for 1 ask to land first");

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 269why, one step back
269 expect(markup).toContain(`href="/oscabriel/datekit/asks/${askId}"`);

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 270–288why, one step back
270 });
271272 it("names a lane's log only as the command that reads it", () => {273 const passing = verdictOf(Outcome.cases.Checking.make({ stage: "checks" }));274 const text = textOf(page({ verdict: passing }));275276 const mentions = [277 ...text.matchAll(/logs\/datekit\/parse-iso-week\/unit/gu),278 ];279280 expect(mentions.length).toBeGreaterThan(0);281282 for (const { index } of mentions) {283 expect(text.slice(index - `${Brand.cli} evidence `.length, index)).toBe(284 `${Brand.cli} evidence `285 );286 }287 });288

Merge build/1500-design-draws into mainoscabrielbefore adoption9bc46b7

line 289why, one step back
289 it("shows held-back checks only as an area's counts and its suite root, shortened, the whole root in its title", () => {

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 290–291why, one step back
290 const bits =
291 /<ul aria-label="Held-back checks by area"[^>]*>(?<inner>.*?)<\/ul>/su.exec(

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 292why, one step back
292 markupOf(refusedPage)

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 293–294why, one step back
293 )?.groups?.inner;
294

Merge build/1500-design-draws into mainoscabrielbefore adoption9bc46b7

lines 295–296why, one step back
295 expect(plainText(bits ?? "").trim()).toBe("export 6/7 @ sha256:4f2a4f…");
296 expect(bits).toContain(`title="${suite}"`);

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 297–298why, one step back
297 });
298

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 299why, one step back
299 it("reads an answer's rounds first in main, newest first, the one on the page selected, and leaves them out of its facts", () => {

Merge build/1500-design-draws into mainoscabrielbefore adoption9bc46b7

lines 300–317why, one step back
300 const states = askStates([
301 claimedEvent(1, "okafor"),302 judgedEvent(2, refused.outcome, CommitSha.make("e".repeat(40))),303 judgedEvent(3, refused.outcome),304 ]);305306 const markup = markupOf(page({ states, verdict: refused }));307 const main = mainOf(markup);308 const rounds = main.slice(main.indexOf('id="answer-rounds"'));309310 expect(main.indexOf('id="answer-rounds"')).toBeGreaterThan(-1);311 expect(main.indexOf('id="answer-rounds"')).toBeLessThan(312 main.indexOf('id="answer-gate"')313 );314 expect(315 inOrder(textIn(rounds), ["Round 2 of 2", "Round 1 of 2"])316 ).toBeTruthy();317 expect(rounds).toMatch(/data-selected="true"[^>]*>[\s\S]*?Round 2 of 2/u);

Merge redesign into mainoscabrielbefore adoptioncaedd21

line 318why, one step back
318 expect(textIn(factsOf(markup))).not.toContain("Rounds");

Merge build/1500-design-draws into mainoscabrielbefore adoption9bc46b7

lines 319–371why, one step back
319 });
320321 it("draws no rounds region for an answer's only round", () => {322 const states = askStates([323 claimedEvent(1, "okafor"),324 judgedEvent(2, refused.outcome),325 ]);326327 expect(mainOf(markupOf(page({ states, verdict: refused })))).not.toContain(328 'id="answer-rounds"'329 );330 });331332 it("tells a waiting answer's contributor there is nothing to run, and what a push would start", () => {333 const waiting = verdictOf(334 Outcome.cases.AwaitingDecision.make({335 decision: DecisionId.make("dec-000001"),336 })337 );338339 const states = askStates([340 claimedEvent(1, "okafor"),341 judgedEvent(2, refused.outcome, CommitSha.make("e".repeat(40))),342 judgedEvent(3, waiting.outcome),343 ]);344345 expect(346 textIn(mainOf(markupOf(page({ states, verdict: waiting }))))347 ).toContain(348 "Nothing for you to run. Pushing again starts round 3; this verdict stays as round 2."349 );350 expect(textIn(mainOf(markupOf(refusedPage)))).not.toContain(351 "Nothing for you to run."352 );353 });354355 it("tells a landing as a sentence, then credits the people at title weight, then links the landing commit", () => {356 const landed = verdictOf(Outcome.cases.Landed.make({ sha: landedSha }));357 const markup = markupOf(page({ landing, verdict: landed }));358 const region = markup.slice(markup.indexOf('id="answer-landing"'));359360 expect(361 inOrder(textIn(region), [362 "Landed as 9b1c3e5",363 "asked by ines-v",364 "Credit",365 "Asked-by: ines-v",366 "The landing commit",367 ])368 ).toBeTruthy();369 expect(region).toMatch(/<h3 class="[^"]*text-title[^"]*">Credit<\/h3>/u);370 });371

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 372–374why, one step back
372 it("shows the refusals' explain lines in order, as git printed them", () => {
373 expect(374 inOrder(

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 375why, one step back
375 textOf(refusedPage),

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 376–380why, one step back
376 explain([checksFailed, heldBackFailed]).map((line) => line.trim())
377 )378 ).toBeTruthy();379 });380

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 381–386why, one step back
381 it("names the answer it judged, its round, and when", () => {
382 const states = askStates([383 claimedEvent(1, "okafor"),384 judgedEvent(2, refused.outcome, CommitSha.make("e".repeat(40))),385 judgedEvent(3, refused.outcome),386 ]);

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 387why, one step back
387

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 388–407why, one step back
388 const element = page({ states, verdict: refused });
389 const text = textOf(element);390391 for (const shown of [392 "round 2 of 2",393 "bbbbbbb",394 "aaaaaaa",395 "redThenGreen@0.0.0+5e1d",396 "20 min ago",397 "okafor's move",398 ]) {399 expect(text).toContain(shown);400 }401 });402403 it("reads a wait on a decision as waiting, in the hero", () => {404 const waiting = verdictOf(405 Outcome.cases.AwaitingDecision.make({406 decision: DecisionId.make("dec-000001"),407 })

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 408why, one step back
408 );

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 409–412why, one step back
409
410 const text = textOf(page({ verdict: waiting }));411412 expect(text).toContain("Waiting on decision dec-000001");

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 413–414why, one step back
413 });
414

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 415–416why, one step back
415 it("gives an ask nobody answered the command that claims it", () => {
416 const text = textOf(page({ verdict: undefined }));

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 417why, one step back
417

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 418why, one step back
418 expect(text).toContain("Nobody has answered this ask yet.");

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

lines 419–421why, one step back
419 expect(text).toContain(
420 `${Brand.cli} claim ${askId} --project oscabriel/datekit`421 );

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 422why, one step back
422 expect(markupOf(page({ verdict: undefined }))).not.toContain("data-stage");

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 423–424why, one step back
423 });
424

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 425–428why, one step back
425 it("names who holds a claimed ask with no answer pushed, and links back to the ask", () => {
426 const states = askStates([claimedEvent(1, "bram")]);427 const element = page({ states, verdict: undefined });428 const main = mainOf(markupOf(element));

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 429why, one step back
429

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 430why, one step back
430 expect(textIn(main)).toContain("Claimed by bram, no answer pushed yet.");

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 431why, one step back
431 expect(main).toContain(`href="/oscabriel/datekit/asks/${askId}"`);

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 432–435why, one step back
432 });
433434 it("shows a landed answer's credit trailers in trailer order, its held-back trailer, and its commit", () => {435 const landed = verdictOf(Outcome.cases.Landed.make({ sha: landedSha }));

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 436why, one step back
436 const text = textOf(page({ landing, verdict: landed }));

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 437–444why, one step back
437
438 expect(text).toContain("Landed as 9b1c3e5");439 expect(440 inOrder(text, ["Asked-by: ines-v", "Signed-off-by: okafor"])441 ).toBeTruthy();442 expect(text).toContain(`Held-back: export 7/7 @ ${suite}`);443 expect(text).toContain("Assisted-by: claude-code:opus-5 (verified)");444 expect(text).toContain(`git show ${landedSha}`);

Merge build/1109 into mainoscabrielbefore adoption1a26053

lines 445–446why, one step back
445 });
446

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 447why, one step back
447 it("links a landed answer's landing (from the hero and the landing) and its base to their commit pages", () => {

Merge build/1109 into mainoscabrielbefore adoption1a26053

line 448why, one step back
448 const landed = verdictOf(Outcome.cases.Landed.make({ sha: landedSha }));

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 449why, one step back
449 const markup = markupOf(page({ landing, verdict: landed }));

Merge build/1109 into mainoscabrielbefore adoption1a26053

line 450why, one step back
450

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 451–454why, one step back
451 expect(commitLinksOf(heroOf(markup))).toStrictEqual([
452 [`/${project}/commit/${landedSha}`, "9b1c3e5"],453 ]);454 expect(commitLinksOf(runOf(markup))).toStrictEqual([

Merge build/1109 into mainoscabrielbefore adoption1a26053

line 455why, one step back
455 [`/${project}/commit/${landed.base}`, landed.base.slice(0, 7)],

Merge build/1500-design-draws into mainoscabrielbefore adoption9bc46b7

line 456why, one step back
456 [`/${project}/commit/${landedSha}`, "9b1c3e5"],

Merge build/1109 into mainoscabrielbefore adoption1a26053

lines 457–462why, one step back
457 [`/${project}/commit/${landedSha}`, "The landing commit"],
458 ]);459 });460461 it("links neither the head nor the merged tree: they live in the claim's fork", () => {462 const landed = verdictOf(Outcome.cases.Landed.make({ sha: landedSha }));

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 463why, one step back
463 const markup = markupOf(page({ landing, verdict: landed }));

Merge build/1109 into mainoscabrielbefore adoption1a26053

lines 464–469why, one step back
464
465 expect(markup).not.toContain(`/commit/${landed.head}`);466 expect(markup).not.toContain(`/commit/${landed.tree}`);467 });468469 it("links the base and no landing when the answer has not landed", () => {

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 470–471why, one step back
470 expect(commitLinksOf(heroOf(markupOf(refusedPage)))).toStrictEqual([]);
471 expect(commitLinksOf(runOf(markupOf(refusedPage)))).toStrictEqual([

Merge build/1109 into mainoscabrielbefore adoption1a26053

lines 472–473why, one step back
472 [`/${project}/commit/${refused.base}`, refused.base.slice(0, 7)],
473 ]);

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 474–475why, one step back
474 });
475

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 476–477why, one step back
476 it("stamps the landed mark only when the page is told the landing came while it was open", () => {
477 const landed = landedAt("human", false);

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 478why, one step back
478

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 479–484why, one step back
479 expect(
480 markupOf(page({ landing: plainLanding, stamp: true, verdict: landed }))481 ).toContain("animate-stamp");482 expect(483 markupOf(page({ landing: plainLanding, verdict: landed }))484 ).not.toContain("animate-stamp");

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 485–486why, one step back
485 });
486

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 487–498why, one step back
487 it("draws a family member's family, the member marked", () => {
488 const child = family.child(1);489490 const markup = markupOf(491 <AnswerView492 ask={child}493 now={now}494 parent={family.parent}495 verdict={refused}496 />497 );498

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 499–500why, one step back
499 expect(factsOf(markup)).toContain(`data-family="${family.parent.id}"`);
500 expect(factsOf(markup)).toMatch(

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 501–502why, one step back
501 /aria-current="true"[^>]*title="retire-old-week-parse"|title="retire-old-week-parse"[^>]*aria-current="true"/u
502 );

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 503–513why, one step back
503 });
504});505506describe(HeldBackBits, () => {507 it("shows one line per area, and nothing else about the held-back checks", () => {508 const results = [509 { area: AreaName.make("export"), passed: 6, suite, total: 7 },510 { area: AreaName.make("parse"), passed: 3, suite, total: 3 },511 ];512513 expect(textOf(<HeldBackBits results={results} />).trim()).toBe(

Merge build/1500-design-draws into mainoscabrielbefore adoption9bc46b7

line 514why, one step back
514 "export 6/7 @ sha256:4f2a4f… parse 3/3 @ sha256:4f2a4f…"

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 515–518why, one step back
515 );
516 });517});518

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 519–528why, one step back
519describe(durationText, () => {
520 it("says how long a lane ran in the unit a person reads", () => {521 expect([640, 8312, 125_000].map(durationText)).toStrictEqual([522 "640 ms",523 "8.3 s",524 "2 min 5 s",525 ]);526 });527});528

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 529why, one step back
529interface Asked {

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 530why, one step back
530 readonly asks: number;

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 531why, one step back
531 readonly landings: number;

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 532why, one step back
532 readonly replays: number;

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 533–535why, one step back
533 readonly verdicts: number;
534}535

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 536–544why, one step back
536const replay = [
537 claimedEvent(1, "bram"),538 claimedEvent(2, "okafor", AskId.make("format-week")),539 judgedEvent(3, refused.outcome),540];541542const count = (asked: Ref.Ref<Asked>, key: keyof Asked) =>543 Ref.update(asked, (seen) => ({ ...seen, [key]: seen[key] + 1 }));544

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 545–547why, one step back
545const platformAt = (
546 asked: Ref.Ref<Asked>,547 outcome: Outcome,

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 548–549why, one step back
548 landingKnown = true,
549 shown: Ask = ask

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 550–556why, one step back
550) =>
551 Layer.effect(Client, RpcTest.makeClient(Contracts)).pipe(552 Layer.provide([553 Layer.mergeAll(554 unanswered,555 Contracts.toLayerHandler("verdict", (payload) =>556 Effect.gen(function* () {

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 557why, one step back
557 yield* count(asked, "verdicts");

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 558–565why, one step back
558
559 if (payload.ask !== askId) {560 return yield* new UnknownAsk({ ask: payload.ask });561 }562563 return { verdict: verdictOf(outcome) };564 })565 ),

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 566–584why, one step back
566 Contracts.toLayerHandler("showAsk", (payload) =>
567 Effect.gen(function* () {568 yield* count(asked, "asks");569570 if (payload.ask !== shown.id && payload.ask !== family.parent.id) {571 return yield* new UnknownAsk({ ask: payload.ask });572 }573574 return {575 ask: payload.ask === shown.id ? shown : family.parent,576 brief,577 };578 })579 ),580 Contracts.toLayerHandler("watch", () =>581 Stream.fromEffect(count(asked, "replays")).pipe(582 Stream.flatMap(() => Stream.fromIterable(replay))583 )584 ),

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 585–586why, one step back
585 Contracts.toLayerHandler("landing", (payload) =>
586 Effect.gen(function* () {

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 587why, one step back
587 yield* count(asked, "landings");

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 588–600why, one step back
588
589 if (!landingKnown || payload.sha !== landedSha) {590 return yield* new UnknownCommit({ sha: payload.sha });591 }592593 return { landing };594 })595 )596 ),597 asTester,598 ])599 );600

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 601why, one step back
601const nothingAsked: Asked = { asks: 0, landings: 0, replays: 0, verdicts: 0 };

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 602–603why, one step back
602
603describe(readAnswer, () => {

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 604–639why, one step back
604 it.effect(
605 "reads a landed answer's landing with its verdict, its ask and the ask's events",606 () =>607 Effect.gen(function* () {608 const asked = yield* Ref.make(nothingAsked);609 const landed = Outcome.cases.Landed.make({ sha: landedSha });610611 const read = yield* readAnswer({ ask: askId, project }).pipe(612 Effect.provide(platformAt(asked, landed))613 );614615 expect({616 events: read.events.map(({ seq }) => seq),617 landing: read.landing?.sha,618 lastSeq: read.lastSeq,619 outcome: read.verdict?.outcome._tag,620 parent: read.parent,621 want: read.askRead.brief.want,622 }).toStrictEqual({623 events: [1, 3],624 landing: landedSha,625 lastSeq: 3,626 outcome: "Landed",627 parent: undefined,628 want: ask.brief.want,629 });630 expect(yield* Ref.get(asked)).toStrictEqual({631 asks: 1,632 landings: 1,633 replays: 1,634 verdicts: 1,635 });636 })637 );638639 it.effect("reads a family member's parent, for the family", () =>

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 640–643why, one step back
640 Effect.gen(function* () {
641 const asked = yield* Ref.make(nothingAsked);642643 const read = yield* readAnswer({ ask: askId, project }).pipe(

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 644–649why, one step back
644 Effect.provide(
645 platformAt(asked, refused.outcome, true, {646 ...family.child(0),647 id: askId,648 })649 )

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 650–651why, one step back
650 );
651

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

lines 652–658why, one step back
652 expect(read.parent?.id).toBe(family.parent.id);
653 expect(yield* Ref.get(asked)).toStrictEqual({654 asks: 2,655 landings: 0,656 replays: 1,657 verdicts: 1,658 });

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 659–671why, one step back
659 })
660 );661662 it.effect("asks for no landing when the answer did not land", () =>663 Effect.gen(function* () {664 const asked = yield* Ref.make(nothingAsked);665666 const read = yield* readAnswer({ ask: askId, project }).pipe(667 Effect.provide(platformAt(asked, refused.outcome))668 );669670 expect(read.verdict?.outcome._tag).toBe("Refused");671 expect(read.landing).toBeUndefined();

Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458

line 672why, one step back
672 expect((yield* Ref.get(asked)).landings).toBe(0);

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 673–740why, one step back
673 })
674 );675 it.effect(676 "shows the verdict alone when the platform no longer finds its landing",677 () =>678 Effect.gen(function* () {679 const asked = yield* Ref.make(nothingAsked);680 const landed = Outcome.cases.Landed.make({ sha: landedSha });681682 const read = yield* readAnswer({ ask: askId, project }).pipe(683 Effect.provide(platformAt(asked, landed, false))684 );685686 expect(read.verdict?.outcome._tag).toBe("Landed");687 expect(read.landing).toBeUndefined();688 })689 );690691 it.effect(692 "is a not-found carrying the UnknownAsk refusal for an ask the project lacks",693 () =>694 Effect.gen(function* () {695 const asked = yield* Ref.make(nothingAsked);696 const missing = AskId.make("no-such-ask");697698 const failed = yield* Effect.flip(699 readAnswer({ ask: missing, project }).pipe(700 Effect.provide(701 platformAt(702 asked,703 Outcome.cases.Checking.make({ stage: "checks" })704 )705 )706 )707 );708709 expect(isNotFound(failed)).toBeTruthy();710711 const carried = yield* Schema.decodeUnknownEffect(Refusals)(712 isNotFound(failed) ? failed.data : undefined713 );714715 expect(explain(carried)).toStrictEqual(716 explain([new UnknownAsk({ ask: missing })])717 );718 })719 );720721 it.effect(722 "is a not-found with no refusal, and asks nothing, when ?head= is not a whole commit id",723 () =>724 Effect.gen(function* () {725 const asked = yield* Ref.make(nothingAsked);726727 const failed = yield* Effect.flip(728 readAnswer({ ask: askId, head: "9b1c3e5", project }).pipe(729 Effect.provide(platformAt(asked, refused.outcome))730 )731 );732733 expect(isNotFound(failed)).toBeTruthy();734 expect(735 isNotFound(failed) ? failed.data : "not a not-found"736 ).toBeUndefined();737 expect(yield* Ref.get(asked)).toStrictEqual(nothingAsked);738 })739 );740});