From 4aec7804e0f8dd7fc8badd8f7e8a7e4671f54d29 Mon Sep 17 00:00:00 2001 From: garrytan Date: Thu, 29 Oct 2026 04:45:28 +0000 Subject: [PATCH] test: recordE2E writes cost_case_id only for a registered label-named case Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- test/paid-report-cost.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/paid-report-cost.test.ts b/test/paid-report-cost.test.ts index 073949b7c..174d8be38 100644 --- a/test/paid-report-cost.test.ts +++ b/test/paid-report-cost.test.ts @@ -11,6 +11,7 @@ import { MODEL_FREE_CASES, caseCost, junitCensus } from '../scripts/lib/paid-rep import { anthropicUsageCostUsd, streamedUsageCostUsd } from '../lib/pricing'; import { E2E_TOUCHFILES } from './helpers/touchfiles-data'; import type { SessionLedgerRow } from './helpers/session-ledger'; +import { recordE2E } from './helpers/e2e-helpers'; const ROOT = path.resolve(import.meta.dir, '..'); const session = (over: Partial): SessionLedgerRow => ({ key: 'k', runner: 'agent-sdk', started_at: 't', elapsed_ms: 1, end: 'aborted', ...over }); @@ -68,6 +69,23 @@ describe('caseCost', () => { }); }); +describe('recordE2E cost_case_id', () => { + const entry = (name: string, testName?: string) => { + const tests: any[] = []; + const result: any = { toolCalls: [], browseErrors: [], exitReason: 'success', duration: 1, output: '', transcript: [], model: 'claude-opus-5-5', + costEstimate: { estimatedCost: 0.05, turnsUsed: 1, estimatedTokens: 1 }, ...(testName ? { testName } : {}) }; + recordE2E({ addTest: (t: any) => tests.push(t) } as any, name, 'suite', result); + return tests[0]; + }; + + test('a display-label record carries its registered runSkillTest testName as cost_case_id, and nothing else does', () => { + expect(entry('browse basic commands', 'browse-basic')).toMatchObject({ name: 'browse basic commands', cost_case_id: 'browse-basic' }); + expect(entry('browse-basic', 'browse-basic').cost_case_id).toBeUndefined(); + expect(entry('browse basic commands', 'not-a-registered-case').cost_case_id).toBeUndefined(); + expect(entry('browse basic commands').cost_case_id).toBeUndefined(); + }); +}); + describe('junitCensus cost binding', () => { const key = 'test/skill-e2e-bws.test.ts'; const census = (records: any[], ledger: SessionLedgerRow[] = []) => {