Skip to content

Commit 2bb8fca

Browse files
Wenyao Gaoclaude
andcommitted
test(app): pin display withholding parity with MEASURED_POWER_METRIC_KEYS | 测试:前端展示层扣留逻辑与 MEASURED_POWER_METRIC_KEYS 保持一致
Drive rowToAggDataEntry with a power_valid=0 row carrying every key in the shared constant and assert each corresponding output field (and workers) comes back undefined — adding a key to the constant that the frontend forgets to withhold now fails this test. The reverse direction (frontend withholding a key missing from the constant) stays hand-audited, as noted in the test comment. 以携带共享常量中全部键的 power_valid=0 行驱动 rowToAggDataEntry,断言 对应输出字段(含 workers)均为 undefined —— 若向常量新增了前端未扣留的 键,此测试即失败。反向情况(前端扣留了常量之外的键)仍由人工审计,测试 注释中已注明。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 46b85cd commit 2bb8fca

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎packages/app/src/lib/benchmark-transform.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { MEASURED_POWER_METRIC_KEYS } from '@semianalysisai/inferencex-constants';
12
import { describe, it, expect, vi } from 'vitest';
23

34
import { getPointLabel } from '@/components/inference/utils/tooltipUtils';
@@ -424,6 +425,28 @@ describe('rowToAggDataEntry', () => {
424425
expect(point.measuredPowerPercentTdp).toBeUndefined();
425426
});
426427

428+
it('withholds every MEASURED_POWER_METRIC_KEYS field when power_valid=0 (ETL parity)', () => {
429+
// Parity with the ingest scrub (benchmark-mapper.ts
430+
// scrubWithheldPowerMetrics): the shared constant is the single source of
431+
// truth for the withheld set, so a key added there without a matching
432+
// display-layer withholding fails here. The reverse direction — the
433+
// display layer withholding a key missing from the constant — stays
434+
// hand-audited.
435+
const metrics: BenchmarkRow['metrics'] = { power_valid: 0 };
436+
for (const key of MEASURED_POWER_METRIC_KEYS) metrics[key] = 123.45;
437+
const entry = rowToAggDataEntry(
438+
makeRow({
439+
metrics,
440+
workers: [{ role: 'agg', worker_idx: 0, num_gpus: 8, avg_power_w: 123.45 }],
441+
}),
442+
);
443+
444+
for (const key of MEASURED_POWER_METRIC_KEYS) {
445+
expect((entry as unknown as Record<string, unknown>)[key]).toBeUndefined();
446+
}
447+
expect(entry.workers).toBeUndefined();
448+
});
449+
427450
it('keeps measured telemetry compatible when a legacy row omits power_valid', () => {
428451
const workers = [{ role: 'agg', worker_idx: 0, num_gpus: 8, avg_power_w: 560 }];
429452
const row = makeRow({

0 commit comments

Comments
 (0)