Public: anyone can read this; the crew can change it.
After a person's first ask, their forge's home leads with their app and the ask box, not with "Make your everyday account" #13808
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13791-after-a-person-s-first-ask-their-forge-s → main 6 commits fork 3 threads · 3 unresolved
12 files
changed +102
−149
docs/features/README.md +1
| @@ -93,6 +93,7 @@ Read with the guide page [Your first app in five minutes](../guide-first-app.md) | ||
| 93 | 93 | - [](start.md) |
| 94 | 94 | - [](welcome.md) |
| 95 | 95 | - [](first-screen-line.md) |
| 96 | - [](home-after-first-ask.md) | |
| 96 | 97 | - [](onboarding-line.md) |
| 97 | 98 | |
| 98 | 99 | ### Tell the crew |
docs/features/home-after-first-ask.md added +8
| @@ -0,0 +1,8 @@ | ||
| 1 | # Home after the first ask | |
| 2 | ||
| 3 | Once a person's first ask exists, their forge's home leads with what they made, not with account chores (#13791). | |
| 4 | ||
| 5 | - **Web** (`src/web/studio/home.ts`, `src/web/pages/next-steps.ts`): the ask's state, a row per app a crew member is on, then the ask box (`composer`), the apps list, the crew-key card, any held-gate line, and last `everydayLine`: one muted sentence, a link to `/settings/everyday` and a post-form button "Keep using admin". An app nobody is on has no row above; the apps list carries it. | |
| 6 | - **The everyday line** shows only for the admin, after the first ask, while the everyday step is not done (account made, or kept as admin). Not for anyone else, and not once done. | |
| 7 | - **Terminal** (`src/tui/screens/dashboard.ts`, `loadClientLines`): already in this order, and has no everyday offer on either side of the first ask: the ask's status line, then one line per app with its crew's sentence, and `t` asks for something. Nothing changed there; `test/tui-first-tell.test.ts` holds it. | |
| 8 | - Tests: `test/next-steps-card.test.ts`, `test/first-login.test.ts`, `test/tui-first-tell.test.ts`. |
src/web/pages/next-steps.ts +20 −63
| @@ -22,26 +22,12 @@ import { hasPassword, type User } from "../../core/users.ts"; | ||
| 22 | 22 | import { passkeyIds } from "../../core/passkeys.ts"; |
| 23 | 23 | import type { Ctx } from "../../http/context.ts"; |
| 24 | 24 | import { html, type Html } from "../html.ts"; |
| 25 | import { icon } from "../icons.ts"; | |
| 26 | import { badge, btn, row } from "../ui.ts"; | |
| 27 | import { EVERYDAY_WHY } from "../../core/everyday.ts"; | |
| 25 | import { btn, row } from "../ui.ts"; | |
| 28 | 26 | import { askRepos, askStatus, type AskStatus } from "../../core/ask-status.ts"; |
| 29 | 27 | import { crewCanRun, crewFirstLine } from "../studio/crew_key.ts"; |
| 30 | 28 | import { NEW_APP_TARGET } from "../studio/feed.ts"; |
| 31 | 29 | import { COMPOSER_FIELDS, TELL_MAX } from "../share_target.ts"; |
| 32 | 30 | |
| 33 | /** One line per app, "<name> is <doing what>" as the row's title and the app its meta; with nobody on it, the app is the title. */ | |
| 34 | export function crewAtWork(ctx: Ctx, repos: Awaited<ReturnType<typeof spawnedRepos>>): Html[] { | |
| 35 | return appCrew(ctx.app.db, repos).map((c) => { | |
| 36 | const href = `/${c.repo.ownerName}/${c.repo.name}`; | |
| 37 | return row({ | |
| 38 | href, | |
| 39 | title: html`${c.who === null ? c.repo.name : c.says}`, | |
| 40 | meta: html`${c.who === null ? c.says : c.repo.name}`, | |
| 41 | }); | |
| 42 | }); | |
| 43 | } | |
| 44 | ||
| 45 | 31 | /** The apps whose crew row shows beside the ask's: a builder at work is said once, so while the ask is building, its app's row goes. */ |
| 46 | 32 | export function besideAsk<R extends { readonly id: string }>(repos: readonly R[], ask: AskStatus | null): R[] { |
| 47 | 33 | return ask?.state === "building" ? repos.filter((r) => r.id !== ask.repoId) : [...repos]; |
| @@ -55,26 +41,6 @@ export function askBlock(s: AskStatus): Html { | ||
| 55 | 41 | </div>`; |
| 56 | 42 | } |
| 57 | 43 | |
| 58 | /** One step: its row (title, "Done" trail; the primary one in bold), then its | |
| 59 | * body as a block of its own under the title. `.row-meta` is one clipped line, | |
| 60 | * no place for a form. */ | |
| 61 | function stepBlock(step: NextStep, primary: boolean, body: Html | null): Html { | |
| 62 | const head = row({ | |
| 63 | lead: step.done ? icon("check") : icon("issue"), | |
| 64 | title: primary ? html`<b>${step.title}</b>` : html`${step.title}`, | |
| 65 | ...(step.done ? { trail: badge("Done", { tone: "success" }) } : {}), | |
| 66 | data: { | |
| 67 | step: step.key, | |
| 68 | done: step.done ? "yes" : "no", | |
| 69 | ...(primary ? { primary: "" } : {}), | |
| 70 | }, | |
| 71 | }); | |
| 72 | return html`<ul class="list"> | |
| 73 | ${head} | |
| 74 | </ul> | |
| 75 | ${!step.done && body ? html`<div class="step-body">${body}</div>` : null}`; | |
| 76 | } | |
| 77 | ||
| 78 | 44 | /** Enter sends the first ask; Shift+Enter (or composing text) makes a newline. */ |
| 79 | 45 | export const firstAskJs = /* js */ ` |
| 80 | 46 | (function () { |
| @@ -121,42 +87,33 @@ export async function nextStepsCard( | ||
| 121 | 87 | ): Promise<Html | null> { |
| 122 | 88 | if (!steps || steps.every((s) => s.done)) return null; |
| 123 | 89 | const repos = await spawnedRepos(ctx.app, user); |
| 124 | const crew = crewAtWork(ctx, repos); | |
| 125 | 90 | if (steps.some((s) => s.key === "tell" && !s.done)) return firstTell(ctx, user); |
| 126 | const primary = steps.find((s) => !s.done)?.key; | |
| 127 | 91 | const ask = askStatus(ctx.app.db, await askRepos(ctx.app, user), user.id, crewCanRun(ctx.app), user.isAdmin === true); |
| 128 | const others = ask?.state === "building" ? crewAtWork(ctx, besideAsk(repos, ask)) : crew; | |
| 129 | const bodies: Record<NextStep["key"], Html | null> = { | |
| 130 | // The account is made on its own page; here the step is one sentence, the way there, and the way to decline. | |
| 131 | everyday: html`<p class="muted small">${EVERYDAY_WHY}</p> | |
| 132 | <p> | |
| 133 | ${btn("Make an everyday account", { href: "/settings/everyday", size: "sm", ...(primary === "everyday" ? { variant: "primary" as const } : {}) })} | |
| 134 | ${btn("Keep using admin", { form: "everyday-keep", variant: "link", size: "sm" })} | |
| 135 | </p> | |
| 136 | <form id="everyday-keep" method="post" action="/settings/everyday/keep" hidden></form>`, | |
| 137 | apps: | |
| 138 | repos.length === 0 | |
| 139 | ? null | |
| 140 | : html`<p>${repos.map((r) => html`${btn(r.name, { href: `/${r.ownerName}/${r.name}`, size: "sm" })} `)}</p>`, | |
| 141 | tell: html`<p class="muted small"> | |
| 142 | Say what you want in one sentence, in the box below; the crew takes it | |
| 143 | from there. | |
| 144 | ${btn("Tell the crew", { | |
| 145 | href: "#composer", | |
| 146 | size: "sm", | |
| 147 | ...(primary === "tell" ? { variant: "primary" as const } : {}), | |
| 148 | })} | |
| 149 | </p>`, | |
| 150 | }; | |
| 92 | // What the person made leads: the ask's state, then each app a crew member is on. An app nobody | |
| 93 | // is on says nothing here; the apps list below carries it. | |
| 94 | const rows = appCrew(ctx.app.db, ask?.state === "building" ? besideAsk(repos, ask) : repos) | |
| 95 | .filter((c) => c.who !== null) | |
| 96 | .map((c) => row({ href: `/${c.repo.ownerName}/${c.repo.name}`, title: html`${c.says}`, meta: html`${c.repo.name}` })); | |
| 97 | if (!ask && rows.length === 0) return null; | |
| 151 | 98 | return html`<section id="next-steps"> |
| 152 | <h2>Your next steps</h2> | |
| 153 | 99 | ${ask ? askBlock(ask) : null} |
| 154 | ${others.length > 0 ? html`<ul class="list">${others}</ul>` : null} | |
| 155 | ${steps.map((s) => stepBlock(s, s.key === primary, bodies[s.key]))} | |
| 100 | ${rows.length > 0 ? html`<ul class="list">${rows}</ul>` : null} | |
| 156 | 101 | ${secondPasskeyLine(ctx, user)} |
| 157 | 102 | </section>`; |
| 158 | 103 | } |
| 159 | 104 | |
| 105 | /** | |
| 106 | * The everyday account, offered once a tell exists, as the quiet last line of home: never a step to | |
| 107 | * take first. | |
| 108 | */ | |
| 109 | export function everydayLine(steps: readonly NextStep[] | undefined): Html | null { | |
| 110 | if (!steps || steps.some((s) => s.key === "tell" && !s.done)) return null; | |
| 111 | if (!steps.some((s) => s.key === "everyday" && !s.done)) return null; | |
| 112 | return html`<p class="small muted" data-step="everyday">Signed in as admin. ${btn("Make an everyday account", { href: "/settings/everyday", size: "sm", variant: "link" })} | |
| 113 | ${btn("Keep using admin", { form: "everyday-keep", variant: "link", size: "sm" })}</p> | |
| 114 | <form id="everyday-keep" method="post" action="/settings/everyday/keep" hidden></form>`; | |
| 115 | } | |
| 116 | ||
| 160 | 117 | /** The steps once per request, for the card and for the lean home to share. */ |
| 161 | 118 | export function nextStepsOf( |
| 162 | 119 | ctx: Ctx, |
src/web/studio/held.ts +3 −13
| @@ -31,20 +31,10 @@ function holds(ctx: Ctx, user: User) { | ||
| 31 | 31 | return out; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | /** | |
| 35 | * One line for each gate that holds work back; where none does, the one next action, but only | |
| 36 | * if `idle` (the first-tell box already carries its own). | |
| 37 | */ | |
| 38 | export function heldLine(ctx: Ctx, user: User, idle = false): Html | null { | |
| 34 | /** One line for each gate that holds work back; none where none does. */ | |
| 35 | export function heldLine(ctx: Ctx, user: User): Html | null { | |
| 39 | 36 | const found = holds(ctx, user); |
| 40 | if (found.length === 0) { | |
| 41 | if (!idle) return null; | |
| 42 | return html`<section class="stack stack-tight" id="held-line" aria-label="Held back"> | |
| 43 | <p class="small muted"> | |
| 44 | Ready for the next issue: <a href="/new/issue">open one</a>. | |
| 45 | </p> | |
| 46 | </section>`; | |
| 47 | } | |
| 37 | if (found.length === 0) return null; | |
| 48 | 38 | return html`<section class="stack stack-tight" id="held-line" aria-label="Held back"> |
| 49 | 39 | ${found.map( |
| 50 | 40 | ({ repo, hold }) => |
src/web/studio/home.ts +2 −3
| @@ -80,7 +80,7 @@ import { newLine, newSince } from "../../feed/last_seen.ts"; | ||
| 80 | 80 | import { homeTabs, unshippedAsks } from "./home_tabs.ts"; |
| 81 | 81 | import { homeFlowPage } from "../pages/home_flow.ts"; |
| 82 | 82 | import { crewKeyCard } from "./crew_key.ts"; |
| 83 | import { firstAskJs, nextStepsCard, nextStepsOf } from "../pages/next-steps.ts"; | |
| 83 | import { everydayLine, firstAskJs, nextStepsCard, nextStepsOf } from "../pages/next-steps.ts"; | |
| 84 | 84 | import { spawnedForge } from "../../spawn/claim.ts"; |
| 85 | 85 | import { readableNotes } from "../../actions/desk.ts"; |
| 86 | 86 | import { deskStrip } from "../desk_strip.ts"; |
| @@ -316,9 +316,8 @@ export async function studioHome( | ||
| 316 | 316 | // Before the first tell the card is the one box and carries the key line and the composer. |
| 317 | 317 | const firstTell = steps.some((s) => s.key === "tell" && !s.done); |
| 318 | 318 | const lean = html`<h1 class="sr-only">Home</h1> |
| 319 | ${firstSteps} ${address} ${startedFromLine(ctx.app.db, ctx.app.config.dataDir, user)} ${firstTell ? null : crewKeyCard(ctx)} ${heldLine(ctx, user, !firstTell)} ${apps} | |
| 319 | ${firstSteps} ${address} ${startedFromLine(ctx.app.db, ctx.app.config.dataDir, user)} ${firstTell ? null : composer(ctx, user)} ${apps} ${firstTell ? null : crewKeyCard(ctx)} ${heldLine(ctx, user)} ${everydayLine(steps)} | |
| 320 | 320 | <div class="stack"> |
| 321 | ${firstTell ? null : composer(ctx, user)} | |
| 322 | 321 | <p class="small muted"> |
| 323 | 322 | <a href="/?all=1">Show everything</a> |
| 324 | 323 | </p> |
test/first-ask-flash.test.ts +1 −1
| @@ -56,7 +56,7 @@ test("with no credit the flash still names them, and keeps the way forward", asy | ||
| 56 | 56 | expect(home).toContain("data-ask-status"); |
| 57 | 57 | expect(home).toContain("No AI account and no included credit left"); |
| 58 | 58 | const card = home.slice(home.indexOf('id="next-steps"')); |
| 59 | const status = card.slice(card.indexOf("data-ask-status"), card.indexOf("data-step=")); | |
| 59 | const status = card.slice(card.indexOf("data-ask-status"), card.indexOf("</section>")); | |
| 60 | 60 | expect(status).toContain("Add a model key"); |
| 61 | 61 | expect(status).not.toContain('data-variant="primary"'); |
| 62 | 62 | } finally { |
test/first-login-words.test.ts +1 −1
| @@ -55,7 +55,7 @@ describe("the first-login page of a spawned forge, in plain words", () => { | ||
| 55 | 55 | const told = await forge.post(owner, "/marias/bakery/tell", { text: "Add a weekly menu page." }); |
| 56 | 56 | expect(told.status).toBeLessThan(400); |
| 57 | 57 | const html = await (await fetch(url("/"), { headers: { cookie: owner } })).text(); |
| 58 | expect(mainOf(html)).toContain("Your next steps"); | |
| 58 | expect(mainOf(html)).toContain("id=\"next-steps\""); | |
| 59 | 59 | expect(jargonIn(html)).toEqual([]); |
| 60 | 60 | }); |
| 61 | 61 |
test/first-login.test.ts +16 −18
| @@ -36,7 +36,7 @@ const PASSWORD = "a-long-first-login-passphrase"; | ||
| 36 | 36 | const FORGE_JSON = JSON.stringify({ |
| 37 | 37 | app: { run: "bun run index.ts", health: "/" }, |
| 38 | 38 | }); |
| 39 | const CARD = "Your next steps"; | |
| 39 | const CARD = 'id="next-steps"'; | |
| 40 | 40 | |
| 41 | 41 | describe("the first login to a spawned forge", () => { |
| 42 | 42 | let dir = ""; |
| @@ -220,24 +220,22 @@ describe("the first login to a spawned forge", () => { | ||
| 220 | 220 | expect(card).not.toContain("arrive here"); |
| 221 | 221 | }); |
| 222 | 222 | |
| 223 | test("once a tell exists the card carries three steps, and the everyday offer comes after it", async () => { | |
| 223 | test("once a tell exists the home leads with the crew's work and the ask box; the everyday account is one quiet line", async () => { | |
| 224 | 224 | const told = await post(owner, "/marias/bakery/tell", { text: "Add a weekly menu page." }); |
| 225 | 225 | expect(told.status).toBeLessThan(400); |
| 226 | 226 | const home = await page(owner); |
| 227 | 227 | expect(home).toContain(CARD); |
| 228 | expect(home).toContain("Make your everyday account"); | |
| 229 | expect(home).toContain("Open your apps"); | |
| 230 | expect(home).toContain("Tell the crew something"); | |
| 231 | expect(steps(home)).toEqual({ everyday: "no", apps: "no", tell: "yes" }); | |
| 228 | expect(home).not.toContain("Your next steps"); | |
| 229 | expect(home).not.toContain("Make your everyday account"); | |
| 230 | expect(home).not.toContain("can break the forge"); | |
| 231 | expect(home).not.toContain("nobody is on it yet"); | |
| 232 | expect(home).not.toContain("Ready for the next issue"); | |
| 233 | expect(home).not.toContain("data-first-tell"); | |
| 232 | 234 | expect(home).toContain('href="/settings/everyday"'); |
| 233 | expect(home).not.toContain('action="/settings/everyday"'); | |
| 234 | expect(home.split("Make your everyday account").length - 1).toBe(1); | |
| 235 | expect(home).not.toContain('data-first-tell'); | |
| 236 | // The crew's rows appear once the first ask exists. | |
| 235 | expect(home.split("Make an everyday account").length - 1).toBe(1); | |
| 237 | 236 | expect(home).toMatch(/href="\/marias\/bakery\/?"[^>]*>[\s\S]*?atlas/); |
| 238 | expect(home).not.toMatch(/class="[^"]*\bsteps\b/); | |
| 239 | expect(home).not.toMatch(/data-step[\s\S]{0,400}row-meta/); | |
| 240 | expect(home).toMatch(/<div class="step-body">\s*<p class="muted small">/); | |
| 237 | expect(home.indexOf('id="composer"')).toBeGreaterThan(-1); | |
| 238 | expect(home.indexOf('id="composer"')).toBeLessThan(home.indexOf('href="/settings/everyday"')); | |
| 241 | 239 | }); |
| 242 | 240 | |
| 243 | 241 | test("the everyday account, made first, joins the client's org and sees the card part-way, every step one it can do", async () => { |
| @@ -253,13 +251,13 @@ describe("the first login to a spawned forge", () => { | ||
| 253 | 251 | daily = (res.headers.get("set-cookie") ?? "").split(";")[0]!; |
| 254 | 252 | expect(getUserByName(child.db, "maria-me")).toBeDefined(); |
| 255 | 253 | const home = await page(daily); |
| 256 | expect(steps(home)).toEqual({ everyday: "yes", apps: "no", tell: "yes" }); | |
| 254 | expect(home).not.toContain('href="/settings/everyday"'); | |
| 257 | 255 | // It can read the client's own apps, and the crew line reads for it too. |
| 258 | 256 | expect(home).toContain('href="/marias/bakery"'); |
| 259 | 257 | expect(home).not.toContain("Your apps arrive here"); |
| 260 | 258 | expect(home).toContain("atlas is ready to work toward Run Maria"); |
| 261 | 259 | // The admin's card moves along with it. |
| 262 | expect(steps(await page(owner)).everyday).toBe("yes"); | |
| 260 | expect(await page(owner)).not.toContain('href="/settings/everyday"'); | |
| 263 | 261 | }); |
| 264 | 262 | |
| 265 | 263 | test("each app is one line: the crew member on it and what they do now, or that nobody is", async () => { |
| @@ -282,12 +280,12 @@ describe("the first login to a spawned forge", () => { | ||
| 282 | 280 | const home = await page(owner); |
| 283 | 281 | expect(home).toMatch(/class="row-title"[^>]*>atlas is working toward Run Maria(?:'|'|')s bakery\.?<\/span\s*>\s*<span class="row-meta">bakery</); |
| 284 | 282 | expect(home.slice(home.indexOf("id=\"next-steps\""), home.indexOf("</section>"))).not.toContain("Direction:"); |
| 285 | expect(home).toMatch(/class="row-title"[^>]*>spare<\/span\s*>\s*<span class="row-meta">nobody is on it yet</); | |
| 283 | expect(home).not.toContain("nobody is on it yet"); | |
| 286 | 284 | // A direction closed or unassigned is nobody on it, too. |
| 287 | 285 | child.db.query("UPDATE issue SET state = 'closed' WHERE id = ?1").run(bakery.direction_issue_id); |
| 288 | expect(await page(owner)).toMatch(/class="row-title"[^>]*>bakery<\/span\s*>\s*<span class="row-meta">nobody is on it yet</); | |
| 286 | expect(await page(owner)).not.toContain("nobody is on it yet"); | |
| 289 | 287 | child.db.query("UPDATE issue SET state = 'open', assignee_id = NULL WHERE id = ?1").run(bakery.direction_issue_id); |
| 290 | expect(await page(owner)).toMatch(/class="row-title"[^>]*>bakery<\/span\s*>\s*<span class="row-meta">nobody is on it yet</); | |
| 288 | expect(await page(owner)).not.toContain("nobody is on it yet"); | |
| 291 | 289 | child.db.query("UPDATE issue SET assignee_id = ?2 WHERE id = ?1").run(bakery.direction_issue_id, atlasId); |
| 292 | 290 | }); |
| 293 | 291 |
test/later-gate.test.ts +2 −8
| @@ -95,15 +95,9 @@ describe("the Later gate in plain sight", () => { | ||
| 95 | 95 | expect(home).not.toContain("held-line"); |
| 96 | 96 | }); |
| 97 | 97 | |
| 98 | test("heldLine says the next action only when asked (idle), and never when the first-tell box is up", () => { | |
| 98 | test("heldLine is null where no gate holds anything", () => { | |
| 99 | 99 | expect(gateHold(app.db, fresh())).toBeUndefined(); |
| 100 | const ctx = { app } as unknown as Ctx; | |
| 101 | expect(heldLine(ctx, alice)).toBeNull(); | |
| 102 | expect(heldLine(ctx, alice, false)).toBeNull(); | |
| 103 | const idle = String(heldLine(ctx, alice, true)); | |
| 104 | expect(idle).toContain('id="held-line"'); | |
| 105 | expect(idle).toContain("Ready for the next issue:"); | |
| 106 | expect(idle).toContain('href="/new/issue"'); | |
| 100 | expect(heldLine({ app } as unknown as Ctx, alice)).toBeNull(); | |
| 107 | 101 | }); |
| 108 | 102 | |
| 109 | 103 | test("a new gate shows up on home: how many, who set it", async () => { |
test/next-steps-card.test.ts +40 −32
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | import { readFileSync, writeFileSync } from "node:fs"; |
| 9 | 9 | import { join } from "node:path"; |
| 10 | 10 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 11 | import { createRepo } from "../src/actions/repos.ts"; | |
| 11 | 12 | import { createSession } from "../src/core/sessions.ts"; |
| 12 | 13 | import { nextStepsFor } from "../src/core/next-steps.ts"; |
| 13 | 14 | import { createUser, getUserByName } from "../src/core/users.ts"; |
| @@ -17,7 +18,7 @@ import { passkeyFields } from "./helpers/passkey.ts"; | ||
| 17 | 18 | |
| 18 | 19 | quietLogs(); |
| 19 | 20 | |
| 20 | const CARD = "Your next steps"; | |
| 21 | const CARD = 'id="next-steps"'; | |
| 21 | 22 | |
| 22 | 23 | describe("the next-steps card of a spawned forge", () => { |
| 23 | 24 | let forge: ClaimedForge; |
| @@ -31,14 +32,6 @@ describe("the next-steps card of a spawned forge", () => { | ||
| 31 | 32 | ); |
| 32 | 33 | const post = (cookie: string, path: string, form: Record<string, string>) => |
| 33 | 34 | forge.post(cookie, path, form); |
| 34 | const steps = (html: string) => { | |
| 35 | const card = html.slice(html.indexOf(CARD)); | |
| 36 | return { | |
| 37 | everyday: /data-step="everyday"[^>]*data-done="(yes|no)"/.exec(card)?.[1], | |
| 38 | apps: /data-step="apps"[^>]*data-done="(yes|no)"/.exec(card)?.[1], | |
| 39 | tell: /data-step="tell"[^>]*data-done="(yes|no)"/.exec(card)?.[1], | |
| 40 | }; | |
| 41 | }; | |
| 42 | 35 | |
| 43 | 36 | beforeAll(async () => { |
| 44 | 37 | forge = await claimedForge("forge-next-steps-card-"); |
| @@ -161,34 +154,42 @@ describe("the next-steps card of a spawned forge", () => { | ||
| 161 | 154 | expect(main).not.toContain('action="/settings/everyday"'); |
| 162 | 155 | }); |
| 163 | 156 | |
| 164 | test("a fresh forge after its first tell names the next issue, in one sentence with a link", async () => { | |
| 157 | test("a fresh forge after its first tell leads with the ask box and apps, not a list of steps", async () => { | |
| 165 | 158 | const home = await page(owner); |
| 166 | const line = home.slice(home.indexOf('id="held-line"'), home.indexOf("</section>", home.indexOf('id="held-line"'))); | |
| 167 | expect(line).toContain("Ready for the next issue:"); | |
| 168 | expect(line).toContain('href="/new/issue"'); | |
| 169 | expect(line).not.toContain("Next:"); | |
| 159 | expect(home).toContain('id="composer"'); | |
| 160 | expect(home).toContain('href="/marias/bakery'); | |
| 161 | expect(home).not.toContain("Your next steps"); | |
| 170 | 162 | }); |
| 171 | 163 | |
| 172 | test("the admin's first home carries exactly three steps, in order, none done", async () => { | |
| 164 | test("an app nobody is on is still reachable from the apps list on home", async () => { | |
| 165 | const made = await createRepo(forge.child, getUserByName(forge.child.db, "maria")!, { owner: "marias", name: "quiet-shop", visibility: "private" }); | |
| 166 | expect(made.ok).toBe(true); | |
| 173 | 167 | const home = await page(owner); |
| 174 | expect(keys(home)).toEqual(["everyday", "apps", "tell"]); | |
| 175 | expect(steps(home)).toEqual({ everyday: "no", apps: "no", tell: "yes" }); | |
| 176 | const titles = ["Make your everyday account", "Open your apps", "Tell the crew something"]; | |
| 177 | const at = titles.map((t) => cardOf(home).indexOf(t)); | |
| 178 | expect(at.every((n) => n >= 0)).toBe(true); | |
| 179 | expect([...at].sort((a, b) => a - b)).toEqual(at); | |
| 168 | const main = home.slice(home.indexOf("<main"), home.indexOf("</main>")); | |
| 169 | expect(main).toMatch(/<a [^>]*href="\/marias\/quiet-shop\/?"/); | |
| 170 | const res = await fetch(url("/marias/quiet-shop"), { headers: { cookie: owner }, redirect: "manual" }); | |
| 171 | expect(res.status).toBe(200); | |
| 180 | 172 | }); |
| 181 | 173 | |
| 182 | test("the steps are one plain section, not boxed in cards", async () => { | |
| 183 | const card = cardOf(await page(owner)); | |
| 184 | expect(card).not.toContain('class="card'); | |
| 185 | expect(card).not.toContain("card-body"); | |
| 186 | // A pending step's body is a block under its row, never an inline sibling of the title. | |
| 187 | expect(card).toMatch(/<\/ul>\s*<div class="step-body">/); | |
| 188 | // The first pending step, and only it, is the primary one. | |
| 189 | expect(card).toMatch(/data-step="everyday"[^>]*data-primary/); | |
| 190 | expect(card.match(/data-primary/g)?.length).toBe(1); | |
| 191 | expect(keys(await page(owner))).toEqual(["everyday", "apps", "tell"]); | |
| 174 | test("the everyday line is one muted sentence: a link, and the keep as a post-form button", async () => { | |
| 175 | const home = await page(owner); | |
| 176 | const at = home.indexOf('data-step="everyday"'); | |
| 177 | expect(at).toBeGreaterThan(-1); | |
| 178 | const line = home.slice(home.lastIndexOf("<p", at), home.indexOf("</p>", at)); | |
| 179 | expect(line).toContain("muted"); | |
| 180 | expect(line).toContain('<a '); | |
| 181 | expect(line).toContain('href="/settings/everyday"'); | |
| 182 | expect(line).toContain('form="everyday-keep"'); | |
| 183 | expect(home).toContain('<form id="everyday-keep" method="post" action="/settings/everyday/keep"'); | |
| 184 | }); | |
| 185 | ||
| 186 | test("the admin's home after the first tell has the ask box first, and the everyday account as one quiet link", async () => { | |
| 187 | const home = await page(owner); | |
| 188 | expect(home).toContain('id="composer"'); | |
| 189 | expect(home).not.toContain("Make your everyday account"); | |
| 190 | expect(home).not.toContain("can break the forge"); | |
| 191 | expect(home).toContain(`href="/settings/everyday"`); | |
| 192 | expect(home.indexOf('id="composer"')).toBeLessThan(home.indexOf('href="/settings/everyday"')); | |
| 192 | 193 | }); |
| 193 | 194 | |
| 194 | 195 | test("each step's way in answers 200 for the admin", async () => { |
| @@ -200,7 +201,7 @@ describe("the next-steps card of a spawned forge", () => { | ||
| 200 | 201 | // Tell the crew: the card points at the composer, which must be on the page. |
| 201 | 202 | expect(home).toContain('id="composer"'); |
| 202 | 203 | // Make your everyday account: the card links to the step's own page. |
| 203 | expect(card).toContain('href="/settings/everyday"'); | |
| 204 | expect(home).toContain('href="/settings/everyday"'); | |
| 204 | 205 | const paths = [...new Set([...apps, "/settings/everyday"])]; |
| 205 | 206 | for (const p of paths) { |
| 206 | 207 | const res = await fetch(url(p), { headers: { cookie: owner }, redirect: "manual" }); |
| @@ -227,6 +228,7 @@ describe("the next-steps card of a spawned forge", () => { | ||
| 227 | 228 | const home = await page(`forge_session=${session.token}`); |
| 228 | 229 | expect(home).not.toContain(CARD); |
| 229 | 230 | expect(home).not.toContain('data-step="'); |
| 231 | expect(home).not.toContain("/settings/everyday"); | |
| 230 | 232 | }); |
| 231 | 233 | |
| 232 | 234 | test("once the everyday account exists, its step reads done", async () => { |
| @@ -242,5 +244,11 @@ describe("the next-steps card of a spawned forge", () => { | ||
| 242 | 244 | expect((await nextStepsFor(forge.child, user))?.map((x) => x.done)).toEqual([true, true, true]); |
| 243 | 245 | expect(await page(owner)).not.toContain(CARD); |
| 244 | 246 | expect(await page(daily)).not.toContain(CARD); |
| 247 | // Done is done: the quiet line is gone too. | |
| 248 | for (const who of [owner, daily]) { | |
| 249 | const home = await page(who); | |
| 250 | expect(home).not.toContain('data-step="everyday"'); | |
| 251 | expect(home).not.toContain('href="/settings/everyday"'); | |
| 252 | } | |
| 245 | 253 | }); |
| 246 | 254 | }); |
test/next-steps-crew-words.test.ts +4 −10
| @@ -13,9 +13,7 @@ import { createRepo } from "../src/actions/repos.ts"; | ||
| 13 | 13 | import { claimRun, createRun } from "../src/core/runs.ts"; |
| 14 | 14 | import { createUser, getUserByName } from "../src/core/users.ts"; |
| 15 | 15 | import { getRepoById } from "../src/core/repos.ts"; |
| 16 | import type { Ctx } from "../src/http/context.ts"; | |
| 17 | 16 | import { appCrew } from "../src/core/app-crew.ts"; |
| 18 | import { crewAtWork } from "../src/web/pages/next-steps.ts"; | |
| 19 | 17 | import { quietLogs } from "./helpers/globals.ts"; |
| 20 | 18 | |
| 21 | 19 | quietLogs(); |
| @@ -48,13 +46,9 @@ async function appWith(title: string) { | ||
| 48 | 46 | const run = createRun(app.db, { repoId: created.value.id, kind: "agent", issueId: issue.value.id, actorId: atlas.id, reason: "assigned" }); |
| 49 | 47 | claimRun(app.db, run.id); |
| 50 | 48 | const repo = getRepoById(app.db, created.value.id)!; |
| 51 | const rows = crewAtWork({ app } as unknown as Ctx, [repo]).map(String).join(" "); | |
| 52 | const text = rows | |
| 53 | .replace(/<[^>]*>/g, " ") | |
| 54 | .replace(/'|'/g, "'") | |
| 55 | .replace(/\s+/g, " ") | |
| 56 | .trim(); | |
| 57 | return { repo, text, rows, runId: run.id, says: appCrew(app.db, [repo])[0]!.says }; | |
| 49 | const says = appCrew(app.db, [repo])[0]!.says; | |
| 50 | const text = `${says} ${repo.name}`; | |
| 51 | return { repo, text, runId: run.id, says }; | |
| 58 | 52 | } |
| 59 | 53 | |
| 60 | 54 | beforeAll(async () => { |
| @@ -68,7 +62,7 @@ test("a clause that introduces a pull number or branch goes with it: the whole s | ||
| 68 | 62 | const a = await appWith("Run Maria's bakery, as in PR #42 on mason/12-menu-page"); |
| 69 | 63 | expect(a.says).toBe("atlas is working toward Run Maria's bakery"); |
| 70 | 64 | expect(a.text).toBe(`atlas is working toward Run Maria's bakery ${a.repo.name}`); |
| 71 | expect(a.rows).not.toContain(a.runId); | |
| 65 | expect(a.text).not.toContain(a.runId); | |
| 72 | 66 | expect(a.text).not.toMatch(/#\d|\bPR\b|mason\/|\/issues\//); |
| 73 | 67 | }); |
| 74 | 68 |
test/tui-first-tell.test.ts +4
| @@ -62,5 +62,9 @@ test("before the first tell the home says what to do and never offers an everyda | ||
| 62 | 62 | await settleApp(after.app); |
| 63 | 63 | expect(after.text()).not.toContain("What do you want built?"); |
| 64 | 64 | expect(after.text()).not.toContain("K keeps using admin"); |
| 65 | // It already leads with the apps and the ask (same order as the web home): the app's line is | |
| 66 | // there, and the key to ask again. | |
| 67 | expect(after.text()).toContain("bakery"); | |
| 68 | expect(after.text()).toContain("ask for something"); | |
| 65 | 69 | after.app.stop(); |
| 66 | 70 | }); |
new above
offline
This line is whitespace only. Remove it.