Commit d9facbae authored by rickywiens's avatar rickywiens

Exclude skipped tests in success calculation

- Users expected tests that were skipped to be excluded in the success
  calculations on the frontend.

https://gitlab.com/gitlab-org/gitlab/-/issues/216265
parent d154f922
......@@ -29,7 +29,14 @@ export default {
successPercentage() {
// Returns a full number when the decimals equal .00.
// Otherwise returns a float to two decimal points
return Number(((this.report.success_count / this.report.total_count) * 100 || 0).toFixed(2));
// Do not include skipped tests as part of the total when doing success calculations.
const totalCompletedCount = this.report.total_count - this.report.skipped_count;
if (totalCompletedCount > 0) {
return Number(((this.report.success_count / totalCompletedCount) * 100 || 0).toFixed(2));
}
return 0;
},
formattedDuration() {
return formatTime(secondsToMilliseconds(this.report.total_time));
......
---
title: Changed test success calculation to exclude skipped tests
merge_request: 31154
type: changed
......@@ -82,17 +82,19 @@ describe('Test reports summary', () => {
describe('success percentage calculation', () => {
it.each`
name | successCount | totalCount | result
${'displays 0 when there are no tests'} | ${0} | ${0} | ${'0'}
${'displays whole number when possible'} | ${10} | ${50} | ${'20'}
${'rounds to 0.01'} | ${1} | ${16604} | ${'0.01'}
${'correctly rounds to 50'} | ${8302} | ${16604} | ${'50'}
${'rounds down for large close numbers'} | ${16603} | ${16604} | ${'99.99'}
${'correctly displays 100'} | ${16604} | ${16604} | ${'100'}
`('$name', ({ successCount, totalCount, result }) => {
name | successCount | totalCount | skippedCount | result
${'displays 0 when there are no tests'} | ${0} | ${0} | ${0} | ${'0'}
${'displays whole number when possible'} | ${10} | ${50} | ${0} | ${'20'}
${'excludes skipped tests from total'} | ${10} | ${50} | ${5} | ${'22.22'}
${'rounds to 0.01'} | ${1} | ${16604} | ${0} | ${'0.01'}
${'correctly rounds to 50'} | ${8302} | ${16604} | ${0} | ${'50'}
${'rounds down for large close numbers'} | ${16603} | ${16604} | ${0} | ${'99.99'}
${'correctly displays 100'} | ${16604} | ${16604} | ${0} | ${'100'}
`('$name', ({ successCount, totalCount, skippedCount, result }) => {
createComponent({
report: {
success_count: successCount,
skipped_count: skippedCount,
total_count: totalCount,
},
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment