Skip to content

Commit

Permalink
don't round to 0 or 100 for percents
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRyanSmith committed May 27, 2022
1 parent ba54a54 commit 2994e3c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions webapp/views/wpt-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,18 @@ class WPTResults extends AmendMetadataMixin(Pluralizer(WPTColors(WPTFlags(PathIn
if (passes === total) {
return '100%';
}

const percent = parseFloat(passes / total * 100).toFixed(1);
// If there are passing tests, but not enough to register 1/10 of 1%,
// show 0.1% rather than 0.0% to differentiate between possible error states.
if (percent < 0.1) {
return '0.1%';
}
// If almost every test is passing, but there are some failures,
// don't round up to 100% so that it's clear some failure exists.
if (percent > 99.9) {
return '99.9%';
}
return `${percent}%`;
}

Expand Down

0 comments on commit 2994e3c

Please sign in to comment.