front.test.tsx
This file
Path
apps/web/test/front.test.tsx
838 lines · 24.9 KiB · TypeScript
Last changed by
Merge redesign into mainoscabrielbefore adoptioncaedd21
History of this fileTake it
1import { describe, expect, it } from "@effect/vitest";2import { Brand } from "@repo/brand";3import { deleteChildId, splitFamily } from "@repo/project/migrate";4import { Client, Contracts } from "@repo/protocol/contracts";5import { AskListing } from "@repo/protocol/domain/ask";6import type { Ask } from "@repo/protocol/domain/ask";7import { CheckSpec } from "@repo/protocol/domain/check";8import { Command, Glob, SymbolName } from "@repo/protocol/domain/common";9import {10 FrontPageEntry,11 ProjectListing,12} from "@repo/protocol/domain/front-page";13import { AskId, KindName, ProjectName } from "@repo/protocol/ids";14import { asTester, unanswered } from "@repo/protocol/testing";15import { DateTime, Effect, Layer, Option, Schema } from "effect";16import { FetchHttpClient } from "effect/http";17import { RpcClient, RpcSerialization, RpcTest } from "effect/rpc";1819import { devServer } from "../src/dev/server.ts";20import { arrange, familiesIn } from "../src/features/front/families.ts";21import {22 filterEntries,23 frontPath,24 readFilter,25} from "../src/features/front/filter.ts";26import type { FrontFilter } from "../src/features/front/filter.ts";27import { FrontPageView } from "../src/features/front/front-page.tsx";28import type { FrontPageProps } from "../src/features/front/front-page.tsx";29import {30 dismissHowTo,31 readHowToDismissed,32} from "../src/features/front/how-to.tsx";33import { FrontPageData, readFrontPage } from "../src/server/front-page.ts";34import { ask as parseIsoWeek } from "./ask-fixtures.ts";35import { textIn } from "./markup.ts";36import { renderAt } from "./render.tsx";37import { reachingTransport } from "./transport.ts";3839const kind = Schema.decodeSync(KindName);4041const rowOf = (markup: string, ask: string) => {42 const start = markup.indexOf(`data-ask="${ask}"`);4344 const ends = ["data-ask=", "<section", "</main>"].flatMap((end) => {45 const at = markup.indexOf(end, start + 1);4647 return at === -1 ? [] : [at];48 });4950 return start === -1 ? "" : markup.slice(start, Math.min(...ends));51};5253const rowsIn = (markup: string) =>54 [...markup.matchAll(/<li\b[^>]*data-ask="(?<ask>[^"]+)"/gu)].map(55 (row) => row.groups?.ask56 );5758const headersIn = (markup: string) =>59 [60 ...markup.matchAll(61 /<section aria-label="(?<project>[^"]+)"[^>]*>(?<header><div\b[\s\S]*?<\/div><\/div>)/gu62 ),63 ].map((match) => [match.groups?.project, match.groups?.header] as const);6465const listIn = (markup: string) =>66 markup.slice(markup.indexOf("data-board-list"), markup.indexOf("</main>"));6768const filtersIn = (markup: string) =>69 /<nav aria-label="Filter the asks"[\s\S]*?<\/nav>/u.exec(markup)?.[0] ?? "";7071const stripIn = (markup: string) =>72 /<section\b[^>]*data-how-to=""[\s\S]*?<\/section>/u.exec(markup)?.[0] ?? "";7374const now = DateTime.makeUnsafe("2026-10-07T12:00:00Z");7576const entries = Schema.decodeSync(Schema.Array(FrontPageEntry))([77 {78 ask: {79 ask: "explain-iso-week",80 blockedBy: [],81 claimed: false,82 kind: "bug",83 reserve: "newcomers",84 territory: "core",85 want: "The docs say which week of the year a date falls in.",86 },87 posture: "open",88 project: "datekit",89 takeable: false,90 },91 {92 ask: {93 ask: "fix-week-start",94 blockedBy: [],95 claimed: false,96 kind: "bug",97 territory: "core",98 want: "A week starts on the locale's first day, not always on Sunday.",99 },100 posture: "open",101 project: "datekit",102 takeable: true,103 },104 {105 ask: {106 ask: "split-format",107 blockedBy: [],108 claimed: false,109 kind: "migrate",110 territory: "format",111 want: "The format package calls the new parser.",112 },113 posture: "openWithSealedEvidence",114 project: "burrow",115 takeable: true,116 },117]);118119const projects = Schema.decodeSync(Schema.Array(ProjectListing))([120 {121 landedAt: "2026-10-06T09:00:00.000Z",122 openAsks: 1,123 posture: "openWithSealedEvidence",124 project: "burrow",125 },126 { openAsks: 2, posture: "open", project: "datekit" },127]);128129const asksOf = (shown: readonly FrontPageEntry[]) =>130 shown.map(({ ask }) => ask.ask);131132const props = (133 filter: FrontFilter,134 more: Partial<FrontPageProps> = {}135): FrontPageProps => ({136 entries,137 events: new Map(),138 filter,139 now,140 parents: [],141 projects,142 ...more,143});144145const front = (filter: FrontFilter, more: Partial<FrontPageProps> = {}) =>146 renderAt(frontPath(filter), <FrontPageView {...props(filter, more)} />);147148describe(filterEntries, () => {149 it("puts the asks the viewer may take first, keeping the order given", () => {150 expect(asksOf(filterEntries(entries, {}))).toStrictEqual([151 "fix-week-start",152 "split-format",153 "explain-iso-week",154 ]);155 });156157 it("narrows the list to one kind", () => {158 expect(159 asksOf(filterEntries(entries, { kind: kind("migrate") }))160 ).toStrictEqual(["split-format"]);161 });162163 it("narrows the list to the asks held for newcomers", () => {164 expect(165 asksOf(filterEntries(entries, { reserved: "newcomers" }))166 ).toStrictEqual(["explain-iso-week"]);167 });168169 it("narrows the list to the asks open to take", () => {170 expect(asksOf(filterEntries(entries, { take: "open" }))).toStrictEqual([171 "fix-week-start",172 "split-format",173 ]);174 });175176 it("narrows the list to one project", () => {177 expect(178 asksOf(179 filterEntries(entries, {180 project: ProjectName.make("oscabriel/burrow"),181 })182 )183 ).toStrictEqual(["split-format"]);184 });185});186187describe(readFilter, () => {188 it("keeps a valid kind, reserve, take and project from the address, and drops what is not one", () => {189 expect(190 readFilter({191 kind: "bug",192 project: "datekit",193 reserved: "newcomers",194 take: "open",195 })196 ).toStrictEqual({197 kind: "bug",198 project: "oscabriel/datekit",199 reserved: "newcomers",200 take: "open",201 });202 expect(203 readFilter({204 kind: "Not A Kind",205 project: "Not_A_Project",206 reserved: "everyone",207 take: "all",208 })209 ).toStrictEqual({});210 });211});212213const listing = (id: string, blockedBy: readonly string[] = []) =>214 Schema.decodeSync(AskListing)({215 ask: id,216 blockedBy,217 claimed: false,218 kind: "migrate",219 territory: ".",220 want: `The want of ${id}.`,221 });222223describe(familiesIn, () => {224 const children = ["drop-fetch-auth", "drop-fetch-kit"];225226 it("reads a family from a parent waiting on asks named after it, with its delete child", () => {227 const listed = [228 listing("drop-fetch", [...children, "drop-fetch-delete"]),229 listing("drop-fetch-auth"),230 listing("drop-fetch-kit"),231 listing("drop-fetch-delete", children),232 listing("fix-week-start"),233 ];234235 expect(familiesIn(listed)).toStrictEqual([236 {237 finale: "drop-fetch-delete",238 members: ["drop-fetch-auth", "drop-fetch-kit", "drop-fetch-delete"],239 parent: "drop-fetch",240 },241 ]);242 });243244 it("reads one where the list leaves its delete child out, or holds only it", () => {245 expect(246 familiesIn([247 listing("drop-fetch", children),248 listing("drop-fetch-auth"),249 listing("drop-fetch-kit"),250 ]).map(({ members }) => members)251 ).toStrictEqual([children]);252 expect(253 familiesIn([254 listing("drop-fetch", ["drop-fetch-delete"]),255 listing("drop-fetch-delete"),256 ]).map(({ members }) => members)257 ).toStrictEqual([["drop-fetch-delete"]]);258 });259260 it("reads no family from an ask that waits on an ask not named after it", () => {261 expect(262 familiesIn([263 listing("footnote-backrefs", ["number-footnotes"]),264 listing("number-footnotes"),265 ])266 ).toStrictEqual([]);267 });268269 it("finds the family the platform's split opens, by the names it gives", () => {270 const migrateParent: Ask = {271 ...parseIsoWeek,272 blockedBy: [],273 brief: { want: "Replace legacyFetch with http.get." },274 check: CheckSpec.cases.Migrate.make({275 count: Command.make("bun run count"),276 from: SymbolName.make("legacyFetch"),277 to: SymbolName.make("http.get"),278 }),279 id: AskId.make("drop-fetch"),280 kind: KindName.make("migrate"),281 project: ProjectName.make("oscabriel/burrow"),282 territory: { module: ".", paths: [Glob.make("packages/**")] },283 };284285 const counted = Option.getOrThrow(286 splitFamily({287 configDir: Brand.configDir,288 counts: { byModule: { auth: 2, kit: 1 }, total: 3 },289 modules: [290 { module: "auth", paths: [Glob.make("packages/auth/**")] },291 { module: "kit", paths: [Glob.make("packages/kit/**")] },292 ],293 parent: migrateParent,294 })295 );296297 const listed = [298 counted.parent,299 ...counted.children,300 counted.deleteChild,301 ].map((ask) => listing(ask.id, ask.blockedBy));302303 expect(familiesIn(listed)).toStrictEqual([304 {305 finale: deleteChildId(counted.parent.id),306 members: [307 ...counted.children.map(({ id }) => id),308 counted.deleteChild.id,309 ],310 parent: counted.parent.id,311 },312 ]);313 });314});315316describe(arrange, () => {317 it("puts each family at its parent's place, its members out of the list", () => {318 const listed = [319 listing("fix-week-start"),320 listing("drop-fetch-auth"),321 listing("drop-fetch", ["drop-fetch-auth"]),322 listing("parse-iso"),323 ];324325 expect(326 arrange(listed).map((item) =>327 item.kind === "family"328 ? `${item.parent.ask}: ${item.members.map(({ ask }) => ask).join(", ")}`329 : item.listing.ask330 )331 ).toStrictEqual([332 "fix-week-start",333 "drop-fetch: drop-fetch-auth",334 "parse-iso",335 ]);336 });337});338339describe(FrontPageView, () => {340 it.effect(341 "shows the asks the viewer may take first, grouped by project",342 () =>343 Effect.gen(function* () {344 expect(rowsIn(yield* front({}))).toStrictEqual([345 "fix-week-start",346 "explain-iso-week",347 "split-format",348 ]);349 })350 );351352 it.effect(353 "says each project's posture once, on its group's header, and on no row",354 () =>355 Effect.gen(function* () {356 const markup = yield* front({});357 const headers = headersIn(markup);358359 const [datekit, burrow] = headers.map(([, header]) => header ?? "");360361 expect(headers.map(([project]) => project)).toStrictEqual([362 "oscabriel/datekit",363 "oscabriel/burrow",364 ]);365 expect({366 burrowLink: burrow?.includes('href="/oscabriel/burrow"'),367 burrowPosture: burrow?.includes(368 'data-posture="openWithSealedEvidence"'369 ),370 burrowWords: textIn(burrow ?? "").includes(371 "Open with sealed evidence"372 ),373 datekitCounts: textIn(datekit ?? "").includes("2 open · 1 to take"),374 }).toStrictEqual({375 burrowLink: true,376 burrowPosture: true,377 burrowWords: true,378 datekitCounts: true,379 });380 expect(listIn(markup).match(/data-posture=/gu)).toHaveLength(2);381 expect(382 ["fix-week-start", "explain-iso-week", "split-format"].filter((ask) =>383 rowOf(markup, ask).includes("data-posture")384 )385 ).toStrictEqual([]);386 })387 );388389 it.effect(390 "draws its rows when the list of projects has not arrived, with no posture yet",391 () =>392 Effect.gen(function* () {393 const markup = yield* front({}, { projects: undefined });394395 expect(rowsIn(markup)).toHaveLength(3);396 expect(listIn(markup)).not.toContain("data-posture=");397 })398 );399400 it.effect(401 "says an ask held for newcomers is held for them whoever reads it, with no command for a viewer who may not take it",402 () =>403 Effect.gen(function* () {404 const markup = yield* front({});405 const row = rowOf(markup, "explain-iso-week");406407 expect(row).toContain('data-takeable="false"');408 expect(textIn(row)).toMatch(409 /^(?!.*Not open to you).*Held for newcomers/su410 );411 expect(row).not.toContain("Open to take");412 expect(row).not.toContain(`${Brand.cli} claim explain-iso-week`);413 expect(rowOf(markup, "fix-week-start")).toContain("Open to take");414 })415 );416417 it.effect("links each ask's want, and shows its kind, territory and id", () =>418 Effect.gen(function* () {419 const row = rowOf(yield* front({}), "split-format");420421 expect(row).toMatch(422 /<a\b[^>]*href="\/oscabriel\/burrow\/asks\/split-format"[^>]*>The format package calls the new parser\.<\/a>/u423 );424 expect(textIn(row)).toContain("migrate · format · split-format");425 })426 );427428 it.effect(429 "gives an ask the viewer may take its claim command as text in its copy button, with no command box",430 () =>431 Effect.gen(function* () {432 const row = rowOf(yield* front({}), "fix-week-start");433434 expect(row).toMatch(435 new RegExp(436 `<button[^>]*aria-label="Copy claim command"[\\s\\S]*?<code[^>]*>${Brand.cli} claim fix-week-start --project oscabriel/datekit</code>`,437 "u"438 )439 );440 // A command box's text is selectable whole; a row's command is a button's.441 expect(row).not.toContain("select-all");442 })443 );444445 it.effect("counts the asks shown, and those open to take", () =>446 Effect.gen(function* () {447 expect(textIn(yield* front({}))).toContain("3 open asks, 2 open to take");448 })449 );450451 it.effect(452 "narrows by kind, offering each kind, who an ask is for, and each project, with counts",453 () =>454 Effect.gen(function* () {455 const markup = yield* front({ kind: kind("migrate") });456 const all = yield* front({});457 const toolbar = filtersIn(all);458459 expect(rowsIn(markup)).toStrictEqual(["split-format"]);460 expect(461 [462 'href="/asks?kind=bug"',463 'href="/asks?kind=migrate&reserved=newcomers"',464 ].filter((href) => !markup.includes(href))465 ).toStrictEqual([]);466 expect(467 [468 'href="/asks?reserved=newcomers"',469 'href="/asks?take=open"',470 'href="/asks?project=oscabriel%2Fburrow"',471 ].filter((href) => !all.includes(href))472 ).toStrictEqual([]);473 expect(textIn(toolbar)).toMatch(474 /Open to take\s*2[\s\S]*Held for newcomers\s*1/u475 );476 expect(477 ["Reserved", "For people, not agents"].filter((words) =>478 textIn(toolbar).includes(words)479 )480 ).toStrictEqual([]);481 })482 );483484 it.effect(485 "draws the filters as a landmark beside the list, and no inspector",486 () =>487 Effect.gen(function* () {488 const markup = yield* front({});489 const board = markup.slice(markup.indexOf("data-board="));490491 expect(492 board.indexOf('<nav aria-label="Filter the asks"')493 ).toBeGreaterThan(-1);494 const list = board.indexOf("data-board-list");495496 expect([497 board.indexOf("</nav>") < list,498 list < board.indexOf('data-ask="'),499 ]).toStrictEqual([true, true]);500 expect(501 ["data-facts", "Start here", "Selected ask", "data-toolbar"].filter(502 (words) => markup.includes(words)503 )504 ).toStrictEqual([]);505 })506 );507508 it.effect(509 "offers each kind, each state and each project in the filters, with counts, and a reset once one is set",510 () =>511 Effect.gen(function* () {512 const filters = filtersIn(yield* front({ kind: kind("bug") }));513514 expect(515 [...filters.matchAll(/<h2\b[^>]*>(?<head>[^<]+)<\/h2>/gu)].map(516 ({ groups }) => groups?.head517 )518 ).toStrictEqual(["Kind", "State", "Project"]);519 expect(textIn(filters)).toMatch(520 /All\s*3[\s\S]*bug\s*2[\s\S]*migrate\s*1[\s\S]*Open to take\s*1[\s\S]*Held for newcomers\s*1/u521 );522 expect(filters).toMatch(523 /<a\b[^>]*aria-current="page"[^>]*href="\/asks\?kind=bug"|<a\b[^>]*href="\/asks\?kind=bug"[^>]*aria-current="page"/u524 );525 expect(filters).toMatch(526 /<a\b[^>]*href="\/asks"[^>]*>Reset filters<\/a>/u527 );528 expect(filtersIn(yield* front({}))).not.toContain("Reset filters");529 })530 );531532 it.effect(533 "keeps the filter in the address, so /asks?kind=bug&take=open shows the bugs open to take and every option keeps the rest",534 () =>535 Effect.gen(function* () {536 const markup = yield* front(readFilter({ kind: "bug", take: "open" }));537538 const filters = filtersIn(markup);539540 expect(rowsIn(markup)).toStrictEqual(["fix-week-start"]);541 expect(542 [543 'href="/asks?kind=bug&reserved=newcomers"',544 'href="/asks?take=open"',545 'href="/asks?kind=migrate&take=open"',546 'href="/asks?kind=bug&take=open&project=oscabriel%2Fdatekit"',547 ].filter((href) => !filters.includes(href))548 ).toStrictEqual([]);549 })550 );551552 it.effect(553 "keeps one command box in the strip on a phone, the other two steps as code in the list",554 () =>555 Effect.gen(function* () {556 const strip = stripIn(yield* front({}));557558 expect(559 [560 ...strip.matchAll(561 /<code\b[^>]*data-step-text=""[^>]*>(?<command>[^<]*)<\/code>/gu562 ),563 ].map(({ groups }) => groups?.command)564 ).toStrictEqual([565 `${Brand.cli} check`,566 `git push ${Brand.slug} HEAD:main`,567 ]);568 expect(strip.match(/<div class="max-tablet:hidden">/gu)).toHaveLength(569 2570 );571 })572 );573574 it.effect(575 "puts one strip of three steps above the list, each a command, with a control that dismisses it",576 () =>577 Effect.gen(function* () {578 const markup = yield* front({});579 const strip = stripIn(markup);580581 expect([582 ...strip.matchAll(/<code\b[^>]*select-all[^>]*>/gu),583 ]).toHaveLength(3);584 expect(585 [586 `${Brand.cli} claim <ask> --project <owner>/<name>`,587 `${Brand.cli} check`,588 `git push ${Brand.slug} HEAD:main`,589 ].filter((command) => !textIn(strip).includes(command))590 ).toStrictEqual([]);591 expect(strip).toMatch(592 /<button\b[^>]*aria-label="Dismiss how to take an ask"/u593 );594 expect(markup.indexOf("data-how-to")).toBeLessThan(595 markup.indexOf("data-board=")596 );597 expect(strip).toContain('href="/llms.txt"');598 })599 );600601 it.effect("with an ask selected, marks its row and opens no inspector", () =>602 Effect.gen(function* () {603 const markup = yield* renderAt(604 "/asks?ask=fix-week-start",605 <FrontPageView {...props({})} />606 );607608 expect(markup).toMatch(609 /<li\b[^>]*data-selected="true"[^>]*data-ask="fix-week-start"/u610 );611 expect(markup).not.toContain("data-facts");612 })613 );614615 it.effect("never uses the words a forge's lists use", () =>616 Effect.gen(function* () {617 const text = textIn(yield* front({})).toLowerCase();618619 for (const word of ["queue", "inbox", "explore", "trending"]) {620 expect(text).not.toContain(word);621 }622 })623 );624625 it.effect(626 "says an empty front page is empty, with the command that starts a project",627 () =>628 Effect.gen(function* () {629 const text = textIn(yield* front({}, { entries: [], projects: [] }));630631 expect(text).toContain("No open asks");632 expect(text).toContain(`${Brand.cli} init`);633 })634 );635636 it.effect(637 "says a front page with projects but no asks needs an ask opened",638 () =>639 Effect.gen(function* () {640 const text = textIn(yield* front({}, { entries: [] }));641642 expect(text).toContain("No open asks");643 expect(text).toContain(`${Brand.cli} ask open`);644 })645 );646});647648const clientOver = (answer: (request: Request) => Promise<Response>) =>649 Layer.effect(Client)(RpcClient.make(Contracts)).pipe(650 Layer.provide(RpcClient.layerProtocolHttp({ url: "http://localhost/rpc" })),651 Layer.provide([FetchHttpClient.layer, RpcSerialization.layerJson]),652 Layer.provide(653 Layer.succeed(FetchHttpClient.Fetch, (input, init) =>654 answer(new Request(input, init))655 )656 )657 );658659const devWorld = Layer.unwrap(660 Effect.gen(function* () {661 const { dispose, handler } = devServer();662663 yield* Effect.addFinalizer(() => Effect.promise(dispose));664665 return clientOver(handler);666 })667);668669const projectsNeverAnswer = Layer.effect(670 Client,671 RpcTest.makeClient(Contracts)672).pipe(673 Layer.provide([674 Layer.mergeAll(675 unanswered,676 Contracts.toLayerHandler("frontPage", () => Effect.succeed({ entries })),677 Contracts.toLayerHandler("listProjects", () => Effect.never)678 ),679 asTester,680 ])681);682683const decodeData = Schema.decodeEffect(FrontPageData);684685/** A fresh dev world seeds itself first, which a full test run can slow past 5 s. */686const seededWorld = { timeout: 30_000 };687688const sentFrom = (data: FrontPageData, filter: FrontFilter = {}) =>689 renderAt(690 "/asks",691 <FrontPageView692 entries={data.entries}693 events={694 new Map(data.events.map(({ events, project }) => [project, events]))695 }696 filter={filter}697 now={data.now}698 parents={data.parents}699 projects={undefined}700 />701 );702703describe("the front page as the server sends it", () => {704 it.effect(705 "holds every open ask's want as a link, grouped by project, burrow's family as one fan row",706 () =>707 Effect.gen(function* () {708 const data = yield* readFrontPage.pipe(709 Effect.flatMap(decodeData),710 Effect.provide(devWorld)711 );712713 const markup = yield* sentFrom(data);714 const text = textIn(markup);715716 expect(listIn(markup)).not.toContain("Reading from the platform");717 expect(markup).toMatch(718 /<a\b[^>]*href="\/oscabriel\/datekit\/asks\/add-months-clamp"[^>]*>[^<]+<\/a>/u719 );720 expect(headersIn(markup).map(([project]) => project)).toStrictEqual([721 "oscabriel/burrow",722 "oscabriel/datekit",723 ]);724 expect(text).toContain("10 open asks, 7 open to take");725726 const family = rowOf(markup, "drop-legacy-fetch");727 const nodes = family.match(/<li class="flex items-center gap-1.5"/gu);728729 expect({730 familyRows: rowsIn(markup).filter(731 (ask) => ask?.startsWith("drop-legacy-fetch") === true732 ),733 nodes: nodes?.length,734 noCommandBox: !listIn(markup).includes("select-all"),735 strip: /0 of 6 landed[\s\S]*Show 6 children/u.test(textIn(family)),736 }).toStrictEqual({737 familyRows: ["drop-legacy-fetch"],738 nodes: 6,739 noCommandBox: true,740 strip: true,741 });742 }),743 seededWorld744 );745746 it.effect(747 "is read without the list of projects, which may never answer",748 () =>749 Effect.gen(function* () {750 const data = yield* readFrontPage.pipe(751 Effect.flatMap(decodeData),752 Effect.provide(projectsNeverAnswer)753 );754755 expect(rowsIn(yield* sentFrom(data))).toHaveLength(3);756 })757 );758});759760/** A browser's storage held in a map, so a test reads back what was kept. */761const memoryStorage = (): Storage => {762 const kept = new Map<string, string>();763764 return {765 clear: () => {766 kept.clear();767 },768 getItem: (key) => kept.get(key) ?? null,769 key: (index) => [...kept.keys()][index] ?? null,770 get length() {771 return kept.size;772 },773 removeItem: (key) => {774 kept.delete(key);775 },776 setItem: (key, value) => {777 kept.set(key, value);778 },779 };780};781782const blocked = () => {783 throw new Error("blocked");784};785786/** Storage a private window or a blocked site refuses. */787const refusingStorage = (): Storage => ({788 clear: blocked,789 getItem: blocked,790 key: blocked,791 length: 0,792 removeItem: blocked,793 setItem: blocked,794});795796describe("the strip's dismissal", () => {797 it("is remembered in the storage it is given, and is not until then", () => {798 const storage = memoryStorage();799800 expect(readHowToDismissed(storage)).toBeFalsy();801802 dismissHowTo(storage);803804 expect(readHowToDismissed(storage)).toBeTruthy();805 expect(storage).toHaveLength(1);806 });807808 it("shows the strip when there is no storage, or the storage refuses", () => {809 expect(readHowToDismissed()).toBeFalsy();810 expect(readHowToDismissed(refusingStorage())).toBeFalsy();811 expect(() => {812 dismissHowTo(refusingStorage());813 }).not.toThrow();814 });815});816817describe("the front page's views", () => {818 const sources: Readonly<Record<string, string>> = import.meta.glob(819 "../src/features/front/**/*.{ts,tsx}",820 { eager: true, import: "default", query: "?raw" }821 );822823 it("import no transport", () => {824 expect(Object.keys(sources).length).toBeGreaterThanOrEqual(1);825 expect(reachingTransport(sources)).toStrictEqual([]);826 });827828 it("never write a cookie: the strip's dismissal is kept in localStorage", () => {829 expect(830 Object.entries(sources).flatMap(([path, source]) =>831 /document\.cookie|cookieStore|set-cookie/iu.test(source) ? [path] : []832 )833 ).toStrictEqual([]);834 expect(sources["../src/features/front/how-to.tsx"]).toContain(835 "localStorage"836 );837 });838});