Skip to content
Myr

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

6 files+152 added−79 removed

modified:apps/web/e2e/a11y.e2e.ts+5 added-5 removed
18 unmodified lines
19 *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 */26import { expect, test } from "@playwright/test";27import type { Browser, BrowserContext, Page } from "@playwright/test";28import { Brand } from "@repo/brand";
4 unmodified lines
33const 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 lines
74 { 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 lines
modified:apps/web/e2e/deployed.e2e.ts+6 added-3 removed
15 unmodified lines
16 * packages"), so `WEB_PROJECT=burrow` alone checks burrow. It only reads.17 */18import { expect, test } from "@playwright/test";19import type { Page } from "@playwright/test";20import { ProjectName } from "@repo/protocol/ids";21import { Config, Effect, Option } from "effect";2223/**24 * What the check looks at in each seeded example unless told otherwise: an
15 unmodified lines
4041/** What the check reads of its env: where the web lives, and which ask to look at. */42const 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 );4847 const example = project === "burrow" ? examples.burrow : examples.datekit;49 const example =50 project === "oscabriel/burrow" ? examples.burrow : examples.datekit;5152 return {53 ask: yield* Config.NonEmptyString("WEB_ASK").pipe(54 Config.withDefault(example.ask)
250 unmodified lines
modified:apps/web/e2e/imports.e2e.ts+121 added-57 removed
13 unmodified lines
14 * 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 */23import { expect, test } from "@playwright/test";24import type { Page } from "@playwright/test";25import { Brand } from "@repo/brand";26import { ProjectName } from "@repo/protocol/ids";24import { Config, Console, Effect, Option } from "effect";27import { Config, Console, Effect, Option, Schema } from "effect";2829/** One imported project: where its pages look, and what they must show. */30interface Imported {31 readonly project: string;
135 unmodified lines
167 };168 })169);170168/** 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 */176const nameOf = (spelled: string): ProjectName =>177 Schema.decodeSync(ProjectName)(spelled);178179/** `text` as a regular expression matches it, literally. */180const escaped = (text: string) =>181 text.replaceAll(/[.*+?^${}()|[\]\\]/gu, "\\$&");182183/** A project's address on the web: its full name. */184const homeOf = (project: string) => `/${nameOf(project)}`;185186/**187 * Those of `all` this run visits: `WEB_IMPORTS`' full names188 * (`github.com/pallets/click`), or all of them.189 */190const 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 );199177 return all.filter(({ project }) => named.has(project));200 return all.filter(({ project }) => named.has(nameOf(project)));201 },202 });203204const visited = visitedOf(imports);
126 unmodified lines
331/** The newest commit's page, as the log links it. */332const 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 );337338 expect(response?.status()).toBe(200);339317 const link = browser.locator(`a[href^="/${project}/commit/"]`).first();340 const link = browser341 .locator(`a[href^="${homeOf(project)}/commit/"]`)342 .first();343344 yield* awaited(() => expect(link).toBeVisible());345346 const href = yield* awaited(() => link.getAttribute("href"));
10 unmodified lines
357 */358const 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 lines
373 Effect.runPromise(374 visit(375 browser,376 project,352 `/${project}`,377 homeOf(project),378 "home",379 homeWanted(project, readme)380 )381 ));
3 unmodified lines
385 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 ));403404 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 lines
420 ));421422 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 lines
453 ));454455 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 lines
466 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 lines
487 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 ));505506 if (timedProject) {507 test(`${project}'s ${file} history lists the commits that changed it`, ({
2 unmodified lines
510 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 lines
525 Effect.runPromise(526 visit(527 browser,528 project,492 `/${project}`,529 homeOf(project),530 "home",531 homeWanted(project, readme)532 )533 ));534535 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 lines
544 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 lines
557 ));558559 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 ));565566 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 lines
580 (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 );593594 const tagged = browser.locator('[data-tag="1.0.0"] a').first();595596 expect(yield* awaited(() => tagged.getAttribute("href"))).toBe(554 "/anyhow/tree/1.0.0"597 `${homeOf("anyhow")}/tree/1.0.0`598 );599557 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 });619620 const href = yield* awaited(() =>
3 unmodified lines
624 .getAttribute("href")625 );626627 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 lines
639 // 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 lines
652 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 lines
674 .first()675 .getAttribute("href")676 );677624 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 );684685 yield* visit(browser, "changesets", href ?? "", "scoped-tag-tree", {686 selectors: ['[data-entry="packages"]'],687 });
3 unmodified lines
691 "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 lines
719 // 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 lines
737 "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 });744680 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"]`;746747 yield* loaded(browser, logo);748 }),749 ],
4 unmodified lines
754 // 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 );762763 // 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 lines
786 // page's own reads.787 test.setTimeout(240_000);788789 for (const imported of visited) {726 test.describe(imported.project, () => {790 test.describe(nameOf(imported.project), () => {791 pages(imported);792793 const specific = specifics.get(imported.project);794
5 unmodified lines
800 });801 }802803 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
modified:apps/web/e2e/tags.e2e.ts+11 added-9 removed
4 unmodified lines
5 * 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 */14import { expect, test } from "@playwright/test";15import { ProjectName } from "@repo/protocol/ids";16import { Config, Effect, Option } from "effect";1718/** What the check reads of its env: where the web lives, and which project to look at. */19const 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 lines
124 const tree = yield* awaited(() =>125 tags.first().locator("a").first().getAttribute("href")126 );127125 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);133134 const opened = yield* awaited(() =>135 browser.goto(`${web}${tree ?? ""}`)136 );
8 unmodified lines
modified:apps/web/e2e/why.e2e.ts+5 added-3 removed