Expect every project's full-name address in the web's e2e checks
Before adoption: this commit came in with the history the project adopted, so no landing records it.
W14 moved each project to its full name (ADR 0032); the e2e checks still looked for legacy keys. Each now reads its project through ProjectName, so WEB_IMPORTS, WEB_PROJECT and WEB_TAGS_PROJECT take full names (a legacy key still reads as its name), and every expected href is the full-name address.
authored by oscabriel · committed by oscabriel · parent 3fcdb5c · Browse files · 6 files·+152 added−79 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+152 added−79 removed
- other:+152 added−79 removed
Provenance
- Commit
1dee558- Tree
35e051a- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent
3fcdb5c
6 files changed+152 added−79 removed
modified:apps/web/e2e/a11y.e2e.ts+5 added-5 removed
18 unmodified lines19 *20 * It runs only against `WEB_URL`, the web's dev world with its fixtures21 * (`VITE_DEV_FIXTURES=1 bun run dev -- --port <port>`): the pages it visits22 * are the fixture project's, and it signs in through the dev world's own23- * `/auth/dev`. `A11Y_PROJECT` names the fixture project (vellum unless24- * given). It only reads, but for the keys switch, kept in this browser.23+ * `/auth/dev`. `A11Y_PROJECT` names the fixture project by its full name24+ * (`oscabriel/vellum` unless given). It only reads, but for the keys switch, kept in this browser.25 */26 import { expect, test } from "@playwright/test";27 import type { Browser, BrowserContext, Page } from "@playwright/test";28 import { Brand } from "@repo/brand";4 unmodified lines33 const settings = Effect.runSync(34 Effect.gen(function* () {35 return {36 project: yield* Config.NonEmptyString("A11Y_PROJECT").pipe(37- Config.withDefault("vellum")37+ Config.withDefault("oscabriel/vellum")38 ),39 web: Option.map(40 yield* Config.option(Config.NonEmptyString("WEB_URL")),41 (url) => url.replace(/\/+$/u, "")32 unmodified lines74 { name: "front, signed in", path: "/asks", signedIn: true },75 { name: "today", path: "/today", signedIn: true },76 { name: "today, signed out", path: "/today" },77 { name: "project home", path: `/${project}` },78- { name: "project home, examples", path: "/burrow" },79- { name: "project home, no open asks", path: "/mossgate" },78+ { name: "project home, examples", path: "/oscabriel/burrow" },79+ { name: "project home, no open asks", path: "/lin-h/mossgate" },80 { name: "ask, open", path: `/${project}/asks/lint-heading-levels` },81 {82 name: "ask, held for newcomers",83 path: `/${project}/asks/document-cli-flags`,659 unmodified linesmodified:apps/web/e2e/deployed.e2e.ts+6 added-3 removed
15 unmodified lines16 * packages"), so `WEB_PROJECT=burrow` alone checks burrow. It only reads.17 */18 import { expect, test } from "@playwright/test";19 import type { Page } from "@playwright/test";20+import { ProjectName } from "@repo/protocol/ids";21 import { Config, Effect, Option } from "effect";22 23 /**24 * What the check looks at in each seeded example unless told otherwise: an15 unmodified lines40 41 /** What the check reads of its env: where the web lives, and which ask to look at. */42 const settings = Effect.runSync(43 Effect.gen(function* () {44+ // Read by the one parser: `burrow` and `oscabriel/burrow` alike.43- const project = yield* Config.NonEmptyString("WEB_PROJECT").pipe(44- Config.withDefault("datekit")45+ const project = yield* Config.schema(ProjectName, "WEB_PROJECT").pipe(46+ Config.withDefault(ProjectName.make("oscabriel/datekit"))47 );48 47- const example = project === "burrow" ? examples.burrow : examples.datekit;49+ const example =50+ project === "oscabriel/burrow" ? examples.burrow : examples.datekit;51 52 return {53 ask: yield* Config.NonEmptyString("WEB_ASK").pipe(54 Config.withDefault(example.ask)250 unmodified linesmodified:apps/web/e2e/imports.e2e.ts+121 added-57 removed
13 unmodified lines14 * root folder, a file at line 5, the log, and why that file's lines are15 * there.16 *17 * It runs only against `WEB_URL` (a dev stage's web origin) and is skipped18- * without it. `WEB_IMPORTS` narrows it to some projects (a comma list),19- * for a run while the imports go in one at a time. It only reads.18+ * without it. `WEB_IMPORTS` narrows it to some projects, a comma list of19+ * full names (`github.com/pallets/click`), for a run while the imports go20+ * in one at a time. Every address it visits or expects is the project's21+ * full name (ADR 0032). It only reads.22 */23 import { expect, test } from "@playwright/test";24 import type { Page } from "@playwright/test";25 import { Brand } from "@repo/brand";26+import { ProjectName } from "@repo/protocol/ids";24-import { Config, Console, Effect, Option } from "effect";27+import { Config, Console, Effect, Option, Schema } from "effect";28 29 /** One imported project: where its pages look, and what they must show. */30 interface Imported {31 readonly project: string;135 unmodified lines167 };168 })169 );170 168-/** Those of `all` this run visits: `WEB_IMPORTS`' names, or all of them. */171+/**172+ * A project's full name, read by the one parser (ADR 0032): an import's173+ * key from before owners (`click`) reads as its source path174+ * (`github.com/pallets/click`), and a full name as itself.175+ */176+const nameOf = (spelled: string): ProjectName =>177+ Schema.decodeSync(ProjectName)(spelled);178+179+/** `text` as a regular expression matches it, literally. */180+const escaped = (text: string) =>181+ text.replaceAll(/[.*+?^${}()|[\]\\]/gu, "\\$&");182+183+/** A project's address on the web: its full name. */184+const homeOf = (project: string) => `/${nameOf(project)}`;185+186+/**187+ * Those of `all` this run visits: `WEB_IMPORTS`' full names188+ * (`github.com/pallets/click`), or all of them.189+ */190 const visitedOf = <A extends { readonly project: string }>(191 all: readonly A[]192 ): readonly A[] =>193 Option.match(settings.only, {194 onNone: () => all,195 onSome: (names) => {175- const named = new Set(names.split(",").map((name) => name.trim()));196+ const named = new Set(197+ names.split(",").map((name) => nameOf(name.trim()))198+ );199 177- return all.filter(({ project }) => named.has(project));200+ return all.filter(({ project }) => named.has(nameOf(project)));201 },202 });203 204 const visited = visitedOf(imports);126 unmodified lines331 /** The newest commit's page, as the log links it. */332 const newestCommit = (browser: Page, project: string) =>333 Effect.gen(function* () {334 const response = yield* awaited(() =>312- browser.goto(at(`/${project}/commits/main`))335+ browser.goto(at(`${homeOf(project)}/commits/main`))336 );337 338 expect(response?.status()).toBe(200);339 317- const link = browser.locator(`a[href^="/${project}/commit/"]`).first();340+ const link = browser341+ .locator(`a[href^="${homeOf(project)}/commit/"]`)342+ .first();343 344 yield* awaited(() => expect(link).toBeVisible());345 346 const href = yield* awaited(() => link.getAttribute("href"));10 unmodified lines357 */358 const homeWanted = (project: string, readme: string) => ({359 selectors: [360 "[data-readme]",336- `section[aria-label="Take part"]:visible:has-text("/${project}.git")`,361+ `section[aria-label="Take part"]:visible:has-text("${homeOf(project)}.git")`,362 ],363 texts: [readme],364 });365 7 unmodified lines373 Effect.runPromise(374 visit(375 browser,376 project,352- `/${project}`,377+ homeOf(project),378 "home",379 homeWanted(project, readme)380 )381 ));3 unmodified lines385 timedProject386 ? timed(387 browser,388 project,364- `/${project}/tree/main/${dir}`,389+ `${homeOf(project)}/tree/main/${dir}`,390 "tree",391 `[data-entry="${entry}"]`392 )368- : visit(browser, project, `/${project}/tree/main/${dir}`, "tree", {369- selectors: [`[data-entry="${entry}"]`],370- })393+ : visit(394+ browser,395+ project,396+ `${homeOf(project)}/tree/main/${dir}`,397+ "tree",398+ {399+ selectors: [`[data-entry="${entry}"]`],400+ }401+ )402 ));403 404 test(`${project}'s ${file} opens at line 5`, ({ page: browser }) =>405 Effect.runPromise(406 Effect.gen(function* () {407 yield* visit(408 browser,409 project,379- `/${project}/blob/main/${file}#L5`,410+ `${homeOf(project)}/blob/main/${file}#L5`,411 "blob",412 {413 selectors: ['[data-toolbar="file"]'],414 texts: ["Permalink"],5 unmodified lines420 ));421 422 test(`${project}'s log groups its commits by day`, ({ page: browser }) =>423 Effect.runPromise(393- visit(browser, project, `/${project}/commits/main`, "commits", {394- selectors: [`a[href^="/${project}/commit/"]`, "[data-day]"],424+ visit(browser, project, `${homeOf(project)}/commits/main`, "commits", {425+ selectors: [`a[href^="${homeOf(project)}/commit/"]`, "[data-day]"],426 texts: ["Landings"],427 })428 ));429 23 unmodified lines453 ));454 455 test(`${project}'s refs show main and its tags`, ({ page: browser }) =>456 Effect.runPromise(426- visit(browser, project, `/${project}/refs`, "refs", {457+ visit(browser, project, `${homeOf(project)}/refs`, "refs", {458 selectors: ['[data-ref="main"]'],459 texts: ["Landed at", "Tags"],460 })461 ));4 unmodified lines466 Effect.runPromise(467 visit(468 browser,469 project,439- `/${project}/people`,470+ `${homeOf(project)}/people`,471 "people",472 evaluated473 ? { selectors: ['[data-paths="**"]'] }474 : {12 unmodified lines487 timedProject488 ? timed(489 browser,490 project,460- `/${project}/why/main/${file}`,491+ `${homeOf(project)}/why/main/${file}`,492 "why",493 "[data-range]"494 )464- : visit(browser, project, `/${project}/why/main/${file}`, "why", {465- selectors: ["[data-range]"],466- })495+ : visit(496+ browser,497+ project,498+ `${homeOf(project)}/why/main/${file}`,499+ "why",500+ {501+ selectors: ["[data-range]"],502+ }503+ )504 ));505 506 if (timedProject) {507 test(`${project}'s ${file} history lists the commits that changed it`, ({2 unmodified lines510 Effect.runPromise(511 timed(512 browser,513 project,477- `/${project}/commits/main?path=${encodeURIComponent(file)}`,514+ `${homeOf(project)}/commits/main?path=${encodeURIComponent(file)}`,515 "commits-path",479- `a[href^="/${project}/commit/"]`516+ `a[href^="${homeOf(project)}/commit/"]`517 )518 ));519 }520 };4 unmodified lines525 Effect.runPromise(526 visit(527 browser,528 project,492- `/${project}`,529+ homeOf(project),530 "home",531 homeWanted(project, readme)532 )533 ));534 535 test(`${project}'s root lists ${file}`, ({ page: browser }) =>536 Effect.runPromise(500- visit(browser, project, `/${project}/tree/main`, "tree", {537+ visit(browser, project, `${homeOf(project)}/tree/main`, "tree", {538 selectors: [`[data-entry="${file}"]`],539 })540 ));541 2 unmodified lines544 Effect.gen(function* () {545 yield* visit(546 browser,547 project,511- `/${project}/blob/main/${file}#L5`,548+ `${homeOf(project)}/blob/main/${file}#L5`,549 "blob",550 {551 selectors: ['[data-toolbar="file"]'],552 }4 unmodified lines557 ));558 559 test(`${project}'s log groups its commits by day`, ({ page: browser }) =>560 Effect.runPromise(524- visit(browser, project, `/${project}/commits/main`, "commits", {525- selectors: [`a[href^="/${project}/commit/"]`, "[data-day]"],561+ visit(browser, project, `${homeOf(project)}/commits/main`, "commits", {562+ selectors: [`a[href^="${homeOf(project)}/commit/"]`, "[data-day]"],563 })564 ));565 566 test(`${project}'s ${file} says why each line is there`, ({567 page: browser,568 }) =>569 Effect.runPromise(533- visit(browser, project, `/${project}/why/main/${file}`, "why", {570+ visit(browser, project, `${homeOf(project)}/why/main/${file}`, "why", {571 selectors: ["[data-range]"],572 })573 ));574 };5 unmodified lines580 (browser) =>581 Effect.gen(function* () {582 // Annotated tags, listed peeled to their commits: a tag's tree opens.583 // The newest come first, a hundred a page: 1.0.0 is on the second.547- yield* visit(browser, "anyhow", "/anyhow/refs?from=100", "refs-tags", {548- selectors: ['[data-tag="1.0.0"]'],549- });584+ yield* visit(585+ browser,586+ "anyhow",587+ `${homeOf("anyhow")}/refs?from=100`,588+ "refs-tags",589+ {590+ selectors: ['[data-tag="1.0.0"]'],591+ }592+ );593 594 const tagged = browser.locator('[data-tag="1.0.0"] a').first();595 596 expect(yield* awaited(() => tagged.getAttribute("href"))).toBe(554- "/anyhow/tree/1.0.0"597+ `${homeOf("anyhow")}/tree/1.0.0`598 );599 557- yield* visit(browser, "anyhow", "/anyhow/tree/1.0.0", "tag-tree", {558- selectors: ['[data-entry="Cargo.toml"]'],559- });600+ yield* visit(601+ browser,602+ "anyhow",603+ `${homeOf("anyhow")}/tree/1.0.0`,604+ "tag-tree",605+ {606+ selectors: ['[data-entry="Cargo.toml"]'],607+ }608+ );609 }),610 ],611 [612 "awesome",613 (browser) =>614 Effect.gen(function* () {615 // The 78 KB README renders, its relative links pinned to a commit.567- yield* visit(browser, "awesome", "/awesome", "readme-links", {616+ yield* visit(browser, "awesome", homeOf("awesome"), "readme-links", {617 texts: ["Contribution guide", "Front-End Development"],618 });619 620 const href = yield* awaited(() =>3 unmodified lines624 .getAttribute("href")625 );626 627 expect(href).toMatch(579- /^\/awesome\/blob\/[0-9a-f]{40}\/contributing\.md$/u628+ new RegExp(629+ `^${escaped(homeOf("awesome"))}/blob/[0-9a-f]{40}/contributing\\.md$`,630+ "u"631+ )632 );633 }),634 ],635 [3 unmodified lines639 // Seven levels down: the deepest folder's file opens.640 yield* visit(641 browser,642 "changesets",591- "/changesets/blob/main/packages/cli/src/commands/status/__tests__/status.test.ts",643+ `${homeOf("changesets")}/blob/main/packages/cli/src/commands/status/__tests__/status.test.ts`,644 "deep-file",645 { texts: ["Permalink"] }646 );647 4 unmodified lines652 while (!found && from < 1000) {653 yield* visit(654 browser,655 "changesets",604- from === 0 ? "/changesets/refs" : `/changesets/refs?from=${from}`,656+ from === 0657+ ? `${homeOf("changesets")}/refs`658+ : `${homeOf("changesets")}/refs?from=${from}`,659 "refs-scoped",660 { texts: ["Tags"] }661 );662 found =11 unmodified lines674 .first()675 .getAttribute("href")676 );677 624- expect(href).toMatch(/^\/changesets\/tree\/%40changesets%2Fcli%40/u);678+ expect(href).toMatch(679+ new RegExp(680+ `^${escaped(homeOf("changesets"))}/tree/%40changesets%2Fcli%40`,681+ "u"682+ )683+ );684 685 yield* visit(browser, "changesets", href ?? "", "scoped-tag-tree", {686 selectors: ['[data-entry="packages"]'],687 });3 unmodified lines691 "click",692 (browser) =>693 Effect.gen(function* () {694 // Past the first 30 commits, by Older.636- yield* visit(browser, "click", "/click/commits/main", "log-first", {637- texts: ["Older"],638- });695+ yield* visit(696+ browser,697+ "click",698+ `${homeOf("click")}/commits/main`,699+ "log-first",700+ {701+ texts: ["Older"],702+ }703+ );704 yield* awaited(() => browser.getByText("Older").first().click());705 yield* awaited(() => browser.waitForURL(/from=30/u));706 yield* awaited(() =>707 expect(643- browser.locator('a[href^="/click/commit/"]').first()708+ browser.locator(`a[href^="${homeOf("click")}/commit/"]`).first()709 ).toBeVisible()710 );711 yield* whole(browser);712 yield* shoot(browser, "click", "log-older");6 unmodified lines719 // A gitlink lists as a submodule, with no page of its own.720 yield* visit(721 browser,722 "fuzzel",658- "/fuzzel/tree/main/external",723+ `${homeOf("fuzzel")}/tree/main/external`,724 "submodule",725 {726 selectors: ['[data-entry="external/wlr-protocols"]'],727 }9 unmodified lines737 "ky",738 (browser) =>739 Effect.gen(function* () {740 // Lowercase `readme.md`, and its SVG logo shown through raw.676- yield* visit(browser, "ky", "/ky", "readme-logo", {741+ yield* visit(browser, "ky", homeOf("ky"), "readme-logo", {742 selectors: ['[data-readme="readme.md"]'],743 });744 680- const logo =681- '[data-readme] img[src^="/ky/raw/"][src$="/media/logo.svg"]';745+ const logo = `[data-readme] img[src^="${homeOf("ky")}/raw/"][src$="/media/logo.svg"]`;746 747 yield* loaded(browser, logo);748 }),749 ],4 unmodified lines754 // A 730 KB header opens, cut or drawn, never a crash.755 yield* visit(756 browser,757 "stb",694- "/stb/blob/main/tests/caveview/glext.h",758+ `${homeOf("stb")}/blob/main/tests/caveview/glext.h`,759 "large-file",760 { texts: ["glext.h"] }761 );762 763 // A PNG shows as an image.764 yield* visit(765 browser,766 "stb",703- "/stb/blob/main/data/easy_font_raw.png",767+ `${homeOf("stb")}/blob/main/data/easy_font_raw.png`,768 "png",769 {706- selectors: ['img[src^="/stb/raw/"]'],770+ selectors: [`img[src^="${homeOf("stb")}/raw/"]`],771 }772 );709- yield* loaded(browser, 'img[src^="/stb/raw/"]');773+ yield* loaded(browser, `img[src^="${homeOf("stb")}/raw/"]`);774 }),775 ],776 ]);777 8 unmodified lines786 // page's own reads.787 test.setTimeout(240_000);788 789 for (const imported of visited) {726- test.describe(imported.project, () => {790+ test.describe(nameOf(imported.project), () => {791 pages(imported);792 793 const specific = specifics.get(imported.project);794 5 unmodified lines800 });801 }802 803 for (const imported of visitedOf(known)) {740- test.describe(imported.project, () => {804+ test.describe(nameOf(imported.project), () => {805 knownPages(imported);806 });807 }808 });modified:apps/web/e2e/people.e2e.ts+4 added-2 removed
6 unmodified lines789101112131415161718171819202122232464 unmodified lines6 unmodified lines * without it. `WEB_PROJECT` picks the project (datekit, which the seed puts * on every stage, unless given). It only reads. */import { expect, test } from "@playwright/test";import { ProjectName } from "@repo/protocol/ids";import { Config, Effect, Option } from "effect";
/** What the check reads of its env: where the web lives, and which project to look at. */const settings = Effect.runSync( Effect.gen(function* () { return { // Read by the one parser: `datekit` and `oscabriel/datekit` alike. project: yield* Config.NonEmptyString("WEB_PROJECT").pipe( Config.withDefault("datekit") project: yield* Config.schema(ProjectName, "WEB_PROJECT").pipe( Config.withDefault(ProjectName.make("oscabriel/datekit")) ), web: Option.map( yield* Config.option(Config.NonEmptyString("WEB_URL")), (url) => url.replace(/\/+$/u, "")64 unmodified linesmodified:apps/web/e2e/tags.e2e.ts+11 added-9 removed
4 unmodified lines5 * the first one's tree opens. The package's page is saved as6 * `e2e/out/tags.png` for the shot list.7 *8 * It runs only against `WEB_URL` (a stage's web origin) and is skipped9- * without it. `WEB_TAGS_PROJECT` picks the project (changesets, which10- * `scripts/import-examples.ts` puts on a dev stage, unless given). It only9+ * without it. `WEB_TAGS_PROJECT` picks the project by its full name10+ * (`github.com/changesets/changesets`, which `scripts/import-examples.ts`11+ * puts on a dev stage, unless given). It only12 * reads.13 */14 import { expect, test } from "@playwright/test";15+import { ProjectName } from "@repo/protocol/ids";16 import { Config, Effect, Option } from "effect";17 18 /** What the check reads of its env: where the web lives, and which project to look at. */19 const settings = Effect.runSync(20 Effect.gen(function* () {21 return {20- project: yield* Config.NonEmptyString("WEB_TAGS_PROJECT").pipe(21- Config.withDefault("changesets")22+ // Read by the one parser: `changesets` and its full name alike.23+ project: yield* Config.schema(ProjectName, "WEB_TAGS_PROJECT").pipe(24+ Config.withDefault(ProjectName.make("github.com/changesets/changesets"))25 ),26 web: Option.map(27 yield* Config.option(Config.NonEmptyString("WEB_URL")),28 (url) => url.replace(/\/+$/u, "")95 unmodified lines124 const tree = yield* awaited(() =>125 tags.first().locator("a").first().getAttribute("href")126 );127 125- expect(tree).toMatch(126- new RegExp(127- `^/${project}/tree/${encodeURIComponent(`${PACKAGE}@`)}`,128- "u"128+ expect(129+ tree?.startsWith(130+ `/${project}/tree/${encodeURIComponent(`${PACKAGE}@`)}`131 )130- );132+ ).toBe(true);133 134 const opened = yield* awaited(() =>135 browser.goto(`${web}${tree ?? ""}`)136 );8 unmodified linesmodified:apps/web/e2e/why.e2e.ts+5 added-3 removed
14 unmodified lines151617181920212223242524252627282930313231333435363754 unmodified lines14 unmodified lines * where nothing was answered). It only reads. */import { expect, test } from "@playwright/test";import { Brand } from "@repo/brand";import { ProjectName } from "@repo/protocol/ids";import { Config, Effect, Option } from "effect";
/** What the check reads of its env: where the web lives, and which file to look at. */const settings = Effect.runSync( Effect.gen(function* () { // Read by the one parser: `burrow` and `oscabriel/burrow` alike. const project = yield* Config.NonEmptyString("WEB_PROJECT").pipe( Config.withDefault("datekit") const project = yield* Config.schema(ProjectName, "WEB_PROJECT").pipe( Config.withDefault(ProjectName.make("oscabriel/datekit")) );
return { path: yield* Config.NonEmptyString("WEB_WHY_PATH").pipe( Config.withDefault( project === "burrow" project === "oscabriel/burrow" ? `${Brand.configDir}/asks/drop-legacy-fetch.ask.ts` : "src/format.ts" ) ),54 unmodified lines