Public: anyone can read this; the crew can change it.
Billing and agents forms re-render through refused/kept with the failing field named #14005
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/14003-billing-and-agents-forms-re-render-throu → main 3 commits fork 2 threads · 2 unresolved
5 files
changed +151
−30
src/web/pages/agents.ts +9 −3
| @@ -11,6 +11,7 @@ import { notePhase, takeSessionTime, timePhase } from "../../core/route_timing.t | ||
| 11 | 11 | import { pageHead } from "../chrome.ts"; |
| 12 | 12 | import { html, type Html } from "../html.ts"; |
| 13 | 13 | import { btn, disclosure, field as formField } from "../ui.ts"; |
| 14 | import { kept, type Refused } from "../form.ts"; | |
| 14 | 15 | import { page } from "../layout.ts"; |
| 15 | 16 | import { renderMarkdown } from "../markdown.ts"; |
| 16 | 17 | import { START_BUTTON } from "../site_line.ts"; |
| @@ -66,7 +67,11 @@ export function guideHtml(body: string): Html { | ||
| 66 | 67 | return renderMarkdown(linkAddresses(withoutTitle(body))); |
| 67 | 68 | } |
| 68 | 69 | |
| 69 | export async function agentsPage(ctx: Ctx): Promise<Response> { | |
| 70 | /** | |
| 71 | * `refusal`: a refused start from this page's form, drawn with the name kept and the reason beside | |
| 72 | * it. | |
| 73 | */ | |
| 74 | export async function agentsPage(ctx: Ctx, refusal?: Refused): Promise<Response> { | |
| 70 | 75 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); |
| 71 | 76 | await loadMcp(); |
| 72 | 77 | const { body } = llmsBody(ctx); |
| @@ -80,11 +85,12 @@ export async function agentsPage(ctx: Ctx): Promise<Response> { | ||
| 80 | 85 | <section class="stack" aria-labelledby="agent-forge-h"> |
| 81 | 86 | <h2 id="agent-forge-h">Get a forge of your own</h2> |
| 82 | 87 | <form method="post" action="/forges/start" class="stack" id="agent-forge"> |
| 83 | ${formField({ label: "Name", name: "name", required: true })} | |
| 88 | <input type="hidden" name="from" value="agents" /> | |
| 89 | ${formField(kept(refusal, { label: "Name", name: "name", required: true }))} | |
| 84 | 90 | ${btn(START_BUTTON, { variant: "primary" })} |
| 85 | 91 | </form> |
| 86 | 92 | </section> |
| 87 | 93 | <div class="prose break"><ol id="agent-steps" aria-label="Build an app with no account">${firstSteps(body).map((step) => html`<li>${stepLine(step)}</li>`)}</ol></div> |
| 88 | 94 | ${disclosure("? Full guide", html`<article class="prose prose-page" id="agents-guide">${guideHtml(body)}</article>`, { id: "agents-more" })}`, |
| 89 | })); | |
| 95 | }, refusal === undefined ? 200 : 422)); | |
| 90 | 96 | } |
src/web/pages/billing.ts +33 −22
| @@ -22,10 +22,11 @@ import { getPlans } from "../../settings/plans.ts"; | ||
| 22 | 22 | import { changeBillingLinks, changePortalUrl, readBillingLinks } from "../../actions/signup.ts"; |
| 23 | 23 | import { funnelReport, type FunnelReport } from "../../perf/funnel.ts"; |
| 24 | 24 | import { notFoundPage, settingsLayout, signInFirst } from "../chrome.ts"; |
| 25 | import { field, readForm } from "../form.ts"; | |
| 25 | import { field, kept, readForm, refused, type Refused } from "../form.ts"; | |
| 26 | 26 | import { html, type Html } from "../html.ts"; |
| 27 | 27 | import { flashTo, page } from "../layout.ts"; |
| 28 | 28 | import { btn, copyField, field as formField, selectField } from "../ui.ts"; |
| 29 | import type { FieldOptions } from "../ui.ts"; | |
| 29 | 30 | import { accountSections } from "./origins.ts"; |
| 30 | 31 | |
| 31 | 32 | const PATH = "/settings/billing"; |
| @@ -42,7 +43,7 @@ const isPerson = (ctx: Ctx): boolean => ctx.auth.user?.isAdmin === true && ctx.a | ||
| 42 | 43 | const day = (iso: string): string => iso.slice(0, 10); |
| 43 | 44 | |
| 44 | 45 | /** The Codes section: make one, copy it once, then one line per code with its one action. */ |
| 45 | function codesSection(ctx: Ctx, shown: Shown | undefined, values: Record<string, string>, error: string | undefined): Html | null { | |
| 46 | function codesSection(ctx: Ctx, shown: Shown | undefined, r: Refused | undefined): Html | null { | |
| 46 | 47 | const read = readCodes(ctx.app, ctx.auth.user); |
| 47 | 48 | if (!read.ok) return null; |
| 48 | 49 | const { codes, plans } = read.value; |
| @@ -67,7 +68,6 @@ function codesSection(ctx: Ctx, shown: Shown | undefined, values: Record<string, | ||
| 67 | 68 | }); |
| 68 | 69 | return html`<section class="settings-block" id="codes"> |
| 69 | 70 | <h2>Codes</h2> |
| 70 | ${error === undefined ? null : html`<p class="error" role="alert">${error}</p>`} | |
| 71 | 71 | ${shown === undefined |
| 72 | 72 | ? null |
| 73 | 73 | : html`<div class="stack stack-tight" id="new-code" role="status"> |
| @@ -76,20 +76,29 @@ function codesSection(ctx: Ctx, shown: Shown | undefined, values: Record<string, | ||
| 76 | 76 | ${copyField("gift-link", shown.link, "The link to send", "Copy the link")} |
| 77 | 77 | </div>`} |
| 78 | 78 | <form class="row-fields" method="post" action="${PATH}/codes" id="make-code"> |
| 79 | ${selectField({ label: "Plan it gives", name: "plan", options: plans.map((p) => ({ value: p, label: p, selected: p === (values["plan"] ?? plans[0]) })) })} | |
| 80 | ${formField({ label: "Uses", name: "uses", type: "number", value: values["uses"] ?? "1" })} | |
| 81 | ${formField({ label: "Note", name: "note", value: values["note"] ?? "", hint: "For Mark" })} | |
| 82 | ${formField({ label: "Expires", name: "expires", type: "date", value: values["expires"] ?? "" })} | |
| 79 | ${selectField(planChoice(kept(r, { label: "Plan it gives", name: "plan", type: "select", options: plans.map((p, i) => ({ value: p, label: p, selected: i === 0 })) })))} | |
| 80 | ${formField(kept(r, { label: "Uses", name: "uses", type: "number", value: "1" }))} | |
| 81 | ${formField(kept(r, { label: "Note", name: "note", value: "", hint: "For Mark" }))} | |
| 82 | ${formField(kept(r, { label: "Expires", name: "expires", type: "date", value: "" }))} | |
| 83 | 83 | ${btn("Make a code", { variant: "primary" })} |
| 84 | 84 | </form> |
| 85 | 85 | ${lines.length === 0 ? html`<p class="muted small">No code yet.</p>` : html`<ul class="list setting-list">${lines}</ul>`} |
| 86 | 86 | </section>`; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | /** | |
| 90 | * A select's options as `selectField` takes them (the kept options are optional on the shared | |
| 91 | * type). | |
| 92 | */ | |
| 93 | const planChoice = (o: FieldOptions) => ({ ...o, options: [...(o.options ?? [])] }); | |
| 94 | ||
| 95 | /** The field of the code form each refusal belongs beside. */ | |
| 96 | const CODE_FIELD: Record<Exclude<CodeError, "not_found">, string> = { bad_plan: "plan", bad_uses: "uses", bad_note: "note", bad_expiry: "expires", no_such_code: "plan" }; | |
| 97 | ||
| 89 | 98 | const codeWords = (e: CodeError): string => (e === "not_found" ? "Not found" : CODE_ERRORS[e]); |
| 90 | 99 | |
| 91 | 100 | /** The Payment links section: one https field per size a paid plan sits on, saved in one submit. */ |
| 92 | function linksSection(ctx: Ctx, retry?: { values: Record<string, string>; error: string }): Html | null { | |
| 101 | function linksSection(ctx: Ctx, r: Refused | undefined): Html | null { | |
| 93 | 102 | const links = readBillingLinks(ctx.app, ctx.auth.user); |
| 94 | 103 | if (!links.ok) return null; |
| 95 | 104 | const paid = getPlans(ctx.app.db).filter((p) => p.priceUsd > 0); |
| @@ -100,10 +109,9 @@ function linksSection(ctx: Ctx, retry?: { values: Record<string, string>; error: | ||
| 100 | 109 | return html`<section class="settings-block" id="links"> |
| 101 | 110 | <h2>Payment links</h2> |
| 102 | 111 | <p class="muted small">Where a buyer pays for each paid plan. With any set, the home page offers paid forges; empty clears one.</p> |
| 103 | ${retry === undefined ? null : html`<p class="error" role="alert">${retry.error}</p>`} | |
| 104 | 112 | <form class="stack" method="post" action="${PATH}/links"> |
| 105 | 113 | ${fields.map((f) => |
| 106 | formField({ label: `${f.named === "" ? f.size : f.named} (${f.size})`, name: f.size, type: "url", value: retry?.values[f.size] ?? links.value[f.size] ?? "", hint: "https://" }), | |
| 114 | formField(kept(r, { label: `${f.named === "" ? f.size : f.named} (${f.size})`, name: f.size, type: "url", value: links.value[f.size] ?? "", hint: "https://" })), | |
| 107 | 115 | )} |
| 108 | 116 | ${btn("Save payment links", { variant: "primary" })} |
| 109 | 117 | </form> |
| @@ -111,14 +119,13 @@ function linksSection(ctx: Ctx, retry?: { values: Record<string, string>; error: | ||
| 111 | 119 | } |
| 112 | 120 | |
| 113 | 121 | /** The one billing-portal address every paying forge's Plan row links to. */ |
| 114 | function portalSection(ctx: Ctx, retry?: { value: string; error: string }): Html | null { | |
| 122 | function portalSection(ctx: Ctx, r: Refused | undefined): Html | null { | |
| 115 | 123 | if (ctx.auth.user?.isAdmin !== true || ctx.auth.user.kind === "agent") return null; |
| 116 | 124 | return html`<section class="settings-block" id="portal"> |
| 117 | 125 | <h2>Billing portal</h2> |
| 118 | 126 | <p class="muted small">Stripe's customer-portal sign-in. A forge that pays through Stripe links its owner here to change a card; empty shows no link.</p> |
| 119 | ${retry === undefined ? null : html`<p class="error" role="alert">${retry.error}</p>`} | |
| 120 | 127 | <form class="stack" method="post" action="${PATH}/portal"> |
| 121 | ${formField({ label: "Portal sign-in address", name: "portal_url", type: "url", value: retry?.value ?? getPortalUrl(ctx.app.db), hint: "https://billing.stripe.com/p/login/…" })} | |
| 128 | ${formField(kept(r, { label: "Portal sign-in address", name: "portal_url", type: "url", value: getPortalUrl(ctx.app.db), hint: "https://billing.stripe.com/p/login/…" }))} | |
| 122 | 129 | ${btn("Save portal address", { variant: "primary" })} |
| 123 | 130 | </form> |
| 124 | 131 | </section>`; |
| @@ -133,7 +140,7 @@ export async function billingSetPortal(ctx: Ctx): Promise<Response> { | ||
| 133 | 140 | const changed = changePortalUrl(ctx.app, ctx.auth.user, value); |
| 134 | 141 | if (!changed.ok && changed.error === "not_found") return notFoundPage(ctx); |
| 135 | 142 | if (changed.ok) return flashTo(ctx, `${PATH}#portal`, { message: "Billing portal address saved." }); |
| 136 | return billingView(ctx, undefined, {}, undefined, 422, undefined, { value, error: `${PORTAL_WORDS}. Nothing was saved.` }); | |
| 143 | return billingView(ctx, undefined, 422, refused(form, { portal_url: `${PORTAL_WORDS}. Nothing was saved.` })); | |
| 137 | 144 | } |
| 138 | 145 | |
| 139 | 146 | // POST /settings/billing/links |
| @@ -149,9 +156,9 @@ export async function billingSetLinks(ctx: Ctx): Promise<Response> { | ||
| 149 | 156 | if (!changed.ok && changed.error === "not_found") return notFoundPage(ctx); |
| 150 | 157 | if (changed.ok) return flashTo(ctx, `${PATH}#links`, { message: "Payment links saved." }); |
| 151 | 158 | // Name the sizes refused, and show the form again with what was typed. |
| 152 | const refused = BILLING_SIZES.filter((z) => !parseBillingLinks({ [z]: next[z] }).ok); | |
| 153 | const error = `${refused.join(" and ")}: each payment link is an https address with no spaces, or empty. Nothing was saved.`; | |
| 154 | return billingView(ctx, undefined, {}, undefined, 422, { values: next, error }); | |
| 159 | const errors: Record<string, string> = {}; | |
| 160 | for (const z of BILLING_SIZES) if (!parseBillingLinks({ [z]: next[z] }).ok) errors[z] = "A payment link is an https address with no spaces, or empty. Nothing was saved."; | |
| 161 | return billingView(ctx, undefined, 422, refused(form, errors)); | |
| 155 | 162 | } |
| 156 | 163 | |
| 157 | 164 | /** |
| @@ -185,7 +192,11 @@ export function billingPage(ctx: Ctx): Response { | ||
| 185 | 192 | return billingView(ctx); |
| 186 | 193 | } |
| 187 | 194 | |
| 188 | function billingView(ctx: Ctx, shown?: Shown, values: Record<string, string> = {}, error?: string, status = 200, links?: { values: Record<string, string>; error: string }, portal?: { value: string; error: string }): Response { | |
| 195 | /** | |
| 196 | * The page; a refused POST passes its `Refused` and each section keeps its own form's fields from | |
| 197 | * it. | |
| 198 | */ | |
| 199 | function billingView(ctx: Ctx, shown?: Shown, status = 200, refusal?: Refused): Response { | |
| 189 | 200 | const read = readBilling(ctx.app, ctx.auth.user); |
| 190 | 201 | if (!read.ok) return notFoundPage(ctx); |
| 191 | 202 | const b = read.value; |
| @@ -254,9 +265,9 @@ function billingView(ctx: Ctx, shown?: Shown, values: Record<string, string> = { | ||
| 254 | 265 | </section> |
| 255 | 266 | ${ledBlock(ctx)} |
| 256 | 267 | ${funnelRow(funnelReport(ctx.app.db, 7))} |
| 257 | ${linksSection(ctx, links)} | |
| 258 | ${portalSection(ctx, portal)} | |
| 259 | ${codesSection(ctx, shown, values, error)}`; | |
| 268 | ${linksSection(ctx, refusal)} | |
| 269 | ${portalSection(ctx, refusal)} | |
| 270 | ${codesSection(ctx, shown, refusal)}`; | |
| 260 | 271 | const response = page({ |
| 261 | 272 | ctx, |
| 262 | 273 | title: "Billing", |
| @@ -276,7 +287,7 @@ export async function billingMakeCode(ctx: Ctx): Promise<Response> { | ||
| 276 | 287 | if (form instanceof Response) return form; |
| 277 | 288 | const values = { plan: field(form, "plan"), uses: field(form, "uses"), note: field(form, "note"), expires: field(form, "expires") }; |
| 278 | 289 | const made = makeCode(ctx.app, ctx.auth.user, values, publicOrigin(ctx.app.config.url, ctx.url.origin)); |
| 279 | if (!made.ok) return made.error === "not_found" ? notFoundPage(ctx) : billingView(ctx, undefined, values, `${codeWords(made.error)}.`, 422); | |
| 290 | if (!made.ok) return made.error === "not_found" ? notFoundPage(ctx) : billingView(ctx, undefined, 422, refused(form, { [CODE_FIELD[made.error]]: `${codeWords(made.error)}.` })); | |
| 280 | 291 | return billingView(ctx, { code: made.value.code, link: made.value.link }); |
| 281 | 292 | } |
| 282 | 293 |
src/web/pages/start-forge.ts +7 −3
| @@ -11,11 +11,12 @@ import { notePhase, takeSessionTime } from "../../core/route_timing.ts"; | ||
| 11 | 11 | import type { Ctx } from "../../http/context.ts"; |
| 12 | 12 | import { spawnDoor } from "../../spawn/door.ts"; |
| 13 | 13 | import { noteForgeMade } from "../funnel_door.ts"; |
| 14 | import { field, readForm } from "../form.ts"; | |
| 14 | import { field, readForm, refused } from "../form.ts"; | |
| 15 | import { agentsPage } from "./agents.ts"; | |
| 15 | 16 | import { madeBody, madeJs } from "../forge_made.ts"; |
| 16 | 17 | import { page, redirect } from "../layout.ts"; |
| 17 | 18 | import { notFoundPage } from "../chrome.ts"; |
| 18 | import { startRefusalHref, startRefusalOf } from "../start_refusal.ts"; | |
| 19 | import { START_REFUSALS, startRefusalHref, startRefusalOf } from "../start_refusal.ts"; | |
| 19 | 20 | |
| 20 | 21 | /** The home's live name check: asks `GET /forges/name/<name>` and says free, taken, or the route's own reason; a 429 or a failure says nothing. */ |
| 21 | 22 | export const startNameJs = `(function(d){ |
| @@ -45,8 +46,11 @@ export async function startForgeSubmit(ctx: Ctx): Promise<Response> { | ||
| 45 | 46 | if (user !== undefined) return redirect(SLUG.test(name) ? `/forges/new?name=${encodeURIComponent(name)}` : "/forges/new"); |
| 46 | 47 | const door = await spawnDoor(ctx, undefined, { name, dryRun: false }, { page: true }); |
| 47 | 48 | if (door.status >= 400) { |
| 49 | const why = startRefusalOf(door); | |
| 50 | // The /agents form is answered on /agents, the name kept and the reason beside it. | |
| 51 | if (field(form, "from") === "agents") return agentsPage(ctx, refused(form, { name: START_REFUSALS[why] })); | |
| 48 | 52 | // Said on the home page, with the name kept (#11238). |
A refused start returns the /agents page from the POST URL, so a reload re-posts the form. Fine for now; a redirect that keeps the name would avoid it. |
||
| 49 | return redirect(startRefusalHref(startRefusalOf(door), typed)); | |
| 53 | return redirect(startRefusalHref(why, typed)); | |
| 50 | 54 | } |
| 51 | 55 | const link = door.body["claimUrl"]; |
| 52 | 56 | if (typeof link !== "string") return redirect(startRefusalHref("taken", name)); |
test/billing-agents-keep.test.ts added +98
| @@ -0,0 +1,98 @@ | ||
| 1 | /** | |
| 2 | * The billing forms (payment links, portal address, code) and the /agents | |
| 3 | * start form re-render a refused POST through `refused`/`kept`: the typed | |
| 4 | * value kept and escaped, the failing field marked `aria-invalid` and named, | |
| 5 | * no bare error line above the form. | |
| 6 | */ | |
| 7 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 8 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 9 | import { tmpdir } from "node:os"; | |
| 10 | import { join } from "node:path"; | |
| 11 | import { createApp, type App } from "../src/app.ts"; | |
| 12 | import { createSession } from "../src/core/sessions.ts"; | |
| 13 | import { createUser } from "../src/core/users.ts"; | |
| 14 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 15 | import { quietLogs } from "./helpers/globals.ts"; | |
| 16 | import { promote } from "./helpers/members.ts"; | |
| 17 | ||
| 18 | quietLogs(); | |
| 19 | ||
| 20 | let dataDir: string; | |
| 21 | let app: App; | |
| 22 | let servers: Servers; | |
| 23 | let cookie: string; | |
| 24 | ||
| 25 | const post = (path: string, fields: Record<string, string>, as = cookie) => | |
| 26 | fetch(`${servers.url}${path}`, { | |
| 27 | method: "POST", | |
| 28 | redirect: "manual", | |
| 29 | headers: { origin: new URL(servers.url).origin, cookie: as }, | |
| 30 | body: new URLSearchParams(fields), | |
| 31 | }); | |
| 32 | ||
| 33 | const XSS = `"><script>alert(1)</script>`; | |
| 34 | const ESCAPED = ""><script>alert(1)</script>"; | |
| 35 | ||
| 36 | beforeAll(async () => { | |
| 37 | dataDir = await mkdtemp(join(tmpdir(), "forge-billing-keep-")); | |
| 38 | app = createApp({ dataDir, port: 0 }); | |
| 39 | servers = await serve(app); | |
| 40 | const made = await createUser(app.db, { | |
| 41 | origin: "seed", | |
| 42 | trusted: true, | |
| 43 | username: "owner", | |
| 44 | email: "[email protected]", | |
| 45 | password: "a-good-passphrase", | |
| 46 | allowReserved: true, | |
| 47 | adminIfFirst: true, | |
| 48 | }); | |
| 49 | if (!made.ok) throw new Error(made.error); | |
| 50 | promote(app.db, made.value); | |
| 51 | cookie = `forge_session=${createSession(app.db, made.value.id).token}`; | |
| 52 | }); | |
| 53 | afterAll(async () => { | |
| 54 | await servers.stop(); | |
| 55 | await rm(dataDir, { recursive: true, force: true }); | |
| 56 | }); | |
| 57 | ||
| 58 | test("a refused payment link keeps the value, escaped, on the failing field", async () => { | |
| 59 | const res = await post("/settings/billing/links", { small: XSS }); | |
| 60 | expect(res.status).toBe(422); | |
| 61 | const text = await res.text(); | |
| 62 | expect(text).not.toContain(XSS); | |
| 63 | expect(text).toContain(`value="${ESCAPED}"`); | |
| 64 | expect(text).toMatch(/<input[^>]*name="small"[^>]*aria-invalid="true"|<input[^>]*aria-invalid="true"[^>]*name="small"/); | |
| 65 | expect(text).toContain('id="f-small-err"'); | |
| 66 | expect(text).not.toContain('<p class="error" role="alert">'); | |
| 67 | }); | |
| 68 | ||
| 69 | test("a refused portal address keeps the value, escaped, on its field", async () => { | |
| 70 | const res = await post("/settings/billing/portal", { portal_url: XSS }); | |
| 71 | expect(res.status).toBe(422); | |
| 72 | const text = await res.text(); | |
| 73 | expect(text).not.toContain(XSS); | |
| 74 | expect(text).toContain(`value="${ESCAPED}"`); | |
| 75 | expect(text).toMatch(/<input[^>]*name="portal_url"[^>]*aria-invalid="true"|<input[^>]*aria-invalid="true"[^>]*name="portal_url"/); | |
| 76 | expect(text).toContain('id="f-portal_url-err"'); | |
| 77 | }); | |
| 78 | ||
| 79 | test("a refused code keeps the note, names the uses field", async () => { | |
| 80 | const res = await post("/settings/billing/codes", { plan: "nope", uses: "0", note: XSS, expires: "" }); | |
| 81 | expect(res.status).toBe(422); | |
| 82 | const text = await res.text(); | |
| 83 | expect(text).not.toContain(XSS); | |
| 84 | expect(text).toContain(`value="${ESCAPED}"`); | |
| 85 | expect(text).toMatch(/<select[^>]*aria-invalid="true"/); | |
| 86 | expect(text).toContain('id="f-plan-err"'); | |
| 87 | expect(text).not.toContain('<p class="error" role="alert">'); | |
| 88 | }); | |
| 89 | ||
| 90 | test("a refused start on /agents comes back on /agents with the name kept", async () => { | |
| 91 | const res = await post("/forges/start", { from: "agents", name: `-${XSS}` }, ""); | |
| 92 | expect(res.status).toBe(422); | |
| 93 | const text = await res.text(); | |
| 94 | expect(text).not.toContain(XSS); | |
| 95 | expect(text).toContain(ESCAPED); | |
| 96 | expect(text).toMatch(/<input[^>]*name="name"[^>]*aria-invalid="true"|<input[^>]*aria-invalid="true"[^>]*name="name"/); | |
| 97 | expect(text).toContain('id="f-name-err"'); | |
| 98 | }); |
test/billing-links.test.ts +4 −2
| @@ -202,8 +202,10 @@ test("Settings → Billing: set three links, the home shows them; clear, the hom | ||
| 202 | 202 | const bad = await links(adminCookie, { ...LINKS, large: "http://nope.test" }); |
| 203 | 203 | expect(bad.status).toBe(422); |
| 204 | 204 | const badPage = await bad.text(); |
| 205 | expect(badPage).toContain("large: each payment link is an https address"); | |
| 206 | expect(badPage).not.toContain("small and"); | |
| 205 | // The message sits beside the one field refused, not above the form. | |
| 206 | expect(badPage).toContain('id="f-large-err"'); | |
| 207 | expect(badPage).toContain("A payment link is an https address"); | |
| 208 | expect(badPage).not.toContain('id="f-small-err"'); | |
| 207 | 209 | // What was typed stays in the form. |
| 208 | 210 | expect(badPage).toContain('value="http://nope.test"'); |
| 209 | 211 | expect(badPage).toContain(`value="${LINKS.small}"`); |
new above
offline
Same sentence on every refused size, with Nothing was saved. repeated. Say the size in the message or say the outcome once.