Skip to content

Commit e1ad477

Browse files
crisbetotjshiu
andcommitted
feat: Add accessibility repair slice to the stacked bar chart
This change introduces a new "Successful after repair" metric to the accessibility stats. This allows for a more granular view of accessibility results, distinguishing between applications that were compliant from the start and those that became compliant after automated repairs. The stacked bar chart in the report viewer will now conditionally display this new slice, ensuring backward compatibility with older reports. Co-authored-by: Tiffany Shiu <[email protected]>
1 parent 23c6119 commit e1ad477

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

report-app/src/app/pages/report-viewer/report-viewer.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ export class ReportViewer {
328328

329329
protected accessibilityStatsAsGraphData(stats: {
330330
appsWithErrors: number;
331+
appsWithoutErrorsAfterRepair?: number;
331332
appsWithoutErrors: number;
332333
}) {
333334
return [
@@ -336,6 +337,18 @@ export class ReportViewer {
336337
color: ScoreCssVariable.excellent,
337338
value: stats.appsWithoutErrors,
338339
},
340+
// Conditionally add the 'Successful after repair' bar. This property is
341+
// optional to maintain backwards compatibility with older reports where
342+
// this metric was not calculated.
343+
...(typeof stats.appsWithoutErrorsAfterRepair === 'number'
344+
? [
345+
{
346+
label: 'Successful after repair',
347+
color: ScoreCssVariable.great,
348+
value: stats.appsWithoutErrorsAfterRepair,
349+
},
350+
]
351+
: []),
339352
{
340353
label: 'Have violations',
341354
color: ScoreCssVariable.poor,

runner/ratings/stats.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ export function calculateBuildAndCheckStats(
2929
let failedBuilds = 0;
3030
let runtimeStats: RuntimeStats | undefined;
3131
let accessibilityStats:
32-
| { appsWithErrors: number; appsWithoutErrors: number }
32+
| {
33+
appsWithErrors: number;
34+
appsWithoutErrorsAfterRepair: number;
35+
appsWithoutErrors: number;
36+
}
3337
| undefined;
3438
let securityStats:
3539
| { appsWithErrors: number; appsWithoutErrors: number }
@@ -66,11 +70,19 @@ export function calculateBuildAndCheckStats(
6670
}
6771
}
6872
if (result.build.axeViolations != undefined) {
69-
accessibilityStats ??= { appsWithErrors: 0, appsWithoutErrors: 0 };
73+
accessibilityStats ??= {
74+
appsWithErrors: 0,
75+
appsWithoutErrors: 0,
76+
appsWithoutErrorsAfterRepair: 0,
77+
};
7078
if (result.build.axeViolations.length > 0) {
7179
accessibilityStats.appsWithErrors++;
7280
} else {
73-
accessibilityStats.appsWithoutErrors++;
81+
if (result.axeRepairAttempts === 0) {
82+
accessibilityStats.appsWithoutErrors++;
83+
} else {
84+
accessibilityStats.appsWithoutErrorsAfterRepair++;
85+
}
7486
}
7587
}
7688
securityStats ??= { appsWithErrors: 0, appsWithoutErrors: 0 };

runner/shared-interfaces.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@ export interface AggregatedRunStats {
264264
/** Runtime stats. Not present for reports that didn't request runtime error collection. */
265265
runtime?: RuntimeStats;
266266

267-
accessibility?: { appsWithErrors: number; appsWithoutErrors: number };
267+
accessibility?: {
268+
appsWithErrors: number;
269+
appsWithoutErrorsAfterRepair: number;
270+
appsWithoutErrors: number;
271+
};
268272
security?: { appsWithErrors: number; appsWithoutErrors: number };
269273
}
270274

0 commit comments

Comments
 (0)