Public: anyone can read this; the crew can change it.
A signed-out visit to /feed shows what shipped on public apps, with the ask box behind sign-in #13893
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13870-a-signed-out-visit-to-feed-shows-what-sh → main 12 commits fork 5 threads · 5 unresolved
docs/features/README.md +1
| @@ -59,6 +59,7 @@ Read with the guide page [What a forge is](../guide-what-a-forge-is.md). | ||
| 59 | 59 | - [](made-from.md) |
| 60 | 60 | - [](explore.md) |
| 61 | 61 | - [](feed-cursor.md) |
| 62 | - [](public-feed.md) | |
| 62 | 63 | - [](fork-tree.md) |
| 63 | 64 | - [](family-collapse.md) |
| 64 | 65 | - [](living-home.md) |
docs/features/public-feed.md added +9
| @@ -0,0 +1,9 @@ | ||
| 1 | # The public feed | |
| 2 | ||
| 3 | A signed-out visit to `/feed` says, in its one visible heading, "What shipped on public apps, newest first." It shows what shipped on public apps: the newest 30 merged pulls, one row each (app, title, time), and one button, "Sign in to tell the crew". The composer and everything private stay behind sign-in; a person who is signed in sees their own feed as before. | |
| 4 | ||
| 5 | Only public, unarchived repositories are listed, and a sealed report's pull never is. The rows come from `shipped` in `src/feed/shipped.ts`, the same query `ships.atom` reads for one repository, so the page, the terminal and the Atom feed agree. | |
| 6 | ||
| 7 | In the terminal: the palette command "Shipped on public apps" (`public-feed`, `src/tui/screens/publicfeed.ts`). `j`/`k` move, Enter shows the pull's address (relative, and said so, on a forge with no URL set), Esc closes. | |
| 8 | ||
| 9 | Left out: an Atom alternate link for the whole forge. |
src/feed/public_ships.ts added +28
| @@ -0,0 +1,28 @@ | ||
| 1 | /** | |
| 2 | * What a stranger sees at /feed: the newest merged pulls across public, | |
| 3 | * unarchived repositories, newest first. The rows are `shipped` (`./shipped.ts`), | |
| 4 | * the query `ships.atom` also reads. Not the signed-in feed's query. | |
| 5 | */ | |
| 6 | ||
| 7 | import type { Database } from "bun:sqlite"; | |
| 8 | import { plainTitle } from "../story/gather.ts"; | |
| 9 | import { shipped } from "./shipped.ts"; | |
| 10 | ||
| 11 | export const PUBLIC_SHIPS = 30; | |
| 12 | ||
| 13 | export interface PublicShip { | |
| 14 | app: string; | |
| 15 | title: string; | |
| 16 | at: string; | |
| 17 | /** Site-relative link to the pull. */ | |
| 18 | href: string; | |
| 19 | } | |
| 20 | ||
| 21 | export function publicShips(db: Database, limit = PUBLIC_SHIPS): PublicShip[] { | |
| 22 | return shipped(db, "public", limit).map((s) => ({ | |
| 23 | app: s.app, | |
| 24 | title: plainTitle(s.issue.title), | |
| 25 | at: s.at, | |
| 26 | href: `/${s.app}/pulls/${s.issue.number}`, | |
| 27 | })); | |
| 28 | } |
src/feed/shipped.ts added +38
| @@ -0,0 +1,38 @@ | ||
| 1 | /** | |
| 2 | * The one query behind every list of shipped work: merged pulls, newest first, | |
| 3 | * never a sealed report's. `ships.atom` asks it for one repository, the public | |
| 4 | * /feed (and its terminal screen) for every public, unarchived one, so the | |
| 5 | * page and the feed cannot drift. | |
| 6 | */ | |
| 7 | ||
| 8 | import type { Database } from "bun:sqlite"; | |
| 9 | import { getIssuesByIds, type Issue } from "../core/issues.ts"; | |
| 10 | ||
| 11 | /** One repository, or every public repository that is not archived. */ | |
| 12 | export type ShipScope = { repoId: string } | "public"; | |
| 13 | ||
| 14 | export interface Shipped { | |
| 15 | issue: Issue; | |
| 16 | at: string; | |
| 17 | /** `owner/name` of the repository the pull is on. */ | |
| 18 | app: string; | |
| 19 | } | |
| 20 | ||
| 21 | export function shipped(db: Database, scope: ShipScope, limit: number): Shipped[] { | |
| 22 | const where = scope === "public" ? "repo.visibility = 'public' AND repo.archived_at IS NULL" : "issue.repo_id = ?2"; | |
| 23 | const args: (string | number)[] = scope === "public" ? [limit] : [limit, scope.repoId]; | |
| 24 | const rows = db | |
| 25 | .query<{ issue_id: string; merged_at: string; owner: string; name: string }, (string | number)[]>( | |
| 26 | `SELECT pull.issue_id, pull.merged_at, user.username AS owner, repo.name AS name | |
| 27 | FROM pull JOIN issue ON issue.id = pull.issue_id | |
| 28 | JOIN repo ON repo.id = issue.repo_id JOIN user ON user.id = repo.owner_id | |
| 29 | WHERE pull.merged_at IS NOT NULL AND issue.sealed = 0 AND ${where} | |
| 30 | ORDER BY pull.merged_at DESC LIMIT ?1`, | |
| 31 | ) | |
| 32 | .all(...args); | |
| 33 | const issues = getIssuesByIds(db, rows.map((r) => r.issue_id)); | |
| 34 | return rows.flatMap((r) => { | |
| 35 | const issue = issues.get(r.issue_id); | |
| 36 | return issue === undefined ? [] : [{ issue, at: r.merged_at, app: `${r.owner}/${r.name}` }]; | |
| 37 | }); | |
| 38 | } |
src/http/atom_routes.ts +2 −12
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | import type { Database } from "bun:sqlite"; |
| 10 | import { shipped } from "../feed/shipped.ts"; | |
| 10 | 11 | import { getIssuesByIds, type Issue } from "../core/issues.ts"; |
| 11 | 12 | import { canRead, getRepo, getRepoById, type Repo } from "../core/repos.ts"; |
| 12 | 13 | import { notePhase, takeSessionTime, timePhase } from "../core/route_timing.ts"; |
| @@ -32,18 +33,7 @@ interface Item { | ||
| 32 | 33 | |
| 33 | 34 | /** The newest merged pulls of one repository, newest first; a sealed report's pull is never one. */ |
| 34 | 35 | export function shippedPulls(db: Database, repoId: string, limit = ATOM_ENTRIES): { issue: Issue; at: string }[] { |
| 35 | const rows = db | |
| 36 | .query<{ issue_id: string; merged_at: string }, [string, number]>( | |
| 37 | `SELECT pull.issue_id, pull.merged_at FROM pull JOIN issue ON issue.id = pull.issue_id | |
| 38 | WHERE issue.repo_id = ?1 AND pull.merged_at IS NOT NULL AND issue.sealed = 0 | |
| 39 | ORDER BY pull.merged_at DESC LIMIT ?2`, | |
| 40 | ) | |
| 41 | .all(repoId, limit); | |
| 42 | const issues = getIssuesByIds(db, rows.map((r) => r.issue_id)); | |
| 43 | return rows.flatMap((r) => { | |
| 44 | const issue = issues.get(r.issue_id); | |
| 45 | return issue === undefined ? [] : [{ issue, at: r.merged_at }]; | |
| 46 | }); | |
| 36 | return shipped(db, { repoId }, limit).map(({ issue, at }) => ({ issue, at })); | |
| 47 | 37 | } |
| 48 | 38 | |
| 49 | 39 | /** The newest unsealed issues one person opened on public repositories; callers check `canRead`. */ |
src/tui/forge.ts +2
| @@ -19,6 +19,7 @@ import { sourceFor } from "../view/source.ts"; | ||
| 19 | 19 | import { fleetCommand } from "./screens/fleet.ts"; |
| 20 | 20 | import { dataCommand } from "./screens/data.ts"; |
| 21 | 21 | import { packsCommand } from "./screens/packs.ts"; |
| 22 | import { publicFeedCommand } from "./screens/publicfeed.ts"; | |
| 22 | 23 | import { statusCommand } from "./screens/status.ts"; |
| 23 | 24 | import { templatesCommand } from "./screens/templates.ts"; |
| 24 | 25 | import { needsCommands } from "./screens/needs.ts"; |
| @@ -271,6 +272,7 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] { | ||
| 271 | 272 | ...needsCommands(session, ctx), |
| 272 | 273 | ...asksAdminCommands(session, ctx), |
| 273 | 274 | packsCommand(session, ctx), |
| 275 | publicFeedCommand(session, ctx), | |
| 274 | 276 | statusCommand(session, ctx), |
| 275 | 277 | templatesCommand(session, ctx), |
| 276 | 278 | shareTellCommand(session, ctx), |
src/tui/screens/publicfeed.ts added +66
| @@ -0,0 +1,66 @@ | ||
| 1 | /** | |
| 2 | * `/feed` as a stranger reads it, in the terminal: what shipped on public | |
| 3 | * apps, newest first, from the same rows the web page and `ships.atom` read | |
| 4 | * (`feed/shipped.ts`). Nothing private is listed. j/k move, Enter shows the | |
| 5 | * pull's address (to open on the web), Esc closes. | |
| 6 | */ | |
| 7 | ||
| 8 | import { publicShips, type PublicShip } from "../../feed/public_ships.ts"; | |
| 9 | import type { Ctx, Screen } from "../app/app.ts"; | |
| 10 | import { binding } from "../app/keys.ts"; | |
| 11 | import { style } from "../term/style.ts"; | |
| 12 | import { truncate } from "../term/width.ts"; | |
| 13 | import type { Session } from "../session.ts"; | |
| 14 | ||
| 15 | /** One ship as a line: the app, the title, the day it merged. */ | |
| 16 | export const shipLine = (s: PublicShip): string => `${s.app} ${s.title} ${s.at.slice(0, 10)}`; | |
| 17 | ||
| 18 | export function publicFeedScreen(session: Session, ctx: Ctx): Screen { | |
| 19 | let at = 0; | |
| 20 | let note = ""; | |
| 21 | const ships = (): PublicShip[] => publicShips(session.app.db); | |
| 22 | const screen: Screen = { | |
| 23 | title: "Shipped on public apps", | |
| 24 | keys: [binding(["j", "k"], "move"), binding(["enter"], "address"), binding(["esc"], "close")], | |
| 25 | render(area, s) { | |
| 26 | const c = ctx.theme.c; | |
| 27 | const list = ships(); | |
| 28 | at = Math.min(at, Math.max(0, list.length - 1)); | |
| 29 | s.text(area.x + 1, area.y, "What shipped on public apps, newest first", style(c.mutedFg, c.bg), area.x + area.w); | |
| 30 | if (list.length === 0) s.text(area.x + 1, area.y + 2, "Nothing has shipped on a public app yet.", style(c.mutedFg, c.bg), area.x + area.w); | |
| 31 | const room = Math.max(1, area.h - 4); | |
| 32 | const from = Math.min(Math.max(0, at - room + 1), Math.max(0, list.length - room)); | |
| 33 | list.slice(from, from + room).forEach((ship, i) => { | |
| 34 | const on = from + i === at; | |
| 35 | s.text(area.x + 1, area.y + 2 + i, truncate(`${on ? "> " : " "}${shipLine(ship)}`, area.w - 2), on ? style(c.accent, c.bg) : style(c.fg, c.bg), area.x + area.w); | |
| 36 | }); | |
| 37 | if (note !== "") s.text(area.x + 1, area.y + area.h - 1, truncate(note, area.w - 2), style(c.accent, c.bg), area.x + area.w); | |
| 38 | }, | |
| 39 | key(e) { | |
| 40 | if (e.ctrl || e.alt) return false; | |
| 41 | const list = ships(); | |
| 42 | if (e.key === "esc" || e.key === "q") ctx.pop(); | |
| 43 | else if (e.key === "j" || e.key === "down") at = Math.min(Math.max(0, list.length - 1), at + 1); | |
| 44 | else if (e.key === "k" || e.key === "up") at = Math.max(0, at - 1); | |
| 45 | else if (e.key === "enter") { | |
| 46 | const ship = list[at]; | |
| 47 | if (ship !== undefined) note = shipAddress(session.app.config.url, ship.href); | |
| 48 | } else return false; | |
| 49 | ctx.invalidate(); | |
| 50 | return true; | |
| 51 | }, | |
| 52 | }; | |
| 53 | return screen; | |
| 54 | } | |
| 55 | ||
| 56 | /** The pull's address: absolute on a forge that knows its URL, else said to be relative to it. */ | |
| 57 | export function shipAddress(url: string | undefined, href: string): string { | |
| 58 | return url ? `${url.replace(/\/+$/, "")}${href}` : `${href} (on this forge)`; | |
| 59 | } | |
| 60 | ||
| 61 | export const publicFeedCommand = (session: Session, ctx: Ctx) => ({ | |
| 62 | id: "public-feed", | |
| 63 | title: "Shipped on public apps", | |
| 64 | hint: "what merged on public apps, newest first", | |
| 65 | run: () => ctx.push(publicFeedScreen(session, ctx)), | |
| 66 | }); |
src/web/studio/feed.ts +20
| @@ -41,6 +41,7 @@ import { heldPostsJs } from "./held_posts.ts"; | ||
| 41 | 41 | import { stepLink } from "./step_link.ts"; |
| 42 | 42 | import { writableAppsOf } from "./asks.ts"; |
| 43 | 43 | import { appsFirst } from "../../actions/first_ask.ts"; |
| 44 | import type { PublicShip } from "../../feed/public_ships.ts"; | |
| 44 | 45 | |
| 45 | 46 | /** Events that can change what the feed says. */ |
| 46 | 47 | export const FEED_LIVE = |
| @@ -307,6 +308,25 @@ export function composer(ctx: Ctx, user: User): Html { | ||
| 307 | 308 | return repos.length === 0 ? html`${form}${noApps}` : form; |
| 308 | 309 | } |
| 309 | 310 | |
| 311 | /** | |
| 312 | * A stranger's feed: what shipped on public apps as rows, and one way in | |
| 313 | * instead of the composer. The page's heading says what the list is, so | |
| 314 | * neither the list nor the empty line says it again. Every string is | |
| 315 | * escaped by `html`. | |
| 316 | */ | |
| 317 | export function publicFeed(ships: readonly PublicShip[], signIn: string): Html { | |
| 318 | return html`<div class="stack"> | |
outdated
Principle 1 (nothing explains itself twice): the list carries an aria-label and the empty state repeats it in its own sentence. Once the page has its one visible sentence, keep the empty state short and do not restate it. |
||
| 319 | ${btn("Sign in to tell the crew", { href: signIn, variant: "primary" })} | |
| 320 | ${ships.length === 0 | |
| 321 | ? html`<p class="muted">Nothing yet.</p>` | |
| 322 | : html`<ul class="list"> | |
| 323 | ${ships.map((s) => | |
| 324 | row({ href: s.href, title: html`${s.app} · ${s.title}`, meta: time(s.at) }), | |
| 325 | )} | |
outdated
Principles 6 and 7: each ship is a |
||
| 326 | </ul>`} | |
| 327 | </div>`; | |
| 328 | } | |
| 329 | ||
| 310 | 330 | /** |
| 311 | 331 | * The reserved line in the feed head: a plain link to the top of the feed, `hidden` (its height |
| 312 | 332 | * kept) with nothing newer. |
src/web/studio/home.ts +13 −3
| @@ -33,7 +33,8 @@ import { canRead, getRepo } from "../../core/repos.ts"; | ||
| 33 | 33 | import { type User } from "../../core/users.ts"; |
| 34 | 34 | import type { Ctx } from "../../http/context.ts"; |
| 35 | 35 | import { activeEdgeToken, edgeLoginUrl } from "../../http/edge.ts"; |
| 36 | import { repoBase, offersSignup, signInFirst, NOT_ADMIN_HERE, forbiddenPage } from "../chrome.ts"; | |
| 36 | import { publicShips } from "../../feed/public_ships.ts"; | |
| 37 | import { repoBase, offersSignup, signInFirst, signInHref, NOT_ADMIN_HERE, forbiddenPage } from "../chrome.ts"; | |
| 37 | 38 | import { field, readForm, type Form } from "../form.ts"; |
| 38 | 39 | import { liveRegionsJs } from "../client.ts"; |
| 39 | 40 | import { html, when, type Html } from "../html.ts"; |
| @@ -64,7 +65,7 @@ import { | ||
| 64 | 65 | import { writableAppsOf } from "./asks.ts"; |
| 65 | 66 | import { needsYouSection } from "./asks_page.ts"; |
| 66 | 67 | import { flowCards } from "./flow_card.ts"; |
| 67 | import { composer, feedJs, feedNote, feedRegion } from "./feed.ts"; | |
| 68 | import { composer, publicFeed, feedJs, feedNote, feedRegion } from "./feed.ts"; | |
| 68 | 69 | import { heldLine } from "./held.ts"; |
| 69 | 70 | import { waitingLine } from "./kpi_row.ts"; |
| 70 | 71 | import { feedCandidateCache } from "../../feed/feed.ts"; |
| @@ -341,7 +342,16 @@ export async function studioHome( | ||
| 341 | 342 | */ |
| 342 | 343 | export async function feedPage(ctx: Ctx): Promise<Response> { |
| 343 | 344 | const user = ctx.auth.user; |
| 344 | if (!user) return signInFirst(ctx); | |
| 345 | if (!user) { | |
| 346 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); | |
| 347 | const ships = timePhase(ctx.request, "feed", () => publicShips(ctx.app.db)); | |
| 348 | return page({ | |
| 349 | ctx, | |
| 350 | title: "Feed", | |
| 351 | description: "What shipped on public apps.", | |
| 352 | body: html`<h1>What shipped on public apps, newest first.</h1>${publicFeed(ships, signInHref(ctx))}`, | |
outdated
Principle 1: the only heading is sr-only, so a sighted visitor gets a sign-in button and a list with no sentence saying what the page is for. Show one visible confident sentence (for example "What shipped on public apps, newest first.") above the list, in plain words per docs/WRITING.md. |
||
| 353 | }); | |
| 354 | } | |
| 345 | 355 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); |
| 346 | 356 | const { repos: appRepos } = timePhase(ctx.request, "repos", () => writableAppsOf(ctx, user)); |
| 347 | 357 | const rendering = performance.now(); |
test/feed-public.test.ts added +117
| @@ -0,0 +1,117 @@ | ||
| 1 | /** A signed-out /feed shows what shipped on public apps, and nothing private. */ | |
| 2 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 3 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 4 | import { tmpdir } from "node:os"; | |
| 5 | import { join } from "node:path"; | |
| 6 | import { openIssue } from "../src/actions/issues.ts"; | |
| 7 | import { createRepo } from "../src/actions/repos.ts"; | |
| 8 | import { createApp, type App } from "../src/app.ts"; | |
| 9 | import { createUser, getUserByName } from "../src/core/users.ts"; | |
| 10 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 11 | import { publicShips, PUBLIC_SHIPS } from "../src/feed/public_ships.ts"; | |
| 12 | import { createForgeApp } from "../src/tui/forge.ts"; | |
| 13 | import { publicFeedScreen, shipAddress } from "../src/tui/screens/publicfeed.ts"; | |
| 14 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; | |
| 15 | import { settleApp } from "./helpers/tui.ts"; | |
| 16 | ||
| 17 | describe("signed-out /feed", () => { | |
| 18 | let dataDir: string; | |
| 19 | let app: App; | |
| 20 | let servers: Servers; | |
| 21 | let origin: string; | |
| 22 | ||
| 23 | beforeAll(async () => { | |
| 24 | dataDir = await mkdtemp(join(tmpdir(), "forge-feed-public-")); | |
| 25 | app = createApp({ dataDir, port: 0 }); | |
| 26 | servers = await serve(app); | |
| 27 | origin = `http://127.0.0.1:${servers.port}`; | |
| 28 | const u = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true }); | |
| 29 | if (!u.ok) throw new Error(u.error); | |
| 30 | for (const [name, visibility, title] of [["open", "public", "Open <b>ship</b>"], ["hush", "private", "Secret ship"]] as const) { | |
| 31 | const made = await createRepo(app, u.value, { name, visibility }); | |
| 32 | if (!made.ok) throw new Error(String(made.error)); | |
| 33 | const issue = openIssue(app, u.value, made.value, { title }); | |
| 34 | if (!issue.ok) throw new Error(String(issue.error)); | |
| 35 | app.db.query("INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, merged_at) VALUES (?1, 'main', 'b', '', '', ?2)").run(issue.value.id, new Date().toISOString()); | |
| 36 | } | |
| 37 | }, 30_000); | |
| 38 | ||
outdated
The two doors rule: the page has no terminal screen in src/tui/ and no docs/features how-to. Add both. A |
||
| 39 | afterAll(async () => { | |
| 40 | servers.stop(); | |
| 41 | app.close(); | |
| 42 | await rm(dataDir, { recursive: true, force: true }); | |
| 43 | }); | |
| 44 | ||
| 45 | test("answers 200 with public ships, escaped, and a sign-in button", async () => { | |
| 46 | const res = await fetch(`${origin}/feed`, { redirect: "manual" }); | |
| 47 | expect(res.status).toBe(200); | |
| 48 | const text = await res.text(); | |
| 49 | expect(text).toContain("alice/open"); | |
| 50 | expect(text).toContain("Open <b>ship</b>"); | |
| 51 | expect(text).toContain("Sign in to tell the crew"); | |
| 52 | expect(text).not.toContain('id="composer"'); | |
| 53 | // One visible sentence says what the page is; the list does not say it again. | |
| 54 | expect(text).toContain("<h1>What shipped on public apps, newest first.</h1>"); | |
| 55 | expect(text).not.toContain('aria-label="Shipped on public apps"'); | |
| 56 | }); | |
| 57 | ||
| 58 | test("Enter's address is absolute with a forge URL, and said to be relative without one", () => { | |
| 59 | expect(shipAddress("https://forge.example/", "/alice/open/pulls/1")).toBe("https://forge.example/alice/open/pulls/1"); | |
| 60 | expect(shipAddress(undefined, "/alice/open/pulls/1")).toBe("/alice/open/pulls/1 (on this forge)"); | |
| 61 | }); | |
| 62 | ||
| 63 | test("nothing from a private repository appears", async () => { | |
| 64 | const text = await (await fetch(`${origin}/feed`)).text(); | |
| 65 | expect(text).not.toContain("Secret ship"); | |
| 66 | expect(text).not.toContain("alice/hush"); | |
| 67 | }); | |
| 68 | ||
| 69 | test("the cap holds, and archived repositories and sealed reports are absent; the page lists ships as rows", async () => { | |
| 70 | const user = getUserByName(app.db, "alice")!; | |
| 71 | const merge = (id: string, at: string) => | |
| 72 | app.db.query("INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, merged_at) VALUES (?1, 'main', 'b', '', '', ?2)").run(id, at); | |
| 73 | const made = await createRepo(app, user, { name: "busy", visibility: "public" }); | |
| 74 | if (!made.ok) throw new Error(String(made.error)); | |
| 75 | for (let i = 0; i < PUBLIC_SHIPS + 5; i++) { | |
| 76 | const issue = openIssue(app, user, made.value, { title: `Busy ship ${i}` }); | |
| 77 | if (!issue.ok) throw new Error(String(issue.error)); | |
| 78 | merge(issue.value.id, new Date(Date.now() + 1000 + i).toISOString()); | |
| 79 | } | |
| 80 | const gone = await createRepo(app, user, { name: "old", visibility: "public" }); | |
| 81 | if (!gone.ok) throw new Error(String(gone.error)); | |
| 82 | const oldIssue = openIssue(app, user, gone.value, { title: "Archived ship" }); | |
| 83 | if (!oldIssue.ok) throw new Error(String(oldIssue.error)); | |
| 84 | merge(oldIssue.value.id, new Date(Date.now() + 10_000).toISOString()); | |
| 85 | app.db.query("UPDATE repo SET archived_at = ?1 WHERE name = 'old'").run(new Date().toISOString()); | |
| 86 | const sealedIssue = openIssue(app, user, made.value, { title: "Sealed ship" }); | |
| 87 | if (!sealedIssue.ok) throw new Error(String(sealedIssue.error)); | |
| 88 | merge(sealedIssue.value.id, new Date(Date.now() + 10_000).toISOString()); | |
| 89 | app.db.query("UPDATE issue SET sealed = 1 WHERE id = ?1").run(sealedIssue.value.id); | |
| 90 | ||
| 91 | const ships = publicShips(app.db); | |
| 92 | expect(ships).toHaveLength(PUBLIC_SHIPS); | |
| 93 | expect(ships.some((s) => s.title === "Archived ship" || s.title === "Sealed ship")).toBe(false); | |
| 94 | const text = await (await fetch(`${origin}/feed`)).text(); | |
| 95 | expect(text).not.toContain("Archived ship"); | |
| 96 | expect(text).not.toContain("Sealed ship"); | |
| 97 | expect(text).not.toContain("card-body"); | |
| 98 | expect(text.match(/class="row"/g)?.length ?? 0).toBe(PUBLIC_SHIPS); | |
| 99 | }); | |
| 100 | ||
| 101 | test("the terminal screen lists the same ships and nothing private", async () => { | |
| 102 | const user = getUserByName(app.db, "alice")!; | |
| 103 | const { app: tui, session } = createForgeApp( | |
| 104 | app, | |
| 105 | { sshUsername: "alice", remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user }, | |
| 106 | { terminal: headlessTerminal(120, 40), exitHooks: false }, | |
| 107 | ); | |
| 108 | tui.start(); | |
| 109 | tui.ctx.push(publicFeedScreen(session, tui.ctx)); | |
| 110 | await settleApp(tui); | |
| 111 | const seen = tui.screen.toText(); | |
| 112 | expect(seen).toContain("alice/busy"); | |
| 113 | expect(seen).not.toContain("Secret ship"); | |
| 114 | expect(seen).not.toContain("Archived ship"); | |
| 115 | tui.stop?.(); | |
| 116 | }); | |
| 117 | }); |
test/home-living.test.ts +5 −2
| @@ -119,13 +119,16 @@ describe("the pipeline in four words", () => { | ||
| 119 | 119 | }); |
| 120 | 120 | |
| 121 | 121 | describe("the feed page", () => { |
| 122 | test("holds the composer and the timeline; a stranger is sent to sign in", async () => { | |
| 122 | test("holds the composer and the timeline; a stranger sees the public ships and no composer", async () => { | |
| 123 | 123 | const page = await (await get("/feed", aliceCookie)).text(); |
| 124 | 124 | expect(page).toContain('id="composer"'); |
| 125 | 125 | expect(page).toContain('id="live-feed"'); |
| 126 | 126 | expect(page).not.toContain("Being built"); |
| 127 | 127 | const stranger = await get("/feed"); |
| 128 | expect(stranger.status).not.toBe(200); | |
| 128 | expect(stranger.status).toBe(200); | |
| 129 | const open = await stranger.text(); | |
| 130 | expect(open).not.toContain('id="composer"'); | |
| 131 | expect(open).toContain("Sign in to tell the crew"); | |
| 129 | 132 | }); |
| 130 | 133 | }); |
| 131 | 134 |
test/palette-roster.test.ts +4
| @@ -53,6 +53,7 @@ test("a site-admin person is offered the whole roster", () => { | ||
| 53 | 53 | ["packs", "Forge packs", "premade forges to deploy, and how to help build their apps"], |
| 54 | 54 | ["mirror-packs", "Mirror the packs' upstreams", "bring each pack's upstream projects in as read-only repositories"], |
| 55 | 55 | ["pack-repos", "Pack repositories", "which repositories /packs lists"], |
| 56 | ["public-feed", "Shipped on public apps", "what merged on public apps, newest first"], | |
| 56 | 57 | ["status", "Status", "is the forge working, in one sentence"], |
| 57 | 58 | ["templates", "Templates", "what a new forge can start from"], |
| 58 | 59 | ["share-tell", "Share a link or text with the crew", "a draft, then where; nothing is sent until you confirm"], |
| @@ -234,6 +235,7 @@ test("a site-admin agent is offered the roster without the person-only entries", | ||
| 234 | 235 | ["needs", "How is my forge?", "what needs you, with a recommendation each; a takes a safe one"], |
| 235 | 236 | ["asks-admin", "What stands in the way", "what waits on you and what stands in your way; a asks whoever can, o opens the control"], |
| 236 | 237 | ["packs", "Forge packs", "premade forges to deploy, and how to help build their apps"], |
| 238 | ["public-feed", "Shipped on public apps", "what merged on public apps, newest first"], | |
| 237 | 239 | ["status", "Status", "is the forge working, in one sentence"], |
| 238 | 240 | ["templates", "Templates", "what a new forge can start from"], |
| 239 | 241 | ["share-tell", "Share a link or text with the crew", "a draft, then where; nothing is sent until you confirm"], |
| @@ -335,6 +337,7 @@ test("a member person is offered the signed-in roster without the admin entries" | ||
| 335 | 337 | ["needs", "How is my forge?", "what needs you, with a recommendation each; a takes a safe one"], |
| 336 | 338 | ["asks-admin", "What stands in the way", "what waits on you and what stands in your way; a asks whoever can, o opens the control"], |
| 337 | 339 | ["packs", "Forge packs", "premade forges to deploy, and how to help build their apps"], |
| 340 | ["public-feed", "Shipped on public apps", "what merged on public apps, newest first"], | |
| 338 | 341 | ["status", "Status", "is the forge working, in one sentence"], |
| 339 | 342 | ["templates", "Templates", "what a new forge can start from"], |
| 340 | 343 | ["share-tell", "Share a link or text with the crew", "a draft, then where; nothing is sent until you confirm"], |
| @@ -432,6 +435,7 @@ test("signed out, the palette offers sign-in and the public entries", () => { | ||
| 432 | 435 | ["explore", "Explore", "on the web"], |
| 433 | 436 | ["explore-feed", "Explore feed", "Atom address"], |
| 434 | 437 | ["packs", "Forge packs", "premade forges to deploy, and how to help build their apps"], |
| 438 | ["public-feed", "Shipped on public apps", "what merged on public apps, newest first"], | |
| 435 | 439 | ["status", "Status", "is the forge working, in one sentence"], |
| 436 | 440 | ["templates", "Templates", "what a new forge can start from"], |
| 437 | 441 | ["share-tell", "Share a link or text with the crew", "a draft, then where; nothing is sent until you confirm"], |
This SQL duplicates shippedPulls in src/http/atom_routes.ts. Share one query so the page and ships.atom stay the same source.