Public: anyone can read this; the crew can change it.
Main green: four new pages' bare 'No …' empty states use the shared words; the empty-words test runs first #16874
Check · Review · Land · Live done — Landed and live in production.
fix/empty-words-red → main 0 commits
19 files
changed +66
−21
- src/core/empty_words.ts
- src/tui/screens/appflags.ts
- src/tui/screens/flags.ts
- src/tui/screens/gifts.ts
- src/web/empty_words.ts
- src/web/pages/app_flags.ts
- src/web/pages/flags.ts
- src/web/pages/gifts.ts
- src/web/pages/read-grants.ts
- src/web/render/reg.ts
- test/app-flags.test.ts
- test/empty-notes.test.ts
- test/empty-words-all.test.ts
- test/flags-language.test.ts
- test/gifts-page.test.ts
- test/gifts-tui.test.ts
- test/keys-flags-list.test.ts
- test/origin-read-grant.test.ts
- test/render-registry.test.ts
src/core/empty_words.ts +20 −1
| @@ -5,6 +5,8 @@ | ||
| 5 | 5 | * every kind and holds each to its sentence and its single link. |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | import { FLAGS_FILE } from "./app_flags.ts"; | |
| 9 | ||
| 8 | 10 | export interface EmptyWords { |
| 9 | 11 | /** One sentence, plain words, ending in a full stop. */ |
| 10 | 12 | readonly sentence: string; |
| @@ -16,6 +18,8 @@ export interface EmptyWords { | ||
| 16 | 18 | readonly href?: string; |
| 17 | 19 | } |
| 18 | 20 | |
| 21 | const NO_FLAG = "No flag is declared."; | |
| 22 | ||
| 19 | 23 | const TABLE = { |
| 20 | 24 | board: { sentence: "No board yet.", label: "Start from a question", href: "/boards/data" }, |
| 21 | 25 | inbox: { sentence: "Nothing is waiting on you.", label: "Tell the crew something", href: "/tell" }, |
| @@ -81,12 +85,28 @@ const TABLE = { | ||
| 81 | 85 | agents: { sentence: "No agents yet.", reason: "Make one below." }, |
| 82 | 86 | displayChoices: { sentence: "No builds to choose from yet." }, |
| 83 | 87 | loads: { sentence: "No load reports in the last 30 days." }, |
| 88 | // Lists drawn as one line (`emptyLine`, and `emptyText` in the terminal). A reason names the | |
| 89 | // step, never where it sits: a phone lays the page out differently. | |
| 90 | gifts: { sentence: "No gift yet.", reason: "Make a gift link and send it to a friend." }, | |
| 91 | readGrants: { sentence: "No one else reads it.", reason: "Grant read to one of your apps or one crew member." }, | |
| 92 | // The forge's own flags are declared in code; an app's in its repository. One sentence for both. | |
| 93 | flags: { sentence: NO_FLAG }, | |
| 94 | appFlags: { sentence: NO_FLAG, reason: `Add a ${FLAGS_FILE} to the repository to declare one.` }, | |
| 95 | regValues: { sentence: "No values." }, | |
| 84 | 96 | } as const satisfies Readonly<Record<string, EmptyWords>>; |
| 85 | 97 | |
| 86 | 98 | export type EmptyKind = keyof typeof TABLE; |
| 87 | 99 | |
| 88 | 100 | export const EMPTY_WORDS: Readonly<Record<EmptyKind, EmptyWords>> = TABLE; |
| 89 | 101 | |
| 102 | /** | |
| 103 | * The sentence and its reason as one line of text: the terminal's empty screens and `emptyLine`. | |
| 104 | */ | |
| 105 | export function emptyText(kind: EmptyKind): string { | |
| 106 | const w: EmptyWords = TABLE[kind]; | |
| 107 | return w.reason === undefined ? w.sentence : `${w.sentence} ${w.reason}`; | |
| 108 | } | |
| 109 | ||
| 90 | 110 | /** |
| 91 | 111 | * The sentence-only empty states: a small note under a card heading, with no action of its own (the |
| 92 | 112 | * page already carries the door). Each key is its sentence in camelCase, so a reader finds a note |
| @@ -118,7 +138,6 @@ export const NOTE_WORDS = { | ||
| 118 | 138 | noChangeYet: "No change yet.", |
| 119 | 139 | noRepositoryRunsOnItsOwn: "No repository runs on its own.", |
| 120 | 140 | nothingOfferedYet: "Nothing offered yet.", |
| 121 | noFlagIsDeclaredYet: "No flag is declared yet.", | |
| 122 | 141 | noProjectInThisFile: "No project in this file.", |
| 123 | 142 | noElementsPlacedInAStorey: "No elements are placed in a storey.", |
| 124 | 143 | nothingProposedToTheParentForgeYet: "Nothing proposed to the parent forge yet.", |
src/tui/screens/appflags.ts +2 −1
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | import { appFlagRows, setAppFlag } from "../../actions/app_flags.ts"; |
| 9 | 9 | import type { AppFlagRow } from "../../core/app_flags.ts"; |
| 10 | 10 | import { getAppByRepo } from "../../core/apps.ts"; |
| 11 | import { emptyText } from "../../core/empty_words.ts"; | |
| 11 | 12 | import { canAdmin, type Repo } from "../../core/repos.ts"; |
| 12 | 13 | import { flagSummary } from "../../web/pages/app_flags.ts"; |
| 13 | 14 | import type { Ctx, Screen } from "../app/app.ts"; |
| @@ -70,7 +71,7 @@ export function appFlagsScreen(f: Session, ctx: Ctx, repo: Repo): Screen { | ||
| 70 | 71 | : !readable |
| 71 | 72 | ? "An app's flags are its admin's." |
| 72 | 73 | : rows.length === 0 |
| 73 | ? "No flag is declared: add a flags.json to the repository." | |
| 74 | ? emptyText("appFlags") | |
| 74 | 75 | : `${rows.length} for ${repo.ownerName}/${repo.name}.`; |
| 75 | 76 | const said = wrap(text, Math.max(1, area.w)).slice(0, 3); |
| 76 | 77 | const [head, list] = split(area, "v", [len(said.length), fill(1)]); |
src/tui/screens/flags.ts +2 −1
| @@ -21,6 +21,7 @@ import { | ||
| 21 | 21 | type FlagValue, |
| 22 | 22 | } from "../../core/flags.ts"; |
| 23 | 23 | import { makeWinnerDefault } from "../../actions/flag_winner.ts"; |
| 24 | import { EMPTY_WORDS } from "../../core/empty_words.ts"; | |
| 24 | 25 | import type { Ctx, Screen } from "../app/app.ts"; |
| 25 | 26 | import { binding } from "../app/keys.ts"; |
| 26 | 27 | import { style } from "../term/style.ts"; |
| @@ -113,7 +114,7 @@ export function flagsScreen(f: Session, ctx: Ctx): Screen { | ||
| 113 | 114 | : !allowed |
| 114 | 115 | ? FLAGS_ADMIN_ONLY |
| 115 | 116 | : names().length === 0 |
| 116 | ? "No flag is declared yet." | |
| 117 | ? EMPTY_WORDS.flags.sentence | |
| 117 | 118 | : usesOf(names()[state.index] ?? names()[0]!); |
| 118 | 119 | s.text(head!.x, head!.y, truncate(text, head!.w), style(c.mutedFg, c.bg), head!.x + head!.w); |
| 119 | 120 | drawList(s, list!, c, state, rows()); |
src/tui/screens/gifts.ts +2 −1
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | import { giveGift, GIFT_WORDS, isSubscriber, readGifts } from "../../actions/gifts.ts"; |
| 8 | import { emptyText } from "../../core/empty_words.ts"; | |
| 8 | 9 | import { publicOrigin } from "../../core/public_origin.ts"; |
| 9 | 10 | import type { Ctx, Screen } from "../app/app.ts"; |
| 10 | 11 | import { binding } from "../app/keys.ts"; |
| @@ -38,7 +39,7 @@ export function giftsScreen(f: Session, ctx: Ctx): Screen { | ||
| 38 | 39 | state.clamp(rows.length); |
| 39 | 40 | const [head, body] = split(area, "v", [len(2), fill(1)]); |
| 40 | 41 | s.text(head!.x, head!.y, truncate(note !== "" ? note : `${left} gifts left: n makes a one-use link for a friend's forge`, head!.w), style(c.mutedFg, c.bg), head!.x + head!.w); |
| 41 | if (rows.length === 0) s.text(body!.x, body!.y, truncate("No gift yet.", body!.w), style(c.mutedFg, c.bg), body!.x + body!.w); | |
| 42 | if (rows.length === 0) s.text(body!.x, body!.y, truncate(emptyText("gifts"), body!.w), style(c.mutedFg, c.bg), body!.x + body!.w); | |
| 42 | 43 | else drawList(s, body!, c, state, rows); |
| 43 | 44 | }, |
| 44 | 45 | key(e) { |
src/web/empty_words.ts +4 −5
| @@ -6,7 +6,7 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | import { html, type Html } from "./html.ts"; |
| 9 | import { EMPTY_WORDS, NOTE_WORDS, type EmptyKind, type EmptyWords, type NoteKey } from "../core/empty_words.ts"; | |
| 9 | import { EMPTY_WORDS, emptyText, NOTE_WORDS, type EmptyKind, type EmptyWords, type NoteKey } from "../core/empty_words.ts"; | |
| 10 | 10 | import { btn, empty, type IconName } from "./ui.ts"; |
| 11 | 11 | |
| 12 | 12 | export { EMPTY_WORDS, type EmptyKind }; |
| @@ -95,10 +95,9 @@ export function emptyList(kind: keyof typeof ICONS, o: EmptyOptions = {}): Html | ||
| 95 | 95 | * the compact form for small inline lists (a fieldset, a list item, a narrow phone), where the |
| 96 | 96 | * picture block would cost layout and bytes; any kind may be drawn this way. */ |
| 97 | 97 | export function emptyLine(kind: EmptyKind, o: { reason?: string; id?: string } = {}): Html { |
| 98 | const w: EmptyWords = EMPTY_WORDS[kind]; | |
| 99 | const reason = o.reason ?? w.reason; | |
| 100 | if (o.id !== undefined) return html`<p class="muted small" id="${o.id}">${reason === undefined ? w.sentence : `${w.sentence} ${reason}`}</p>`; | |
| 101 | return html`<p class="muted small">${reason === undefined ? w.sentence : `${w.sentence} ${reason}`}</p>`; | |
| 98 | const text = o.reason === undefined ? emptyText(kind) : `${EMPTY_WORDS[kind].sentence} ${o.reason}`; | |
| 99 | if (o.id !== undefined) return html`<p class="muted small" id="${o.id}">${text}</p>`; | |
| 100 | return html`<p class="muted small">${text}</p>`; | |
| 102 | 101 | } |
| 103 | 102 | |
| 104 | 103 | /** A list of none that is a headed section: the table's sentence as the heading (so a screen |
src/web/pages/app_flags.ts +3 −2
| @@ -5,13 +5,14 @@ | ||
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | import { setAppFlag } from "../../actions/app_flags.ts"; |
| 8 | import { FLAGS_FILE, type AppFlagRow } from "../../core/app_flags.ts"; | |
| 8 | import type { AppFlagRow } from "../../core/app_flags.ts"; | |
| 9 | 9 | import type { Ctx } from "../../http/context.ts"; |
| 10 | 10 | import { adminForm } from "../admin_form.ts"; |
| 11 | 11 | import { repoBase } from "../chrome.ts"; |
| 12 | 12 | import { field } from "../form.ts"; |
| 13 | 13 | import { html, type Html } from "../html.ts"; |
| 14 | 14 | import { flashTo } from "../layout.ts"; |
| 15 | import { emptyLine } from "../empty_words.ts"; | |
| 15 | 16 | import { row, rowList } from "../ui.ts"; |
| 16 | 17 | |
| 17 | 18 | /** One line of what is set. */ |
| @@ -41,7 +42,7 @@ export function appFlagsView(base: string, rows: readonly AppFlagRow[]): Html { | ||
| 41 | 42 | <p class="muted small">Choose who sees each flag the app declares.</p> |
| 42 | 43 | ${items.length > 0 |
| 43 | 44 | ? rowList(items, { bare: true }) |
| 44 | : html`<p class="muted small">No flag is declared: add a <span class="mono">${FLAGS_FILE}</span> to the repository.</p>`} | |
| 45 | : emptyLine("appFlags")} | |
| 45 | 46 | </section>`; |
| 46 | 47 | } |
| 47 | 48 |
src/web/pages/flags.ts +2 −2
| @@ -7,7 +7,7 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | import { sshOn } from "../../settings/ssh.ts"; |
| 10 | import { emptyNote } from "../empty_words.ts"; | |
| 10 | import { emptyLine } from "../empty_words.ts"; | |
| 11 | 11 | import { readFlags } from "../../actions/flags_view.ts"; |
| 12 | 12 | import { checkInput, FLAGS_ADMIN_ONLY, flagRegistry, usesLine, winnerOffer, mayManageFlags, useFlagRegistry, type FlagValue } from "../../core/flags.ts"; |
| 13 | 13 | import { makeWinnerDefault } from "../../actions/flag_winner.ts"; |
| @@ -111,7 +111,7 @@ export function flagsPage(ctx: Ctx): Response { | ||
| 111 | 111 | const body = html`<section class="settings-block"> |
| 112 | 112 | <h2>Flags</h2> |
| 113 | 113 | ${names.length === 0 |
| 114 | ? emptyNote("noFlagIsDeclaredYet") | |
| 114 | ? emptyLine("flags") | |
| 115 | 115 | : html`<ul class="list setting-list"> |
| 116 | 116 | ${rows} |
| 117 | 117 | </ul>`} |
src/web/pages/gifts.ts +2 −1
| @@ -11,6 +11,7 @@ import type { Ctx } from "../../http/context.ts"; | ||
| 11 | 11 | import { notFoundPage, signInFirst } from "../chrome.ts"; |
| 12 | 12 | import { readForm } from "../form.ts"; |
| 13 | 13 | import { html, type Html } from "../html.ts"; |
| 14 | import { emptyLine } from "../empty_words.ts"; | |
| 14 | 15 | import { btn, copyField, dot } from "../ui.ts"; |
| 15 | 16 | import { accountShell } from "./account.ts"; |
| 16 | 17 | |
| @@ -44,7 +45,7 @@ export function giftsBlock(ctx: Ctx, shown?: Shown, refusal?: string): Html | nu | ||
| 44 | 45 | ${copyField("gift-link", shown.link, "The link to send", "Copy the link")} |
| 45 | 46 | </div>`} |
| 46 | 47 | <form method="post" action="/settings/gifts">${btn("Make a gift link", { variant: "primary" })}</form> |
| 47 | ${lines.length === 0 ? html`<p class="muted small">No gift yet.</p>` : html`<dl class="status-rows">${lines}</dl>`} | |
| 48 | ${lines.length === 0 ? emptyLine("gifts") : html`<dl class="status-rows">${lines}</dl>`} | |
| 48 | 49 | </section>`; |
| 49 | 50 | } |
| 50 | 51 |
src/web/pages/read-grants.ts +2 −1
| @@ -11,6 +11,7 @@ import { forbiddenPage, loadRepo, NOT_YOURS_TO_DO, repoBase, repoNotFound } from | ||
| 11 | 11 | import { field, readForm } from "../form.ts"; |
| 12 | 12 | import { html, type Html } from "../html.ts"; |
| 13 | 13 | import { flashTo } from "../layout.ts"; |
| 14 | import { emptyLine } from "../empty_words.ts"; | |
| 14 | 15 | import { btn, confirmAction, field as formField, selectField, time } from "../ui.ts"; |
| 15 | 16 | |
| 16 | 17 | /** |
| @@ -24,7 +25,7 @@ export function readGrantsSection(ctx: Ctx, repo: Repo): Html | null { | ||
| 24 | 25 | <h2>Who may read this</h2> |
| 25 | 26 | <p class="muted">Let one of your apps, or one crew member, read this mirror's commits, branches and pulls, and nothing else, until you revoke it.</p> |
| 26 | 27 | ${grants.length === 0 |
| 27 | ? html`<p class="muted small">No one else reads it.</p>` | |
| 28 | ? emptyLine("readGrants") | |
| 28 | 29 | : html`<dl class="status-rows"> |
| 29 | 30 | ${grants.map( |
| 30 | 31 | (g) => html`<div class="status-row"> |
src/web/render/reg.ts +2 −1
| @@ -9,6 +9,7 @@ | ||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | import { escapeHtml, html, raw } from "../html.ts"; |
| 12 | import { emptyLine } from "../empty_words.ts"; | |
| 12 | 13 | import { fileSize } from "../ui.ts"; |
| 13 | 14 | import type { Rendered, RenderInput } from "./renderers.ts"; |
| 14 | 15 | |
| @@ -187,7 +188,7 @@ export function registry(input: RenderInput): Rendered { | ||
| 187 | 188 | .join(""); |
| 188 | 189 | const table = |
| 189 | 190 | k.values.length === 0 |
| 190 | ? `<p class="muted small">No values.</p>` | |
| 191 | ? String(emptyLine("regValues")) | |
| 191 | 192 | : `<table class="table" data-dense aria-label="Values of ${escapeHtml(k.path)}"><thead><tr><th scope="col">Name</th><th scope="col">Type</th><th scope="col">Data</th></tr></thead><tbody>${rows}</tbody></table>`; |
| 192 | 193 | const left = k.left > 0 ? `<p class="muted small">${noun(k.left, "more value", "more values")} in the raw file.</p>` : ""; |
| 193 | 194 | sections += `<section><h3>${code(k.path)}</h3>${table}${left}</section>`; |
test/app-flags.test.ts +6
| @@ -13,6 +13,8 @@ import { newApp } from "../src/actions/apps.ts"; | ||
| 13 | 13 | import { commitToBranch } from "../src/actions/repos.ts"; |
| 14 | 14 | import { appEnv } from "../src/apps/process.ts"; |
| 15 | 15 | import { parseDecls } from "../src/core/app_flags.ts"; |
| 16 | import { appFlagsView } from "../src/web/pages/app_flags.ts"; | |
| 17 | import { emptyLine } from "../src/web/empty_words.ts"; | |
| 16 | 18 | import { bucket } from "../src/core/flags.ts"; |
| 17 | 19 | import { createToken } from "../src/core/tokens.ts"; |
| 18 | 20 | import { createRepo } from "../src/actions/repos.ts"; |
| @@ -31,6 +33,10 @@ test("a declaration keeps what is valid and drops the rest", () => { | ||
| 31 | 33 | expect(parseDecls(undefined)).toEqual({}); |
| 32 | 34 | }); |
| 33 | 35 | |
| 36 | test("an app that declares no flag says the table's line, drawn by emptyLine", () => { | |
| 37 | expect(String(appFlagsView("/alice/budgeting", []))).toContain(String(emptyLine("appFlags"))); | |
| 38 | }); | |
| 39 | ||
| 34 | 40 | test("the app is told where its flags are", () => { |
| 35 | 41 | const env = appEnv({ port: 1, dataDir: "/d", env: "production", url: "http://a", commitOid: "abc", forgeUrl: "https://forge.test/", repo: "alice/budgeting", identityKey: "k" }); |
| 36 | 42 | expect(env["FORGE_FLAGS_URL"]).toBe("https://forge.test/api/v1/repos/alice/budgeting/flags"); |
test/empty-notes.test.ts +1 −1
| @@ -16,7 +16,7 @@ test("every note is plain words ending in a full stop", () => { | ||
| 16 | 16 | |
| 17 | 17 | test("emptyNote draws the table's sentence in one muted paragraph", () => { |
| 18 | 18 | expect(String(emptyNote("noGateHasRunYet"))).toBe('<p class="muted">No gate has run yet.</p>'); |
| 19 | expect(String(emptyNote("noFlagIsDeclaredYet"))).toContain(NOTE_WORDS.noFlagIsDeclaredYet); | |
| 19 | expect(String(emptyNote("noChangeYet"))).toContain(NOTE_WORDS.noChangeYet); | |
| 20 | 20 | }); |
| 21 | 21 | |
| 22 | 22 | // Pages that word their own empty note, by file. Move one onto NOTE_WORDS and lower its count. |
test/empty-words-all.test.ts +2
| @@ -2,6 +2,8 @@ | ||
| 2 | 2 | * One table of empty words (#15851): every empty state a page registers has an entry (a sentence; a |
| 3 | 3 | * reason and one link only where they add something and the place exists), and a page that words |
| 4 | 4 | * its own "No …" empty state is named below until it moves. |
| 5 | * | |
| 6 | * @tree-scan: walks all of src/web/ through readdirSync on a parameter. | |
| 5 | 7 | */ |
| 6 | 8 | import { expect, test } from "bun:test"; |
| 7 | 9 | import { readdirSync, readFileSync, statSync } from "node:fs"; |
test/flags-language.test.ts +1 −1
| @@ -65,5 +65,5 @@ test("no flag declared is one plain sentence, no card", async () => { | ||
| 65 | 65 | useFlagRegistry(makeFlags({})); |
| 66 | 66 | const body = await page(); |
| 67 | 67 | expect(body).not.toContain('class="card'); |
| 68 | expect(body).toContain("No flag is declared yet."); | |
| 68 | expect(body).toContain("No flag is declared."); | |
| 69 | 69 | }); |
test/gifts-page.test.ts +3
| @@ -12,6 +12,7 @@ import { insertCode, noteRedeemed, revokeCode } from "../src/billing/codes.ts"; | ||
| 12 | 12 | import { createSession } from "../src/core/sessions.ts"; |
| 13 | 13 | import { createUser } from "../src/core/users.ts"; |
| 14 | 14 | import { serve, type Servers } from "../src/http/server.ts"; |
| 15 | import { emptyLine } from "../src/web/empty_words.ts"; | |
| 15 | 16 | import { quietLogs } from "./helpers/globals.ts"; |
| 16 | 17 | |
| 17 | 18 | quietLogs(); |
| @@ -59,6 +60,8 @@ test("a person without a paid forge sees no block and cannot make a link", async | ||
| 59 | 60 | |
| 60 | 61 | test("one tap makes a link shown once; the settings then list it as waiting", async () => { |
| 61 | 62 | expect(await get(sub)).toContain("Make a gift link"); |
| 63 | // No gift yet: the table's line, drawn by emptyLine, not words of the page's own. | |
| 64 | expect(await get(sub)).toContain(String(emptyLine("gifts"))); | |
| 62 | 65 | const res = await make(sub); |
| 63 | 66 | expect(res.status).toBe(200); |
| 64 | 67 | expect(res.headers.get("cache-control")).toBe("no-store"); |
test/gifts-tui.test.ts +3 −1
| @@ -12,6 +12,7 @@ import { createUser, type User } from "../src/core/users.ts"; | ||
| 12 | 12 | import { createForgeApp } from "../src/tui/forge.ts"; |
| 13 | 13 | import { entry, giftsScreen } from "../src/tui/screens/gifts.ts"; |
| 14 | 14 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 15 | import { emptyText } from "../src/core/empty_words.ts"; | |
| 15 | 16 | import { quietLogs } from "./helpers/globals.ts"; |
| 16 | 17 | import { settleApp } from "./helpers/tui.ts"; |
| 17 | 18 | |
| @@ -57,7 +58,8 @@ test("a subscriber makes a gift link and sees it listed as waiting", async () => | ||
| 57 | 58 | const { tui, session } = open(sub); |
| 58 | 59 | tui.ctx.push(giftsScreen(session, tui.ctx)); |
| 59 | 60 | await settleApp(tui); |
| 60 | expect(tui.screen.toText()).toContain("No gift yet."); | |
| 61 | // The table's sentence and reason, as the page says them. | |
| 62 | expect(tui.screen.toText()).toContain(emptyText("gifts")); | |
| 61 | 63 | tui.dispatch(key("n")); |
| 62 | 64 | await settleApp(tui); |
| 63 | 65 | expect(tui.screen.toText()).toMatch(/forge-[a-z0-9]{4}-[a-z0-9]{4}/); |
test/keys-flags-list.test.ts +1 −1
| @@ -64,6 +64,6 @@ test("each flag row is one data-nav row whose primary link is its owner issue", | ||
| 64 | 64 | test("the empty list draws no flag data-nav row", async () => { |
| 65 | 65 | useFlagRegistry(makeFlags({})); |
| 66 | 66 | const text = await get(); |
| 67 | expect(text).toContain("No flag is declared yet."); | |
| 67 | expect(text).toContain("No flag is declared."); | |
| 68 | 68 | expect(text).not.toMatch(/class="row"[^>]*data-nav tabindex="-1"/); |
| 69 | 69 | }); |
test/origin-read-grant.test.ts +3 −1
| @@ -35,6 +35,7 @@ import { syncsSettled } from "../src/origins/sync.ts"; | ||
| 35 | 35 | import { mirrorAndWait, newFakeState, serveFakeForge, type FakeForge } from "./fake-origin.ts"; |
| 36 | 36 | import { seedAdmin } from "./helpers/admin.ts"; |
| 37 | 37 | import { proveAll } from "./helpers/verified.ts"; |
| 38 | import { emptyLine } from "../src/web/empty_words.ts"; | |
| 38 | 39 | |
| 39 | 40 | |
| 40 | 41 | const LOGIN = "octo"; |
| @@ -175,7 +176,8 @@ describe("a read grant on a read-only mirror", () => { | ||
| 175 | 176 | const page = (path = `/alice/${NAME}/settings`) => fetch(`${servers.url}${path}`, { headers: { cookie } }); |
| 176 | 177 | const html = await (await page()).text(); |
| 177 | 178 | expect(html).toContain("Who may read this"); |
| 178 | expect(html).toContain("No one else reads it."); | |
| 179 | // The table's line, drawn by emptyLine, not words of the page's own. | |
| 180 | expect(html).toContain(String(emptyLine("readGrants"))); | |
| 179 | 181 | const form = new URLSearchParams({ kind: "app", name: "morning-paper" }); |
| 180 | 182 | const res = await fetch(`${servers.url}/alice/${NAME}/settings/read-grants`, { |
| 181 | 183 | method: "POST", |
test/render-registry.test.ts +5
| @@ -4,6 +4,7 @@ import { aboutReg, decodeReg, DELETE_CAP, KEY_CAP, parseReg, registry, VALUE_CAP | ||
| 4 | 4 | import { fileKind, RENDER_CAP } from "../src/web/render/kinds.ts"; |
| 5 | 5 | import { RENDERERS } from "../src/web/render/renderers.ts"; |
| 6 | 6 | import { registryView } from "../src/tui/screens/workspace_registry.ts"; |
| 7 | import { emptyLine } from "../src/web/empty_words.ts"; | |
| 7 | 8 | |
| 8 | 9 | const enc = (s: string): Uint8Array => new TextEncoder().encode(s); |
| 9 | 10 | const utf16 = (s: string): Uint8Array => { |
| @@ -53,6 +54,10 @@ describe("registry", () => { | ||
| 53 | 54 | expect(out).toContain("<td>dword</td><td>0x00000001 (1)</td>"); |
| 54 | 55 | }); |
| 55 | 56 | |
| 57 | test("a key with no values says the table's line, drawn by emptyLine", () => { | |
| 58 | expect(String(registry(input(enc(HEAD + "[HKEY_A]\r\n"))).content)).toContain(String(emptyLine("regValues"))); | |
| 59 | }); | |
| 60 | ||
| 56 | 61 | test("every value is escaped", () => { |
| 57 | 62 | const body = enc(HEAD + '[HKEY_A\\<script>1</script>]\n"<b>n</b>"="<img src=x onerror=1>"\n"<i>v</i>"=-\n[-HKEY_<u>]\n'); |
| 58 | 63 | const out = String(registry(input(body)).content); |
new above
offline