Files
loki/scripts/test/display-formatters.ts
22a3bedd10 feat(projects): one row shape for every project, one section chrome for the profile (#338)
The list page bifurcated on a boolean: a flagged project rendered as a fat
two-column card, everything else as a bare 44px line — the same object with
two incompatible looks, under section headings that only appeared
conditionally, with a caveat paragraph shipped as UI copy to explain the
grouping. Now every project renders through ProjectRow: identity + badges,
one context line, and a quiet meta column answering the question the page
could not answer at all before — what moved.

List page:
- ProjectGridCard + ProjectListRow collapse into ProjectRow; the shared row
  type moves to project-grid-row.ts. Dead .ui-projects-card* CSS removed, and
  the twice-hand-composed negative/warning badge recipes become
  ui-projects-badge-negative / -warning.
- New recency + open-feedback signals per row (getProjectsLastDispatch reads
  prompt_history through the smoke-marker filter, so probe traffic can't make
  an idle project look active; feedback counts reuse listFeedbackSummary).
- Flagged projects can never be folded below the 'Show all' line.
- A user with zero projects is told to create one instead of to clear filters
  they never set.

Project profile:
- The jump nav indexed 4 of ~8 sections; it now indexes the whole page, with
  owner-only anchors filtered for readonly viewers.
- Header buttons drop to one ghost tier — they are destinations, not actions,
  and five look-alike secondary buttons hid the page's real CTA.
- One section chrome: ui-project-section replaces the hairline recipe that
  was repeated verbatim in four files.
- Feedback moves above the historical activity log (inbound work outranks the
  past), and funding moves down into Activity as evidence — rendered only
  when money actually arrived, via a shared formatBtc that no longer prints a
  bare '0' under a 'Confirmed on OrangeCat' headline.
- Uncurated attributes stop printing raw snake_case DB keys at the reader
  (humanizeAttrKey, SSOT in project-attrs.ts).
- The three 34px-tall Fix / Run next step buttons the repo's own audit flagged
  now meet the 44px touch floor.

Both formatters are unit-tested (scripts/test/display-formatters.ts).

Co-authored-by: t <t@t.t>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 15:43:36 +00:00

29 lines
1.4 KiB
TypeScript

// Formatters that each fixed a real "the UI printed raw data at me" bug.
// Both had grown ad-hoc copies in components before being centralised.
import assert from "node:assert/strict";
import { formatBtc } from "../../src/lib/format";
import { humanizeAttrKey } from "../../src/config/project-attrs";
// THE regression pin: trimming every trailing zero off "0.00000000" leaves an
// empty string, so the project profile printed a bare `0` under a "Confirmed
// on OrangeCat" headline.
assert.equal(formatBtc(0), "0");
assert.equal(formatBtc(1.5), "1.5");
assert.equal(formatBtc(0.0021), "0.0021");
assert.equal(formatBtc(0.00000001), "0.00000001");
// Below one satoshi must not round down into a confident zero.
assert.equal(formatBtc(0.000000001), "<0.00000001");
assert.equal(formatBtc(Number.NaN), "—");
// Raw snake_case keys were rendered as labels ("production url", "gtm").
assert.equal(humanizeAttrKey("production_url"), "Production URL");
assert.equal(humanizeAttrKey("gtm"), "GTM");
assert.equal(humanizeAttrKey("next_step"), "Next step");
assert.equal(humanizeAttrKey("orangecat_profile"), "OrangeCat profile");
assert.equal(humanizeAttrKey("github"), "GitHub");
// Unknown keys still degrade to sentence case rather than shouting or mush.
assert.equal(humanizeAttrKey("some_new_field"), "Some new field");
assert.equal(humanizeAttrKey(""), "");
console.log("✓ display formatter tests passed");