Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

23 lignes
1.5 KiB

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