|
- // Report-only evidence rules. These functions do not run the application.
- export function resolveBrowserProof(proof, rows) {
- if (!proof.testTitle) return { ...proof }
- const candidates = rows.filter(row => row.title === proof.testTitle || row.rawTitle === proof.testTitle)
- if (candidates.length !== 1) return { ...proof, status: 'PENDING', verificationNote: candidates.length ? '同名测试不唯一,不能推断关联。' : '当前 results.json 没有此测试,旧证据不计入。' }
- const test = candidates[0]
- if (test.status !== 'PASS') return { ...proof, status: test.status, verificationNote: '当前 results.json 对应用例未通过;定向重跑不能覆盖此轮失败。' }
- const recorded = Date.parse(proof.recordedAt), started = Date.parse(test.startTime)
- const duration = Number(test.duration)
- if (!Number.isFinite(recorded) || !Number.isFinite(started) || !Number.isFinite(duration)
- || recorded < started - 2000 || recorded > started + duration + 2000) {
- return { ...proof, status: 'PENDING', verificationNote: '证据时间不在当前测试的执行范围内,需核对是否属于预跑/重跑。' }
- }
- return { ...proof }
- }
-
- export function screenshotProofStatus(associations) {
- if (!associations.length) return 'PENDING'
- if (associations.some(item => item.status === 'FAIL')) return 'FAIL'
- if (associations.some(item => item.status === 'WARN')) return 'WARN'
- return associations.every(item => item.status === 'PASS' && item.hashMatches === true) ? 'PASS' : 'PENDING'
- }
|