Public: anyone can read this; the crew can change it.
Every issue and pull row shows its #N; titles and comment times link to themselves (#16418) #16419
Check · Review · Land · Live done — Landed and live in production.
fix/pinpoint → main 0 commits
14 files
changed +222
−17
docs/design/areas/pinpoint.md added +6
| @@ -0,0 +1,6 @@ | ||
| 1 | # Pinpointing | |
| 2 | ||
| 3 | A row that stands for an issue or a pull leads its meta line with its number, `.row-num` (`#12 · | |
| 4 | just now`), at every width, so a person on a phone can say which one they mean | |
| 5 | (`test/row-numbers.test.ts`). A page's own `#N` beside its title is a link to itself, and a | |
| 6 | comment's time links to the comment's anchor (`.permalink`), each an address to copy or share. |
docs/design/attention-budget.json +8 −6
| @@ -63,27 +63,29 @@ | ||
| 63 | 63 | }, |
| 64 | 64 | "issues list": { |
| 65 | 65 | "390": { |
| 66 | "words": 30, | |
| 66 | "words": 32, | |
| 67 | 67 | "blocks": 7, |
| 68 | 68 | "colours": 2 |
| 69 | 69 | }, |
| 70 | 70 | "1280": { |
| 71 | "words": 30, | |
| 71 | "words": 32, | |
| 72 | 72 | "blocks": 7, |
| 73 | 73 | "colours": 2 |
| 74 | } | |
| 74 | }, | |
| 75 | "note": "Raised by 2 words for the #N that leads each row's meta line, so a person on a phone can say which one they mean (#16418)." | |
| 75 | 76 | }, |
| 76 | 77 | "pulls list": { |
| 77 | 78 | "390": { |
| 78 | "words": 24, | |
| 79 | "words": 26, | |
| 79 | 80 | "blocks": 6, |
| 80 | 81 | "colours": 1 |
| 81 | 82 | }, |
| 82 | 83 | "1280": { |
| 83 | "words": 24, | |
| 84 | "words": 26, | |
| 84 | 85 | "blocks": 6, |
| 85 | 86 | "colours": 1 |
| 86 | } | |
| 87 | }, | |
| 88 | "note": "Raised by 2 words for the #N that leads each row's meta line, so a person on a phone can say which one they mean (#16418)." | |
| 87 | 89 | }, |
| 88 | 90 | "runs": { |
| 89 | 91 | "390": { |
src/web/comments.ts +3 −1
| @@ -27,6 +27,8 @@ export interface CommentCard { | ||
| 27 | 27 | originKind?: IconName; |
| 28 | 28 | /** The canonical URL at the origin, for "view on origin". */ |
| 29 | 29 | originUrl?: string | null; |
| 30 | /** The id the page gives this comment, so its time links to it: the address to share. */ | |
| 31 | anchor?: string; | |
| 30 | 32 | } |
| 31 | 33 | |
| 32 | 34 | export function commentCard(card: CommentCard): Html { |
| @@ -42,7 +44,7 @@ export function commentCard(card: CommentCard): Html { | ||
| 42 | 44 | return html`<div ${idAttr}class="comment-row"> |
| 43 | 45 | <div class="comment-head"> |
| 44 | 46 | ${byline} |
| 45 | <span class="muted">${card.verb} ${time(card.at)}</span> | |
| 47 | <span class="muted">${card.verb} ${card.anchor === undefined ? time(card.at) : html`<a class="permalink" href="#${card.anchor}" title="This comment's address">${time(card.at)}</a>`}</span> | |
| 46 | 48 | ${when( |
| 47 | 49 | card.originUrl != null && card.originUrl !== "", |
| 48 | 50 | () => html`<span class="spacer"></span> |
src/web/pages/thread.ts +1
| @@ -512,6 +512,7 @@ export function threadComment( | ||
| 512 | 512 | return html`<div class="tl-item" id="c-${id}" data-kind="comment" data-comment-id="${id}"> |
| 513 | 513 | <span class="tl-dot">${icon("comment")}</span>${commentCard({ |
| 514 | 514 | id, |
| 515 | anchor: `c-${id}`, | |
| 515 | 516 | author, |
| 516 | 517 | mark: origin.mark, |
| 517 | 518 | at, |
src/web/studio/change.ts +1 −1
| @@ -290,7 +290,7 @@ export function changeHead( | ||
| 290 | 290 | const accounts = accountsByName(ctx.app.db, [pull.authorName, who ?? ""], repo.id); |
| 291 | 291 | const marks = marksOf(accounts); |
| 292 | 292 | return html`<div class="page-head"> |
| 293 | <h1>${pull.title} <span class="num">#${pull.number}</span></h1> | |
| 293 | <h1>${pull.title} <a class="num self" href="${changeHref(repoBase(repo), pull.number)}" title="This pull's address">#${pull.number}</a></h1> | |
| 294 | 294 | <div class="page-head-sub bar muted small"> |
| 295 | 295 | ${stateDot( |
| 296 | 296 | pullState(pull), |
src/web/studio/land_as_is.ts +1
| @@ -113,6 +113,7 @@ export function landOnApp(ctx: Ctx, repo: Repo): Html | null { | ||
| 113 | 113 | return listCard( |
| 114 | 114 | green.map((pull) => |
| 115 | 115 | row({ |
| 116 | num: pull.number, | |
| 116 | 117 | title: html`<a href="${changeHref(repoBase(repo), pull.number)}">${pull.title}</a>`, |
| 117 | 118 | trail: html`<span class="bar">${landForm(repo, pull)}${when(previewOf(ctx.app, repo, pull), (href) => btn("Preview", { href, size: "sm" }))}</span>`, |
| 118 | 119 | }), |
src/web/studio/lists.ts +2
| @@ -517,6 +517,7 @@ export async function tellsList(ctx: Ctx): Promise<Response> { | ||
| 517 | 517 | rows.map(({ issue, info }) => |
| 518 | 518 | row({ |
| 519 | 519 | href: tellHref(base, issue.number), |
| 520 | num: issue.number, | |
| 520 | 521 | nav: true, |
| 521 | 522 | lead: wordDot(info.word, info.note), |
| 522 | 523 | title: titled(issue.title, labels.get(issue.id)), |
| @@ -692,6 +693,7 @@ export async function changesList(ctx: Ctx): Promise<Response> { | ||
| 692 | 693 | rows.map(({ pull, info }) => |
| 693 | 694 | row({ |
| 694 | 695 | href: changeHref(base, pull.number), |
| 696 | num: pull.number, | |
| 695 | 697 | nav: true, |
| 696 | 698 | lead: wordDot(info.word, info.note), |
| 697 | 699 | title: titled(pull.title, labels.get(pull.id)), |
src/web/studio/now.ts +5
| @@ -256,6 +256,7 @@ export async function nowCard( | ||
| 256 | 256 | ); |
| 257 | 257 | return row({ |
| 258 | 258 | href: tellHref(base, i.number), |
| 259 | num: i.number, | |
| 259 | 260 | nav: true, |
| 260 | 261 | lead: avatar(who), |
| 261 | 262 | title: i.title, |
| @@ -277,6 +278,7 @@ export async function nowCard( | ||
| 277 | 278 | if (previewLinks) |
| 278 | 279 | return row({ |
| 279 | 280 | nav: true, |
| 281 | num: p.number, | |
| 280 | 282 | lead: avatar(who), |
| 281 | 283 | title: html`<a href="${changeHref(base, p.number)}">${p.title}</a>`, |
| 282 | 284 | meta: html`${meta} · <a href="${base}/app/${previewEnv(p.number)}/open">Preview</a>`, |
| @@ -284,6 +286,7 @@ export async function nowCard( | ||
| 284 | 286 | }); |
| 285 | 287 | return row({ |
| 286 | 288 | href: changeHref(base, p.number), |
| 289 | num: p.number, | |
| 287 | 290 | nav: true, |
| 288 | 291 | lead: avatar(who), |
| 289 | 292 | title: p.title, |
| @@ -300,6 +303,7 @@ export async function nowCard( | ||
| 300 | 303 | ); |
| 301 | 304 | return row({ |
| 302 | 305 | href: tellHref(base, i.number), |
| 306 | num: i.number, | |
| 303 | 307 | nav: true, |
| 304 | 308 | lead: avatar(who), |
| 305 | 309 | title: i.title, |
| @@ -316,6 +320,7 @@ export async function nowCard( | ||
| 316 | 320 | ...stuck.map((i) => { |
| 317 | 321 | return row({ |
| 318 | 322 | lead: avatar("crew"), |
| 323 | num: i.number, | |
| 319 | 324 | title: html`<a href="${tellHref(base, i.number)}">${i.title}</a>`, |
| 320 | 325 | // The invitation is a writer's (the shelf's rule, `ownerFacts`); the |
| 321 | 326 | // fact — nobody has taken it — stays for everyone. |
src/web/studio/tell.ts +3 −3
| @@ -92,7 +92,7 @@ import { | ||
| 92 | 92 | originGlyph, |
| 93 | 93 | threadContext, |
| 94 | 94 | } from "../pages/thread.ts"; |
| 95 | import { changeHref } from "./nouns.ts"; | |
| 95 | import { changeHref, tellHref } from "./nouns.ts"; | |
| 96 | 96 | import { |
| 97 | 97 | knowPulls, |
| 98 | 98 | knowRunPulls, |
| @@ -400,7 +400,7 @@ async function tellClosingPull( | ||
| 400 | 400 | const base = repoBase(repo); |
| 401 | 401 | const { word, note } = await pullWord(wordCtx, pull); |
| 402 | 402 | return html`${listCard( |
| 403 | [row({ href: changeHref(base, pull.number), title: pull.title, meta: html`${note}`, trail: wordBadge(word) })], | |
| 403 | [row({ href: changeHref(base, pull.number), num: pull.number, title: pull.title, meta: html`${note}`, trail: wordBadge(word) })], | |
| 404 | 404 | { head: html`${icon("pull")} <h2>Closes with</h2>` }, |
| 405 | 405 | )}${previewBlock(ctx, repo, pull)}`; |
| 406 | 406 | } |
| @@ -539,7 +539,7 @@ async function studioTell( | ||
| 539 | 539 | const accounts = accountsByName(db, [issue.authorName, issue.assigneeName ?? ""], repo.id); |
| 540 | 540 | const marks = marksOf(accounts); |
| 541 | 541 | const head = html`<div class="page-head"> |
| 542 | <h1>${issue.title} <span class="num">#${issue.number}</span></h1> | |
| 542 | <h1>${issue.title} <a class="num self" href="${tellHref(repoBase(repo), issue.number)}" title="This issue's address">#${issue.number}</a></h1> | |
| 543 | 543 | <div class="page-head-sub bar muted small"> |
| 544 | 544 | ${direction |
| 545 | 545 | ? html`<span class="muted small" |
src/web/ui.ts +10 −2
| @@ -987,6 +987,11 @@ export interface RowOptions { | ||
| 987 | 987 | href?: string; |
| 988 | 988 | title: Html | string; |
| 989 | 989 | meta?: Html; |
| 990 | /** | |
| 991 | * The issue's or pull's number: `#N` first in the meta line, at every width, so a person can say | |
| 992 | * which one they mean (`test/row-numbers.test.ts`). | |
| 993 | */ | |
| 994 | num?: number; | |
| 990 | 995 | /** Facts about the row, one `dt`/`dd` pair each, in a `dl.row-facts` under the meta. With facts |
| 991 | 996 | * the row's main column is a `<div>`, so the `dl` is valid HTML: not for a `fold` row, whose |
| 992 | 997 | * `<summary>` takes phrasing only. */ |
| @@ -1024,6 +1029,9 @@ export interface RowOptions { | ||
| 1024 | 1029 | tree?: { level: number; open: boolean }; |
| 1025 | 1030 | } |
| 1026 | 1031 | |
| 1032 | /** A row's `#N`, a span of its own so no width rule can take it without the test seeing. */ | |
| 1033 | const numOf = (n: number | undefined): Html | null => (n === undefined ? null : html`<span class="row-num">#${String(n)}</span>${raw(" · ")}`); | |
| 1034 | ||
| 1027 | 1035 | /** One list row. `<a>` when it navigates, `<div>` when it holds its own |
| 1028 | 1036 | * controls, `<summary>` when it folds — the hover affordance follows |
| 1029 | 1037 | * automatically. */ |
| @@ -1038,7 +1046,7 @@ export function row(o: RowOptions): Html { | ||
| 1038 | 1046 | ${o.titleAttr ? html`title="${o.titleAttr}"` : null} |
| 1039 | 1047 | >${o.title}</span |
| 1040 | 1048 | > |
| 1041 | ${o.meta || o.metaSlot ? html`<span class="row-meta">${o.meta}</span>` : null} | |
| 1049 | ${o.meta || o.metaSlot || o.num !== undefined ? html`<span class="row-meta">${numOf(o.num)}${o.meta}</span>` : null} | |
| 1042 | 1050 | <dl class="row-facts">${o.facts!.map((f) => html`<div><dt>${f.label}</dt><dd>${f.value}</dd></div>`)}</dl> |
| 1043 | 1051 | </div>` : html`<span class="row-main"> |
| 1044 | 1052 | <span |
| @@ -1046,7 +1054,7 @@ export function row(o: RowOptions): Html { | ||
| 1046 | 1054 | ${o.titleAttr ? html`title="${o.titleAttr}"` : null} |
| 1047 | 1055 | >${o.title}</span |
| 1048 | 1056 | > |
| 1049 | ${o.meta || o.metaSlot ? html`<span class="row-meta">${o.meta}</span>` : null} | |
| 1057 | ${o.meta || o.metaSlot || o.num !== undefined ? html`<span class="row-meta">${numOf(o.num)}${o.meta}</span>` : null} | |
| 1050 | 1058 | </span>`} |
| 1051 | 1059 | ${o.trail && o.trail.text.trim() !== "" |
| 1052 | 1060 | ? html`<span class="row-trail">${o.trail}</span>` |
test/changelog-depth.test.ts +2 −1
| @@ -71,7 +71,8 @@ test("from /changelog each tap reaches the next step: wave, change, pull, conver | ||
| 71 | 71 | const pull = await fetch(`${servers.url}${pullHref}`); |
| 72 | 72 | expect(pull.status).toBe(200); |
| 73 | 73 | const pullHtml = await pull.text(); |
| 74 | expect(pullHtml.replace(/\s+/g, "").includes(`<h1>Build${number - 7000}<spanclass="num">#${number}</span></h1>`)).toBe(true); | |
| 74 | // Its number beside the title is the link to the pull itself (#16418). | |
| 75 | expect(pullHtml).toMatch(new RegExp(`<h1>Build ${number - 7000} <a class="num self" href="/alice/shop/pulls/${number}"[^>]*>#${number}</a></h1>`)); | |
| 75 | 76 | |
| 76 | 77 | // 4. The same page holds the conversation: its opening post, which the pull's body wrote. |
| 77 | 78 | const at = pullHtml.indexOf('id="conversation"'); |
test/keys-decide.test.ts +1 −1
| @@ -132,5 +132,5 @@ test("the issues list the server draws carries data-nav rows, and the pulls list | ||
| 132 | 132 | // The fixture has no open pull to draw; the row the pulls list builds is the one declared here. |
| 133 | 133 | const lists = readFileSync(new URL("../src/web/studio/lists.ts", import.meta.url), "utf8"); |
| 134 | 134 | const pulls = lists.slice(lists.indexOf("export async function changesList"), lists.indexOf("export function isWorkingNow")); |
| 135 | expect(pulls).toMatch(/row\(\{\s*href: changeHref\(base, pull\.number\),\s*nav: true,/); | |
| 135 | expect(pulls).toMatch(/row\(\{\s*href: changeHref\(base, pull\.number\),(\s*num: pull\.number,)?\s*nav: true,/); | |
| 136 | 136 | }); |
test/number-retired.test.ts +3 −2
| @@ -58,7 +58,8 @@ test("the stylesheet no longer contains .number", () => { | ||
| 58 | 58 | |
| 59 | 59 | test("the issue heading marks its number with .num", async () => { |
| 60 | 60 | const page = await (await fetch(`${base}/n/r/issues/1`)).text(); |
| 61 | expect(page).toMatch(/<h1>a issue\s*<span class="num">#1<\/span><\/h1>/); | |
| 61 | // Marked with .num, and a link to the issue itself (#16418). | |
| 62 | expect(page).toMatch(/<h1>a issue\s*<a class="num self" href="\/[^"]+\/issues\/1"[^>]*>#1<\/a><\/h1>/); | |
| 62 | 63 | expect(page).not.toContain('class="number"'); |
| 63 | 64 | }); |
| 64 | 65 | |
| @@ -79,6 +80,6 @@ test("the pull heading marks its number with .num", () => { | ||
| 79 | 80 | draftRun: null, |
| 80 | 81 | }; |
| 81 | 82 | const head = String(changeHead({ app, auth: { user: undefined, scope: undefined, via: "none" } } as Ctx, repo, pull, null, undefined)); |
| 82 | expect(head).toContain('<h1>a pull <span class="num">#2</span></h1>'); | |
| 83 | expect(head).toMatch(/<h1>a pull <a class="num self" href="\/[^"]+\/pulls\/2"[^>]*>#2<\/a><\/h1>/); | |
| 83 | 84 | expect(head).not.toContain('class="number"'); |
| 84 | 85 | }); |
test/row-numbers.test.ts added +176
| @@ -0,0 +1,176 @@ | ||
| 1 | /** | |
| 2 | * A row that stands for an issue or a pull shows its `#N`, at every width: a person on a phone | |
| 3 | * must be able to say which one they mean. Three ways it could go missing, each a check: | |
| 4 | * a row drawn without its number, a style that hides the number under a breakpoint, and the | |
| 5 | * list pages themselves (rendered for real, every row read for the number its link names). | |
| 6 | * A page's own `#N` and a comment's time are links to themselves, to copy and share. | |
| 7 | */ | |
| 8 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 9 | import { readdirSync, readFileSync } from "node:fs"; | |
| 10 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 11 | import { tmpdir } from "node:os"; | |
| 12 | import { join } from "node:path"; | |
| 13 | import { openIssue } from "../src/actions/issues.ts"; | |
| 14 | import { openPull } from "../src/actions/pulls.ts"; | |
| 15 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; | |
| 16 | import { createApp, type App } from "../src/app.ts"; | |
| 17 | import { createSession } from "../src/core/sessions.ts"; | |
| 18 | import { createUser } from "../src/core/users.ts"; | |
| 19 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 20 | ||
| 21 | /** Every `.ts` file under `dir`, with its text. */ | |
| 22 | const sources = (dir: string): { path: string; text: string }[] => | |
| 23 | readdirSync(dir, { recursive: true, withFileTypes: true }) | |
| 24 | .filter((e) => e.isFile() && e.name.endsWith(".ts")) | |
| 25 | .map((e) => { | |
| 26 | const path = join(e.parentPath, e.name); | |
| 27 | return { path, text: readFileSync(path, "utf8") }; | |
| 28 | }); | |
| 29 | ||
| 30 | /** Each `row({ … })` call's argument text, by brace counting. */ | |
| 31 | function rowCalls(text: string): string[] { | |
| 32 | const out: string[] = []; | |
| 33 | for ( | |
| 34 | let at = text.indexOf("row({"); | |
| 35 | at !== -1; | |
| 36 | at = text.indexOf("row({", at + 1) | |
| 37 | ) { | |
| 38 | if (/[A-Za-z0-9_.]$/.test(text.slice(Math.max(0, at - 1), at))) continue; | |
| 39 | let depth = 0; | |
| 40 | let end = at + 4; | |
| 41 | for (; end < text.length; end++) { | |
| 42 | if (text[end] === "{") depth++; | |
| 43 | else if (text[end] === "}" && --depth === 0) break; | |
| 44 | } | |
| 45 | out.push(text.slice(at, end + 1)); | |
| 46 | } | |
| 47 | return out; | |
| 48 | } | |
| 49 | ||
| 50 | test("every row that opens an issue or a pull names its number (`num`)", () => { | |
| 51 | const missing: string[] = []; | |
| 52 | for (const { path, text } of sources("src/web")) | |
| 53 | for (const call of rowCalls(text)) | |
| 54 | if (/\b(tellHref|changeHref)\(/.test(call) && !/\bnum:/.test(call)) | |
| 55 | missing.push(`${path}: ${call.slice(0, 80).replace(/\s+/g, " ")}`); | |
| 56 | expect(missing).toEqual([]); | |
| 57 | }); | |
| 58 | ||
| 59 | test("no style hides a row's number, at any width", () => { | |
| 60 | const hiding: string[] = []; | |
| 61 | for (const { path, text } of sources("src/web/style")) | |
| 62 | for (const m of text.matchAll(/([^{}]*\.row-num[^{}]*)\{([^}]*)\}/g)) | |
| 63 | if ( | |
| 64 | /display\s*:\s*none|visibility\s*:\s*hidden|font-size\s*:\s*0|width\s*:\s*0/.test( | |
| 65 | m[2]!, | |
| 66 | ) | |
| 67 | ) | |
| 68 | hiding.push(`${path}: ${m[1]!.trim()}`); | |
| 69 | expect(hiding).toEqual([]); | |
| 70 | }); | |
| 71 | ||
| 72 | describe("the list pages, rendered", () => { | |
| 73 | let dir: string; | |
| 74 | let app: App; | |
| 75 | let servers: Servers; | |
| 76 | let cookie = ""; | |
| 77 | ||
| 78 | beforeAll(async () => { | |
| 79 | dir = await mkdtemp(join(tmpdir(), "forge-row-numbers-")); | |
| 80 | app = createApp({ dataDir: dir, port: 0 }); | |
| 81 | servers = await serve(app); | |
| 82 | const made = await createUser(app.db, { | |
| 83 | origin: "seed", | |
| 84 | trusted: true, | |
| 85 | username: "alice", | |
| 86 | email: "[email protected]", | |
| 87 | password: "a-good-passphrase", | |
| 88 | adminIfFirst: true, | |
| 89 | }); | |
| 90 | if (!made.ok) throw new Error(made.error); | |
| 91 | const repo = await createRepo(app, made.value, { | |
| 92 | name: "shop", | |
| 93 | visibility: "public", | |
| 94 | }); | |
| 95 | if (!repo.ok) throw new Error(String(repo.error)); | |
| 96 | await commitToBranch(app, made.value, repo.value, { | |
| 97 | message: "Start", | |
| 98 | files: [{ path: "README.md", content: "# shop\n" }], | |
| 99 | }); | |
| 100 | await commitToBranch(app, made.value, repo.value, { | |
| 101 | branch: "fix", | |
| 102 | message: "Fix", | |
| 103 | files: [{ path: "README.md", content: "# shop, fixed\n" }], | |
| 104 | }); | |
| 105 | for (const title of [ | |
| 106 | "Prices show three decimals", | |
| 107 | "Search ignores accents", | |
| 108 | "Cart empties after sign-in", | |
| 109 | ]) | |
| 110 | openIssue(app, made.value, repo.value, { title }); | |
| 111 | const pull = await openPull(app, made.value, repo.value, { | |
| 112 | title: "Fix the readme", | |
| 113 | baseBranch: "main", | |
| 114 | headBranch: "fix", | |
| 115 | }); | |
| 116 | if (!pull.ok) throw new Error(String(pull.error)); | |
| 117 | cookie = `forge_session=${createSession(app.db, made.value.id).token}`; | |
| 118 | }); | |
| 119 | ||
| 120 | afterAll(async () => { | |
| 121 | servers.stop(); | |
| 122 | app.close(); | |
| 123 | await rm(dir, { recursive: true, force: true }); | |
| 124 | }); | |
| 125 | ||
| 126 | const page = async (path: string): Promise<string> => | |
| 127 | (await fetch(`${servers.url}${path}`, { headers: { cookie } })).text(); | |
| 128 | ||
| 129 | test("every row of the issues and pulls lists shows the number its link names", async () => { | |
| 130 | for (const [path, noun] of [ | |
| 131 | ["/alice/shop/issues", "issues"], | |
| 132 | ["/alice/shop/pulls", "pulls"], | |
| 133 | ] as const) { | |
| 134 | const html = await page(path); | |
| 135 | const rows = [ | |
| 136 | ...html.matchAll( | |
| 137 | /<li(?:\s[^>]*)?>\s*<a\s+href="\/alice\/shop\/(issues|pulls)\/(\d+)"\s+class="row"[\s\S]*?<\/li>/g, | |
| 138 | ), | |
| 139 | ]; | |
| 140 | expect(rows.length).toBeGreaterThan(0); | |
| 141 | for (const r of rows) { | |
| 142 | expect(r[1]).toBe(noun); | |
| 143 | expect(r[0]).toContain(`<span class="row-num">#${r[2]}</span>`); | |
| 144 | } | |
| 145 | } | |
| 146 | }); | |
| 147 | ||
| 148 | test("an issue's and a pull's own #N link to themselves", async () => { | |
| 149 | expect(await page("/alice/shop/issues/1")).toMatch( | |
| 150 | /<h1>[^<]*<a class="num self" href="\/alice\/shop\/issues\/1"[^>]*>#1<\/a><\/h1>/, | |
| 151 | ); | |
| 152 | expect(await page("/alice/shop/pulls/4")).toMatch( | |
| 153 | /<h1>[^<]*<a class="num self" href="\/alice\/shop\/pulls\/4"[^>]*>#4<\/a><\/h1>/, | |
| 154 | ); | |
| 155 | }); | |
| 156 | ||
| 157 | test("a comment's time links to the comment", async () => { | |
| 158 | const posted = await fetch( | |
| 159 | `${servers.url}/api/v1/repos/alice/shop/issues/1/comments`, | |
| 160 | { | |
| 161 | method: "POST", | |
| 162 | headers: { | |
| 163 | "content-type": "application/json", | |
| 164 | authorization: `Basic ${btoa("alice:a-good-passphrase")}`, | |
| 165 | }, | |
| 166 | body: JSON.stringify({ body: "Seen on an iPhone SE." }), | |
| 167 | }, | |
| 168 | ); | |
| 169 | const comment = (await posted.json()) as { id: string }; | |
| 170 | const html = await page("/alice/shop/issues/1"); | |
| 171 | expect(html).toContain(`id="c-${comment.id}"`); | |
| 172 | expect(html).toMatch( | |
| 173 | new RegExp(`<a class="permalink" href="#c-${comment.id}"`), | |
| 174 | ); | |
| 175 | }); | |
| 176 | }); |
new above
offline