Skip to content

Commit 79b9906

Browse files
feat: enhance accessibility scan report with issue count and pagination details (#45)
1 parent b376a26 commit 79b9906

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/tools/accessibility.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,19 @@ async function runAccessibilityScan(
4848
// Fetch CSV report link
4949
const reportLink = await reportFetcher.getReportLink(scanId, scanRunId);
5050

51-
const { records } = await parseAccessibilityReportFromCSV(reportLink);
51+
const { records, page_length, total_issues } =
52+
await parseAccessibilityReportFromCSV(reportLink);
5253

5354
return {
5455
content: [
5556
{
5657
type: "text",
5758
text: `✅ Accessibility scan "${name}" completed. check the BrowserStack dashboard for more details [https://scanner.browserstack.com/site-scanner/scan-details/${name}].`,
5859
},
60+
{
61+
type: "text",
62+
text: `We found ${total_issues} issues. Below are the details of the ${page_length} most critical issues.`,
63+
},
5964
{
6065
type: "text",
6166
text: `Scan results: ${JSON.stringify(records, null, 2)}`,

src/tools/accessiblity-utils/report-parser.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ type PaginationOptions = {
2020
type PaginatedResult = {
2121
records: SimplifiedAccessibilityIssue[];
2222
/** Character offset for the next page, or null if done */
23+
page_length: number;
24+
total_issues: number;
2325
next_page: number | null;
2426
};
2527

@@ -43,6 +45,8 @@ export async function parseAccessibilityReportFromCSV(
4345
severity: (row["Severity"] || "unknown").trim(),
4446
}));
4547

48+
const totalIssues = all.length;
49+
4650
// 2) Sort by severity
4751
const order: Record<string, number> = {
4852
critical: 0,
@@ -70,9 +74,13 @@ export async function parseAccessibilityReportFromCSV(
7074
charCursor += recStr.length;
7175
}
7276

73-
const hasMore = idx + page.length < all.length;
77+
const pageLength = page.length;
78+
79+
const hasMore = idx + pageLength < totalIssues;
7480
return {
7581
records: page,
7682
next_page: hasMore ? charCursor : null,
83+
page_length: pageLength,
84+
total_issues: totalIssues,
7785
};
7886
}

0 commit comments

Comments
 (0)