shared.test.tsx
This file
Path
apps/web/test/shared.test.tsx
256 lines · 8.6 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–2why, one step back1import { describe, expect, it } from "@effect/vitest";2import { Brand } from "@repo/brand";Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 3why, one step back3import { Handle } 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 4–5why, one step back4import { DateTime, Schema } from "effect";5Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 6why, one step back6import { Definition, Definitions } from "../src/features/ask/fields.tsx";Merge redesign into mainoscabrielbefore adoptioncaedd21
line 7why, one step back7import { CommandLine } from "../src/features/shared/command.tsx";Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 8why, one step back8import { CopyAction } from "../src/features/shared/copy-action.tsx";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–10why, one step back9import { EmptyState } from "../src/features/shared/empty.tsx";10import { HandleLink } from "../src/features/shared/handle.tsx";Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 11–14why, one step back11import {12 STATE_MARK_NAMES,13 STATE_MARKS,14} from "../src/features/shared/marks.tsx";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 15why, one step back15import { PostureBadge } from "../src/features/shared/posture.tsx";Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 16–20why, one step back16import {17 FactsSkeleton,18 RowSkeleton,19} from "../src/features/shared/skeleton.tsx";20import { StateBadge } from "../src/features/shared/state-badge.tsx";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 21–22why, one step back21import { themeColors } from "../src/features/shared/theme.ts";22import { When } from "../src/features/shared/time.tsx";Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 23why, one step back23import { markupOf, textOf } 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 24–30why, one step back2425import styles from "../src/styles.css?raw";2627const handle = Schema.decodeSync(Handle);2829const now = DateTime.makeUnsafe("2026-10-07T12:00:00Z");30Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 31–32why, one step back31describe(StateBadge, () => {32 const states = STATE_MARK_NAMES;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 33why, one step back33Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 34–38why, one step back34 it.each(states)(35 "says %s in a word beside its mark, which the screen reader skips",36 (state) => {37 const element = <StateBadge mark={state} />;38 const markup = 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 39why, one step back39Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 40–43why, one step back40 expect(textOf(element).trim()).toBe(STATE_MARKS[state].word);41 expect(STATE_MARKS[state].word.length).toBeGreaterThan(0);42 expect(markup).toMatch(/<svg\b[^>]*aria-hidden="true"/u);43 expect(markup).toContain(`data-mark="${state}"`);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 44why, one step back44 }Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 45why, one step back45 );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 46why, one step back46Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 47–49why, one step back47 it("is never a pill: no fill and no rounded edge", () => {48 for (const state of states) {49 const markup = markupOf(<StateBadge mark={state} />);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 50why, one step back50Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 51–52why, one step back51 expect(markup).not.toMatch(/\brounded-(?:full|md|lg|xl)\b|\bbg-/u);52 }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 53–54why, one step back53 });54Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 55–61why, one step back55 it("gives refused to a refusal only, and waiting its own role", () => {56 expect(STATE_MARKS.refused.tone).toBe("text-refused");57 expect(STATE_MARKS.waiting.tone).toBe("text-waiting");58 expect(STATE_MARKS.retry.tone).toBe("text-waiting");59 expect(60 states.filter((state) => STATE_MARKS[state].tone === "text-refused")61 ).toStrictEqual(["refused"]);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 62–63why, one step back62 });63Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 64–66why, one step back64 it("can say a state in its own words", () => {65 expect(textOf(<StateBadge mark="open" word="Open to take" />).trim()).toBe(66 "Open to take"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 67–68why, one step back67 );68 });Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 69why, one step back69});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 70why, one step back70Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 71–72why, one step back71describe(CopyAction, () => {72 it("holds its command as text and is named for what it copies", () => {Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 73why, one step back73 const command = `${Brand.cli} claim fix-week-start --project oscabriel/datekit`;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 74why, one step back74Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 75–76why, one step back75 const markup = markupOf(76 <CopyAction command={command} label="Copy claim command" />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 77–78why, one step back77 );78Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 79–81why, one step back79 expect(markup).toMatch(/^<button\b[^>]*aria-label="Copy claim command"/u);80 expect(markup).toContain(`<code class="sr-only">${command}</code>`);81 expect(markup).toContain('aria-live="polite"');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 82why, one step back82 });Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
line 83why, one step back83});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 84why, one step back84Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 85–90why, one step back85describe("the skeletons", () => {86 it("hold a row's place at its height, and a fact block's under its label", () => {87 expect(markupOf(<RowSkeleton />)).toContain("h-16");88 expect(markupOf(<RowSkeleton />)).not.toMatch(/animate-|shimmer/u);89 expect(markupOf(<FactsSkeleton labels={["State", "Claim"]} />)).toContain(90 "Claim"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 91–143why, one step back91 );92 });93});9495describe(PostureBadge, () => {96 it("shows the label it is given and keeps the posture as a data attribute", () => {97 const element = (98 <PostureBadge99 label="Open · sealed checks in parser"100 posture="openWithSealedEvidence"101 />102 );103104 expect(textOf(element)).toBe("Open · sealed checks in parser");105 expect(markupOf(element)).toContain(106 'data-posture="openWithSealedEvidence"'107 );108 });109});110111describe(HandleLink, () => {112 it("links a handle to that person's page", () => {113 expect(markupOf(<HandleLink handle={handle("ines-v")} />)).toMatch(114 /^<a\b[^>]*\bhref="\/people\/ines-v"[^>]*>ines-v<\/a>$/u115 );116 });117});118119describe(When, () => {120 it("says how far ahead a time is", () => {121 const at = DateTime.add(now, { hours: 3 });122 const element = <When at={at} now={now} />;123124 expect(textOf(element)).toBe("in 3 h");125 expect(markupOf(element)).toContain('dateTime="2026-10-07T15:00:00.000Z"');126 });127128 it("says how long ago a time was", () => {129 expect(130 textOf(<When at={DateTime.subtract(now, { days: 2 })} now={now} />)131 ).toBe("2 d ago");132 expect(133 textOf(<When at={DateTime.subtract(now, { minutes: 5 })} now={now} />)134 ).toBe("5 min ago");135 });136137 it("says now for anything under a minute either way", () => {138 expect(139 textOf(<When at={DateTime.add(now, { seconds: 20 })} now={now} />)140 ).toBe("now");141 });142});143Merge build/1315-command-line into mainoscabrielbefore adoption252b871
lines 144–146why, one step back144const hangs = (command: string) =>145 [146 ...markupOf(<CommandLine command={command} />).matchAll(Merge redesign into mainoscabrielbefore adoptioncaedd21
line 147why, one step back147 /class="tablet:pl-\(--hang\) tablet:-indent-\(--hang\) block" style="--hang:(?<hang>\d+)ch"/guMerge build/1315-command-line into mainoscabrielbefore adoption252b871
lines 148–150why, one step back148 ),149 ].map((found) => Number(found.groups?.hang));150Merge 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 151–158why, one step back151describe(CommandLine, () => {152 it("shows the command, with a button that copies it", () => {153 const command = `${Brand.cli} claim fix-week-start`;154 const element = <CommandLine command={command} />;155156 expect(textOf(element)).toContain(command);157 expect(markupOf(element)).toMatch(/<button\b[^>]*>.*Copy.*<\/button>/u);158 });Finish the Control room: every page passes axe and a keyboard walk in both schemesoscabrielbefore adoption3fd50a5
lines 159–160why, one step back159160 it("keeps each word whole on its line, so a narrow column breaks between words", () => {Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 161why, one step back161 const command = `${Brand.cli} claim lint-heading-levels --project oscabriel/vellum`;Finish the Control room: every page passes axe and a keyboard walk in both schemesoscabrielbefore adoption3fd50a5
lines 162–172why, one step back162 const markup = markupOf(<CommandLine command={command} />);163164 const words = [165 ...markup.matchAll(166 /<span class="inline-block[^"]*">(?<word>[^<]*)<\/span>/gu167 ),168 ].map(([, word]) => word);169170 expect(words).toStrictEqual(command.split(" "));171 // The words keep the command's own spaces between them.172 expect(textOf(<CommandLine command={command} />)).toContain(command);Merge build/1315-command-line into mainoscabrielbefore adoption252b871
lines 173–174why, one step back173 });174Merge redesign into mainoscabrielbefore adoptioncaedd21
line 175why, one step back175 it("hangs a line 6ch from tablet, less when its longest word would not fit beside the hang", () => {Merge build/1315-command-line into mainoscabrielbefore adoption252b871
lines 176–181why, one step back176 // `today` (5ch) beside a 6ch hang needs 11ch; the line is 9ch, so the177 // box hugging it would break the word in two. It never wraps, so its178 // hang never shows.179 expect(hangs(`${Brand.cli} today`)).toStrictEqual([4]);180 expect(181 hangs(Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 182why, one step back182 `${Brand.cli} claim lint-heading-levels --project oscabriel/vellum \\\n --json`Merge build/1315-command-line into mainoscabrielbefore adoption252b871
lines 183–184why, one step back183 )184 ).toStrictEqual([6, 2]);Finish the Control room: every page passes axe and a keyboard walk in both schemesoscabrielbefore adoption3fd50a5
line 185why, one step back185 });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 186–194why, one step back186});187188describe(EmptyState, () => {189 it("says what is empty and the command that would change it", () => {190 const command = `${Brand.cli} ask open`;191 const text = textOf(<EmptyState command={command} title="No open asks" />);192193 expect(text).toContain("No open asks");194 expect(text).toContain(command);Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 195–202why, one step back195 expect(196 markupOf(<EmptyState command={command} title="No open asks" />)197 ).toContain(markupOf(<CommandLine command={command} />));198 });199200 it("gives a way onward when no command changes it", () => {201 const text = textOf(202 <EmptyStateMerge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 203why, one step back203 onward={<a href="/oscabriel/datekit">Back to datekit</a>}Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726
lines 204–225why, one step back204 title="Nobody has answered this ask yet."205 />206 );207208 expect(text).toContain("Back to datekit");209 });210});211212describe(Definitions, () => {213 it("reads each term before its value, in a list named for what it holds", () => {214 const element = (215 <Definitions label="Limits">216 <Definition term="Claims at once">2</Definition>217 <Definition term="Proposals a week">5</Definition>218 </Definitions>219 );220221 const markup = markupOf(element);222223 expect(markup).toMatch(/^<dl\b[^>]*aria-label="Limits"/u);224 expect(markup.match(/<dt\b/gu)).toHaveLength(2);225 expect(textOf(element)).toBe("Claims at once2Proposals a week5");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 226–228why, one step back226 });227});228Put every page in the Control room shell: rail, bars, workspace, router links, keys, head, error and pending statesoscabrielbefore adoptionddbd51e
line 229why, one step back229describe("the theme", () => {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 230–256why, one step back230 it("names the paper colours the theme-color meta repeats", () => {231 expect(styles).toContain(`--background: ${themeColors.light};`);232 expect(styles).toContain(`--background: ${themeColors.dark};`);233 });234});235236describe("the shared pieces", () => {237 // Views only: props in, markup out. A shared piece that fetched would238 // tie every page that shows it to one transport (src/surfaces.ts).239 const sources: Readonly<Record<string, string>> = import.meta.glob(240 "../src/features/shared/**/*.{ts,tsx}",241 { eager: true, import: "default", query: "?raw" }242 );243244 const transport =245 /from\s+["'](?:@repo\/protocol\/contracts|effect\/(?:rpc|http|reactivity)|#backend|[./]+\/(?:surfaces|client\/[^"']*|server\/[^"']*)(?:\.tsx?)?)["']/u;246247 it("import no transport", () => {248 expect(Object.keys(sources).length).toBeGreaterThan(5);249250 const reaching = Object.entries(sources).flatMap(([path, source]) =>251 transport.test(source) ? [path] : []252 );253254 expect(reaching).toStrictEqual([]);255 });256});