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

A test pins /system's sizes, spans and sparkline, and a reading outside 0–100 or not a number still draws one block #6889

Merged opened this

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

Merged

I added `test/system-format.test.ts` and made one code change, to `spark` in `src/system/format.ts`, because the test found a hole there. `test/system-format.test.ts` and `test/mcp-size.test.ts` passed on the first run except one spark expectation of mine. I fixed that and re-ran only `test/system-format.test.ts`, which passes. The first push went up with that failing expectation and the second pu…

shipped production is serving it deploy c3de1ab

opened this

I added test/system-format.test.ts and made one code change, to spark in src/system/format.ts, because the test found a hole there. test/system-format.test.ts and test/mcp-size.test.ts passed on the first run except one spark expectation of mine. I fixed that and re-ran only test/system-format.test.ts, which passes. The first push went up with that failing expectation and the second push corrected it. I did not re-run bun x tsc --noEmit after the fix. Its output scrolled past on the first run, so I don't have a reading of it.

  • bytes: checked at 0 B, 1023 B, 1.0 KiB (1024), 10 KiB and 1.5 GiB.
  • span: checked at 89s, 2m (120), 90m (5399) and 2d (172800).
  • spark test: one block per reading, below 0 gives the lowest block and above 100 the highest, and an empty history gives an empty string.
  • plural: checked for 1 comment, 0 comments, and an irregular plural (1 person, 2 people).
  • The hole in spark: it used to drop a NaN reading, which shifted the rest of the history left. I tested the NaN case and then fixed spark to draw NaN, Infinity and -Infinity as the lowest block (▁). The same one-block-per-reading test now fails without that fix.
  • My own test slip: my first draft expected a reading of 10 to draw ▂. It draws ▁, since floor(0.8) is 0, so the expectation was wrong and I changed the reading to 20.

How to try it: bun test test/system-format.test.ts.

Closes #6876

commented

I added test/system-format.test.ts and made one code change, to spark in src/system/format.ts, because the test found a hole there. test/system-format.test.ts and test/mcp-size.test.ts passed on the first run except one spark expectation of mine. I fixed that and re-ran only test/system-format.test.ts, which passes. The first push went up with that failing expectation and the second push corrected it. I did not re-run bun x tsc --noEmit after the fix. Its output scrolled past on the first run, so I don't have a reading of it.

  • bytes: checked at 0 B, 1023 B, 1.0 KiB (1024), 10 KiB and 1.5 GiB.
  • span: checked at 89s, 2m (120), 90m (5399) and 2d (172800).
  • spark test: one block per reading, below 0 gives the lowest block and above 100 the highest, and an empty history gives an empty string.
  • plural: checked for 1 comment, 0 comments, and an irregular plural (1 person, 2 people).
  • The hole in spark: it used to drop a NaN reading, which shifted the rest of the history left. I tested the NaN case and then fixed spark to draw NaN, Infinity and -Infinity as the lowest block (▁). The same one-block-per-reading test now fails without that fix.
  • My own test slip: my first draft expected a reading of 10 to draw ▂. It draws ▁, since floor(0.8) is 0, so the expectation was wrong and I changed the reading to 20.

How to try it: bun test test/system-format.test.ts.

Approved

Approved. At head b91831a, bun test ./test/system-format.test.ts passes 4/4 and bun x tsc --noEmit is clean. I put back main's src/system/format.ts and the spark test failed: BLOCKS[NaN] is undefined and join drops it, so the history shifted left. The fix is a small Number.isFinite guard in the shared formatter, so the web page (src/web/pages/system.ts:118) and the terminal (src/tui/screens/system.ts:55) both get it. The preview is up: / answers 200, and /system sends a guest to /signin?next=%2Fsystem with the CSP header in place. That gate is the same as before. Nothing changes for security: there are no inputs, writes or dependencies. One non-blocking note is inline.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs