Apply the AGENTS.md comments guideline to every .ts under tests/: remove what the code already expresses, keep only what it cannot. Removed: spec-header coverage inventories the describe/test tree already names; comments restating the next line's assertion or its message; helper JSDoc whose body already says it; within-file duplicates; five stale claims (trendChart's "six aggregated turns" against agg.length === 8, agentGraph's "six categories" against CATS' seven, fold-timing's "cheapest call LAST" against a loop that feeds it first, fold-surface's unreachable plain-JSON note, contextView's "two turns" for a one-turn fixture). Kept and condensed: the projection-freeze class, strict wire/state-schema hazards, retention and pricing windows, pairing rules, hostile-input rationale, fixture and expectation-array ground truth, jsdom mechanics, and issue-numbered regressions. Comment lines 2604 -> 2014 (-22%); 85 module headers kept, 30 coverage inventories dropped; every surviving comment line is within the 140-column limit, with 36 wrapped lines joined onto fuller ones. No logic, string, identifier, import or directive changed: a comment-strip gate proves each file's comment-free code is byte-identical to HEAD, and a line-level proof pairs all 845 changed lines with an unchanged code part. pnpm run lint && pnpm run test (106 files / 2061 tests, per-file 100% coverage) && pnpm run build all pass.
39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
// The view kit (src/client/viewkit.ts): the dependency bag's translate/format helpers and event-text delegates.
|
|
// Full event-text coverage lives in the events spec — here only one delegation spot-check.
|
|
|
|
import assert from 'node:assert/strict'
|
|
import { describe, test } from 'vitest'
|
|
import { fmt, fmtTime } from '../../src/client/format'
|
|
import { DICT_EN } from '../../src/client/i18n'
|
|
import { makeViewKit } from '../../src/client/viewkit'
|
|
import type { ContextEventRecord } from '../../src/shared/types'
|
|
import { makeKit, makeTranslate } from './helpers/kit'
|
|
|
|
describe('makeViewKit', () => {
|
|
test('exposes t, fmt, and fmtTime', () => {
|
|
const t = makeTranslate()
|
|
const kit = makeViewKit(t)
|
|
assert.equal(kit.t, t)
|
|
assert.equal(kit.fmt, fmt)
|
|
assert.equal(kit.fmtTime, fmtTime)
|
|
})
|
|
|
|
test('catLabel maps through the dictionary', () => {
|
|
const kit = makeKit()
|
|
assert.equal(kit.catLabel('system'), DICT_EN['cat.system'])
|
|
assert.equal(kit.catLabel('tool'), DICT_EN['cat.tool'])
|
|
})
|
|
|
|
test('eventLabel delegates to makeEventText (compaction with a count)', () => {
|
|
const kit = makeKit()
|
|
const ev: ContextEventRecord = { seq: 1, time: 1000, kind: 'compaction', count: 3, turn: 2, step: 4 }
|
|
assert.equal(kit.eventLabel(ev), DICT_EN['ev.compaction'].replace('{n}', '3'))
|
|
})
|
|
|
|
test('eventAt is null for an event without a turn/step anchor', () => {
|
|
const kit = makeKit()
|
|
const ev: ContextEventRecord = { seq: 2, time: 1000, kind: 'inject', form: 'notice' }
|
|
assert.equal(kit.eventAt(ev), null)
|
|
})
|
|
})
|