ask.test.tsx
This file
Path
apps/web/test/ask.test.tsx
660 lines · 20.1 KiB · TypeScript
Last changed by
Merge redesign into mainoscabrielbefore adoptioncaedd21
History of this fileTake 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 back1import { 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–19why, one step back4import type { Ask } from "@repo/protocol/domain/ask";5import { Outcome } from "@repo/protocol/domain/outcome";6import {7 AskId,8 BlobSha,9 CommitSha,10 Handle,11 ProjectName,12 RepoPath,13} from "@repo/protocol/ids";14import {15 OutOfScope,16 UnknownAsk,17 UnknownPath,18 UnknownProject,19} from "@repo/protocol/refusal";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 20–22why, one step back20import { explain } from "@repo/protocol/render";21import { asTester, unanswered } from "@repo/protocol/testing";22import { isNotFound } from "@tanstack/react-router";Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 23why, one step back23import { 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 24–25why, one step back24import { RpcTest } from "effect/rpc";25Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 26why, one step back26import { readAsk } from "../src/features/answer/reads.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 27why, one step back27import { AskView } from "../src/features/ask/ask-page.tsx";Fold every page's project events once, keep Markdown off the first load, and cache what never changesoscabrielbefore adoption38e5215
line 28why, one step back28import { NoSuchAsk } from "../src/features/ask/refused.tsx";Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 29why, one step back29import { 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 30why, one step back30import { 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
lines 31–34why, one step back31import {32 ask,33 askId,34 brief,Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 35–37why, one step back35 claimedEvent,36 closedEvent,37 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 38why, one step back38 inOrder,Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 39–40why, one step back39 judgedEvent,40 landedSha,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 41–42why, one step back41 markupOf,42 now,Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 43why, one step back43 plainText,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 44–45why, one step back44 project,45 textOf,Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 46why, one step back46 verdictOf,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 47why, one step back47} from "./ask-fixtures.ts";Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 48why, one step back48import { textIn } from "./markup.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 49–54why, one step back4950const platformUrl = "https://platform-test.example.workers.dev";5152const inPre = (markup: string) =>53 /<pre\b[^>]*>(?<inner>.*?)<\/pre>/su.exec(markup)?.groups?.inner;54Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 55–71why, one step back55const mainOf = (markup: string) =>56 /<main\b[^>]*>(?<inner>.*)<\/main>/su.exec(markup)?.groups?.inner ?? "";5758const trailOf = (markup: string) =>59 /<nav aria-label="Breadcrumb"[^>]*>(?<inner>.*?)<\/nav>/su.exec(markup)60 ?.groups?.inner ?? "";6162type AskProps = Parameters<typeof AskView>[0];6364const page = (shown = ask, more: Partial<AskProps> = {}) => (65 <AskView66 ask={shown}67 brief={brief}68 now={now}69 platformUrl={platformUrl}70 {...more}71 />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 72–73why, one step back72);73Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 74–82why, one step back74const checkSource = (lines: number) => ({75 path: RepoPath.make("test/parse-week.test.ts"),76 sha: "f".repeat(40),77 text: Array.from(78 { length: lines },79 (_, index) => `expect(parseWeek("2026-W41-${index}")).not.toBeNull();`80 ).join("\n"),81});82Merge 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 83–103why, one step back83describe(AskView, () => {84 it("titles the page with the want, then reads the brief's sections in order", () => {85 const markup = markupOf(page());8687 expect(markup).toMatch(88 /<h1\b[^>]*>Parse ISO week dates like 2026-W41-3<\/h1>/u89 );90 expect(91 inOrder(textOf(page()), [92 "Current behaviour",93 "parseWeek returns null for 2026-W41-3.",94 "Out of scope",95 "Formatting week dates back to strings.",96 "Terms",97 "Week date: a date written as year, week and weekday.",98 "Context",99 "ISO 8601 numbers weeks from the Monday of the week holding 4 January.",100 ])101 ).toBeTruthy();102 });103Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 104–119why, one step back104 it("sets a want of 80 characters at the headline, and a longer one a step down, whole", () => {105 const want =106 "The linter reports a heading that skips a level, such as a level-two heading followed by a level-four one.";107108 const long = markupOf(page({ ...ask, brief: { ...ask.brief, want } }));109110 expect(111 /<h1\b[^>]*class="(?<classes>[^"]*)"/u.exec(long)?.groups?.classes112 ).toContain("text-title");113 expect(long).toContain(`>${want}</h1>`);114 expect(115 /<h1\b[^>]*class="(?<classes>[^"]*)"/u.exec(markupOf(page()))?.groups116 ?.classes117 ).toContain("text-headline");118 });119Merge 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 120–129why, one step back120 it("leaves out a section the brief does not have", () => {121 const text = textOf(122 page({ ...ask, brief: { want: "Parse ISO week dates like 2026-W41-3" } })123 );124125 expect(text).not.toContain("Current behaviour");126 expect(text).not.toContain("Out of scope");127 expect(text).not.toContain("Terms");128 });129Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 130–133why, one step back130 it("names the project, its asks and the ask in the context bar's trail", () => {131 const trail = trailOf(markupOf(page()));132133 expect(inOrder(plainText(trail), ["datekit", "Asks", askId])).toBeTruthy();Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 134why, one step back134 expect(trail).toContain('href="/oscabriel/datekit"');Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 135–147why, one step back135 });136137 it("says an open ask is open to take, who it is held for, and gives its kind, asker and age", () => {138 const held = {139 ...ask,140 mentor: Handle.make("okonkwo"),141 reserve: "newcomers" as const,142 };143144 const text = textOf(page(held));145146 expect(text).toContain("Open to take");147 expect(text).toContain("Held for newcomers, mentored by okonkwo");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 148why, one step back148 expect(Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 149why, one step back149 inOrder(text, ["fix", "asked by", "ines-v", "opened 2 d ago"])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 150why, one step back150 ).toBeTruthy();Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 151–152why, one step back151 expect(markupOf(page(held))).toContain('href="/people/okonkwo"');152 expect(markupOf(page())).toContain('href="/people/ines-v"');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 153–154why, one step back153 });154Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 155why, one step back155 it("gives the ask's territory and its check", () => {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 156–158why, one step back156 const text = textOf(page());157158 expect(Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 159–163why, one step back159 inOrder(text, [160 "Territory and check",161 "@datekit/parse",162 "test/parse-week.test.ts",163 ])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 164why, one step back164 ).toBeTruthy();Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 165why, one step back165 expect(markupOf(page())).toContain(Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 166why, one step back166 'href="/oscabriel/datekit/blob/main/test/parse-week.test.ts"'Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 167–170why, one step back167 );168 });169170 it("gives the lines that clone the project, claim the ask and check an answer, with the CLI's own name", () => {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 171why, one step back171 expect(Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 172why, one step back172 inOrder(textOf(page()), [Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
lines 173–174why, one step back173 `git clone ${platformUrl}/oscabriel/datekit.git`,174 `${Brand.cli} claim ${askId} --project oscabriel/datekit`,Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 175–176why, one step back175 `${Brand.cli} check`,176 ])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 177why, one step back177 ).toBeTruthy();Merge build/1105 into mainoscabrielbefore adoption1fc92ed
lines 178–179why, one step back178 });179Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 180–184why, one step back180 it("names who holds a claimed ask and offers no way to take it", () => {181 const states = askStates([claimedEvent(1, "tamsin")]);182183 const text = textIn(184 markupOf(page({ ...ask, state: "claimed" }, { states }))Merge build/1105 into mainoscabrielbefore adoption1fc92ed
lines 185–186why, one step back185 );186Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 187–206why, one step back187 expect(text).toContain("Claimed by tamsin, no answer pushed yet");188 expect(text).toContain("tamsin's move");189 expect(text).not.toContain("Take it");190 expect(text).not.toContain(`${Brand.cli} claim`);191 });192193 it("says where a refused answer was refused, whose move it is and what to run", () => {194 const refusal = new OutOfScope({ paths: [RepoPath.make("README.md")] });195 const outcome = Outcome.cases.Refused.make({ refusals: [refusal] });196197 const states = askStates([198 claimedEvent(1, "tamsin"),199 judgedEvent(2, outcome),200 ]);201202 const text = textOf(203 page(204 { ...ask, state: "claimed" },205 { states, verdict: { ...verdictOf(outcome), stage: "shape" } }206 )Merge build/1105 into mainoscabrielbefore adoption1fc92ed
lines 207–209why, one step back207 );208209 expect(Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 210–216why, one step back210 inOrder(text, [211 "Refused",212 "at Shape",213 "OutOfScope",214 "tamsin's move",215 refusal.next,216 ])Merge build/1105 into mainoscabrielbefore adoption1fc92ed
line 217why, one step back217 ).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 218–219why, one step back218 });219Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 220–231why, one step back220 it("says a landed ask landed, with its commit", () => {221 const states = askStates([222 claimedEvent(1, "tamsin"),223 judgedEvent(2, Outcome.cases.Landed.make({ sha: landedSha })),224 closedEvent(3),225 ]);226227 const markup = markupOf(page({ ...ask, state: "closed" }, { states }));228229 expect(textOf(page({ ...ask, state: "closed" }, { states }))).toContain(230 "Landed as 9b1c3e5"231 );Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 232why, one step back232 expect(markup).toContain(`href="/oscabriel/datekit/commit/${landedSha}"`);Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 233–268why, one step back233 });234235 it("gives a round the word its landing or verdict has since said, not the one it was judged with", () => {236 const states = askStates([237 claimedEvent(1, "tamsin"),238 judgedEvent(2, Outcome.cases.Checking.make({ stage: "human" })),239 closedEvent(3),240 ]);241242 const answers = plainText(243 mainOf(markupOf(page({ ...ask, state: "closed" }, { states })))244 );245246 expect(inOrder(answers, ["Round 1", "bbbbbbb", "Landed"])).toBeTruthy();247 expect(answers).not.toContain("Checking");248 });249250 it("lists one answer row per judged round, each linking its answer", () => {251 const states = askStates([252 claimedEvent(1, "tamsin"),253 judgedEvent(254 2,255 Outcome.cases.Refused.make({256 refusals: [new OutOfScope({ paths: [RepoPath.make("README.md")] })],257 }),258 CommitSha.make("e".repeat(40))259 ),260 judgedEvent(3, Outcome.cases.Checking.make({ stage: "checks" })),261 ]);262263 const main = mainOf(264 markupOf(page({ ...ask, state: "claimed" }, { states }))265 );266267 const rows = [268 ...main.matchAll(Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 269why, one step back269 /href="\/oscabriel\/datekit\/answers\/parse-iso-week\?head=(?<head>[0-9a-f]+)"/guMerge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 270–273why, one step back270 ),271 ].map(({ groups }) => groups?.head);272273 expect(rows).toStrictEqual(["e".repeat(40), "b".repeat(40)]);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 274why, one step back274 expect(Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 275–282why, one step back275 inOrder(plainText(main), [276 "Answers",277 "Round 1",278 "eeeeeee",279 "Refused",280 "Round 2",281 "bbbbbbb",282 "Checking",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 283–286why, one step back283 ])284 ).toBeTruthy();285 });286Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 287–303why, one step back287 it("shows the check's source inline when it was read, its first 30 lines until asked for the whole", () => {288 const markup = mainOf(markupOf(page(ask, { check: checkSource(45) })));289 const text = plainText(markup);290291 expect(text).toContain('expect(parseWeek("2026-W41-29")).not.toBeNull();');292 expect(text).not.toContain(293 'expect(parseWeek("2026-W41-30")).not.toBeNull();'294 );295 expect(text).toContain("Show the whole check");296 expect(markup).toContain('data-code="plain"');297 });298299 it("shows only the check's path when its source could not be read", () => {300 const markup = mainOf(markupOf(page()));301302 expect(markup).not.toContain('data-code="plain"');303 expect(markup).toContain(Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 304why, one step back304 'href="/oscabriel/datekit/blob/main/test/parse-week.test.ts"'Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 305–334why, one step back305 );306 });307308 it("says a family's delete child waits for its siblings in the family's terms", () => {309 const { children, deleteChild, parent } = family;310 const states = askStates([closedEvent(1, children[0] ?? parent.id)]);311 const text = textOf(page(deleteChild, { parent, states }));312313 expect(text).toContain("Waiting for 2 of 3 children to land");314 expect(text).not.toContain("Waits on");315 });316317 it("says a delete child whose siblings all landed is open to take, and never that it waits", () => {318 const { children, deleteChild, parent } = family;319320 const states = askStates(321 children.map((child, index) => closedEvent(index + 1, child))322 );323324 const markup = markupOf(325 page({ ...deleteChild, state: "open" }, { parent, states })326 );327328 const text = textOf(329 page({ ...deleteChild, state: "open" }, { parent, states })330 );331332 expect(text).toContain("Open to take");333 expect(text).not.toContain("Waits on");334 expect(text).not.toContain("to land first");Merge redesign into mainoscabrielbefore adoptioncaedd21
line 335why, one step back335 expect(mainOf(markup)).toContain(`data-family="${parent.id}"`);Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 336–346why, one step back336 });337338 it("says a family's parent waits for its family in the family's terms, never as a list of ids", () => {339 const { children, deleteChild, parent } = family;340 const states = askStates([closedEvent(1, children[0] ?? parent.id)]);341 const markup = mainOf(markupOf(page(parent, { states })));342343 expect(plainText(markup)).toContain(344 "Waits for 2 of 3 children and the delete step to land first; a claim waits until they do."345 );346 expect(plainText(markup)).not.toContain("Waits on");Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
lines 347–349why, one step back347 expect(markup).toContain(348 `href="/oscabriel/datekit/asks/${deleteChild.id}"`349 );Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 350–364why, one step back350 });351352 it("says a family's parent whose children all landed waits only for the delete step", () => {353 const { children, parent } = family;354355 const states = askStates(356 children.map((child, index) => closedEvent(index + 1, child))357 );358359 expect(plainText(mainOf(markupOf(page(parent, { states }))))).toContain(360 "Waits for the delete step to land first"361 );362 });363364 it("names the asks an ask outside a family waits on, each linking to its page", () => {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 365–380why, one step back365 const blocked = {366 ...ask,367 blockedBy: [AskId.make("split-format"), AskId.make("split-parse")],368 };369370 const text = textOf(page(blocked));371 const markup = markupOf(page(blocked));372373 expect(374 inOrder(text, [375 "Waits on",376 "split-format",377 "split-parse",378 "to land first",379 ])380 ).toBeTruthy();Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
lines 381–382why, one step back381 expect(markup).toContain('href="/oscabriel/datekit/asks/split-format"');382 expect(markup).toContain('href="/oscabriel/datekit/asks/split-parse"');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 383–384why, one step back383 });384Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 385why, one step back385 it("names nothing it waits on when nothing blocks it, or what blocked it 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 386–387why, one step back386 expect(textOf(page())).not.toContain("Waits on");387Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 388why, one step back388 const states = askStates([closedEvent(1, AskId.make("split-format"))]);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 389why, one step back389Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 390–394why, one step back390 expect(391 textOf(392 page({ ...ask, blockedBy: [AskId.make("split-format")] }, { states })393 )394 ).not.toContain("Waits on");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 395–406why, one step back395 });396397 it("gives no claim line once the ask is closed", () => {398 const text = textOf(page({ ...ask, state: "closed" }));399400 expect(text).toContain("Closed");401 expect(text).not.toContain(`${Brand.cli} claim`);402 });403404 it("links to the ask's Markdown and to the verdict on its latest answer", () => {405 const markup = markupOf(page());406Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
lines 407–408why, one step back407 expect(markup).toContain(`href="/oscabriel/datekit/asks/${askId}.md"`);408 expect(markup).toContain(`href="/oscabriel/datekit/answers/${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 409–413why, one step back409 });410411 it("shows the brief exactly as an agent reads it", () => {412 expect(inPre(markupOf(page()))).toBe(inPre(markupOf(<pre>{brief}</pre>)));413 });Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 414–419why, one step back414415 it("gives the project's posture when the list of projects has it", () => {416 const text = textOf(page(ask, { posture: "openWithSealedEvidence" }));417418 expect(text).toContain("Open with sealed evidence");419 });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 420–441why, one step back420});421422describe(NoSuchAsk, () => {423 it("shows the refusal a loader's not-found carried from the server, as git printed it", () => {424 const refusal = new UnknownAsk({ ask: AskId.make("no-such-ask") });425426 // The not-found's data, as it crosses from the server: encoded, then cloned.427 const data = structuredClone(Schema.encodeSync(Refusals)([refusal]));428429 expect(430 inOrder(textOf(<NoSuchAsk data={data} />), [431 "No such ask",432 ...explain([refusal]).map((line) => line.trim()),433 `${Brand.cli} asks`,434 ])435 ).toBeTruthy();436 });437438 it("says nothing is at an address that names no ask at all", () => {439 expect(textOf(<NoSuchAsk />)).toContain("Nothing is at this address");440 });441Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 442–444why, one step back442 it("offers the way onward: the project, and the open asks", () => {443 const markup = markupOf(<NoSuchAsk project="datekit" />);444Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 445why, one step back445 expect(markup).toContain('href="/oscabriel/datekit"');Merge build/1300-w13-foundation into mainoscabrielbefore adoption0e29c37
line 446why, one step back446 expect(markup).toContain('href="/asks"');Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 447–458why, one step back447 expect(textOf(<NoSuchAsk project="datekit" />)).toContain("Open asks");448 });449450 it("names the project and its asks in the trail, and no crumb for the ask that is not there", () => {451 const refusal = new UnknownAsk({ ask: AskId.make("no-such-ask") });452 const data = structuredClone(Schema.encodeSync(Refusals)([refusal]));453454 const trail = trailOf(455 markupOf(<NoSuchAsk data={data} project="datekit" />)456 );457458 expect(inOrder(plainText(trail), ["datekit", "Asks"])).toBeTruthy();Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 459why, one step back459 expect(trail).toContain('href="/oscabriel/datekit"');Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 460–464why, one step back460 expect(trail).not.toContain("no-such-ask");461 });462463 it("links no project the platform says it does not have", () => {464 const refusal = new UnknownProject({Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 465why, one step back465 project: ProjectName.make("oscabriel/nowhere"),Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 466–471why, one step back466 });467468 const data = structuredClone(Schema.encodeSync(Refusals)([refusal]));469 const markup = markupOf(<NoSuchAsk data={data} project="nowhere" />);470471 expect(markup).not.toContain('href="/nowhere"');Merge build/1300-w13-foundation into mainoscabrielbefore adoption0e29c37
line 472why, one step back472 expect(markup).toContain('href="/asks"');Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 473–474why, one step back473 });474Merge 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 475–481why, one step back475 it("says what its route gives it when a not-found carries no refusal", () => {476 expect(477 textOf(<NoSuchAsk nothing="No answer is at this head." />)478 ).toContain("No answer is at this head.");479 });480});481Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 482–505why, one step back482interface Asked {483 readonly asks: number;484 readonly files: number;485 readonly replays: number;486 readonly verdicts: number;487}488489const nothingAsked: Asked = { asks: 0, files: 0, replays: 0, verdicts: 0 };490491const count = (asked: Ref.Ref<Asked>, key: keyof Asked) =>492 Ref.update(asked, (seen) => ({ ...seen, [key]: seen[key] + 1 }));493494const replay = [495 claimedEvent(1, "tamsin"),496 claimedEvent(2, "okafor", AskId.make("format-week")),497];498499const platformOf = (500 asked: Ref.Ref<Asked>,501 {502 readable = true,503 shown = ask,504 }: { readonly readable?: boolean; readonly shown?: Ask } = {}505) =>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 506–511why, one step back506 Layer.effect(Client, RpcTest.makeClient(Contracts)).pipe(507 Layer.provide([508 Layer.mergeAll(509 unanswered,510 Contracts.toLayerHandler("showAsk", (payload) =>511 Effect.gen(function* () {Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 512why, one step back512 yield* count(asked, "asks");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 513why, one step back513Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 514–517why, one step back514 if (payload.ask === family.parent.id) {515 return { ask: family.parent, brief };516 }517Merge 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 518–521why, one step back518 if (payload.ask !== askId) {519 return yield* new UnknownAsk({ ask: payload.ask });520 }521Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 522why, one step back522 return { ask: shown, brief };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 523why, one step back523 })Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 524–553why, one step back524 ),525 Contracts.toLayerHandler("verdict", () =>526 Effect.as(count(asked, "verdicts"), {})527 ),528 Contracts.toLayerHandler("watch", () =>529 Stream.fromEffect(count(asked, "replays")).pipe(530 Stream.flatMap(() => Stream.fromIterable(replay))531 )532 ),533 Contracts.toLayerHandler("readFile", (payload) =>534 Effect.gen(function* () {535 yield* count(asked, "files");536537 if (!readable) {538 return yield* new UnknownPath({539 commit: CommitSha.make("a".repeat(40)),540 path: payload.path,541 });542 }543544 return {545 at: CommitSha.make("a".repeat(40)),546 binary: false,547 path: payload.path,548 sha: BlobSha.make("f".repeat(40)),549 size: 42,550 text: 'test("parses", () => {});',551 truncated: false,552 };553 })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 554–560why, one step back554 )555 ),556 asTester,557 ])558 );559560describe(readAsk, () => {Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 561–565why, one step back561 it.effect(562 "reads the ask, its brief, its events and its check's source for the page",563 () =>564 Effect.gen(function* () {565 const asked = yield* Ref.make(nothingAsked);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 566why, one step back566Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 567–569why, one step back567 const read = yield* readAsk({ ask: askId, project }).pipe(568 Effect.provide(platformOf(asked))569 );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 570why, one step back570Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 571–592why, one step back571 expect({572 ask: read.ask.id,573 brief: read.brief,574 check: read.check?.text,575 events: read.events.map(({ seq }) => seq),576 lastSeq: read.lastSeq,577 parent: read.parent,578 }).toStrictEqual({579 ask: askId,580 brief,581 check: 'test("parses", () => {});',582 events: [1],583 lastSeq: 2,584 parent: undefined,585 });586 expect(yield* Ref.get(asked)).toStrictEqual({587 asks: 1,588 files: 1,589 replays: 1,590 verdicts: 1,591 });592 })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 593–595why, one step back593 );594595 it.effect(Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
lines 596–616why, one step back596 "reads a family member's parent, and shows the ask without its check's source when the file cannot be read",597 () =>598 Effect.gen(function* () {599 const asked = yield* Ref.make(nothingAsked);600601 const read = yield* readAsk({ ask: askId, project }).pipe(602 Effect.provide(603 platformOf(asked, {604 readable: false,605 shown: { ...family.child(0), check: ask.check, id: askId },606 })607 )608 );609610 expect(read.parent?.id).toBe(family.parent.id);611 expect(read.check).toBeUndefined();612 expect((yield* Ref.get(asked)).asks).toBe(2);613 })614 );615616 it.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 617–619why, one step back617 "is a not-found carrying the UnknownAsk refusal for an ask the project lacks",618 () =>619 Effect.gen(function* () {Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 620why, one step back620 const asked = yield* Ref.make(nothingAsked);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 621–624why, one step back621 const missing = AskId.make("no-such-ask");622623 const failed = yield* Effect.flip(624 readAsk({ ask: missing, project }).pipe(Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 625why, one step back625 Effect.provide(platformOf(asked))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 626–644why, one step back626 )627 );628629 expect(isNotFound(failed)).toBeTruthy();630631 const carried = yield* Schema.decodeUnknownEffect(Refusals)(632 isNotFound(failed) ? failed.data : undefined633 );634635 expect(explain(carried)).toStrictEqual(636 explain([new UnknownAsk({ ask: missing })])637 );638 })639 );640641 it.effect(642 "is a not-found with no refusal, and asks nothing, for a name no ask can have",643 () =>644 Effect.gen(function* () {Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 645why, one step back645 const asked = yield* Ref.make(nothingAsked);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 646–648why, one step back646647 const failed = yield* Effect.flip(648 readAsk({ ask: "Not_An-Ask", project }).pipe(Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 649why, one step back649 Effect.provide(platformOf(asked))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–656why, one step back650 )651 );652653 expect(isNotFound(failed)).toBeTruthy();654 expect(655 isNotFound(failed) ? failed.data : "not a not-found"656 ).toBeUndefined();Merge build/1223-ask-and-answeroscabrielbefore adoptiondf02458
line 657why, one step back657 expect(yield* Ref.get(asked)).toStrictEqual(nothingAsked);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 658–660why, one step back658 })659 );660});