Public: anyone can read this; the crew can change it.

Design: the /boards data and pin forms draw their fields as §5 `.field`, not `.qf` #4001

Parked opened this
Closed without merging

scout/forge:scout/3906-design-the-boards-data-and-pin-forms-dra → main 16 commits fork 1 thread · 1 unresolved

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
9 files changed +97 −98
docs/DESIGN.md +1 −1
@@ -395,7 +395,7 @@ gone, so this list only shrinks.
395395 A `.field` directly inside a `.bar` drops its bottom margin and the bar aligns to the end, so a labelled input and its button share a baseline
396396 - **`style/components.ts`** — parts of the §5 components that the table does not spell out — the palette's list, the menu's items, a dialog's head and foot, comments, the theme picker — and a few small helpers beside them: `.cat` `.clone` `.clone-text` `.comment` `.comment-body` `.comment-form` `.dash` `.dialog-body` `.dialog-foot` `.dialog-head` `.empty-title` `.error-note` `.field-row` `.form-actions` `.hex` `.ico` `.ico-loader` `.list` `.live-status` `.menu-item` `.menu-panel` `.menu-sep` `.menu-title` `.palette-empty` `.palette-foot` `.palette-group` `.palette-heading` `.palette-input` `.palette-item` `.palette-list` `.passkey` `.passkey-lead` `.passkey-note` `.passkey-off` `.passkey-on` `.preview` `.sep` `.split` `.sprite` `.swatch` `.table-scroll` `.tell-here` `.theme-apply` `.theme-option` `.tick` `.timeline` `.tl-dot` `.toast-body` `.topbar-search`
397397 - **`style/components.ts`, settings rows** — a list whose rows are settings (limits, capacity): the `<ul class="list setting-list">` lets title and meta wrap instead of ellipsizing, and a row's controls take their own line under 640px. `.row-fields` is the form in that row's trail (input, Save, Default): always visible, never hover-gated, wrapping under the text before it would clip. Use both for any page whose rows show a name, a current value, and a control to change it; use `.row-actions` only for secondary actions (delete, wake, pin, revoke). Flags, telemetry, cloud, people, crew roles and subscription headroom/budget use `.row-fields`. Classes: `.row-fields` `.setting-list`
398 - **`style/content.ts`, page furniture** — what frames a page's content: page and repo heads, the merge box, the front page and its tiles, explore, backups, boards, the fleet chart's series colours, lineage: `.app-shelf` `.app-tile` `.app-tile-body` `.app-tile-desc` `.app-tile-look` `.app-tile-name` `.backups-drill` `.backups-error` `.backups-now` `.backups-restore` `.bform` `.bgrid` `.bmanage` `.boards-result` `.bp-h2` `.bp-h3` `.bp-w2` `.bp-w3` `.break` `.bt-bar` `.bt-grid` `.bt-group` `.bt-hist` `.bt-name` `.bt-procs` `.bt-row` `.bt-val` `.commit-body` `.commit-head` `.domain-records` `.explore-filters` `.explore-line` `.explore-main` `.explore-name` `.explore-row` `.fg-s0` `.fg-s1` `.fg-s2` `.fg-s3` `.fg-s4` `.fg-s5` `.fg-s6` `.fg-s7` `.filters` `.flag-form` `.front-admin` `.front-controls` `.front-crew` `.front-featured` `.front-featured-body` `.front-featured-look` `.front-issues` `.front-live` `.front-more` `.front-pick` `.front-pin-any` `.front-weights` `.frozen` `.frozen-form` `.frozen-sentence` `.headroom` `.issue-head` `.issue-meta` `.merge-box` `.merge-form` `.merge-headline` `.merge-sub` `.mirror-form` `.number` `.origin-link` `.origin-mark` `.origin-name` `.origin-row` `.owner` `.page-head` `.path-head` `.policy-line` `.qf` `.repo-actions` `.repo-audience` `.repo-desc` `.repo-layout` `.repo-lineage` `.repo-title` `.search` `.slash` `.stage-detail` `.stage-dot` `.steps` `.sub` `.sys-pair` `.table-wrap` `.terminal-line` `.tok` `.tree-row` `.tree-total` `.wall-cells` `.where-sep`
398 - **`style/content.ts`, page furniture** — what frames a page's content: page and repo heads, the merge box, the front page and its tiles, explore, backups, boards, the fleet chart's series colours, lineage: `.app-shelf` `.app-tile` `.app-tile-body` `.app-tile-desc` `.app-tile-look` `.app-tile-name` `.backups-drill` `.backups-error` `.backups-now` `.backups-restore` `.bform` `.bgrid` `.bmanage` `.boards-result` `.bp-h2` `.bp-h3` `.bp-w2` `.bp-w3` `.break` `.bt-bar` `.bt-grid` `.bt-group` `.bt-hist` `.bt-name` `.bt-procs` `.bt-row` `.bt-val` `.commit-body` `.commit-head` `.domain-records` `.explore-filters` `.explore-line` `.explore-main` `.explore-name` `.explore-row` `.fg-s0` `.fg-s1` `.fg-s2` `.fg-s3` `.fg-s4` `.fg-s5` `.fg-s6` `.fg-s7` `.filters` `.flag-form` `.front-admin` `.front-controls` `.front-crew` `.front-featured` `.front-featured-body` `.front-featured-look` `.front-issues` `.front-live` `.front-more` `.front-pick` `.front-pin-any` `.front-weights` `.frozen` `.frozen-form` `.frozen-sentence` `.headroom` `.issue-head` `.issue-meta` `.merge-box` `.merge-form` `.merge-headline` `.merge-sub` `.mirror-form` `.number` `.origin-link` `.origin-mark` `.origin-name` `.origin-row` `.owner` `.page-head` `.path-head` `.policy-line` `.repo-actions` `.repo-audience` `.repo-desc` `.repo-layout` `.repo-lineage` `.repo-title` `.search` `.slash` `.stage-detail` `.stage-dot` `.steps` `.sub` `.sys-pair` `.table-wrap` `.terminal-line` `.tok` `.tree-row` `.tree-total` `.wall-cells` `.where-sep`
399399 - **`style/content.ts`, code view** — the source view and the syntax-highlight token classes `highlight-html.ts` builds as `tok-${kind}`: `.blob-view` `.ln` `.tok-attribute` `.tok-comment` `.tok-constant` `.tok-decorator` `.tok-deleted` `.tok-emphasis` `.tok-function` `.tok-heading` `.tok-inserted` `.tok-keyword` `.tok-link` `.tok-meta` `.tok-number` `.tok-operator` `.tok-plain` `.tok-property` `.tok-punctuation` `.tok-regex` `.tok-string` `.tok-tag` `.tok-type` `.tok-variable`
400400 - **`style/content.ts`, prose (markdown)** — table cell alignment, built by `markdown.ts` as `ta-${align}`: `.ta-c` `.ta-r`
401401 - **`style/content.ts`, diff viewer** — the diff table: its gutters, line kinds, file head and inline review comments: `.add` `.del` `.dh` `.diff` `.diff-body` `.diff-head` `.diff-note` `.diff-path` `.diff-stat` `.diff-stub` `.diff-summary` `.diff-table` `.dl` `.dl-review` `.dn` `.dn-comment` `.nonl` `.rc-hidden` `.rc-resolve` `.rc-resolved` `.wd`
src/web/pages/boards-view.ts +11 −17
@@ -18,7 +18,7 @@ import { liveRegionsJs } from "../client.ts";
1818 import { notFoundPage } from "../chrome.ts";
1919 import { html, raw, when, type Html } from "../html.ts";
2020 import { fragment, page } from "../layout.ts";
21 import { btn, card, chartBox, empty } from "../ui.ts";
21 import { btn, card, chartBox, empty, field, selectField } from "../ui.ts";
2222 import { flowPanel } from "./flow-panel.ts";
2323 import { isPinned, listPins } from "../../boards/pins.ts";
2424 import { panelData, runFor } from "../../boards/panel_data.ts";
@@ -27,9 +27,6 @@ import { cellsOf, paramsOf, queryFields, readParams } from "./boards.ts";
2727 /** The events the panels' queries read (runs, pulls, checks, issues, usage): any of them may change a chart. */
2828 const READS = "run.queued,run.started,run.finished,pull.*,check.*,issue.*,usage.*";
2929
30 const option = (value: string, selected: boolean) =>
31 html`<option value="${value}" ${selected ? raw("selected") : null}>${value}</option>`;
32
3330 /** Where a panel lives: its board's slug and its place on it, which name its data door. */
3431 export type PanelAt = { slug: string; index: number };
3532
@@ -84,7 +81,7 @@ export async function boardsList(ctx: Ctx): Promise<Response> {
8481 const listed = await timePhaseAsync(ctx.request, "boards", () => listAllBoards(ctx.app, ctx.auth.user));
8582 if (!listed.ok) return notFoundPage(ctx);
8683 const make = html`<form method="post" action="/boards/new" class="bform">
87 <label class="qf"><span>New board</span><input class="input" name="title" required maxlength="${String(MAX_TITLE)}" placeholder="Title" /></label>
84 ${field({ id: "new-title", label: "New board", name: "title", required: true, maxlength: MAX_TITLE, placeholder: "Title" })}
8885 ${btn("Make board", { variant: "primary" })}
8986 </form>`;
9087 const body =
@@ -115,15 +112,12 @@ export async function boardsList(ctx: Ctx): Promise<Response> {
115112 }
116113
117114 function panelForm(slug: string, op: string, p: Panel | undefined, index: number, fields: Html): Html {
115 const at = op === "edit" ? `e${String(index)}` : "m";
118116 return html`<form method="post" action="/boards/${slug}/${op}" class="bform">
119117 ${op === "edit" ? html`<input type="hidden" name="index" value="${String(index)}" />` : null}
120 <label class="qf"><span>Panel title</span><input class="input" name="title" required maxlength="${String(MAX_TITLE)}" value="${p?.title ?? ""}" placeholder="Panel title" /></label>
121 <label class="qf"><span>Width</span><select class="input" name="w">
122 ${[1, 2, 3].slice(0, MAX_W).map((n) => html`<option value="${String(n)}" ${n === (p?.w ?? 1) ? raw("selected") : null}>${String(n)} wide</option>`)}
123 </select></label>
124 <label class="qf"><span>Height</span><select class="input" name="h">
125 ${[1, 2, 3].slice(0, MAX_H).map((n) => html`<option value="${String(n)}" ${n === (p?.h ?? 1) ? raw("selected") : null}>${String(n)} high</option>`)}
126 </select></label>
118 ${field({ id: `${at}-title`, label: "Panel title", name: "title", required: true, maxlength: MAX_TITLE, value: p?.title ?? "", placeholder: "Panel title" })}
119 ${selectField({ id: `${at}-w`, label: "Width", name: "w", options: [1, 2, 3].slice(0, MAX_W).map((n) => ({ value: String(n), label: `${String(n)} wide`, selected: n === (p?.w ?? 1) })) })}
120 ${selectField({ id: `${at}-h`, label: "Height", name: "h", options: [1, 2, 3].slice(0, MAX_H).map((n) => ({ value: String(n), label: `${String(n)} high`, selected: n === (p?.h ?? 1) })) })}
127121 ${fields}
128122 ${btn(op === "edit" ? "Save panel" : "Add panel", { variant: "primary" })}
129123 </form>`;
@@ -143,7 +137,7 @@ function manage(slug: string, board: Board, adding: Html, pins: ReturnType<typeo
143137 const one = (p: Panel, i: number) => html`<li class="row">
144138 <details class="row-main">
145139 <summary><strong class="break">${p.title}</strong> <span class="muted small">${CHART_NAMES[p.chart]} · ${String(p.w)}×${String(p.h)}</span></summary>
146 ${panelForm(slug, "edit", p, i, queryFields(paramsOf(p.query, p.chart)))}
140 ${panelForm(slug, "edit", p, i, queryFields(paramsOf(p.query, p.chart), `e${String(i)}`))}
147141 </details>
148142 <div class="row-trail bar">
149143 ${pinForm(slug, p.title, isPinned(pins, slug, p.title))}
@@ -168,12 +162,12 @@ function manage(slug: string, board: Board, adding: Html, pins: ReturnType<typeo
168162 )}
169163 ${card(
170164 html`<form method="post" action="/boards/${slug}/rename" class="bform">
171 <label class="qf"><span>Board title</span><input class="input" name="title" required maxlength="${String(MAX_TITLE)}" value="${board.title}" /></label>
165 ${field({ id: "board-title", label: "Board title", name: "title", required: true, maxlength: MAX_TITLE, value: board.title })}
172166 ${btn("Rename")}
173167 </form>
174168 <form method="post" action="/boards/${slug}/settings" class="bform">
175 <label class="qf"><span>Range</span><select class="input" name="range">${RANGES.map((r) => option(r, r === board.range))}</select></label>
176 <label class="qf"><span>Live</span><select class="input" name="refresh"><option value="off" ${board.refresh === "off" ? raw("selected") : null}>off</option><option value="10s" ${board.refresh === "off" ? null : raw("selected")}>on: redraw when events arrive</option></select></label>
169 ${selectField({ id: "board-range", label: "Range", name: "range", options: RANGES.map((r) => ({ value: r, label: r, selected: r === board.range })) })}
170 ${selectField({ id: "board-refresh", label: "Live", name: "refresh", options: [{ value: "off", label: "off", selected: board.refresh === "off" }, { value: "10s", label: "on: redraw when events arrive", selected: board.refresh !== "off" }] })}
177171 ${btn("Save settings")}
178172 </form>
179173 <form method="post" action="/boards/${slug}/duplicate" class="bform">${btn("Duplicate")}</form>
@@ -197,7 +191,7 @@ export async function boardShow(ctx: Ctx): Promise<Response> {
197191 body: html`<div class="page-head"><h1>${board.title}</h1>
198192 ${btn("All boards", { href: "/boards", variant: "ghost" })}</div>
199193 ${panels}
200 ${manage(slug, board, queryFields(readParams(ctx.url.searchParams)), listPins(ctx.app.db, ctx.auth.user?.id ?? ""))}`,
194 ${manage(slug, board, queryFields(readParams(ctx.url.searchParams), "m"), listPins(ctx.app.db, ctx.auth.user?.id ?? ""))}`,
201195 scriptJs: liveRegionsJs,
202196 });
203197 notePhase(ctx.request, "render", performance.now() - rendering);
src/web/pages/boards.ts +30 −63
@@ -18,7 +18,7 @@ import { notePhase, takeSessionTime, timePhase, timePhaseAsync } from "../../cor
1818 import { notFoundPage } from "../chrome.ts";
1919 import { html, raw, when } from "../html.ts";
2020 import { page } from "../layout.ts";
21 import { btn, card, chartBox, empty } from "../ui.ts";
21 import { btn, card, chartBox, empty, field, selectField } from "../ui.ts";
2222
2323 const BUCKET_MS = { minute: 60_000, hour: 3_600_000, day: 86_400_000 } as const;
2424 const AGGREGATES = ["count", "sum", "avg", "max"] as const;
@@ -133,67 +133,36 @@ export function machineLinks(now: number): { label: string; href: string }[] {
133133 ];
134134 }
135135
136 const option = (value: string, label: string, selected: boolean) =>
137 html`<option value="${value}" ${selected ? raw("selected") : null}>${label}</option>`;
138
139136 /** The inputs that say a query, filled from `p`; the page's form and a panel's share them. */
140 export function queryFields(p: Params) {
137 export function queryFields(p: Params, idp: string) {
141138 const src = Object.hasOwn(SOURCES, p.source) ? SOURCES[p.source]! : undefined;
142139 const cols = src ? Object.keys(src.columns) : [];
140 const opt = (value: string, label: string, current: string) => ({ value, label, selected: value === current });
141 const pick = (name: string, label: string, options: { value: string; label: string; selected: boolean }[]) =>
142 selectField({ label, name, id: `${idp}-${name}`, options });
143 const text = (name: string, label: string, value: string, placeholder: string) =>
144 field({ label, name, id: `${idp}-${name}`, value, placeholder, mono: true, maxlength: MAX_PARAM });
143145 return html`
144 <label class="qf"><span>Chart</span>
145 <select class="input" name="chart">
146 ${CHARTS.map((c) => option(c, CHART_NAMES[c], c === p.chart))}
147 </select>
148 </label>
149 <label class="qf"><span>Source</span>
150 <select class="input" name="source">
151 ${Object.keys(SOURCES).map((n) => option(n, n, n === p.source))}
152 </select>
153 </label>
154 <label class="qf"><span>Aggregate</span>
155 <select class="input" name="aggregate">
156 ${AGGREGATES.map((a) => option(a, a, a === p.aggregate))}
157 </select>
158 </label>
159 <label class="qf" title="Column to aggregate"><span>Column</span>
160 <select class="input" name="column">
161 ${option("", "(rows)", p.column === "")}
162 ${cols.filter((c) => src!.columns[c] === "number").map((c) => option(c, c, c === p.column))}
163 </select>
164 </label>
165 <label class="qf" title="Group by"><span>Group by</span>
166 <select class="input" name="by">
167 ${(Object.keys(BUCKET_MS) as Bucket[]).map((b) => option(b, `per ${b}`, b === p.by))}
168 ${cols.map((c) => option(c, `by ${c}`, c === p.by))}
169 </select>
170 </label>
171 <label class="qf" title="Series (stacked area, heat strip, table)"><span>Series</span>
172 <select class="input" name="series">
173 ${option("", "(one series)", p.series === "")}
174 ${cols.map((c) => option(c, `split by ${c}`, c === p.series))}
175 </select>
176 </label>
177 <label class="qf"><span>From</span>
178 <input class="input mono" name="from" value="${p.from}" placeholder="from 2026-10-01" maxlength="${MAX_PARAM}" />
179 </label>
180 <label class="qf"><span>To</span>
181 <input class="input mono" name="to" value="${p.to}" placeholder="to 2026-10-08" maxlength="${MAX_PARAM}" />
182 </label>
183 <label class="qf"><span>Filter column</span>
184 <select class="input" name="fcolumn">
185 ${option("", "(no filter)", p.fcolumn === "")}
186 ${cols.map((c) => option(c, c, c === p.fcolumn))}
187 </select>
188 </label>
189 <label class="qf"><span>Filter operator</span>
190 <select class="input" name="fop">
191 ${OPS.map((o) => option(o, o, o === p.fop))}
192 </select>
193 </label>
194 <label class="qf"><span>Filter value</span>
195 <input class="input mono" name="fvalue" value="${p.fvalue}" placeholder="value" maxlength="${MAX_PARAM}" />
196 </label>
146 ${pick("chart", "Chart", CHARTS.map((c) => opt(c, CHART_NAMES[c], p.chart)))}
147 ${pick("source", "Source", Object.keys(SOURCES).map((n) => opt(n, n, p.source)))}
148 ${pick("aggregate", "Aggregate", AGGREGATES.map((a) => opt(a, a, p.aggregate)))}
149 ${pick("column", "Column", [
150 opt("", "(rows)", p.column),
151 ...cols.filter((c) => src!.columns[c] === "number").map((c) => opt(c, c, p.column)),
152 ])}
153 ${pick("by", "Group by", [
154 ...(Object.keys(BUCKET_MS) as Bucket[]).map((b) => opt(b, `per ${b}`, p.by)),
155 ...cols.map((c) => opt(c, `by ${c}`, p.by)),
156 ])}
157 ${pick("series", "Series", [
158 opt("", "(one series)", p.series),
159 ...cols.map((c) => opt(c, `split by ${c}`, p.series)),
160 ])}
161 ${text("from", "From", p.from, "from 2026-10-01")}
162 ${text("to", "To", p.to, "to 2026-10-08")}
163 ${pick("fcolumn", "Filter column", [opt("", "(no filter)", p.fcolumn), ...cols.map((c) => opt(c, c, p.fcolumn))])}
164 ${pick("fop", "Filter operator", OPS.map((o) => opt(o, o, p.fop)))}
165 ${text("fvalue", "Filter value", p.fvalue, "value")}
197166 `;
198167 }
199168
@@ -248,7 +217,7 @@ export async function boardsPage(ctx: Ctx): Promise<Response> {
248217
249218 const form = card(
250219 html`<form method="get" action="/boards/data" class="bform">
251 ${queryFields(p)}
220 ${queryFields(p, "q")}
252221 ${btn("Draw", { variant: "primary" })}
253222 </form>`,
254223 { head: html`<h2>Query</h2>` },
@@ -295,10 +264,8 @@ export async function boardsPage(ctx: Ctx): Promise<Response> {
295264 (k) => html`<input type="hidden" name="${k}" value="${p[k as keyof Params]}" />`,
296265 )}
297266 <input type="hidden" name="w" value="1" /><input type="hidden" name="h" value="1" />
298 <label class="qf"><span>Board</span><select class="input" name="slug">
299 ${boards.map((b) => html`<option value="${b.slug}">${b.board.title}</option>`)}
300 </select></label>
301 <label class="qf"><span>Panel title</span><input class="input" name="title" required maxlength="80" value="${`${p.aggregate} of ${p.source}`}" /></label>
267 ${selectField({ label: "Board", name: "slug", id: "pin-slug", options: boards.map((b) => ({ value: b.slug, label: b.board.title })) })}
268 ${field({ label: "Panel title", name: "title", id: "pin-title", value: `${p.aggregate} of ${p.source}`, required: true, maxlength: 80 })}
302269 ${btn("Pin to board")}
303270 </form>`,
304271 { head: html`<h2>Pin this query</h2>` },
src/web/style/content.ts +1 −2
@@ -295,8 +295,7 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); }
295295 .bp-h2 .chart-box.is-table { height: 400px; }
296296 .bp-h3 .chart-box.is-table { height: 540px; }
297297 .bform { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; margin-bottom: 8px; }
298 .bform .qf { display: flex; flex-direction: column; gap: 4px; flex: 1 1 140px; min-width: 0; }
299 .bform .qf > span { font-size: 12.5px; font-weight: 600; color: var(--fg); }
298 .bform .field { flex: 1 1 140px; min-width: 0; margin: 0; }
300299 .bform .btn { flex: none; }
301300 .boards-result .table { margin-top: 12px; }
302301 .bt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 2px 16px; font-family: var(--mono); font-size: 12.5px; margin-top: 8px; }
src/web/ui.ts +3 −8
@@ -1173,18 +1173,13 @@ export function selectField(
11731173 const id = o.id ?? `f-${o.name}`;
11741174 return html`<div class="field">
11751175 <label for="${id}">${o.label}</label>
1176 <select class="input" id="${id}" name="${o.name}">
1176 <select class="input" id="${id}" name="${o.name}"${o.hint ? html` aria-describedby="${id}-hint"` : null}>
11771177 ${o.options.map(
11781178 (opt) =>
1179 html`<option
1180 value="${opt.value}"
1181 ${opt.selected ? raw("selected") : null}
1182 >
1183 ${opt.label}
1184 </option>`,
1179 html`<option value="${opt.value}"${opt.selected ? raw(" selected") : null}>${opt.label}</option>`,
11851180 )}
11861181 </select>
1187 ${o.hint ? html`<span class="hint">${o.hint}</span>` : null}
1182 ${o.hint ? html`<span class="hint" id="${id}-hint">${o.hint}</span>` : null}
11881183 </div>`;
11891184 }
11901185
test/boards-page.test.ts +3 −3
@@ -224,9 +224,9 @@ describe("every chart type from one seeded query", () => {
224224 });
225225 test("the chart is chosen beside the query", async () => {
226226 const body = await drawn("heat");
227 expect(body).toMatch(/<select class="input" name="chart"[^>]*>/);
228 expect(body).toContain('<option value="heat" selected>heat strip</option>');
229 expect(body).toContain('<option value="kind" selected>split by kind</option>');
227 expect(body).toMatch(/<select\s+class="input"\s+id="q-chart"\s+name="chart"[^>]*>/);
228 expect(body).toMatch(/<option\s+value="heat"\s+selected\s*>\s*heat strip\s*<\/option>/);
229 expect(body).toMatch(/<option\s+value="kind"\s+selected\s*>\s*split by kind\s*<\/option>/);
230230 });
231231 });
232232
test/boards-selectors.test.ts +35 −2
@@ -58,10 +58,13 @@ test("every query selector has a visible label and sits outside .row-actions", a
5858 expect(form![0]).not.toContain("row-actions");
5959 expect(form![0]).toContain('class="bform"');
6060 for (const name of ["chart", "source", "aggregate", "column", "by", "series", "from", "to", "fcolumn", "fop", "fvalue"]) {
61 const m = form![1]!.match(new RegExp(`<label class="qf"[^>]*><span>([^<]+)</span>\\s*<(?:select|input)[^>]* name="${name}"`));
61 const m = form![1]!.match(new RegExp(`<div class="field"[^>]*>\\s*<label for="([^"]+)">([^<]+)</label>\\s*<(?:select|input)[^>]*\\sid="\\1"\\s+name="${name}"`));
6262 expect(m, name).not.toBeNull();
63 expect(m![1]!.trim().length, name).toBeGreaterThan(0);
63 expect(m![2]!.trim().length, name).toBeGreaterThan(0);
6464 }
65 expect(html).not.toContain('class="qf"');
66 expect(html).not.toMatch(/<div class="field"[^>]*\stitle=/);
67 expect(form![0]).not.toContain('class="hint"'); // a hint under one select makes a wrapped .bform row ragged
6568 });
6669
6770 test("the selector styles never hide or collapse a control", () => {
@@ -82,3 +85,33 @@ test("in every theme the label, field text and border read against their ground"
8285 expect(t.card.toLowerCase(), `${name} field ground`).not.toBe(t.fg.toLowerCase());
8386 }
8487 });
88
89 test("selectField ties its hint to the select with aria-describedby", async () => {
90 const { selectField } = await import("../src/web/ui.ts");
91 const out = String(selectField({ id: "x", label: "L", name: "n", hint: "H", options: [{ value: "a", label: "A" }] }));
92 expect(out).toMatch(/<select[^>]*aria-describedby="x-hint"/);
93 expect(out).toContain('id="x-hint"');
94 expect(String(selectField({ id: "y", label: "L", name: "n", options: [] }))).not.toContain("aria-describedby");
95 });
96
97 test("the boards list and a board draw every form field as .field with unique ids", async () => {
98 const h = { authorization: `Bearer ${token}`, origin: servers.url, "content-type": "application/x-www-form-urlencoded" };
99 const made = await fetch(`${servers.url}/boards/new`, { method: "POST", headers: h, body: "title=Forms", redirect: "manual" });
100 const slug = (made.headers.get("location") ?? "").split("/").pop()!;
101 const list = await (await fetch(`${servers.url}/boards`, { headers: h })).text();
102 expect(list).not.toContain('class="qf"');
103 expect(list).toMatch(/<label for="new-title">New board<\/label>/);
104 const page = await (await fetch(`${servers.url}/boards/${slug}`, { headers: h })).text();
105 expect(page).not.toContain('class="qf"');
106 for (const id of ["board-title", "board-range", "board-refresh", "m-title", "m-w", "m-h"]) {
107 expect(page, id).toContain(`<label for="${id}">`);
108 }
109 const ids = [...page.matchAll(/\sid="([^"]+)"/g)].map((m) => m[1]);
110 expect(new Set(ids).size).toBe(ids.length);
111 });
112
113 test(".bform drops the .field bottom margin so buttons align with the inputs", () => {
114 const rule = (content + components).match(/\.bform \.field \{([^}]*)\}/);
115 expect(rule).not.toBeNull();
116 expect(rule![1]).toMatch(/margin:\s*0\b/);
117 });
test/boards-store.test.ts +12 −1
@@ -231,6 +231,17 @@ describe("/boards", () => {
231231 expect((await asAdmin("/boards/scratch-b")).status).toBe(404);
232232 });
233233
234 test("no id repeats on a board page with several panels", async () => {
235 await post("/boards/new", { title: "Ids" });
236 const q = { source: "runs", aggregate: "count", column: "", by: "day", from: "", to: "", fcolumn: "", fop: "eq", fvalue: "" };
237 for (const title of ["one", "two", "three"]) await post("/boards/ids/add", { ...q, title, w: "1", h: "1" });
238 const page = await (await asAdmin("/boards/ids")).text();
239 const ids = [...page.matchAll(/\sid="([^"]+)"/g)].map((m) => m[1]!);
240 expect(ids).toContain("e2-chart");
241 expect(ids).toContain("m-chart");
242 expect(ids.filter((id, i) => ids.indexOf(id) !== i)).toEqual([]);
243 });
244
234245 test("a pinned query lands on the board", async () => {
235246 const data = await (await asAdmin("/boards/data?source=runs&by=kind")).text();
236247 expect(data).toContain('action="/boards/pin"');
@@ -250,7 +261,7 @@ describe("/boards", () => {
250261 // runs in range: three days × three kinds for the heat strip; three days of bars, the series set aside
251262 expect(page.match(/<rect class="cell"/g)?.length).toBe(9);
252263 expect(page.match(/<rect class="bar"/g)?.length).toBe(3);
253 expect(page).toContain('<option value="heat" selected>heat strip</option>');
264 expect(page).toMatch(/<option\s+value="heat"\s+selected\s*>\s*heat strip\s*<\/option>/);
254265 expect(parseBoard({ ...board, panels: [{ ...board.panels[0], chart: "pie" }] }).ok).toBe(false);
255266 await deleteBoard(app, alice, "charts");
256267 });
test/ssh-site.test.ts +1 −1
@@ -103,7 +103,7 @@ describe("the terminal on the website", () => {
103103 const page = await fetch(`${base}/settings/crew`, {
104104 headers: { cookie },
105105 }).then((r) => r.text());
106 expect(page).toContain('<select class="input" id="f-model" name="model">');
106 expect(page).toContain('<select class="input" id="f-model" name="model" aria-describedby="f-model-hint">');
107107 expect(page).toContain('value="opus"');
108108 expect(page).toContain('value="sonnet"');
109109 expect(page).toContain('value="haiku"');

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs