From 408bbc1a297437952968d6bc85c2c6ca09614eb6 Mon Sep 17 00:00:00 2001 From: bowenliang123 Date: Thu, 15 Oct 2026 02:51:33 +0800 Subject: [PATCH] test(client): pin the trend detail row anatomy instead of the deleted bar class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code review flagged the two "no mini bar" assertions as a duplicated absent-class check. One anatomy pin per mode now asserts the child sequence a row is made of — dot, label, figure, share — and a mutation test confirmed reintroducing .lc-bar-track anywhere in the row fails both modes. --- tests/client/components/requestDetail.spec.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/client/components/requestDetail.spec.ts b/tests/client/components/requestDetail.spec.ts index 3f6f94d..c3ab918 100644 --- a/tests/client/components/requestDetail.spec.ts +++ b/tests/client/components/requestDetail.spec.ts @@ -23,6 +23,13 @@ function req(over: Partial): RequestRecord { /** Full-category fixture so every row renders a non-zero figure. */ const FULL = { system: 100, tools: 200, user: 300, inject: 50, assistant: 400, tool: 250, total: 1300 } +/** A detail row's anatomy — dot, label, figure, share — by each child's base class (a delta row's figure adds a + * sign modifier). Pinned structurally, so reintroducing a per-row mini bar fails here in either mode, instead of + * passing an absence check on a deleted class. */ +const ROW_ANATOMY = ['', 'lc-detail-label', 'lc-detail-num', 'lc-detail-pct'] +const anatomy = (container: HTMLElement): string[][] => + queryAll(container, '.lc-detail-row').map(r => Array.from(r.children).map(el => el.className.split(' ')[0])) + describe('RequestDetail header', () => { test('null request renders nothing', async () => { const m = await mount(h(RequestDetail, { request: null })) @@ -51,7 +58,7 @@ describe('RequestDetail header', () => { assert.ok(text(rows[0]).includes('≈100')) const pcts = queryAll(m.container, '.lc-detail-pct').map(el => text(el)) assert.ok(pcts.some(p => p.endsWith('%')), 'percentages rendered when total > 0') - assert.equal(queryAll(m.container, '.lc-bar-track').length, 0, 'a row carries figures only, no mini bar') + assert.deepEqual(anatomy(m.container), Array.from({ length: 7 }, () => ROW_ANATOMY)) await m.unmount() }) @@ -156,7 +163,7 @@ describe('RequestDetail delta mode', () => { assert.ok(nums[2].className.includes('lc-detail-num-down')) assert.ok(!nums[1].className.includes('lc-detail-num-up'), 'zero delta is neutral') assert.ok(queryAll(m.container, '.lc-detail-pct').every(el => text(el) === ''), 'no percentages in delta mode') - assert.equal(queryAll(m.container, '.lc-bar-track').length, 0, 'no mini bar in either mode') + assert.deepEqual(anatomy(m.container), Array.from({ length: 7 }, () => ROW_ANATOMY), 'delta rows carry no diverging bar') await m.unmount() })