deployed.e2e.ts
This file
Path
apps/web/e2e/deployed.e2e.ts
259 lines · 7.1 KiB · TypeScript
Last changed by
Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248
History of this fileTake it
Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
lines 1–2why, one step back1import { expect, test } from "@playwright/test";2import type { Page } from "@playwright/test";Merge build/1499-w14-integration into mainoscabrielbefore adoptioncb4fcca
line 3why, one step back3import { ProjectName } from "@repo/protocol/ids";Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
lines 4–5why, one step back4import { Config, Effect, Option } from "effect";5Close the wave: openings are heard as landings, and the code store is written downoscabrielbefore adoption2587726
lines 6–18why, one step back6const examples = {7 burrow: {8 ask: "drop-legacy-fetch",9 file: "packages/kit/src/http.ts",10 readme: "six small TypeScript packages",11 },12 datekit: {13 ask: "format-ordinal",14 file: "src/add.ts",15 readme: "Small, dependency-free date helpers",16 },17} as const;18Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
lines 19–20why, one step back19const settings = Effect.runSync(20 Effect.gen(function* () {Merge build/1499-w14-integration into mainoscabrielbefore adoptioncb4fcca
lines 21–22why, one step back21 const project = yield* Config.schema(ProjectName, "WEB_PROJECT").pipe(22 Config.withDefault(ProjectName.make("oscabriel/datekit"))Close the wave: openings are heard as landings, and the code store is written downoscabrielbefore adoption2587726
lines 23–24why, one step back23 );24Merge build/1499-w14-integration into mainoscabrielbefore adoptioncb4fcca
lines 25–26why, one step back25 const example =26 project === "oscabriel/burrow" ? examples.burrow : examples.datekit;Close the wave: openings are heard as landings, and the code store is written downoscabrielbefore adoption2587726
line 27why, one step back27Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
lines 28–29why, one step back28 return {29 ask: yield* Config.NonEmptyString("WEB_ASK").pipe(Close the wave: openings are heard as landings, and the code store is written downoscabrielbefore adoption2587726
line 30why, one step back30 Config.withDefault(example.ask)Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
line 31why, one step back31 ),Let the deployed-web check open any project's file, so burrow's run can passoscabrielbefore adoption177ee96
line 32why, one step back32 file: yield* Config.NonEmptyString("WEB_FILE").pipe(Close the wave: openings are heard as landings, and the code store is written downoscabrielbefore adoption2587726
line 33why, one step back33 Config.withDefault(example.file)Let the deployed-web check open any project's file, so burrow's run can passoscabrielbefore adoption177ee96
line 34why, one step back34 ),Close the wave: openings are heard as landings, and the code store is written downoscabrielbefore adoption2587726
line 35why, one step back35 project,Merge build/1005oscabrielbefore adoptionb124cbb
line 36why, one step back36 readme: yield* Config.NonEmptyString("WEB_README_PHRASE").pipe(Close the wave: openings are heard as landings, and the code store is written downoscabrielbefore adoption2587726
line 37why, one step back37 Config.withDefault(example.readme)Merge build/1005oscabrielbefore adoptionb124cbb
line 38why, one step back38 ),Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
lines 39–46why, one step back39 web: Option.map(40 yield* Config.option(Config.NonEmptyString("WEB_URL")),41 (url) => url.replace(/\/+$/u, "")42 ),43 };44 })45);46Merge build/1005oscabrielbefore adoptionb124cbb
line 47why, one step back47const { ask, file: FILE, project, readme: README_PHRASE } = settings;Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
line 48why, one step back48Let the deployed-web check open any project's file, so burrow's run can passoscabrielbefore adoption177ee96
lines 49–50why, one step back49const FOLDER = FILE.split("/")[0] ?? FILE;50Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
lines 51–54why, one step back51const out = decodeURIComponent(new URL("out/", import.meta.url).pathname);5253const UNREACHABLE = "The platform did not answer";54Merge branch 'build/904-web-code-browser'oscabrielbefore adoption06e2229
lines 55–56why, one step back55const NOT_BUILT = "not built";56Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
lines 57–59why, one step back57const at = (path: string) =>58 `${Option.getOrElse(settings.web, () => "")}${path}`;59Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248
line 60why, one step back60// A text may also sit in markup a width hides, so each is found among the visible matches.Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
lines 61–75why, one step back61const page = (62 browser: Page,63 path: string,64 shot: string,65 texts: readonly string[]66) =>67 Effect.gen(function* () {68 const response = yield* Effect.promise(() => browser.goto(at(path)));6970 expect(response?.status()).toBe(200);7172 yield* Effect.forEach(73 texts,74 (text) =>75 Effect.promise(() =>Describe the Control room as built: DESIGN.md, PRODUCT.md, four ADRs, the demo docs and a tighter web entry limitoscabrielbefore adoption207eb8c
lines 76–78why, one step back76 expect(77 browser.getByText(text).filter({ visible: true }).first()78 ).toBeVisible()Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
lines 79–91why, one step back79 ),80 { discard: true }81 );8283 yield* Effect.promise(() =>84 expect(browser.getByText(UNREACHABLE)).toHaveCount(0)85 );8687 yield* Effect.promise(() =>88 browser.screenshot({ fullPage: true, path: `${out}${shot}.png` })89 );90 });91Merge branch 'build/904-web-code-browser'oscabrielbefore adoption06e2229
lines 92–105why, one step back92const code = (93 browser: Page,94 path: string,95 shot: string,96 texts: readonly string[]97) =>98 Effect.gen(function* () {99 yield* page(browser, path, shot, texts);100101 yield* Effect.promise(() =>102 expect(browser.getByText(NOT_BUILT)).toHaveCount(0)103 );104 });105Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
lines 106–149why, one step back106const markdown = (107 browser: Page,108 path: string,109 shot: string,110 texts: readonly string[]111) =>112 Effect.gen(function* () {113 const response = yield* Effect.promise(() => browser.request.get(at(path)));114115 const body = yield* Effect.promise(() => response.text());116117 expect({118 status: response.status(),119 title: body.startsWith("# "),120 type: response.headers()["content-type"]?.split(";")[0],121 }).toStrictEqual({ status: 200, title: true, type: "text/markdown" });122123 for (const text of texts) {124 expect(body).toContain(text);125 }126127 yield* Effect.promise(() =>128 browser.setContent(129 `<pre style="white-space: pre-wrap; font: 14px/1.5 monospace; margin: 24px"></pre>`130 )131 );132133 yield* Effect.promise(() =>134 browser.locator("pre").evaluate((pre, text) => {135 pre.textContent = text;136 }, body)137 );138139 yield* Effect.promise(() =>140 browser.screenshot({ fullPage: true, path: `${out}${shot}.png` })141 );142 });143144test.describe("the deployed web", () => {145 test.skip(146 Option.isNone(settings.web),147 "WEB_URL is not set: point it at a deployed web's origin to run this check"148 );149Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248
line 150why, one step back150 // The heading renders before the platform answers, so each list page also waits for a row only the answer holds.Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
line 151why, one step back151 test("the front page lists the open asks", ({ page: browser }) =>Deploy and seed the demo stage, and make the deployed-web check wait for the platform's rowsoscabrielbefore adoption1c958b4
lines 152–154why, one step back152 Effect.runPromise(153 page(browser, "/", "front-page", ["Open asks", project])154 ));Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
lines 155–156why, one step back155156 test(`${project}'s page shows the project`, ({ page: browser }) =>Deploy and seed the demo stage, and make the deployed-web check wait for the platform's rowsoscabrielbefore adoption1c958b4
lines 157–158why, one step back157 Effect.runPromise(158 page(browser, `/${project}`, "project-page", [project, ask])Merge build/1005oscabrielbefore adoptionb124cbb
lines 159–160why, one step back159 ));160Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248
line 161why, one step back161 // A request, not a page: this is the HTML the server sent, as a crawler reads it.Merge build/1005oscabrielbefore adoptionb124cbb
lines 162–176why, one step back162 test(`${project}'s page arrives with its README rendered by the server`, ({163 page: browser,164 }) =>165 Effect.runPromise(166 Effect.gen(function* () {167 const response = yield* Effect.promise(() =>168 browser.request.get(at(`/${project}`))169 );170171 const body = yield* Effect.promise(() => response.text());172173 expect(response.status()).toBe(200);174 expect(body).toContain(README_PHRASE);175 expect(body).toContain('data-readme="');176 })Deploy and seed the demo stage, and make the deployed-web check wait for the platform's rowsoscabrielbefore adoption1c958b4
line 177why, one step back177 ));Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
lines 178–194why, one step back178179 test(`${project}/${ask}'s page shows the ask`, ({ page: browser }) =>180 Effect.runPromise(181 page(browser, `/${project}/asks/${ask}`, "ask-page", [ask])182 ));183184 test(`${project}/${ask}.md is the ask's brief in Markdown`, ({185 page: browser,186 }) =>187 Effect.runPromise(188 markdown(browser, `/${project}/asks/${ask}.md`, "ask-markdown", [189 `Ask \`${ask}\` in ${project}`,190 ])191 ));192193 test("/llms.txt is the web's Markdown for agents", ({ page: browser }) =>194 Effect.runPromise(markdown(browser, "/llms.txt", "llms-txt", [project])));Merge branch 'build/904-web-code-browser'oscabrielbefore adoption06e2229
lines 195–199why, one step back195196 test(`${project}'s code at main lists its folders and README`, ({197 page: browser,198 }) =>199 Effect.runPromise(Let the deployed-web check open any project's file, so burrow's run can passoscabrielbefore adoption177ee96
line 200why, one step back200 code(browser, `/${project}/tree/main`, "code-tree", [FOLDER, "README.md"])Merge branch 'build/904-web-code-browser'oscabrielbefore adoption06e2229
lines 201–216why, one step back201 ));202203 test(`${project}'s ${FILE} opens at line 3`, ({ page: browser }) =>204 Effect.runPromise(205 Effect.gen(function* () {206 yield* code(browser, `/${project}/blob/main/${FILE}#L3`, "code-file", [207 FILE,208 "Permalink",209 ]);210211 expect(new URL(browser.url()).hash).toBe("#L3");212 })213 ));214215 test(`${project}'s log groups its commits by day`, ({ page: browser }) =>216 Effect.runPromise(Describe the Control room as built: DESIGN.md, PRODUCT.md, four ADRs, the demo docs and a tighter web entry limitoscabrielbefore adoption207eb8c
lines 217–230why, one step back217 Effect.gen(function* () {218 yield* code(browser, `/${project}/commits/main`, "code-log", [219 "Landings",220 ]);221222 yield* Effect.promise(() =>223 expect(224 browser225 .locator("[data-day] h2")226 .first()227 .getByText(/^[A-Z][a-z]+ \d{1,2}, \d{4}$/u)228 ).toBeVisible()229 );230 })Merge branch 'build/904-web-code-browser'oscabrielbefore adoption06e2229
lines 231–258why, one step back231 ));232233 test(`${project}'s newest commit shows what it changed`, ({234 page: browser,235 }) =>236 Effect.runPromise(237 Effect.gen(function* () {238 yield* Effect.promise(() =>239 browser.goto(at(`/${project}/commits/main`))240 );241242 const href = yield* Effect.promise(() =>243 browser244 .locator(`a[href^="/${project}/commit/"]`)245 .first()246 .getAttribute("href")247 );248249 expect(href).toMatch(/\/commit\/[0-9a-f]{40}$/u);250251 yield* code(browser, href ?? "", "code-commit", ["changed"]);252 })253 ));254255 test(`${project}'s refs show main and its tags`, ({ page: browser }) =>256 Effect.runPromise(257 code(browser, `/${project}/refs`, "code-refs", ["main", "Tags", "Forks"])258 ));Add the live-run tooling: smoke --loop, seed --as, a recording lock for deploys, and a Playwright check of the deployed weboscabrielbefore adoption030c4d6
line 259why, one step back259});