Public: anyone can read this; the crew can change it.

The Admin test: a new owner is guided to a separate everyday account, told why in two sentences, and can still choose otherwise on purpose, in one journey test #12478

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`test/admin-journey.test.ts` is new: it walks a new owner's first minutes on a fresh forge, entirely through the pages a person uses. It found one gap, which this pull fixes: the access-codes list showed an admin's `rw` token as plain `rw`, though every token an admin holds acts as admin.

shipped production is serving it deploy 9cda780

opened this

test/admin-journey.test.ts is new: it walks a new owner's first minutes on a fresh forge, entirely through the pages a person uses. It found one gap, which this pull fixes: the access-codes list showed an admin's rw token as plain rw, though every token an admin holds acts as admin.

What the journey covers

  • First sign-in is the admin. The operator's first-admin code is redeemed at /first-admin with a test passkey, and that account is the admin.
  • The offer. The home shows the one quiet line ("You are signed in as the admin. Make an everyday account") and no role="alert". /settings/everyday says the existing EVERYDAY_WHY once; the test checks it is two sentences. The page has exactly one primary action, "Make it with a passkey", plus "Keep using admin".
  • Make it. The browser is signed in as the new ada-me account, which is not an admin and is linked both ways to ada. From that session, /admin/limits and /settings/people answer 403 with the existing sentence, "This is for the forge's admin account, so sign in as admin to do it."
  • Keep using admin, on a second fresh forge. It is one post. Its receipt is the flash "You keep working as admin.", shown as a toast rather than an alert, and the choice is recorded. Afterwards the home no longer mentions an everyday account, and the account page still offers the way without "Keep using admin".
  • Tokens. A token the admin mints (with the "I mean to give this access code admin" box ticked) is listed as rw plus an acts as admin badge. The everyday account's token has no badge.

The fix: in src/web/pages/account.ts (tokensView), every token row of an admin now carries the acts as admin badge. With the fix removed, the token check in the journey test fails. No copy was rewritten, and no banner was added.

Filed, not fixed here: #12476. The terminal's access-codes screen (src/tui/screens/signins.ts) still lists an admin's token as name · rw with no admin label. It also mints ro/rw codes for an admin without the confirm the web page asks for.

Checks: bun test on test/admin-journey.test.ts, test/admin-refusal-table.test.ts, test/everyday.test.ts and test/calm-no-banner.test.ts passes (38 tests), as do bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts. The gate already includes every test/*.test.ts that isn't on its exclusion list, so the new file needed no listing.

There was no keep_plan tool in this session, so no plan was kept on the issue.

Try it: sign in to the preview as its admin and open /settings/tokens. Mint an access code with "I mean to give this access code admin" ticked, and the list shows acts as admin beside its scope.

🤖 Generated with Claude Code

Closes #12466

2 earlier comments · 1 event
commented

test/admin-journey.test.ts is new: it walks a new owner's first minutes on a fresh forge, entirely through the pages a person uses. It found one gap, which this pull fixes: the access-codes list showed an admin's rw token as plain rw, though every token an admin holds acts as admin.

What the journey covers

  • First sign-in is the admin. The operator's first-admin code is redeemed at /first-admin with a test passkey, and that account is the admin.
  • The offer. The home shows the one quiet line ("You are signed in as the admin. Make an everyday account") and no role="alert". /settings/everyday says the existing EVERYDAY_WHY once; the test checks it is two sentences. The page has exactly one primary action, "Make it with a passkey", plus "Keep using admin".
  • Make it. The browser is signed in as the new ada-me account, which is not an admin and is linked both ways to ada. From that session, /admin/limits and /settings/people answer 403 with the existing sentence, "This is for the forge's admin account, so sign in as admin to do it."
  • Keep using admin, on a second fresh forge. It is one post. Its receipt is the flash "You keep working as admin.", shown as a toast rather than an alert, and the choice is recorded. Afterwards the home no longer mentions an everyday account, and the account page still offers the way without "Keep using admin".
  • Tokens. A token the admin mints (with the "I mean to give this access code admin" box ticked) is listed as rw plus an acts as admin badge. The everyday account's token has no badge.

The fix: in src/web/pages/account.ts (tokensView), every token row of an admin now carries the acts as admin badge. With the fix removed, the token check in the journey test fails. No copy was rewritten, and no banner was added.

Filed, not fixed here: #12476. The terminal's access-codes screen (src/tui/screens/signins.ts) still lists an admin's token as name · rw with no admin label. It also mints ro/rw codes for an admin without the confirm the web page asks for.

Checks: bun test on test/admin-journey.test.ts, test/admin-refusal-table.test.ts, test/everyday.test.ts and test/calm-no-banner.test.ts passes (38 tests), as do bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts. The gate already includes every test/*.test.ts that isn't on its exclusion list, so the new file needed no listing.

There was no keep_plan tool in this session, so no plan was kept on the issue.

Try it: sign in to the preview as its admin and open /settings/tokens. Mint an access code with "I mean to give this access code admin" ticked, and the list shows acts as admin beside its scope.

🤖 Generated with Claude Code

Changes requested — before the latest push

The journey test is good and the page label works. One change: both doors. The label "acts as admin" exists only on the web token list; the terminal access-codes screen (src/tui/screens/signins.ts) still shows an admin token as plain name · rw. The pull knowingly leaves this to #12476, but the rule is that what the page says the terminal says too, and the fix is a few lines. Add the same label there (one source for the text, shared with the page), add a test in the TUI test for signins, and keep #12476 only for the missing admin confirm on minting if you do not fix that here. Also say in docs/features/tokens-harness.md (or admin-flows.md) that admin tokens are labelled. Everything else (security, design tokens, one primary action, no README change, no new dependency) is fine.

commented

A new owner's first minutes are now one journey test. The setup guides them to a separate everyday account and says why in two sentences. They can still keep working as the admin if they choose to. Every token a site admin owns is now labelled "acts as admin" on both the web page and the terminal, because such a token acts as admin whatever its scope (#596).

What changed

  • One source for the words. ACTS_AS_ADMIN_WORDS in src/core/tokens.ts holds the label. Settings › Tokens (src/web/pages/account.ts) uses it for the badge.
  • Terminal. The sign-ins screen (src/tui/screens/signins.ts) now shows a site admin's token as name · rw · acts as admin, with the OAuth client after it when there is one.
  • Tests.

- test/tui-signins.test.ts has a new test: an admin's rw token row carries the label, and a non-admin's row does not. - test/admin-journey.test.ts takes the badge text from the constant instead of a literal.

  • Docs. docs/features/tokens-harness.md has a new section, "A site admin's tokens are labelled", covering both doors and where each is tested.

One existing test changed. test/tokens-oauth-client.test.ts checks exact sign-ins rows. Its alice is the first user, so a site admin, and her two rows now end in acts as admin. The old expectation described the behaviour this pull changes on purpose, so I updated it rather than changing the code.

Left out. The admin confirm when minting a token is still for #12476. The terminal already asks for a second y when minting an admin-scope token, so this pull does not touch minting.

Checks. bun scripts/gate.ts, bun x tsc --noEmit and bun scripts/design-lint.ts pass. scripts/fast.ts named 2,325 test files (about 3h16m, against a 5-minute budget) because core/tokens.ts is imported almost everywhere. Instead I ran the 21 test files that check token and sign-in rows, plus tui-token-make and tui-signins-token: all pass.

To try it: sign in as the first (admin) user. Settings › Tokens shows "acts as admin" beside each token, and the terminal's "Signed in" screen shows the same words on each token row.

🤖 Generated with Claude Code

commented

A new owner's first minutes are now one journey test (test/admin-journey.test.ts). The setup guides them to a separate everyday account and says why in two sentences. They can still keep working as the admin if they choose to.

A site admin's tokens are labelled "acts as admin", because such a token acts as admin whatever its scope (#596). The words come from one constant, ACTS_AS_ADMIN_WORDS in src/core/tokens.ts. Two places use it:

  • Settings › Tokens shows it as a badge beside each token's scope.
  • The terminal's sign-ins screen shows it in each token row: name · scope · acts as admin, with the OAuth client after it when there is one.

docs/features/tokens-harness.md describes the label on both and where each is tested.

After merging main. #12483 on main had already added the terminal label, with the words written inline, and the confirm before an admin mints an access code. The merge keeps all of #12483: its row format, its mint confirm and its test in test/tui-signins.test.ts. The row now builds the label from the shared constant, and that test checks against it. This branch's own terminal test duplicated #12483's coverage and created a second carol user, so it was dropped. In test/tokens-oauth-client.test.ts, main already expected the label on alice's rows (she is the first user, so a site admin); only a comment saying why is added there.

Left out. The admin confirm on minting is #12483's work and is unchanged here, so #12476 has nothing left for this pull to do.

Checks. After the merge, bun scripts/gate.ts, bun x tsc --noEmit and bun scripts/design-lint.ts pass. The full test list scripts/fast.ts would name is too broad to run here (core/tokens.ts is imported almost everywhere). Instead these six files pass, 41 tests: tui-signins, tui-signins-token, tui-token-make, tokens-oauth-client, admin-journey and everyday.

To try it: sign in as the first (admin) user. Settings › Tokens shows "acts as admin" beside each token, and the terminal's "Signed in" screen shows the same words on each token row.

🤖 Generated with Claude Code

Approved

Clean. The journey test covers first admin sign-in, the two-sentence offer with one primary action, making the everyday account, the 403 with the sign-in-as-admin words, and keeping admin as one receipted post. The "acts as admin" badge shows on the token list. The terminal shows the same words from one shared constant, and the docs section is in tokens-harness.md, not the README. No new dependency, and the design stays on the named components. Boxes 1-3 are met by the test and the badge, and box 4 is met because #12476 is now covered. For box 5 I did not run the tests or tsc myself; I rely on the pull being green, and the gate lists every test file not excluded.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs