Something went wrong. Try again.
Web frontend and supporting services for lance.blue
Something went wrong. Try again.
2.6 kB · 67 lines
JavaScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768/** * The report dialog is the flare form without a match screen under it, and * the ways it goes wrong are the quiet ones: a dialog announced as "dialog" * and nothing else, a board link that points somewhere the reports do not * land, and an account menu left open behind the backdrop. Nothing errors in * any of those, so this reads the source, the same way signin-form.test.mjs * does. * * Run with `npm test`. */import { test } from "node:test";import assert from "node:assert/strict";import { readFile } from "node:fs/promises";import { fileURLToPath } from "node:url";
const src = fileURLToPath(new URL("../src/", import.meta.url));const modal = await readFile(`${src}report-modal.ts`, "utf8");const account = await readFile(`${src}account.ts`, "utf8");
test("the dialog is named by the heading it mints", () => { assert.match(modal, /const headingId = /, "the heading's id moved"); assert.match(modal, /"aria-labelledby": headingId/); assert.match(modal, /id: headingId/);});
test("the notice links to userinput.app's page for a space", () => { const url = modal.match(/const BOARD_URL =\s*"([^"]+)"/); assert.ok(url, "BOARD_URL moved"); // The at:// form of the space is infra's FLARE_SPACE; what a browser can // open is /s/<did>/<rkey> on userinput.app, so that is the shape held here. assert.match( url[1], /^https:\/\/userinput\.app\/s\/did:plc:[a-z2-7]+\/[a-z2-7]+$/, );});
// The tags are the board's four, written down here and again in arena's// in-match dialog. Both lists have to say the same thing, so this pins the// one here rather than leaving a typo to show up as a tag nothing filters.test("the dialog offers the board's four tags", () => { const list = modal.match(/const TAGS = \[([^\]]*)\]/); assert.ok(list, "TAGS moved"); assert.deepEqual( list[1].split(",").map((tag) => tag.trim().replace(/"/g, "")), ["bug", "feature", "question", "thanks"], );});
test("a sent report is linked by the sender's did and the new rkey", () => { assert.match( modal, /userinput\.app\/d\/\$\{session\.did\}\/\$\{written\.rkey\}/, );});
test("the account menu puts itself away before the dialog opens", () => { const handler = account.match( /report\.addEventListener\("click", \(\) => \{([\s\S]*?)\n {2}\}\);/, ); assert.ok(handler, "the report item's click handler moved"); const closes = handler[1].indexOf("setOpen(false)"); const opens = handler[1].indexOf('import("./report-modal")'); assert.ok( closes >= 0 && opens > closes, "the menu must close before the dialog opens, or it sits open behind the backdrop", );});