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.
54 lines
2.7 KiB
TypeScript
54 lines
2.7 KiB
TypeScript
import { createElement as h } from 'react'
|
|
import assert from 'node:assert/strict'
|
|
import { describe, test } from 'vitest'
|
|
import { makeCurrentComposition } from '../../../src/client/components/currentComposition'
|
|
import { makeLegend, makeStackedBar } from '../../../src/client/components/stackedBar'
|
|
import type { Headline } from '../../../src/client/headline'
|
|
import { hover, makeKit, mount, query, queryAll, text } from '../helpers/kit'
|
|
|
|
const kit = makeKit()
|
|
const CurrentComposition = makeCurrentComposition(kit, makeStackedBar(kit), makeLegend(kit))
|
|
|
|
const PARTS = [{ key: 'user', color: '#123456', value: 5000 }]
|
|
|
|
function headOf(over: Partial<Headline> = {}): Headline {
|
|
return { tokens: 5000, pct: null, parts: PARTS, ...over }
|
|
}
|
|
|
|
describe('CurrentComposition header', () => {
|
|
test('windowed head: tokens/window figure, used percentage, reserve band, subtitle', async () => {
|
|
const m = await mount(h(CurrentComposition, {
|
|
head: headOf({ window: 10000, pct: 50.4 }),
|
|
subtitle: 'deepseek-v4-flash',
|
|
}))
|
|
assert.ok(text(m.container).includes('Current Context'))
|
|
assert.equal(query(m.container, '.lc-card-sub').textContent, 'deepseek-v4-flash')
|
|
const num = query(m.container, '.lc-overview-num')
|
|
assert.ok(text(num).includes('5.0k / 10.0k tokens'))
|
|
// The reading keeps one decimal, a whole tenth included (headline.ts).
|
|
assert.equal(query(num, '.lc-overview-pct b').textContent, '50.4%')
|
|
await m.update(h(CurrentComposition, { head: headOf({ window: 10000, pct: 50 }) }))
|
|
assert.equal(query(num, '.lc-overview-pct b').textContent, '50.0%')
|
|
assert.ok(text(num).includes('of context used'))
|
|
// The reserve band mirrors the 80% auto-compaction threshold.
|
|
const band = query(m.container, '.lc-reserve')
|
|
await hover(band)
|
|
const tip = query(m.container, '.lc-bar-tip')
|
|
assert.ok(tip.textContent!.includes('Auto-compaction reserve'))
|
|
assert.ok(tip.textContent!.includes('80%'))
|
|
await m.unmount()
|
|
})
|
|
|
|
test('windowless head: estimate label, no percentage, no reserve, no subtitle', async () => {
|
|
const m = await mount(h(CurrentComposition, { head: headOf() }))
|
|
assert.ok(text(m.container).includes('tokens (estimated)'))
|
|
assert.equal(queryAll(m.container, '.lc-overview-pct').length, 0)
|
|
assert.equal(queryAll(m.container, '.lc-reserve').length, 0)
|
|
assert.equal(queryAll(m.container, '.lc-card-sub').length, 0)
|
|
await m.update(h(CurrentComposition, { head: headOf({ window: 0 }), subtitle: '' }))
|
|
assert.equal(queryAll(m.container, '.lc-card-sub').length, 0)
|
|
assert.equal(queryAll(m.container, '.lc-reserve').length, 0)
|
|
assert.ok(text(m.container).includes('tokens (estimated)'))
|
|
await m.unmount()
|
|
})
|
|
}) |