Public: anyone can read this; the crew can change it.
v0.7.713 was released and does not look right #17631
Merged 21h 23m ago, live in production
scout/forge:scout/17628-v0-7-713-was-released-and-does-not-look → main 0 commits fork
3 files
changed +52
−3
src/web/studio/asks.ts +4 −2
| @@ -96,13 +96,15 @@ export function appsOf(ctx: Pick<Ctx, "app">, user: User | undefined, archived = | ||
| 96 | 96 | /** The apps a person can write — their own, or their organisations' — as |
| 97 | 97 | * repositories, with their records. This is "your apps": the studio home's |
| 98 | 98 | * shelf and its cost line, never widened by what a stranger merely made |
| 99 | * public. */ | |
| 100 | export function writableAppsOf(ctx: Pick<Ctx, "app">, user: User | undefined) { | |
| 99 | * public. `withoutCounts` skips the star, fork and issue counts for a reader that only needs | |
| 100 | * names (the home's tell box). */ | |
| 101 | export function writableAppsOf(ctx: Pick<Ctx, "app">, user: User | undefined, withoutCounts = false) { | |
| 101 | 102 | return appsFiltered( |
| 102 | 103 | ctx, |
| 103 | 104 | listReposWritableTo(ctx.app.db, user, { |
| 104 | 105 | limit: 200, |
| 105 | 106 | withoutArchived: true, |
| 107 | withoutCounts, | |
| 106 | 108 | }), |
| 107 | 109 | ); |
| 108 | 110 | } |
src/web/studio/living.ts +1 −1
| @@ -34,7 +34,7 @@ export function pipelineNow(db: Database, at = Date.now()): Now { | ||
| 34 | 34 | |
| 35 | 35 | /** The box that tells the crew: one line, the app it goes to, Tell. Posts to `/tell` as the composer does. */ |
| 36 | 36 | export function tellBox(ctx: Ctx, user: User): Html { |
| 37 | const { repos } = writableAppsOf(ctx, user); | |
| 37 | const { repos } = writableAppsOf(ctx, user, true); | |
| 38 | 38 | const slug = (r: { ownerName: string; name: string }) => `${r.ownerName}/${r.name}`; |
| 39 | 39 | const shared = sharedDraft(ctx.url.searchParams).slice(0, TELL_MAX); |
| 40 | 40 | const { ordered, onlyForgeCopy } = appsFirst(ctx.app, repos); |
test/tell-box-lean.test.ts added +47
| @@ -0,0 +1,47 @@ | ||
| 1 | /** | |
| 2 | * The home's tell box reads only the names of the apps it can send to, not their issue and pull | |
| 3 | * counts (#17628). | |
| 4 | */ | |
| 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 6 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 7 | import { tmpdir } from "node:os"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { createApp, type App } from "../src/app.ts"; | |
| 10 | import { createRepo } from "../src/actions/repos.ts"; | |
| 11 | import { createApp as createAppRecord } from "../src/core/apps.ts"; | |
| 12 | import type { User } from "../src/core/users.ts"; | |
| 13 | import { writableAppsOf } from "../src/web/studio/asks.ts"; | |
| 14 | import { seedAdmin } from "./helpers/admin.ts"; | |
| 15 | import { quietLogs } from "./helpers/globals.ts"; | |
| 16 | ||
| 17 | quietLogs(); | |
| 18 | ||
| 19 | let dir: string; | |
| 20 | let app: App; | |
| 21 | let user: User; | |
| 22 | ||
| 23 | beforeAll(async () => { | |
| 24 | dir = await mkdtemp(join(tmpdir(), "forge-tell-lean-")); | |
| 25 | app = createApp({ dataDir: dir, port: 0 }); | |
| 26 | const a = await seedAdmin(app, { username: "alice", email: "[email protected]", password: "a-long-passphrase" }); | |
| 27 | if (!a.ok) throw new Error("signup failed"); | |
| 28 | user = a.value; | |
| 29 | const made = await createRepo(app, user, { name: "engine", visibility: "private" }); | |
| 30 | if (!made.ok) throw new Error(String(made.error)); | |
| 31 | const record = createAppRecord(app.db, { repoId: made.value.id, slug: "engine", access: "private" }); | |
| 32 | if (!record.ok) throw new Error(record.error); | |
| 33 | }); | |
| 34 | ||
| 35 | afterAll(async () => { | |
| 36 | app.close?.(); | |
| 37 | await rm(dir, { recursive: true, force: true }); | |
| 38 | }); | |
| 39 | ||
| 40 | test("the lean read names the same apps and leaves the counts unread", () => { | |
| 41 | const full = writableAppsOf({ app }, user); | |
| 42 | const lean = writableAppsOf({ app }, user, true); | |
| 43 | expect(lean.repos.map((r) => r.id)).toEqual(full.repos.map((r) => r.id)); | |
| 44 | expect(lean.repos.length).toBeGreaterThan(0); | |
| 45 | expect(full.repos.every((r) => r.counts !== undefined)).toBe(true); | |
| 46 | expect(lean.repos.every((r) => r.counts === undefined)).toBe(true); | |
| 47 | }); |
new above
offline