Skip to content

Commit

Permalink
feat: Добавлен вывод длительности тестов в Slack уведомлении
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitive authored and qtm committed Jan 28, 2022
1 parent 52649f0 commit e1f5ba1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion modules/tools/upload-allure-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,24 @@ function formatPercentage(num) {
return (num * 100).toFixed(2).replace('.', ',')
}

function formatDuration(ms) {
const totalSeconds = Math.floor(ms / 1000)
const totalMinutes = Math.floor(totalSeconds / 60)
const totalHours = Math.floor(totalMinutes / 60)

const hours = totalHours
const minutes = totalMinutes - totalHours * 60
const seconds = totalSeconds - totalMinutes * 60

return [
hours && `${hours} hours`,
minutes && `${minutes} minutes`,
seconds && `${seconds} seconds`,
]
.filter(Boolean)
.join(' ')
}

async function main() {
const envHash = await getEnvHash()
const s3Prefix =
Expand Down Expand Up @@ -228,13 +246,15 @@ async function main() {
const passedPercentage = s.passed / (s.total - s.skipped)
const failedPercentage = 1 - passedPercentage
const summaryText = [
`*Summary*: ${formatPercentage(passedPercentage)}% of tests passed`,
`*Summary:* ${formatPercentage(passedPercentage)}% of tests passed`,
`Total: ${s.total}`,
`Passed: ${s.passed}`,
`Failed: ${s.failed}`,
`Skipped: ${s.skipped}`,
`Broken: ${s.broken}`,
`Unknown: ${s.unknown}`,
'',
`*Duration:* ${formatDuration(summaryData.time.duration)}`,
].join('\n')

const reportLink = `https://test-reports.csssr.com/r/${htmlReportID}`
Expand Down

0 comments on commit e1f5ba1

Please sign in to comment.