Fix the decider pages' review findings: drafted code shows, a failed choice says why, a taken finish keeps its record
Before adoption: this commit came in with the history the project adopted, so no landing records it.
- Drafted files (a proposal's ask file and check, an OpenProposal decision's evidence) rendered empty in the browser: Pierre's `File` draws nothing with `disableFileHeader`, so the drafted file keeps its header again, as before. - A decision page dropped a failed choice on the floor (DecisionClosed, UnknownDecision, a lapsed session, no answer): the route now draws it through `ProposalFailure` above the choices, on every subject and on a finish (above the diff, and above the phone's choices). - A finish's choice bar below 1440 px kept offering Accept and Decline after the choice was taken; it now shows the record in their place. - The decision route decodes its loader data once per read, so the finish's parsed files and read marks are not rebuilt on every render. - Propose waiting for a want says so at full strength, dashed like a field still to fill, rather than greyed out; the territory select's breakpoint is the named `tablet` one. - Evidence sets label beside value only where it has the width (a container query): in Today's inspector it reads label over value instead of a path broken over four lines. - The decision inspector marks expiry with the hourglass and the default with the shield; the phone's choice bar is 8 px shorter. - Removed the finish atoms nothing reads any more (`client/decide.ts`), and `changedFiles` reads `fileBlocks` instead of repeating its parse. - Tests: a finish taken on its page keeps the record at the diff's foot and offers no choice; a refused choice shows its refusal before the choices (both red on the previous code by assertion).
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
14 files+194 added−91 removed
- tests:+51 added−4 removed
- other:+143 added−87 removed
Provenance
- Commit
2bfe61b- Tree
a9b2e6d- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent
ee0e76e
14 files changed+194 added−91 removed
modified:apps/web/src/client/decide.ts-26 removed
5 unmodified lines678910111213141011171213141513 unmodified lines2930313239404142434445464748495051525354555657585 unmodified lines * decision leaves Today. A choice that comes too late (`DecisionClosed`: * someone decided first, or it expired to its default) or names a decision * Today no longer has (`UnknownDecision`) fails with that refusal, and Today * reads again so the stale decision leaves the list. * * Also here: the public reads a `Finish` decision's page shows beside the * diff, the ask and the verdict on the answer's head (no other client module * holds them; the same `ContractsClient.query` atoms * serve any other page that asks for them with the same keys). */import type { Decide } from "@repo/protocol/contracts";import type { AskId, CommitSha, ProjectName } from "@repo/protocol/ids";import { Effect } from "effect";import { Reactivity } from "effect/reactivity";
import { ContractsClient } from "../surfaces.ts";13 unmodified lines ) ); }));
/** The ask a `Finish` decision's answer answers: its want, beside the diff. */export const finishAskAtom = (project: ProjectName, ask: AskId) => ContractsClient.query( "showAsk", { ask, project }, { reactivityKeys: keys.ask(project, ask) } );
/** The verdict on the answer's head a `Finish` decision names. */export const finishVerdictAtom = ( project: ProjectName, ask: AskId, head: CommitSha) => ContractsClient.query( "verdict", { ask, head, project }, { reactivityKeys: keys.ask(project, ask) } );modified:apps/web/src/features/decision/choices.tsx+1 added-1 removed
180 unmodified lines181 * the bottom bar; from a tablet's width, where they sit.182 */183 export const stuckAboveBar = (node: ReactNode) => (184 <div185- className="border-rule bg-background tablet:static tablet:border-t-0 tablet:p-0 tablet:mx-0 sticky bottom-[calc(3.5rem+env(safe-area-inset-bottom))] z-[6] -mx-4 border-t px-4 pt-3 pb-3"185+ className="border-rule bg-background tablet:static tablet:border-t-0 tablet:p-0 tablet:mx-0 sticky bottom-[calc(3.5rem+env(safe-area-inset-bottom))] z-[6] -mx-4 border-t px-4 py-2"186 data-choices-bar=""187 >188 {node}189 </div>1 unmodified linemodified:apps/web/src/features/decision/decision-page.tsx+23 added-1 removed
19 unmodified lines20 import type { Decision } from "@repo/protocol/domain/decision";21 import type { Proposal } from "@repo/protocol/domain/proposal";22 import type { DecisionId, ProjectName } from "@repo/protocol/ids";23 import type { DateTime } from "effect";24+import { Hourglass, Shield } from "lucide-react";25 import type { ReactNode } from "react";26 27 import { signInHref } from "../auth/session-slot.tsx";28 import { MarkerNote } from "../finish/annotation.tsx";61 unmodified lines90 <When at={decision.openedAt} now={now} />91 </dd>92 <dt className="text-label text-muted-foreground pt-0.5">Expires</dt>93 <dd className={soon ? "text-waiting font-medium" : ""} data-soon={soon}>94+ <Hourglass95+ aria-hidden="true"96+ className="mr-1.5 inline size-4 align-[-0.1875rem]"97+ strokeWidth={1.75}98+ />99 <When at={decision.expiresAt} now={now} />100 <span className="text-muted-foreground font-normal">101 {" "}102 · {byWhen(decision.expiresAt)}103 </span>104 </dd>105 <dt className="text-label text-muted-foreground pt-0.5">Default</dt>100- <dd data-default={decision.default}>{decision.default}</dd>106+ <dd data-default={decision.default}>107+ <Shield108+ aria-hidden="true"109+ className="text-muted-foreground mr-1.5 inline size-4 align-[-0.1875rem]"110+ strokeWidth={1.75}111+ />112+ {decision.default}113+ </dd>114 </dl>115 </FactBlock>116 );117 96 unmodified lines214 readonly files?: readonly PatchFile[];215 /** The page for a finish, when the decision is one (the route draws it whole). */216 readonly finish?: ReactNode;217 readonly here: string;218+ /** What the reader's last choice came back with, when it failed: shown above the choices. */219+ readonly failure?: ReactNode;220 }221 222 /** A decision the reader may take, whole. */223 const Found = ({224 busy,225+ failure,226 files,227 found,228 now,229 onDecide,4 unmodified lines234 readonly onDecide: (input: DecideInput) => void;235 readonly busy: boolean;236 readonly files: readonly PatchFile[];237 readonly taken: Decision | undefined;238+ readonly failure: ReactNode;239 }) => {240 const decision = taken ?? found.decision;241 242 const subject = {43 unmodified lines286 soon={found.soon}287 stamp={taken !== undefined}288 >289 <WaiverDiff decision={decision} files={files} />290+ <div aria-live="polite" className="empty:hidden">291+ {failure}292+ </div>293 </DecisionCard>294 </Workspace>295 );296 };16 unmodified lines313 314 export const DecisionView = ({315 busy = false,316 data,317+ failure,318 files = NO_FILES,319 finish,320 here,321 onDecide,5 unmodified lines327 finish328 ) : (329 <Found330 busy={busy}331+ failure={failure}332 files={files}333 found={found}334 now={data.now}335 onDecide={onDecide}39 unmodified linesmodified:apps/web/src/features/decision/evidence.tsx+5 added-3 removed
51 unmodified lines52 readonly label: string;53 }) => (54 <div className="contents">55 <dt className="text-label text-muted-foreground pt-0.5">{label}</dt>56- <dd className="text-ui tablet:mb-0 mb-1.5 min-w-0 [overflow-wrap:anywhere]">56+ <dd className="text-ui mb-1.5 min-w-0 [overflow-wrap:anywhere] @lg:mb-0">57 {children}58 </dd>59 </div>60 );61 62 const FactList = ({ children }: { readonly children: ReactNode }) => (63- <dl className="tablet:grid-cols-[minmax(7rem,auto)_1fr] grid grid-cols-1 gap-x-4 gap-y-1.5">63+ // Label beside value where the evidence has the width (main), label over64+ // value where it has not (the inspector, a phone).65+ <dl className="grid grid-cols-1 gap-x-4 gap-y-1.5 @lg:grid-cols-[minmax(7rem,auto)_1fr]">66 {children}67 </dl>68 );69 266 unmodified lines336 }) => {337 const files = filesOf(decision);338 339 return (338- <div className="flex min-w-0 flex-col gap-3" data-evidence="">340+ <div className="@container flex min-w-0 flex-col gap-3" data-evidence="">341 <SubjectFacts decision={decision} />342 <OtherFacts decision={decision} files={files} />343 {files.map(({ label, value }) => (344 <DraftedCode9 unmodified linesmodified:apps/web/src/features/finish/finish-view.tsx+66 added-18 removed
38 unmodified lines39 import { statsOf } from "../code/diff-model.ts";40 import { DiffPane, PANE_SCROLLER } from "../code/diff-pane.tsx";41 import type { DiffAnnotation, DiffFileSlot } from "../code/diff-view.tsx";42 import { shortSha } from "../code/paths.ts";43-import { Choices, stuckAboveBar } from "../decision/choices.tsx";43+import {44+ Choices,45+ DecisionRecord,46+ stuckAboveBar,47+} from "../decision/choices.tsx";48 import { DecisionCard, ExpiryLines } from "../decision/decision-card.tsx";49 import type { DecideInput } from "../decision/decision-card.tsx";50 import { describeSubject } from "../decision/subject.ts";51 import { CommandLine } from "../shared/command.tsx";138 unmodified lines190 /** The Files button, below the shell's width. */191 readonly filesButton?: ReactNode;192 /** Settle the record's mark: the choice was taken while the page was open. */193 readonly stamp?: boolean;194+ /** What the reader's last choice came back with, when it failed. */195+ readonly failure?: ReactNode;196 }197 198 const NO_FILES: ReadonlySet<string> = new Set();199 47 unmodified lines247 </Button>248 </output>249 );250 245-/** The choices kept at the foot of the diff below 1440 px, where the inspector is a sheet. */251+/**252+ * The choices kept at the foot of the diff below 1440 px, where the253+ * inspector is a sheet; once taken, the choice's record in their place.254+ */255 const DecisionBar = ({256 busy,257 decision,258 now,259 onDecide,260 soon,261+ stamp,262 }: {263 readonly decision: FinishDecision;264 readonly busy: boolean;265 readonly now: DateTime.Utc;266 readonly onDecide: (input: DecideInput) => void;267 readonly soon: boolean;268+ readonly stamp: boolean;269 }) => (270 <section271 aria-label="Your choice"272 className="border-rule bg-background codefacts:hidden flex shrink-0 flex-wrap items-start gap-x-6 gap-y-2 border-t px-4 py-3"273 data-decision-bar=""274 >275+ {decision.decided === undefined ? (276+ <>264- <div className="min-w-0 flex-1 basis-56">265- <ExpiryLines decision={decision} now={now} soon={soon} />266- </div>267- <div className="max-w-[34rem] min-w-0 flex-[2] basis-80">268- <Choices269- busy={busy}277+ <div className="min-w-0 flex-1 basis-56">278+ <ExpiryLines decision={decision} now={now} soon={soon} />279+ </div>280+ <div className="max-w-[34rem] min-w-0 flex-[2] basis-80">281+ <Choices282+ busy={busy}283+ decision={decision}284+ onChoose={(choice) => {285+ onDecide({286+ choice,287+ decision: decision.id,288+ project: decision.project,289+ });290+ }}291+ />292+ </div>293+ </>294+ ) : (295+ <DecisionRecord296+ decided={decision.decided}297 decision={decision}271- onChoose={(choice) => {272- onDecide({273- choice,274- decision: decision.id,275- project: decision.project,276- });277- }}298+ now={now}299+ stamp={stamp}300 />279- </div>301+ )}302 </section>303 );304 305+/** A choice that came back failed: said where the reader looks next, and politely. */306+const Failure = ({307+ children,308+ className = "",309+}: {310+ readonly children: ReactNode;311+ readonly className?: string;312+}) => (313+ <div aria-live="polite" className={`empty:hidden ${className}`}>314+ {children}315+ </div>316+);317+318 /** On a phone: the diff one file at a time, with the way to the next and the one before. */319 const OneFileAtATime = ({320 files,321 notes,72 unmodified lines394 const WideDiff = ({395 busy,396 decision,397 draw,398+ failure,399 files,400 folded,401 newerHead,402 now,3 unmodified lines406 placed,407 read,408 soon,409 split,410+ stamp,411 }: Required<412 Pick<413 FinishViewProps,414 | "busy"5 unmodified lines420 | "placed"421 | "read"422 | "soon"423 | "split"424+ | "stamp"425 >426 > &389- Pick<FinishViewProps, "folded" | "newerHead" | "onFold" | "onMark">) => {427+ Pick<428+ FinishViewProps,429+ "failure" | "folded" | "newerHead" | "onFold" | "onMark"430+ >) => {431 const refused = new Set(placed.map(({ path }) => path));432 433 const plain = (434 <div className={PANE_SCROLLER}>26 unmodified lines461 );462 463 return (464 <div className="tablet:contents hidden">465+ <Failure className={`py-3 ${GUTTER}`}>{failure}</Failure>466 {newerHead === undefined ? null : <NewerHead head={newerHead} />}467 <DiffPane>468 {draw ? (469 <ClientDiffs14 unmodified lines484 decision={decision}485 now={now}486 onDecide={onDecide}487 soon={soon}488+ stamp={stamp}489 />490 </DiffPane>491 </div>492 );3 unmodified lines496 const PhoneFinish = ({497 ask,498 busy,499 decision,500+ failure,501 files,502 newerHead,503 now,504 onDecide,16 unmodified lines521 | "soon"522 | "stamp"523 >524 > &481- Pick<FinishViewProps, "ask" | "newerHead" | "onMark" | "verdict">) => (525+ Pick<526+ FinishViewProps,527+ "ask" | "failure" | "newerHead" | "onMark" | "verdict"528+ >) => (529 <div className={`tablet:hidden flex flex-col gap-6 ${GUTTER}`}>530 {ask === undefined ? null : (531 <p className="text-want max-w-[70ch]">{ask.brief.want}</p>532 )}10 unmodified lines543 />544 </div>545 )}546 {newerHead === undefined ? null : <NewerHead head={newerHead} />}547+ <Failure>{failure}</Failure>548 <DecisionCard549 busy={busy}550 choices={stuckAboveBar}551 decision={decision}160 unmodified linesmodified:apps/web/src/features/finish/patch.ts+9 added-27 removed
65 unmodified lines666768697071727374757677787980818283848586878889909192939495967071727322 unmodified lines9697989910010110210310410510610710810911011111225 unmodified lines65 unmodified lines Option.orElse(() => first(HEADER)) );};
/** * The files a unified diff changes, in its order: each `diff --git` block's * new path (its old path when the file is deleted). A diff without git's * headers counts as one block per `---`/`+++` pair. */export const changedFiles = (patch: string): readonly string[] => { const lines = patch.split("\n"); const gitHeaders = lines.some((line) => HEADER.test(line));
const starts = (line: string, next: string | undefined) => gitHeaders ? line.startsWith("diff --git ") : OLD_FILE.test(line) && next !== undefined && NEW_FILE.test(next);
const blocks: string[][] = [];
for (const [index, line] of lines.entries()) { if (starts(line, lines[index + 1])) { blocks.push([line]); } else { blocks.at(-1)?.push(line); } }
return Arr.dedupe(blocks.flatMap((block) => Option.toArray(pathOf(block))));};
/** The text of each file's block of a unified diff, by the path it ends up at. */export const fileBlocks = (patch: string): ReadonlyMap<string, string> => { const lines = patch.split("\n"); const gitHeaders = lines.some((line) => HEADER.test(line));22 unmodified lines );};
/** * The files a unified diff changes, in its order: each `diff --git` block's * new path (its old path when the file is deleted). A diff without git's * headers counts as one block per `---`/`+++` pair. */export const changedFiles = (patch: string): readonly string[] => [ ...fileBlocks(patch).keys(),];
/** * A short, stable id for one file's change: a polynomial hash over its * block of the diff, kept under a 32-bit prime. A new head that changes * the file changes its id, so whatever was kept against the old one no * longer matches.25 unmodified linesmodified:apps/web/src/features/proposal/drafted-file.tsx-2 removed
20 unmodified lines21 }22 23 const options: FileOptions<undefined, undefined> = {24 ...diffsOptions,25- // The path is the section's heading already.26- disableFileHeader: true,25 overflow: "scroll",26 };27 28 export const DraftedFile = ({ content, path }: DraftedFileProps) => {14 unmodified linesmodified:apps/web/src/features/proposal/failure.tsx+6 added-5 removed
1 /**2- * A call the propose and proposal pages sent, failed. A session that ended3- * (or never began) asks the reader to sign in and come back to the same4- * address, so the form or the proposal is where they left it; a refusal5- * reads as the platform gave it, through `RefusalView`; anything else is6- * the platform not answering, in ink, never as a refusal.2+ * A call the propose, proposal or decision pages sent, failed. A session3+ * that ended (or never began) asks the reader to sign in and come back to4+ * the same address, so the form, the proposal or the decision is where5+ * they left it; a refusal reads as the platform gave it, through6+ * `RefusalView`; anything else is the platform not answering, in ink,7+ * never as a refusal.8 */9 import { Unauthenticated } from "@repo/protocol/principal";10 import { Refusal } from "@repo/protocol/refusal";11 import { Cause, Option, Schema } from "effect";51 unmodified linesmodified:apps/web/src/features/propose/client-territory.tsx+1 added-1 removed
20 unmodified lines21 const StandIn = ({ choices, labelledBy, value }: TerritorySelectProps) => (22 <>23 <button24 aria-labelledby={labelledBy}25- className="border-input tablet:text-ui flex h-11 w-full max-w-xs items-center justify-between gap-1.5 border bg-transparent py-2 pr-2 pl-2.5 text-base sm:h-9"25+ className="border-input tablet:text-ui tablet:h-9 flex h-11 w-full max-w-xs items-center justify-between gap-1.5 border bg-transparent py-2 pr-2 pl-2.5 text-base"26 data-slot="select-trigger"27 disabled28 type="button"29 >24 unmodified linesmodified:apps/web/src/features/propose/propose-view.tsx+4 added-1 removed
255 unmodified lines256 257 {children}258 259 <Button260- className="tablet:h-9 tablet:w-fit h-11 w-full min-w-28 px-4"260+ // Waiting for a want, it says so at full strength, dashed like any261+ // field still to fill, rather than sitting grey.262+ className={`tablet:h-9 tablet:w-fit h-11 w-full min-w-28 px-4 ${written ? "" : "text-muted-foreground border-dashed disabled:opacity-100"}`}263 data-written={written}264 disabled={busy || !written}265 type="submit"266+ variant={written ? "default" : "outline"}267 >268 {busy ? <Spinner /> : null}269 {proposeWords(written, busy)}270 </Button>101 unmodified linesmodified:apps/web/src/features/propose/territory-select.tsx+2 added-1 removed
23 unmodified lines24 readonly value: string;25 }26 27 /** The trigger's look, shared with the server's stand-in for it. */28-export const TRIGGER = "tablet:text-ui h-11 w-full max-w-xs text-base sm:h-9";28+export const TRIGGER =29+ "tablet:text-ui tablet:h-9 h-11 w-full max-w-xs text-base";30 31 export const TerritorySelect = ({32 choices,33 labelledBy,30 unmodified linesmodified:apps/web/src/routes/$project/decisions/$decision.tsx+26 added-1 removed
11 unmodified lines12 import { Effect, Option, Schema } from "effect";13 import type { DateTime } from "effect";14 import { AsyncResult } from "effect/reactivity";15 import { useCallback, useMemo, useState } from "react";16+import type { ReactNode } from "react";17 18 import { decideAtom } from "../../../client/decide.ts";19 import { projectEventsAtom } from "../../../client/events.ts";20 import { watchAtom } from "../../../client/watch.ts";21 unmodified lines42 waiverPatchOf,43 } from "../../../features/finish/patch.ts";44 import type { FinishDecision } from "../../../features/finish/patch.ts";45 import { marksKey, useReadMarks } from "../../../features/finish/read-marks.ts";46+import { ProposalFailure } from "../../../features/proposal/failure.tsx";47 import { pageHead } from "../../../features/shared/head.ts";48 import { personalPage } from "../../../server/cache-headers.ts";49 import { serverClient } from "../../../server/client.ts";50 49 unmodified lines100 /** A finish's page: its files, folds, layout, read marks and keys. */101 const Finish = ({102 busy,103 decision,104+ failure,105 found,106 now,107 onDecide,108 taken,3 unmodified lines112 readonly now: DateTime.Utc;113 readonly onDecide: (input: DecideInput) => void;114 readonly busy: boolean;115 readonly taken: Decision | undefined;116+ readonly failure: ReactNode;117 }) => {118 const { platformUrl } = root.useLoaderData();119 const router = useRouter();120 const { ask, head } = decision.subject;97 unmodified lines218 decision={219 taken === undefined ? decision : { ...taken, subject: decision.subject }220 }221 draw222+ failure={failure}223 files={files}224 filesButton={<FinishFilesButton />}225 folded={folded}226 newerHead={newerHead}16 unmodified lines243 );244 };245 246 const DecisionPage = () => {242- const data = Schema.decodeSync(DecisionPageData)(Route.useLoaderData());247+ const loaded = Route.useLoaderData();248+249+ // Decoded once per read, so what is built from it (the diff's parsed250+ // files above all) is built once too.251+ const data = useMemo(252+ () => Schema.decodeSync(DecisionPageData)(loaded),253+ [loaded]254+ );255+256 const [decided, decide] = useAtom(decideAtom);257 const here = useLocation({ select: hereOf });258 259+ // A choice that failed says why where the choices are: its refusal, the260+ // way to sign in, or that the platform did not answer.261+ const failure = AsyncResult.isFailure(decided) ? (262+ <ProposalFailure263+ cause={decided.cause}264+ doing="take this decision"265+ here={here}266+ />267+ ) : undefined;268+269 const waiverFiles = useMemo(270 () =>271 Option.getOrElse(272 Option.flatMap(foundOf(data.read), ({ decision }) =>11 unmodified lines284 const finish = Option.isSome(found) ? (285 <Finish286 busy={decided.waiting}287 decision={found.value.decision}288+ failure={failure}289 found={found.value.found}290 now={data.now}291 onDecide={decide}292 taken={takenHere(decided, found.value.decision)}3 unmodified lines296 return (297 <DecisionView298 busy={decided.waiting}299 data={data}300+ failure={failure}301 files={waiverFiles}302 finish={finish}303 here={here}304 onDecide={decide}17 unmodified linesmodified:apps/web/test/decision.test.tsx+26 added-1 removed
44 unmodified lines45 } from "../src/features/decision/decision-page.tsx";46 import type { DecisionPageData } from "../src/features/decision/decision-page.tsx";47 import { patchFiles } from "../src/features/finish/files.ts";48 import { waiverPatchOf } from "../src/features/finish/patch.ts";49+import { ProposalFailure } from "../src/features/proposal/failure.tsx";50 import {51 DraftRead,52 draftReadOf,53 readDraft,492 unmodified lines546 reason: "A quote in a code span needs the escaper's context.",547 }),548 };549 549-const pageOf = (read: DecisionRead, chosen?: Decision) => {550+const pageOf = (551+ read: DecisionRead,552+ chosen?: Decision,553+ failure?: ReactElement554+) => {555 const data: DecisionPageData = {556 decision: waiver.id,557 now,558 project: vellum,13 unmodified lines572 files={files}573 here="/vellum/decisions/dec-000002"574 onDecide={() => {}}575 taken={chosen}576+ {...(failure === undefined ? {} : { failure })}577 />578 );579 };580 49 unmodified lines630 expect(plainTextOf(markup)).toContain("Accepted");631 expect(plainTextOf(markup)).toContain("Split out.");632 });633 634+ it("says why a choice came back refused, before the choices", () => {635+ const closed = new DecisionClosed({ decision: waiver.id });636+637+ const markup = pageOf(638+ found,639+ undefined,640+ <ProposalFailure641+ cause={Cause.fail(closed)}642+ doing="take this decision"643+ here="/vellum/decisions/dec-000002"644+ />645+ );646+647+ const refusal = markup.indexOf('data-refusal="DecisionClosed"');648+649+ expect(refusal).toBeGreaterThan(-1);650+ expect(refusal).toBeLessThan(markup.indexOf("data-choices="));651+ });652+653 it("signed out, says what a decision is and who takes it, with no choices and no evidence", () => {654 const markup = pageOf(DecisionRead.cases.SignedOut.make({}));655 const text = plainTextOf(markup);656 7 unmodified linesmodified:apps/web/test/finish.test.tsx+25 added-3 removed
61 unmodified lines62 ]);63 64 const markupOf = (element: ReactElement) => renderToStaticMarkup(element);65 66-/** What a reader sees: the markup without its tags, entities decoded. */67-const textOf = (element: ReactElement) =>68- markupOf(element)66+/** What a reader sees of `markup`: the text without its tags, entities decoded. */67+const textIn = (markup: string) =>68+ markup69 .replaceAll(/<[^>]+>/gu, " ")70 .replaceAll(71 /&(?:#x27|amp|gt|lt|quot);/gu,72 (entity) => ENTITIES.get(entity) ?? entity73 )74 .replaceAll(/\s+/gu, " ");75 76+/** What a reader sees of `element`. */77+const textOf = (element: ReactElement) => textIn(markupOf(element));78+79 const PLATFORM_URL = "https://platform-test.example.workers.dev";80 81 const datekit = ProjectName.make("datekit");82 270 unmodified lines353 );354 });355 });356 357+describe("a finish taken on its page", () => {358+ it("keeps the choice's record at the diff's foot, where its choices were, and offers them no more", () => {359+ const markup = markupOf(360+ pageOf({361+ ...withPatch,362+ decided: { at: now, by: okonkwo, choice: "accept" },363+ })364+ );365+366+ const bar = markup.slice(markup.indexOf("data-decision-bar"));367+368+ expect(markup).not.toContain("data-choice=");369+ expect(bar).toContain('data-decided="accept"');370+ expect(textIn(bar)).toContain(371+ "Accepted · Lands the answer as it is, with you as Finished-by."372+ );373+ });374+});375+376 /** A browser storage over a map, as `localStorage` behaves. */377 const storageOver = (kept: Map<string, string>): Storage => ({378 clear: () => {379 kept.clear();136 unmodified lines