first commit

This commit is contained in:
baozaotumao2025
2026-07-18 21:10:39 +08:00
commit 1b90e552a5
91 changed files with 9056 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
import { describe, expect, it } from 'vitest'
import { reportSchema } from '../../../src/schemas/reports'
describe('reportSchema', () => {
it('accepts the backend-defined arbitrary report summary', () => {
const result = reportSchema.parse({
run_id: 1,
summary: {
test_result: { passed: 8, failed: 2 },
admission: {
decision: 'NOT_EVALUATED',
coverage: { evaluated: 0, total: 10 },
evidence: ['retired'],
unmet_evidence: ['retired'],
},
missing_metrics: ['retired'],
},
})
expect(result.summary).toMatchObject({
test_result: { passed: 8, failed: 2 },
missing_metrics: ['retired'],
})
})
})
+27
View File
@@ -0,0 +1,27 @@
import { describe, expect, it } from 'vitest'
import { runDetailSchema } from '../../../src/schemas/runs'
const run = {
run_id: 1,
status: 'running',
terminal: false,
phase: 'executing',
selected_count: 10,
processed_count: 5,
completed_count: 4,
error_count: 1,
progress_percent: 50,
current_execution_id: 'R0006',
started_at: '2026-07-17T00:00:00Z',
finished_at: null,
error_message: null,
poll_after_seconds: 2,
summary: {},
}
describe('runDetailSchema', () => {
it('accepts a consistent running task', () => expect(runDetailSchema.safeParse(run).success).toBe(true))
it('rejects inconsistent counters', () => expect(runDetailSchema.safeParse({ ...run, processed_count: 7 }).success).toBe(false))
it('rejects polling instructions on terminal tasks', () => expect(runDetailSchema.safeParse({ ...run, status: 'completed', terminal: true }).success).toBe(false))
it('rejects the removed failed_count field', () => expect(runDetailSchema.safeParse({ ...run, error_count: undefined, failed_count: 1 }).success).toBe(false))
})