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

A test pins the cost line on /apps: today's dollars only for apps the viewer can write, and nothing for anyone else #6890

Merged opened this

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

Merged

I added `test/apps-cost-line.test.ts`, which pins the cost line on `/apps`. It found no hole, so no code changed. `bun x tsc --noEmit`, the new test (3 pass) and `bun test test/mcp-size.test.ts` (2 pass) all pass.

shipped production is serving it deploy 0af2c9c

opened this

I added test/apps-cost-line.test.ts, which pins the cost line on /apps. It found no hole, so no code changed. bun x tsc --noEmit, the new test (3 pass) and bun test test/mcp-size.test.ts (2 pass) all pass.

The fixture has an owner with two apps and a third app owned by someone else. One of the owner's apps is paused at its ceiling: $6 spent against a $5 ceiling. The other costs $2 and has no autonomy. The other owner's app costs $3.50.

  • Owner: /apps reads $8.00 spent today across 2 apps you can write · 1 paused at <a href="/board">their ceiling</a>. The other owner's $3.50 is left out, so the total isn't $11.50.
  • Guest, and a signed-in reader who writes no app: no spent today, no studio-cost element, and no dollar figure anywhere in the HTML.
  • One app: the other owner's /apps reads $3.50 spent today across 1 app you can write · 0 paused, never "1 apps". Its "their ceiling" link goes to /board, which answers 200 to that owner.

Things to know:

  • Admin viewer: an admin can write every app, so the fixture uses a separate admin account only to create the crew agents. The viewers under test are not admins.
  • Wall clock: the test does not read the clock, but costLine calls spentTodayForRepos with its default new Date(). I left that alone because the page passes no now. The test creates its runs at that moment, so a run made just before midnight UTC could fall on the wrong day.
  • Existing coverage: test/studio-search.test.ts already asserts the $8.00 line for the owner and its absence for a reader. The new file adds the app the owner can't write, the guest, the singular case and the link check.

Closes #6874

commented

I added test/apps-cost-line.test.ts, which pins the cost line on /apps. It found no hole, so no code changed. bun x tsc --noEmit, the new test (3 pass) and bun test test/mcp-size.test.ts (2 pass) all pass.

The fixture has an owner with two apps and a third app owned by someone else. One of the owner's apps is paused at its ceiling: $6 spent against a $5 ceiling. The other costs $2 and has no autonomy. The other owner's app costs $3.50.

  • Owner: /apps reads $8.00 spent today across 2 apps you can write · 1 paused at <a href="/board">their ceiling</a>. The other owner's $3.50 is left out, so the total isn't $11.50.
  • Guest, and a signed-in reader who writes no app: no spent today, no studio-cost element, and no dollar figure anywhere in the HTML.
  • One app: the other owner's /apps reads $3.50 spent today across 1 app you can write · 0 paused, never "1 apps". Its "their ceiling" link goes to /board, which answers 200 to that owner.

Things to know:

  • Admin viewer: an admin can write every app, so the fixture uses a separate admin account only to create the crew agents. The viewers under test are not admins.
  • Wall clock: the test does not read the clock, but costLine calls spentTodayForRepos with its default new Date(). I left that alone because the page passes no now. The test creates its runs at that moment, so a run made just before midnight UTC could fall on the wrong day.
  • Existing coverage: test/studio-search.test.ts already asserts the $8.00 line for the owner and its absence for a reader. The new file adds the app the owner can't write, the guest, the singular case and the link check.
Approved

Test-only pull; the preview /apps answers 200 and the three tests cover the owner sum (excludes the unwritable app), guest/non-writer absence, and the singular case plus the /board link. Security, both-doors and cleanliness checks raise nothing: no production code is touched. Two things I would do next: (1) pass a fixed now into the cost line, or create the runs relative to a pinned clock, so a run made just before 00:00 UTC cannot flake the $8.00 assertion; scout names this risk and the direction asks for tests that never flake. (2) Fold the overlap with test/studio-search.test.ts (it already asserts the $8.00 line and the reader case) so the two files do not drift.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs