import assert from 'node:assert/strict' import test from 'node:test' import { resolveBrowserProof, screenshotProofStatus } from './model-editor-report-evidence.mjs' const row = { title: '已保存蓝图', rawTitle: '已保存蓝图', status: 'PASS', startTime: '2026-09-06T07:00:00Z', duration: 10000 } const proof = { testTitle: row.title, status: 'PASS', recordedAt: '2026-09-06T07:00:05Z', kind: 'e2e' } test('本轮同标题且时间落在实际运行内的证据可关联', () => { assert.equal(resolveBrowserProof(proof, [row]).status, 'PASS') }) test('定向重跑成功不得覆盖全量结果中仍然失败的同名用例', () => { assert.equal(resolveBrowserProof({ ...proof, recordedAt: '2026-09-06T08:00:05Z' }, [{ ...row, status: 'FAIL' }]).status, 'FAIL') }) test('同名旧证据、未来重跑证据和没有时间的证据不计本轮通过', () => { for (const recordedAt of ['2026-09-06T06:00:05Z', '2026-09-06T08:00:05Z', undefined]) assert.equal(resolveBrowserProof({ ...proof, recordedAt }, [row]).status, 'PENDING') }) test('不以标题子串或重复同名跨配置结果推定关联', () => { assert.equal(resolveBrowserProof({ ...proof, testTitle: '保存' }, [row]).status, 'PENDING') assert.equal(resolveBrowserProof(proof, [row, { ...row }]).status, 'PENDING') }) test('没有浏览器 testTitle 的单元证据保留自身状态', () => { const unit = { title: 'multi-track unit', status: 'PASS', kind: 'unit' } assert.deepEqual(resolveBrowserProof(unit, []), unit) }) test('截图必须与当前通过用例的正式附件字节一致', () => { assert.equal(screenshotProofStatus([{ status: 'PASS', hashMatches: true }]), 'PASS') assert.equal(screenshotProofStatus([{ status: 'PASS', hashMatches: false }]), 'PENDING') assert.equal(screenshotProofStatus([]), 'PENDING') }) test('失败或不稳定用例截图不因同名重拍而标通过', () => { assert.equal(screenshotProofStatus([{ status: 'FAIL', hashMatches: true }]), 'FAIL') assert.equal(screenshotProofStatus([{ status: 'PASS', hashMatches: true }, { status: 'WARN', hashMatches: true }]), 'WARN') })