diff --git a/capability/app_accessibility.capability-index.json b/capability/app_accessibility.capability-index.json index 4df18d7c..16d64c6b 100644 --- a/capability/app_accessibility.capability-index.json +++ b/capability/app_accessibility.capability-index.json @@ -3,7 +3,7 @@ "version": "1.0", "build_id": "app_accessibility-v1.0-lists", "app_accessibility": { - "summary": "BrowserStack App Accessibility: WCAG accessibility results for mobile apps (Android and iOS), from automated App Automate tests run with accessibility checks on, and from manual App Live sessions scanned with Workflow Analyzer. Find the account's App Accessibility projects, a project's builds, and its manual reports, each with the id, status, app and issue counts needed to pick one. These capabilities list results; they do not read a build's or report's individual issues, compare builds, start tests or scans, or change or delete anything. Websites are covered by a separate product.", + "summary": "BrowserStack App Accessibility: WCAG accessibility results for mobile apps (Android and iOS), from automated App Automate tests run with accessibility checks on, Screen Reader Automation runs, and manual App Live sessions scanned with Workflow Analyzer. Find projects, builds and manual reports; read a build's overview, score trend, tests, issues and WCAG conformance, compare builds, read Screen Reader Automation builds, and read a manual report's details, overview, rules and WCAG levels. Writes, each needing approval: hide, unhide and review issues. Nothing here starts tests or scans or deletes anything; a full issue list for reading comes from fetchAccessibilityIssues. Websites are covered by a separate product.", "routing_terms": [ "app accessibility", "accessibility score", @@ -11,15 +11,24 @@ "mobile accessibility", "workflow analyzer", "manual accessibility report", - "testhub id" + "testhub id", + "app accessibility build overview", + "wcag conformance", + "compare builds", + "screen reader automation", + "talkback", + "voiceover" ], "auth": { "type": "http", "scheme": "basic" }, "base_url": "https://api-app-accessibility.browserstack.com", + "hosts": { "dashboard": "https://app-accessibility.browserstack.com" }, "capabilities": [ { "name": "list_app_accessibility_projects", "method": "GET", "path": "/automate/api/v1/project", + "host": "dashboard", + "auth": { "type": "oauth2" }, "mode": "read", "entity": "project", "query": [ @@ -60,15 +69,17 @@ "paginated": true, "responses": { "200": { "$response": "ListAppAccessibilityProjects" }, - "401": { "$response": "Unauthorized" }, - "403": { "$response": "Forbidden" }, - "500": { "$response": "InternalServerError" } + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "500": { "$response": "DashboardUpstreamFailure" } } }, { "name": "list_app_accessibility_builds", "method": "GET", "path": "/automate/api/v1/project/{project_id}/build", + "host": "dashboard", + "auth": { "type": "oauth2" }, "mode": "read", "entity": "build", "path_params": [ @@ -154,35 +165,2648 @@ "responses": { "200": { "$response": "ListAppAccessibilityBuilds" }, "400": { "$response": "BadRequest" }, - "401": { "$response": "Unauthorized" }, - "403": { "$response": "Forbidden" }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, "404": { "$response": "EmptyList" }, - "500": { "$response": "InternalServerError" } + "500": { "$response": "DashboardUpstreamFailure" } } }, { "name": "list_manual_app_accessibility_reports", "method": "GET", - "path": "/api/v1/reports", + "path": "/api/v1/app_scanner", + "host": "dashboard", + "auth": { "type": "oauth2" }, "mode": "read", "entity": "manual_report", "query": [ { "name": "report_name", "type": "string", - "description": "Keeps reports whose name, app name, app version, package name, or creator's name or email contains this text.", + "description": "Keeps reports whose name, app name, app version, package name or bundle id, or owner's name, username or email contains this text.", "example": "Checkout" }, + { + "name": "os", + "type": "string", + "description": "Keeps reports from devices of these platforms, as a JSON array: [\"android\"], [\"ios\"] or both.", + "example": "[\"android\"]" + }, + { + "name": "created_after", + "type": "string", + "description": "Keeps reports that ended after this date, as a JSON string with its quotes, such as \"2026-01-01\".", + "example": "\"2026-01-01\"" + }, + { + "name": "page", + "type": "integer", + "required": true, + "minimum": 1, + "description": "Page number, from 1. Always send it with page_size: without both the whole list comes back at once, with no info.", + "example": 1 + }, + { + "name": "page_size", + "type": "integer", + "required": true, + "minimum": 1, + "maximum": 100, + "description": "Reports per page, at most 100.", + "example": 20 + } + ], + "intent": "List manual App Accessibility reports (App Live sessions scanned with Workflow Analyzer) newest first, with each report's id, app, device, status and issue counts - use this to find a report QA shared or the latest manual scan of an app.", + "guidance": [ + "report_id is a UUID: the accessibility issue tools read a manual report by it, or by its dashboard link.", + "issues.total is the dashboard's count, duplicates left out; issues.duplicate_issues counts the repeats.", + "info.next is the following page, null on the last.", + "There is no status filter: status is in_progress while the App Live session is still recording.", + "Each row also carries the report's whole test configuration: pass select.fields to keep only what is needed." + ], + "returns": [ + "data.report_id", + "data.report_name", + "data.created_at", + "data.status", + "data.app_details", + "data.device", + "data.issues", + "info.next" + ], + "paginated": true, + "max_page_size": 100, + "narrowable": { + "path": "data", + "fields": [ + "report_id", + "report_name", + "created_at", + "end_time", + "status", + "report_type", + "app_details", + "device", + "user", + "issues", + "snapshots", + "a11y_score" + ], + "note": "Applied after the call, to the page that came back; info.next still pages through the list." + }, + "responses": { + "200": { "$response": "ListManualAppAccessibilityReports" }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "get_app_accessibility_build", + "method": "GET", + "path": "/automate/api/v1/build/{th_build_id}", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "build", + "path_params": [ + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The build's th_build_id (40 characters), from list_app_accessibility_builds or the testhub id the SDK prints.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "intent": "Read one App Accessibility build's header: project, creator, devices, app and framework, SDK version, WCAG version and rule settings, public link state and issue counts.", + "guidance": [ + "meta_data.eligible_rules lists every rule by category with is_selected; it is large, so read it only when the question is which rules ran.", + "meta_data.public_link.isEnabled says whether a shareable report link is on; link is that URL.", + "issue_summary.total is the dashboard's count, duplicates left out; raw_scan_count includes screens later dropped as duplicates." + ], + "returns": [ + "meta_data.th_build_id", + "meta_data.name", + "meta_data.project_name", + "meta_data.created_at", + "meta_data.created_by", + "meta_data.issue_summary", + "meta_data.app_details", + "meta_data.app_framework", + "meta_data.session_data", + "meta_data.wcag_version", + "meta_data.public_link" + ], + "paginated": false, + "responses": { + "200": { + "description": "The build's header.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "meta_data": { + "type": "object", + "properties": { + "build_id": { "type": "integer" }, + "th_build_id": { "type": "string" }, + "name": { "type": "string" }, + "project_name": { "type": "string" }, + "created_at": { "type": "string" }, + "ended_at": { "type": "string" }, + "created_by": { "$schema": "BuildCreator" }, + "public_link": { + "type": "object", + "properties": { + "isEnabled": { "type": "boolean" }, + "link": { "type": "string" } + } + }, + "issue_summary": { "$schema": "IssueSummary" }, + "app_details": { + "type": "object", + "properties": { + "os": { "type": "string" }, + "name": { "type": "string" }, + "version": { "type": "string" }, + "package_name": { "type": "string" }, + "rule_engine_version": { "type": "string" } + } + }, + "app_framework": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "source": { "type": "string" } + } + }, + "session_data": { "type": "object" }, + "wcag_version": { + "type": "array", + "items": { "type": "string" } + }, + "best_practice": { "type": "boolean" }, + "experimental_rules": { "type": "boolean" }, + "eligible_rules": { "type": "object" } + } + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "get_app_accessibility_build_overview", + "method": "GET", + "path": "/automate/api/v1/project/{project_id}/build/{th_build_id}/overview", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "build", + "path_params": [ + { + "name": "project_id", + "type": "integer", + "required": true, + "minimum": 1, + "description": "The project's integer id, from list_app_accessibility_projects.", + "example": 123456 + }, + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The build's th_build_id (40 characters), from list_app_accessibility_builds or the testhub id the SDK prints.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "query": [ + { + "name": "test_case_uuid", + "type": "string", + "description": "Limits the overview to one test, by its uuid from list_app_accessibility_build_tests.", + "example": "57ce30d9-13b5-48aa-bae8-deaa4bc88b36" + }, + { + "name": "device", + "type": "string", + "description": "Limits the counts to devices: one model or several comma-separated, as test_cases.device.model shows.", + "example": "Pixel 8" + } + ], + "intent": "Read an App Accessibility build's overview: issue counts by severity and category, test health, accessibility score with its per-severity breakdown, and the trend over the last same-named builds.", + "guidance": [ + "data.trend_data holds up to the last 10 builds with the same name, each with its own issue_summary, test_health and a11y_score: use it for 'is it getting better'.", + "data.a11y_score.by_severity shows, per severity, how many rules failed and passed and how much each moved the score.", + "data.comparison_widget.available says whether this build can be compared on the dashboard; reason says why not." + ], + "returns": [ + "data.issue_summary", + "data.issue_category", + "data.test_health", + "data.a11y_score", + "data.trend_data", + "data.report_status" + ], + "paginated": false, + "responses": { + "200": { + "description": "The build's overview.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "object", + "properties": { + "th_build_id": { "type": "string" }, + "build_number": { "type": "integer" }, + "issue_summary": { "$schema": "IssueSummary" }, + "issue_category": { + "type": "array", + "items": { + "type": "object", + "properties": { + "category": { "type": "string" }, + "count": { "type": "integer" }, + "design_owned": { "type": "boolean" } + } + }, + "description": "Issue counts per issue category; design_owned marks categories a designer usually fixes." + }, + "test_health": { + "type": "object", + "properties": { + "total_count": { "type": "integer" }, + "failed_count": { "type": "integer" } + } + }, + "a11y_score": { "$schema": "AccessibilityScore" }, + "trend_data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "th_build_id": { "type": "string" }, + "build_number": { "type": "integer" }, + "issue_summary": { "$schema": "IssueSummary" }, + "a11y_score": { "$schema": "AccessibilityScore" } + } + } + }, + "report_status": { "type": "string" }, + "comparison_widget": { + "type": "object", + "properties": { + "available": { "type": "boolean" }, + "reason": { "type": "string" } + } + } + } + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "get_app_accessibility_build_conformance_summary", + "method": "GET", + "path": "/automate/api/v1/build/{th_build_id}/conformance-summary", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "build", + "path_params": [ + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The build's th_build_id (40 characters), from list_app_accessibility_builds or the testhub id the SDK prints.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "query": [ + { + "name": "hide_duplicate_issues", + "type": "boolean", + "description": "true leaves repeats of an issue out of the counts, as the dashboard does by default.", + "example": true + } + ], + "intent": "Read an App Accessibility build's conformance summary: each WCAG success criterion (and RAAM criterion) with the status derived from the build's scans.", + "guidance": [ + "A 404 'Conformance summary is not enabled for this group' means the account does not have this view; it is not a missing build.", + "wcag holds one row per success criterion; scanned_standard is the WCAG version and level the scans used." + ], + "returns": ["scanned_standard", "platform", "wcag", "raam"], + "paginated": false, + "responses": { + "200": { + "description": "The conformance grid.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "scanned_standard": { + "type": "object", + "properties": { + "authority": { "type": "string" }, + "version": { "type": "string" }, + "level": { "type": "string" } + }, + "description": "The standard the scans were run against." + }, + "derivation_basis": { + "type": "object", + "properties": { + "authority": { "type": "string" }, + "version": { "type": "string" }, + "level": { "type": "string" } + } + }, + "platform": { "type": "string" }, + "scans": { "type": "array", "items": { "type": "object" } }, + "wcag": { + "type": "array", + "items": { "type": "object" }, + "description": "One row per WCAG success criterion with its derived status." + }, + "raam": { + "type": "object", + "properties": { + "themes": { + "type": "array", + "items": { "type": "object" } + }, + "criteria": { + "type": "array", + "items": { "type": "object" } + } + }, + "description": "The same results against RAAM (Requirements for Accessible Apps on Mobile)." + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "list_app_accessibility_comparable_builds", + "method": "GET", + "path": "/automate/api/v1/project/{project_id}/build/{th_build_id}/comparable-builds", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "build", + "path_params": [ + { + "name": "project_id", + "type": "integer", + "required": true, + "minimum": 1, + "description": "The project's integer id, from list_app_accessibility_projects.", + "example": 123456 + }, + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The build's th_build_id (40 characters), from list_app_accessibility_builds or the testhub id the SDK prints.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "query": [ + { + "name": "page", + "type": "integer", + "minimum": 1, + "default": 1, + "description": "Page number, from 1." + }, + { + "name": "per_page", + "type": "integer", + "minimum": 1, + "maximum": 50, + "default": 20, + "description": "Rows per page, up to 50." + } + ], + "intent": "List the older builds with the same name that an App Accessibility build can be compared against, each saying whether the comparison is meaningful.", + "guidance": [ + "A 403 'Compare Reports is not enabled for your account' means the plan lacks server-side compare; fetchAccessibilityIssues with compareWith still compares two builds.", + "comparability and comparability_reason say whether the two runs used the same app, WCAG level and standard; pass a comparable th_build_id as base_build_id to compare_app_accessibility_builds." + ], + "returns": [ + "data.current_build", + "data.comparable_builds", + "data.pagination" + ], + "paginated": false, + "responses": { + "200": { + "description": "Builds this one can be compared against.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "object", + "properties": { + "current_build": { "type": "object" }, + "comparable_builds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "th_build_id": { "type": "string" }, + "build_number": { "type": "integer" }, + "created_at": { "type": "string" }, + "comparability": { "type": "string" }, + "comparability_reason": { "type": "string" } + } + } + }, + "pagination": { + "type": "object", + "properties": { + "page": { "type": "integer" }, + "per_page": { "type": "integer" }, + "total": { "type": "integer" } + } + } + } + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "compare_app_accessibility_builds", + "method": "GET", + "path": "/automate/api/v1/project/{project_id}/build/{th_build_id}/compare/{base_build_id}", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "build", + "path_params": [ + { + "name": "project_id", + "type": "integer", + "required": true, + "minimum": 1, + "description": "The project's integer id, from list_app_accessibility_projects.", + "example": 123456 + }, + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The build's th_build_id (40 characters), from list_app_accessibility_builds or the testhub id the SDK prints.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + }, + { + "name": "base_build_id", + "type": "string", + "required": true, + "description": "th_build_id of the older build to compare against, from list_app_accessibility_comparable_builds.", + "example": "q1w2e3r4t5y6u7i8o9p0a1s2d3f4g5h6j7k8l9z0" + } + ], + "query": [ + { + "name": "tab", + "type": "string", + "values": ["summary", "issues"], + "default": "summary", + "description": "summary gives new, retained and resolved counts and a per-test breakdown; issues gives the issue list." + }, + { + "name": "filter", + "type": "string", + "values": ["new", "retained", "resolved"], + "default": "new", + "description": "Issues tab only: which issues to list." + }, + { + "name": "page", + "type": "integer", + "minimum": 1, + "default": 1, + "description": "Issues tab page, from 1." + }, + { + "name": "per_page", + "type": "integer", + "minimum": 1, + "maximum": 50, + "default": 20, + "description": "Issues tab rows per page, up to 50." + } + ], + "intent": "Compare an App Accessibility build with an older one: how many issues are new, retained or resolved, per test, or the list of the new, retained or resolved issues.", + "guidance": [ + "A 202 means the comparison is still being computed; call again in a few seconds.", + "A 403 'Compare Reports is not enabled for your account' means the plan lacks server-side compare; fetchAccessibilityIssues with compareWith still compares two builds.", + "Pick base_build_id from list_app_accessibility_comparable_builds; comparability says whether the two runs can be compared fairly." + ], + "returns": [ + "data.comparability", + "data.summary", + "data.severity_breakdown", + "data.tests", + "data.issues", + "data.pagination" + ], + "paginated": false, + "responses": { + "200": { + "description": "The comparison.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "object", + "properties": { + "comparability": { "type": "string" }, + "comparability_reason": { "type": "string" }, + "warning_message": { "type": "string" }, + "base_run": { "type": "object" }, + "new_run": { "type": "object" }, + "summary": { "type": "object" }, + "severity_breakdown": { "type": "object" }, + "test_health": { "type": "object" }, + "tests": { "type": "array", "items": { "type": "object" } }, + "filter": { "type": "string" }, + "total_count": { "type": "integer" }, + "issues": { + "type": "array", + "items": { "type": "object" } + }, + "pagination": { "type": "object" } + } + } + } + } + }, + "202": { "$response": "CompareInProgress" }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "422": { "$response": "DashboardUnprocessable" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "list_app_accessibility_build_tests", + "method": "GET", + "path": "/automate/api/v1/project/{project_id}/build/{th_build_id}/test", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "test_case", + "path_params": [ + { + "name": "project_id", + "type": "integer", + "required": true, + "minimum": 1, + "description": "The project's integer id, from list_app_accessibility_projects.", + "example": 123456 + }, + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The build's th_build_id (40 characters), from list_app_accessibility_builds or the testhub id the SDK prints.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "query": [ + { + "name": "search", + "type": "string", + "description": "Keeps tests whose name contains this text.", + "example": "login" + }, + { + "name": "test_health", + "type": "string", + "description": "Keeps tests by outcome: passed, failed, skipped or running; several comma-separated. Any other value is refused with 400.", + "example": "failed" + }, + { + "name": "device", + "type": "string", + "description": "Keeps tests run on one device model, as device.model shows.", + "example": "Pixel 8" + }, + { + "name": "page", + "type": "integer", + "minimum": 1, + "default": 1, + "description": "Page number, from 1." + }, + { + "name": "page_size", + "type": "integer", + "minimum": 1, + "default": 30, + "description": "Rows per page." + } + ], + "intent": "List the tests of an App Accessibility build, each with its device, outcome, issue counts and accessibility score - use this to find the tests with the most issues.", + "guidance": [ + "uuid is the test_case_id list_app_accessibility_test_issues takes.", + "issue_summary.total is the dashboard's per-test count, duplicates left out.", + "info.next is the following page, null on the last." + ], + "returns": [ + "test_cases.uuid", + "test_cases.name", + "test_cases.status", + "test_cases.device", + "test_cases.issue_summary", + "test_cases.a11y_score", + "info.next" + ], + "paginated": true, + "responses": { + "200": { + "description": "A page of the build's tests.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "filters": { "type": "object" }, + "test_cases": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { "type": "integer" }, + "uuid": { "type": "string" }, + "name": { "type": "string" }, + "status": { "type": "string" }, + "created_at": { "type": "string" }, + "device": { + "type": "object", + "properties": { + "model": { "type": "string" }, + "display_name": { "type": "string" }, + "os": { "type": "string" }, + "os_version": { "type": "string" } + } + }, + "issue_summary": { "$schema": "IssueSummary" }, + "a11y_score": { "$schema": "AccessibilityScore" } + } + } + }, + "info": { "$schema": "PageInfo" } + } + } + }, + "400": { "$response": "DashboardBadRequest" }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "list_app_accessibility_test_issues", + "method": "GET", + "path": "/automate/api/v1/build/{th_build_id}/test/{test_case_id}/snapshot", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "test_case", + "path_params": [ + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The build's th_build_id (40 characters), from list_app_accessibility_builds or the testhub id the SDK prints.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + }, + { + "name": "test_case_id", + "type": "string", + "required": true, + "description": "The test's uuid, from list_app_accessibility_build_tests (test_cases.uuid).", + "example": "57ce30d9-13b5-48aa-bae8-deaa4bc88b36" + } + ], + "query": [ + { + "name": "severity", + "type": "string", + "description": "Keeps issues of these severities: critical, serious, moderate, minor; several comma-separated.", + "example": "critical,serious" + }, + { + "name": "rules", + "type": "string", + "description": "Keeps issues of these rule ids, comma-separated.", + "example": "text-color-contrast" + }, + { + "name": "hide_duplicate_issues", + "type": "boolean", + "description": "true leaves repeats of an issue out of the counts, as the dashboard does by default.", + "example": true + }, + { + "name": "scanWithIssuesOnly", + "type": "boolean", + "description": "true leaves out screens with no issues." + }, + { + "name": "includeNeedsReviewIndex", + "type": "boolean", + "description": "true adds info.needs_review_index: the screens holding issues that need review." + }, + { + "name": "page", + "type": "integer", + "minimum": 1, + "default": 1, + "description": "Page number, from 1." + }, + { + "name": "page_size", + "type": "integer", + "minimum": 1, + "default": 10, + "description": "Rows per page.", + "maximum": 100 + } + ], + "intent": "List one test's scanned screens in an App Accessibility build, each with its issues grouped by rule - the per-test view of the report.", + "guidance": [ + "Each data.details[] is one screen: meta has the screenshot and device, aggregated_results groups its issues by rule with label, severity, WCAG level and suggestion.", + "For every issue of a whole build at once, use fetchAccessibilityIssues instead.", + "info.next is the following page, null on the last." + ], + "returns": ["data.details", "data.info", "data.test_name"], + "paginated": true, + "responses": { + "200": { + "description": "A page of the test's screens with their issues.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "object", + "properties": { + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "meta": { "type": "object" }, + "aggregated_results": { + "type": "array", + "items": { "type": "object" } + }, + "bounding_boxes": { "type": "object" } + } + } + }, + "info": { "$schema": "PageInfo" }, + "issue_counts": { + "type": "object", + "description": "Issue counts across the test's screens." + }, + "test_name": { "type": "string" }, + "testcase_name": { "type": "string" } + } + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "list_app_accessibility_build_names", + "method": "GET", + "path": "/automate/api/v1/project/{project_id}/build_names", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "project", + "path_params": [ + { + "name": "project_id", + "type": "integer", + "required": true, + "minimum": 1, + "description": "The project's integer id, from list_app_accessibility_projects.", + "example": 123456 + } + ], + "query": [ + { + "name": "name", + "type": "string", + "description": "Keeps build names containing this text.", + "example": "Nightly" + }, + { + "name": "page", + "type": "integer", + "required": true, + "minimum": 1, + "description": "Page number, from 1. Always send it: left out, the route reads page 30 and answers an empty list.", + "example": 1 + }, + { + "name": "page_size", + "type": "integer", + "minimum": 1, + "default": 30, + "description": "Rows per page." + } + ], + "intent": "List the distinct build names in an App Accessibility project, to filter its builds by name.", + "guidance": [ + "Pass one as build_name to list_app_accessibility_builds." + ], + "returns": ["data", "info.next"], + "paginated": true, + "responses": { + "200": { + "description": "Distinct build names.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { "type": "array", "items": { "type": "string" } }, + "info": { "$schema": "PageInfo" } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "list_app_accessibility_bundle_ids", + "method": "GET", + "path": "/automate/api/v1/project/{project_id}/bundle_ids", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "project", + "path_params": [ + { + "name": "project_id", + "type": "integer", + "required": true, + "minimum": 1, + "description": "The project's integer id, from list_app_accessibility_projects.", + "example": 123456 + } + ], + "query": [ + { + "name": "bundle_id", + "type": "string", + "description": "Keeps bundle ids containing this text.", + "example": "com.example" + }, + { + "name": "page", + "type": "integer", + "required": true, + "minimum": 1, + "description": "Page number, from 1. Always send it: left out, the route reads page 30 and answers an empty list.", + "example": 1 + }, + { + "name": "page_size", + "type": "integer", + "minimum": 1, + "default": 30, + "description": "Rows per page." + } + ], + "intent": "List the app bundle ids and package names an App Accessibility project's builds tested, to filter its builds by app.", + "guidance": ["Pass one as bundle_id to list_app_accessibility_builds."], + "returns": ["data", "info.next"], + "paginated": true, + "responses": { + "200": { + "description": "Distinct bundle ids.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { "type": "array", "items": { "type": "string" } }, + "info": { "$schema": "PageInfo" } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "list_app_accessibility_users", + "method": "GET", + "path": "/api/v1/user", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "user", + "query": [ + { + "name": "full_name", + "type": "string", + "description": "Keeps people whose full name contains this text.", + "example": "Priya" + }, + { + "name": "page", + "type": "integer", + "minimum": 1, + "default": 1, + "description": "Page number, from 1." + }, + { + "name": "page_size", + "type": "integer", + "minimum": 1, + "default": 30, + "description": "Rows per page." + } + ], + "intent": "List the people in the account who use App Accessibility, with their ids - use this to filter builds or manual reports by person.", + "guidance": [ + "user_id is the BrowserStack user id list_app_accessibility_builds takes as user_id.", + "info.next is the following page, null on the last." + ], + "returns": [ + "users.id", + "users.user_id", + "users.full_name", + "info.next" + ], + "paginated": true, + "responses": { + "200": { + "description": "A page of the account's users.", + "schema": { + "type": "object", + "properties": { + "status": { "type": "string" }, + "users": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { "type": "integer" }, + "user_id": { "type": "integer" }, + "full_name": { "type": "string" }, + "email": { "type": "string" }, + "group_id": { "type": "integer" } + } + } + }, + "info": { "$schema": "PageInfo" } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "count_manual_app_accessibility_reports", + "method": "GET", + "path": "/api/v1/app_scanner/total", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "manual_report", + "query": [ + { + "name": "report_name", + "type": "string", + "description": "Counts reports whose name, app, package or owner contains this text.", + "example": "Checkout" + } + ], + "intent": "Count the account's manual App Accessibility reports, optionally those matching a name, app or owner.", + "guidance": [ + "To read the reports themselves, use list_manual_app_accessibility_reports." + ], + "returns": ["total_count"], + "paginated": false, + "responses": { + "200": { + "description": "How many reports match.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "total_count": { "type": "integer" } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "list_manual_app_accessibility_devices", + "method": "GET", + "path": "/api/v1/app_scanner/devices", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "manual_report", + "query": [ + { + "name": "model", + "type": "string", + "description": "Keeps one exact device model.", + "example": "Galaxy S24" + } + ], + "intent": "List the devices the account's manual App Accessibility sessions ran on.", + "guidance": ["The list is not paginated."], + "returns": ["devices.model", "devices.os", "devices.version"], + "paginated": false, + "responses": { + "200": { + "description": "Devices used.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "devices": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { "type": "integer" }, + "model": { "type": "string" }, + "version": { "type": "string" }, + "os": { "type": "string" } + } + } + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "get_manual_app_accessibility_report", + "method": "GET", + "path": "/api/v1/app_scanner/{report_id}/meta_data", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "manual_report", + "path_params": [ + { + "name": "report_id", + "type": "string", + "required": true, + "description": "The manual report's UUID, from list_manual_app_accessibility_reports or the report's dashboard link.", + "example": "ce941692-14e0-4ef2-a0f4-198d27684a20" + } + ], + "intent": "Read one manual App Accessibility report's details: name, status, app, device, owner, scan count, test configuration and public link state.", + "guidance": [ + "data.test_configuration.eligible_rules lists every rule by category; it is large, so read it only when the question is which rules ran.", + "status is in_progress while the App Live session is still recording." + ], + "returns": [ + "data.report_name", + "data.status", + "data.created_at", + "data.scan_count", + "data.app_details", + "data.device", + "data.user", + "data.test_configuration" + ], + "paginated": false, + "responses": { + "200": { + "description": "The report's details.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "object", + "properties": { + "report_id": { "type": "string" }, + "report_name": { "type": "string" }, + "session_id": { "type": "string" }, + "session_type": { "type": "string" }, + "status": { "type": "string" }, + "created_at": { "type": "string" }, + "updated_at": { "type": "string" }, + "end_time": { "type": "string" }, + "scan_count": { "type": "integer" }, + "app_details": { + "type": "object", + "properties": { + "os": { "type": "string" }, + "name": { "type": "string" }, + "version": { "type": "string" }, + "package_name": { "type": "string" }, + "rule_engine_version": { "type": "string" } + } + }, + "device": { + "type": "object", + "properties": { + "model": { "type": "string" }, + "os": { "type": "string" }, + "os_version": { "type": "string" } + } + }, + "user": { "$schema": "User" }, + "test_configuration": { + "type": "object", + "properties": { + "best_practice": { "type": "boolean" }, + "wcag_criteria": { + "type": "array", + "items": { "type": "string" } + }, + "eligible_rules": { "type": "object" }, + "experimental_rules": { "type": "boolean" }, + "needs_review_enabled": { "type": "boolean" } + } + } + } + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "get_manual_app_accessibility_report_overview", + "method": "GET", + "path": "/api/v1/app_scanner/{report_id}/overview", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "manual_report", + "path_params": [ + { + "name": "report_id", + "type": "string", + "required": true, + "description": "The manual report's UUID, from list_manual_app_accessibility_reports or the report's dashboard link.", + "example": "ce941692-14e0-4ef2-a0f4-198d27684a20" + } + ], + "intent": "Read a manual App Accessibility report's overview: issue counts by severity and category, and the accessibility score with its per-severity breakdown.", + "guidance": [ + "data.issues.total is the dashboard's count, duplicates left out; hidden_issues and duplicate_issues are counted apart.", + "While the report is in_progress the counts are provisional." + ], + "returns": [ + "data.status", + "data.issues", + "data.issue_by_category", + "data.a11y_score" + ], + "paginated": false, + "responses": { + "200": { + "description": "The report's overview.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "object", + "properties": { + "report_id": { "type": "string" }, + "status": { "type": "string" }, + "issues": { "type": "object" }, + "issue_by_category": { + "type": "array", + "items": { + "type": "object", + "properties": { + "category": { "type": "string" }, + "count": { "type": "integer" }, + "design_owned": { "type": "boolean" } + } + }, + "description": "Issue counts per issue category; design_owned marks categories a designer usually fixes." + }, + "show_deduplication": { "type": "boolean" }, + "a11y_score": { "$schema": "AccessibilityScore" } + } + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "list_manual_app_accessibility_report_rules", + "method": "GET", + "path": "/api/v1/app_scanner/{report_id}/rules", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "manual_report", + "path_params": [ + { + "name": "report_id", + "type": "string", + "required": true, + "description": "The manual report's UUID, from list_manual_app_accessibility_reports or the report's dashboard link.", + "example": "ce941692-14e0-4ef2-a0f4-198d27684a20" + } + ], + "query": [ + { + "name": "hide_duplicate_issues", + "type": "boolean", + "description": "true leaves repeats of an issue out of the counts, as the dashboard does by default.", + "example": true + } + ], + "intent": "List the rules a manual App Accessibility report's issues broke, each with its issue count and WCAG guidelines.", + "guidance": [ + "Every rule the report checked is listed, with issue_count 0 when it found nothing; sort by issue_count for the worst ones.", + "Only failed issues are counted, not needs-review ones.", + "A guideline with an empty version and the message 'Best Practice' is a best-practice rule with no WCAG level." + ], + "returns": [ + "data.rule_id", + "data.label", + "data.category", + "data.issue_count", + "data.guidelines" + ], + "paginated": false, + "responses": { + "200": { + "description": "Rules with issue counts.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "rule_id": { "type": "string" }, + "label": { "type": "string" }, + "category": { "type": "string" }, + "issue_count": { "type": "integer" }, + "guidelines": { + "type": "array", + "items": { "type": "object" } + } + } + } + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "list_manual_app_accessibility_report_wcag_levels", + "method": "GET", + "path": "/api/v1/app_scanner/{report_id}/wcag_levels", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "manual_report", + "path_params": [ + { + "name": "report_id", + "type": "string", + "required": true, + "description": "The manual report's UUID, from list_manual_app_accessibility_reports or the report's dashboard link.", + "example": "ce941692-14e0-4ef2-a0f4-198d27684a20" + } + ], + "query": [ + { + "name": "hide_duplicate_issues", + "type": "boolean", + "description": "true leaves repeats of an issue out of the counts, as the dashboard does by default.", + "example": true + } + ], + "intent": "Count a manual App Accessibility report's issues per WCAG version and level, such as 2.1 AA.", + "guidance": [ + "Only failed issues are counted, not needs-review ones.", + "One issue counts under every WCAG version and level its rule maps to, so the rows do not add up to the report total.", + "A row with an empty version and a null level counts best-practice rules, which map to no WCAG level." + ], + "returns": ["data.label", "data.version", "data.level", "data.count"], + "paginated": false, + "responses": { + "200": { + "description": "Issue counts per WCAG level.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "label": { "type": "string" }, + "value": { "type": "string" }, + "version": { "type": "string" }, + "level": { "type": "string", "nullable": true }, + "count": { "type": "integer" } + } + } + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "get_manual_app_accessibility_report_conformance_summary", + "method": "GET", + "path": "/api/v1/app_scanner/{report_id}/conformance-summary", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "manual_report", + "path_params": [ + { + "name": "report_id", + "type": "string", + "required": true, + "description": "The manual report's UUID, from list_manual_app_accessibility_reports or the report's dashboard link.", + "example": "ce941692-14e0-4ef2-a0f4-198d27684a20" + } + ], + "query": [ + { + "name": "hide_duplicate_issues", + "type": "boolean", + "description": "true leaves repeats of an issue out of the counts, as the dashboard does by default.", + "example": true + } + ], + "intent": "Read a manual App Accessibility report's conformance summary: each WCAG success criterion (and RAAM criterion) with the status derived from its scans.", + "guidance": [ + "A 404 'Conformance summary is not enabled for this group' means the account does not have this view; it is not a missing report.", + "wcag holds one row per success criterion; scanned_standard is the WCAG version and level the scans used." + ], + "returns": ["scanned_standard", "platform", "wcag", "raam"], + "paginated": false, + "responses": { + "200": { + "description": "The conformance grid.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "scanned_standard": { + "type": "object", + "properties": { + "authority": { "type": "string" }, + "version": { "type": "string" }, + "level": { "type": "string" } + }, + "description": "The standard the scans were run against." + }, + "derivation_basis": { + "type": "object", + "properties": { + "authority": { "type": "string" }, + "version": { "type": "string" }, + "level": { "type": "string" } + } + }, + "platform": { "type": "string" }, + "scans": { "type": "array", "items": { "type": "object" } }, + "wcag": { + "type": "array", + "items": { "type": "object" }, + "description": "One row per WCAG success criterion with its derived status." + }, + "raam": { + "type": "object", + "properties": { + "themes": { + "type": "array", + "items": { "type": "object" } + }, + "criteria": { + "type": "array", + "items": { "type": "object" } + } + }, + "description": "The same results against RAAM (Requirements for Accessible Apps on Mobile)." + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "list_app_accessibility_build_issues", + "method": "GET", + "path": "/automate/api/v1/build/{th_build_id}/snapshot", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "build", + "path_params": [ + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The build's th_build_id (40 characters), from list_app_accessibility_builds or the testhub id the SDK prints.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "query": [ + { + "name": "severity", + "type": "string", + "description": "Keeps issues of these severities: critical, serious, moderate, minor; several comma-separated.", + "example": "critical,serious" + }, + { + "name": "rules", + "type": "string", + "description": "Keeps issues of these rule ids, comma-separated.", + "example": "text-color-contrast" + }, + { + "name": "hide_duplicate_issues", + "type": "boolean", + "description": "true leaves repeats of an issue out of the counts, as the dashboard does by default.", + "example": true + }, + { + "name": "scanWithIssuesOnly", + "type": "boolean", + "description": "true leaves out screens with no issues." + }, + { + "name": "includeNeedsReviewIndex", + "type": "boolean", + "description": "true adds info.needs_review_index: the screens holding needs-review issues." + }, + { + "name": "page", + "type": "integer", + "minimum": 1, + "default": 1, + "description": "Page number, from 1." + }, + { + "name": "page_size", + "type": "integer", + "minimum": 1, + "default": 10, + "description": "Rows per page.", + "maximum": 100 + } + ], + "intent": "List an App Accessibility build's scanned screens with each issue's uid, status and screen id - the ids hiding, unhiding or reviewing an issue needs.", + "guidance": [ + "For reading or summarising issues, fetchAccessibilityIssues is simpler; use this when an issue is to be hidden, unhidden or reviewed.", + "details[].meta.snapshot_id is the screen id; aggregated_results[].rule_issues[] carry uid, status and duplication_count.", + "info.next is the following page, null on the last." + ], + "returns": ["data.details", "data.info"], + "paginated": true, + "responses": { + "200": { + "description": "A page of the build's screens with their issues.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "object", + "properties": { + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "meta": { + "type": "object", + "description": "snapshot_id, screenshot_url and the screen's device." + }, + "aggregated_results": { + "type": "array", + "items": { + "type": "object", + "description": "One rule: rule_id, label, severity and rule_issues[] (uid, status, duplication_count)." + } + }, + "bounding_boxes": { "type": "object" } + } + } + }, + "info": { "$schema": "PageInfo" } + } + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "list_manual_app_accessibility_report_issues", + "method": "GET", + "path": "/api/v1/app_scanner/{report_id}/snapshot", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "manual_report", + "path_params": [ + { + "name": "report_id", + "type": "string", + "required": true, + "description": "The manual report's UUID, from list_manual_app_accessibility_reports or the report's dashboard link.", + "example": "ce941692-14e0-4ef2-a0f4-198d27684a20" + } + ], + "query": [ + { + "name": "severity", + "type": "string", + "description": "Keeps issues of these severities, as a JSON array of capitalised names: [\"Critical\",\"Serious\"] (Critical, Serious, Moderate, Minor). Lower case drops every issue; anything but a JSON array is ignored.", + "example": "[\"Critical\",\"Serious\"]" + }, + { + "name": "rules", + "type": "string", + "description": "Keeps issues of these rule ids, as a JSON array: [\"text-color-contrast\"]. Anything but a JSON array is ignored.", + "example": "[\"text-color-contrast\"]" + }, + { + "name": "hide_duplicate_issues", + "type": "boolean", + "description": "true leaves repeats of an issue out of the counts, as the dashboard does by default.", + "example": true + }, + { + "name": "scanWithIssuesOnly", + "type": "boolean", + "description": "true leaves out screens with no issues." + }, + { + "name": "includeNeedsReviewIndex", + "type": "boolean", + "description": "true adds info.needs_review_index: the screens holding needs-review issues." + }, + { + "name": "page", + "type": "integer", + "minimum": 1, + "default": 1, + "description": "Page number, from 1." + }, + { + "name": "page_size", + "type": "integer", + "minimum": 1, + "default": 10, + "description": "Rows per page.", + "maximum": 100 + } + ], + "intent": "List a manual App Accessibility report's scanned screens with each issue's uid, status and screen id - the ids hiding, unhiding or reviewing an issue needs.", + "guidance": [ + "For reading or summarising issues, fetchAccessibilityIssues is simpler; use this when an issue is to be hidden, unhidden or reviewed.", + "details[].meta.snapshot_id is the screen id; aggregated_results[].rule_issues[] carry uid, status and duplication_count.", + "Skip rule_issues that carry duplicated_element_uid or element_snapshot_id: they repeat another issue; act on the original.", + "info.next is the following page, null on the last." + ], + "returns": ["data.details", "data.info"], + "paginated": true, + "responses": { + "200": { + "description": "A page of the report's screens with their issues.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "object", + "properties": { + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "meta": { + "type": "object", + "description": "snapshot_id, screenshot_url and the screen's device." + }, + "aggregated_results": { + "type": "array", + "items": { + "type": "object", + "description": "One rule: rule_id, label, severity and rule_issues[] (uid, status, duplication_count)." + } + }, + "bounding_boxes": { "type": "object" } + } + } + }, + "info": { "$schema": "PageInfo" } + } + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "hide_app_accessibility_issues", + "method": "POST", + "path": "/automate/api/v1/scan/{th_build_id}/hide-issue", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "write", + "entity": "issue", + "path_params": [ + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The build's th_build_id (40 characters), from list_app_accessibility_builds or the testhub id the SDK prints.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "body": [ + { + "name": "hide_level", + "type": "string", + "required": true, + "values": ["issue", "component", "rule"], + "json_path": "/hide_level", + "description": "issue: this issue and its duplicates; component: every issue on this element in this screen; rule: every issue of the rule in the whole report.", + "example": "issue" + }, + { + "name": "reason_code", + "type": "string", + "required": true, + "values": [ + "Not relevant", + "Not a priority", + "Technical challenges", + "False positive", + "Duplicate", + "Others" + ], + "json_path": "/reason_code", + "description": "Why it is hidden: one of the dashboard's six reasons.", + "example": "False positive" + }, + { + "name": "explanation", + "type": "string", + "json_path": "/explanation", + "description": "Free text, required when reason_code is Others.", + "example": "Decorative image, read as part of the card" + }, + { + "name": "rule_id", + "type": "string", + "required": true, + "json_path": "/rule_id", + "description": "The rule's id, aggregated_results[].rule_id of the issue read.", + "example": "text-color-contrast" + }, + { + "name": "uid", + "type": "string", + "json_path": "/uid", + "description": "The issue's uid, rule_issues[].uid. Required for hide_level issue and component.", + "example": "1210624664-9929a318-5969-4626-a2cb-1630c4b09efc_40" + }, + { + "name": "snapshot_id", + "type": "integer", + "json_path": "/snapshot_id", + "description": "The screen's id, details[].meta.snapshot_id. Required for hide_level issue and component.", + "example": 12345 + }, + { + "name": "status", + "type": "string", + "values": ["fail", "needs_review"], + "json_path": "/status", + "description": "The issue's current status, rule_issues[].status.", + "example": "fail" + } + ], + "intent": "Hide accessibility issues in an App Accessibility build at issue, element or rule level, with a reason - the dashboard's Hide issue action. Changes the build's issue counts and score.", + "guidance": [ + "APPROVAL FIRST: before calling, tell the user exactly what will change (which issues are hidden, in which report, and how many issues: for hide_level rule or component, from count_app_accessibility_issues_to_hide; for hide_level issue, the issue and its duplicates, 1 + its rule_issues[].duplication_count from list_app_accessibility_build_issues) and wait for an explicit yes in their own words ('yes', 'go ahead'). A request to make the change, however specific, is not that yes: ask first, and send user_permission granted only after it.", + "Read the ids first: list_app_accessibility_build_issues (or list_app_accessibility_test_issues for one test) gives details[].meta.snapshot_id and, per rule, rule_issues[].uid and .status. fetchAccessibilityIssues does not return them.", + "Ask for the reason by offering exactly the six reason_code values. With Others, ask for an explanation and send it: the dashboard requires one, the backend does not check. 'Not an issue' is a needs-review decision (review_app_accessibility_issue), not a hide reason.", + "Undo is unhide_app_accessibility_issues with the same hide_level, rule_id, uid and snapshot_id.", + "Hides in this build only. A persistent hide that carries into later builds is not available to an agent: the backend refuses it.", + "A 403 that names the owner means this account lets only the build's owner hide its issues.", + "403 AGENT_REPORT_ACTIONS_DISABLED means BrowserStack has switched off agent writes for this user or group. Nothing changed. Tell the user to do it on the App Accessibility dashboard; do not retry, a retry is refused too." + ], + "returns": ["data.message", "data.issue_summary"], + "paginated": false, + "responses": { + "200": { + "description": "Hidden; issue_summary is the build's new counts.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "object", + "properties": { + "message": { "type": "string" }, + "issue_summary": { "$schema": "IssueSummary" } + } + } + } + } + }, + "400": { "$response": "DashboardBadRequest" }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "unhide_app_accessibility_issues", + "method": "POST", + "path": "/automate/api/v1/scan/{th_build_id}/unhide-issue", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "write", + "entity": "issue", + "path_params": [ + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The build's th_build_id (40 characters), from list_app_accessibility_builds or the testhub id the SDK prints.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "body": [ + { + "name": "hide_level", + "type": "string", + "required": true, + "values": ["issue", "component", "rule"], + "json_path": "/hide_level", + "description": "issue: this issue and its duplicates; component: every issue on this element in this screen; rule: every issue of the rule in the whole report.", + "example": "issue" + }, + { + "name": "rule_id", + "type": "string", + "required": true, + "json_path": "/rule_id", + "description": "The rule's id, aggregated_results[].rule_id of the issue read.", + "example": "text-color-contrast" + }, + { + "name": "uid", + "type": "string", + "json_path": "/uid", + "description": "The issue's uid, rule_issues[].uid. Required for hide_level issue and component.", + "example": "1210624664-9929a318-5969-4626-a2cb-1630c4b09efc_40" + }, + { + "name": "snapshot_id", + "type": "integer", + "json_path": "/snapshot_id", + "description": "The screen's id, details[].meta.snapshot_id. Required for hide_level issue and component.", + "example": 12345 + }, + { + "name": "status", + "type": "string", + "json_path": "/status", + "description": "The issue's current status, rule_issues[].status of a hidden issue.", + "example": "hidden_issues" + } + ], + "intent": "Unhide accessibility issues hidden in an App Accessibility build, at issue, element or rule level - undoes hide_app_accessibility_issues.", + "guidance": [ + "APPROVAL FIRST: before calling, tell the user exactly what will change (which hidden issues come back, in which report, and how many issues: for hide_level rule or component, from count_app_accessibility_issues_to_unhide; for hide_level issue, the issue and its duplicates, 1 + its rule_issues[].duplication_count from list_app_accessibility_build_issues) and wait for an explicit yes in their own words ('yes', 'go ahead'). A request to make the change, however specific, is not that yes: ask first, and send user_permission granted only after it.", + "Send the same hide_level, rule_id, uid and snapshot_id the hide used; hidden issues are read from list_app_accessibility_build_issues.", + "Restores issues hidden in this build only.", + "403 AGENT_REPORT_ACTIONS_DISABLED means BrowserStack has switched off agent writes for this user or group. Nothing changed. Tell the user to do it on the App Accessibility dashboard; do not retry, a retry is refused too." + ], + "returns": ["data.message", "data.issue_summary"], + "paginated": false, + "responses": { + "200": { + "description": "Restored; issue_summary is the build's new counts.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "object", + "properties": { + "message": { "type": "string" }, + "issue_summary": { "$schema": "IssueSummary" } + } + } + } + } + }, + "400": { "$response": "DashboardBadRequest" }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "review_app_accessibility_issue", + "method": "POST", + "path": "/automate/api/v1/build/{th_build_id}/review-issue", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "write", + "entity": "issue", + "path_params": [ + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The build's th_build_id (40 characters), from list_app_accessibility_builds or the testhub id the SDK prints.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "body": [ + { + "name": "snapshot_id", + "type": "integer", + "json_path": "/snapshot_id", + "description": "The screen's id, details[].meta.snapshot_id. Required for hide_level issue and component.", + "example": 12345, + "required": true + }, + { + "name": "rule_id", + "type": "string", + "required": true, + "json_path": "/rule_id", + "description": "The rule's id, aggregated_results[].rule_id of the issue read.", + "example": "text-color-contrast" + }, + { + "name": "uid", + "type": "string", + "json_path": "/uid", + "description": "The issue's uid, rule_issues[].uid. Required for hide_level issue and component.", + "example": "1210624664-9929a318-5969-4626-a2cb-1630c4b09efc_40", + "required": true + }, + { + "name": "duplication_count", + "type": "integer", + "json_path": "/duplication_count", + "description": "rule_issues[].duplication_count of the issue; 0 when absent.", + "example": 0 + }, + { + "name": "current_status", + "type": "string", + "required": true, + "values": ["needs_review", "confirmed", "non_issues"], + "json_path": "/current_status", + "description": "The issue's status now, rule_issues[].status.", + "example": "needs_review" + }, + { + "name": "moved_status", + "type": "string", + "required": true, + "values": ["confirmed", "non_issues", "needs_review"], + "json_path": "/moved_status", + "description": "confirmed: it is an issue; non_issues: it is not; needs_review: undo an earlier decision.", + "example": "confirmed" + } + ], + "intent": "Decide one needs-review issue in an App Accessibility build: confirm it as an issue, mark it not an issue, or undo the decision.", + "guidance": [ + "APPROVAL FIRST: before calling, tell the user exactly what will change (which needs-review issue is decided, and to what, in which report, and how many issues, from list_app_accessibility_build_issues with includeNeedsReviewIndex true) and wait for an explicit yes in their own words ('yes', 'go ahead'). A request to make the change, however specific, is not that yes: ask first, and send user_permission granted only after it.", + "Moves one issue: needs_review to confirmed (it is an issue) or to non_issues (it is not), or back to needs_review (undo). Take snapshot_id, rule_id, uid, the current status and duplication_count from list_app_accessibility_build_issues with includeNeedsReviewIndex true.", + "A 403 'Review issue feature is not enabled' means needs-review is off for this build; 'Issue can only be reviewed by author' means only its author may review in this account.", + "Undo is the same call with moved_status needs_review and current_status the status it was moved to.", + "403 AGENT_REPORT_ACTIONS_DISABLED means BrowserStack has switched off agent writes for this user or group. Nothing changed. Tell the user to do it on the App Accessibility dashboard; do not retry, a retry is refused too." + ], + "returns": ["data.message", "data.issue_summary"], + "paginated": false, + "responses": { + "200": { + "description": "Decided; issue_summary is the build's new counts.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "object", + "properties": { + "message": { "type": "string" }, + "issue_summary": { "$schema": "IssueSummary" } + } + } + } + } + }, + "400": { "$response": "DashboardBadRequest" }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "count_app_accessibility_issues_to_hide", + "method": "POST", + "path": "/automate/api/v1/scan/{th_build_id}/get-hide-count", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "issue", + "path_params": [ + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The build's th_build_id (40 characters), from list_app_accessibility_builds or the testhub id the SDK prints.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "body": [ + { + "name": "rule_id", + "type": "string", + "required": true, + "json_path": "/rule_id", + "description": "The rule's id, aggregated_results[].rule_id of the issue read.", + "example": "text-color-contrast" + }, + { + "name": "uid", + "type": "string", + "json_path": "/uid", + "description": "The issue's uid, rule_issues[].uid. Required for hide_level issue and component.", + "example": "1210624664-9929a318-5969-4626-a2cb-1630c4b09efc_40" + }, + { + "name": "snapshot_id", + "type": "integer", + "json_path": "/snapshot_id", + "description": "The screen's id, details[].meta.snapshot_id. Required for hide_level issue and component.", + "example": 12345 + } + ], + "intent": "Count how many issues hiding a rule, or an element, in an App Accessibility build would change - the preview the Hide dialog shows.", + "guidance": [ + "Reads only; use it to say how many issues a hide or unhide would change before asking for approval.", + "hide_rule_count is how many issues the rule-level action would change; hide_component_count how many on this element in this screen." + ], + "returns": ["hide_rule_count", "hide_component_count"], + "paginated": false, + "responses": { + "200": { + "description": "Counts.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "hide_rule_count": { "type": "integer" }, + "hide_component_count": { "type": "integer" } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "count_app_accessibility_issues_to_unhide", + "method": "POST", + "path": "/automate/api/v1/scan/{th_build_id}/get-unhide-count", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "issue", + "path_params": [ + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The build's th_build_id (40 characters), from list_app_accessibility_builds or the testhub id the SDK prints.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "body": [ + { + "name": "rule_id", + "type": "string", + "required": true, + "json_path": "/rule_id", + "description": "The rule's id, aggregated_results[].rule_id of the issue read.", + "example": "text-color-contrast" + }, + { + "name": "uid", + "type": "string", + "json_path": "/uid", + "description": "The issue's uid, rule_issues[].uid. Required for hide_level issue and component.", + "example": "1210624664-9929a318-5969-4626-a2cb-1630c4b09efc_40" + }, + { + "name": "snapshot_id", + "type": "integer", + "json_path": "/snapshot_id", + "description": "The screen's id, details[].meta.snapshot_id. Required for hide_level issue and component.", + "example": 12345 + } + ], + "intent": "Count how many hidden issues unhiding a rule, or an element, in an App Accessibility build would bring back.", + "guidance": [ + "Reads only; use it to say how many issues a hide or unhide would change before asking for approval.", + "hide_rule_count is how many issues the rule-level action would change; hide_component_count how many on this element in this screen." + ], + "returns": ["hide_rule_count", "hide_component_count"], + "paginated": false, + "responses": { + "200": { + "description": "Counts.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "hide_rule_count": { "type": "integer" }, + "hide_component_count": { "type": "integer" } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "hide_manual_app_accessibility_issues", + "method": "POST", + "path": "/api/v1/app_scanner/{report_id}/hide-issue", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "write", + "entity": "issue", + "path_params": [ + { + "name": "report_id", + "type": "string", + "required": true, + "description": "The manual report's UUID, from list_manual_app_accessibility_reports or the report's dashboard link.", + "example": "ce941692-14e0-4ef2-a0f4-198d27684a20" + } + ], + "body": [ + { + "name": "hide_level", + "type": "string", + "required": true, + "values": ["issue", "component", "rule"], + "json_path": "/hide_level", + "description": "issue: this issue and its duplicates; component: every issue on this element in this screen; rule: every issue of the rule in the whole report.", + "example": "issue" + }, + { + "name": "reason_code", + "type": "string", + "required": true, + "values": [ + "Not relevant", + "Not a priority", + "Technical challenges", + "False positive", + "Duplicate", + "Others" + ], + "json_path": "/reason_code", + "description": "Why it is hidden: one of the dashboard's six reasons.", + "example": "False positive" + }, + { + "name": "explanation", + "type": "string", + "json_path": "/explanation", + "description": "Free text, required when reason_code is Others.", + "example": "Decorative image, read as part of the card" + }, + { + "name": "rule_id", + "type": "string", + "required": true, + "json_path": "/rule_id", + "description": "The rule's id, aggregated_results[].rule_id of the issue read.", + "example": "text-color-contrast" + }, + { + "name": "uid", + "type": "string", + "json_path": "/uid", + "description": "The issue's uid, rule_issues[].uid. Required for hide_level issue and component.", + "example": "1210624664-9929a318-5969-4626-a2cb-1630c4b09efc_40" + }, + { + "name": "snapshot_id", + "type": "integer", + "json_path": "/snapshot_id", + "description": "The screen's id, details[].meta.snapshot_id. Required for hide_level issue and component.", + "example": 12345 + }, + { + "name": "status", + "type": "string", + "values": ["fail", "needs_review"], + "json_path": "/status", + "description": "The issue's current status, rule_issues[].status.", + "example": "fail" + } + ], + "intent": "Hide accessibility issues in a manual App Accessibility report at issue, element or rule level, with a reason - the dashboard's Hide issue action. Changes the report's issue counts and score.", + "guidance": [ + "APPROVAL FIRST: before calling, tell the user exactly what will change (which issues are hidden, in which report, and how many issues: for hide_level rule or component, from count_manual_app_accessibility_issues_to_hide; for hide_level issue, the issue and its duplicates, 1 + its rule_issues[].duplication_count from list_manual_app_accessibility_report_issues) and wait for an explicit yes in their own words ('yes', 'go ahead'). A request to make the change, however specific, is not that yes: ask first, and send user_permission granted only after it.", + "Read the ids first: list_manual_app_accessibility_report_issues gives details[].meta.snapshot_id and, per rule, rule_issues[].uid and .status. fetchAccessibilityIssues does not return them.", + "Ask for the reason by offering exactly the six reason_code values. With Others, ask for an explanation and send it: the dashboard requires one, the backend does not check. 'Not an issue' is a needs-review decision (review_manual_app_accessibility_issue), not a hide reason.", + "Undo is unhide_manual_app_accessibility_issues with the same hide_level, rule_id, uid and snapshot_id.", + "Hides in this report only. A persistent hide that carries into later reports is not available to an agent: the backend refuses it.", + "A 403 that names the owner means this account lets only the report's owner hide its issues.", + "403 AGENT_REPORT_ACTIONS_DISABLED means BrowserStack has switched off agent writes for this user or group. Nothing changed. Tell the user to do it on the App Accessibility dashboard; do not retry, a retry is refused too." + ], + "returns": ["affected_count"], + "paginated": false, + "responses": { + "200": { + "description": "Hidden.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "affected_count": { + "description": "How many issues changed; at hide_level component the backend answers the list of rule ids it changed instead." + } + } + } + }, + "400": { "$response": "DashboardBadRequest" }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "unhide_manual_app_accessibility_issues", + "method": "POST", + "path": "/api/v1/app_scanner/{report_id}/unhide-issue", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "write", + "entity": "issue", + "path_params": [ + { + "name": "report_id", + "type": "string", + "required": true, + "description": "The manual report's UUID, from list_manual_app_accessibility_reports or the report's dashboard link.", + "example": "ce941692-14e0-4ef2-a0f4-198d27684a20" + } + ], + "body": [ + { + "name": "hide_level", + "type": "string", + "required": true, + "values": ["issue", "component", "rule"], + "json_path": "/hide_level", + "description": "issue: this issue and its duplicates; component: every issue on this element in this screen; rule: every issue of the rule in the whole report.", + "example": "issue" + }, + { + "name": "rule_id", + "type": "string", + "required": true, + "json_path": "/rule_id", + "description": "The rule's id, aggregated_results[].rule_id of the issue read.", + "example": "text-color-contrast" + }, + { + "name": "uid", + "type": "string", + "json_path": "/uid", + "description": "The issue's uid, rule_issues[].uid. Required for hide_level issue and component.", + "example": "1210624664-9929a318-5969-4626-a2cb-1630c4b09efc_40" + }, + { + "name": "snapshot_id", + "type": "integer", + "json_path": "/snapshot_id", + "description": "The screen's id, details[].meta.snapshot_id. Required for hide_level issue and component.", + "example": 12345 + }, { "name": "status", "type": "string", - "values": ["in_progress", "completed"], - "description": "Keeps reports still being recorded (in_progress) or finished (completed)." + "json_path": "/status", + "description": "The issue's current status, rule_issues[].status of a hidden issue.", + "example": "hidden_issues" + } + ], + "intent": "Unhide accessibility issues hidden in a manual App Accessibility report, at issue, element or rule level - undoes hide_manual_app_accessibility_issues.", + "guidance": [ + "APPROVAL FIRST: before calling, tell the user exactly what will change (which hidden issues come back, in which report, and how many issues: for hide_level rule or component, from count_manual_app_accessibility_issues_to_unhide; for hide_level issue, the issue and its duplicates, 1 + its rule_issues[].duplication_count from list_manual_app_accessibility_report_issues) and wait for an explicit yes in their own words ('yes', 'go ahead'). A request to make the change, however specific, is not that yes: ask first, and send user_permission granted only after it.", + "Send the same hide_level, rule_id, uid and snapshot_id the hide used; hidden issues are read from list_manual_app_accessibility_report_issues.", + "Restores issues hidden in this report only.", + "403 AGENT_REPORT_ACTIONS_DISABLED means BrowserStack has switched off agent writes for this user or group. Nothing changed. Tell the user to do it on the App Accessibility dashboard; do not retry, a retry is refused too." + ], + "returns": ["affected_count"], + "paginated": false, + "responses": { + "200": { + "description": "Restored.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "affected_count": { + "description": "How many issues changed; at hide_level component the backend answers the list of rule ids it changed instead." + } + } + } + }, + "400": { "$response": "DashboardBadRequest" }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "review_manual_app_accessibility_issue", + "method": "POST", + "path": "/api/v1/app_scanner/{report_id}/review-issue", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "write", + "entity": "issue", + "path_params": [ + { + "name": "report_id", + "type": "string", + "required": true, + "description": "The manual report's UUID, from list_manual_app_accessibility_reports or the report's dashboard link.", + "example": "ce941692-14e0-4ef2-a0f4-198d27684a20" + } + ], + "body": [ + { + "name": "snapshot_id", + "type": "integer", + "json_path": "/snapshot_id", + "description": "The screen's id, details[].meta.snapshot_id. Required for hide_level issue and component.", + "example": 12345, + "required": true + }, + { + "name": "rule_id", + "type": "string", + "required": true, + "json_path": "/rule_id", + "description": "The rule's id, aggregated_results[].rule_id of the issue read.", + "example": "text-color-contrast" + }, + { + "name": "uid", + "type": "string", + "json_path": "/uid", + "description": "The issue's uid, rule_issues[].uid. Required for hide_level issue and component.", + "example": "1210624664-9929a318-5969-4626-a2cb-1630c4b09efc_40", + "required": true + }, + { + "name": "duplication_count", + "type": "integer", + "json_path": "/duplication_count", + "description": "rule_issues[].duplication_count of the issue; 0 when absent.", + "example": 0 + }, + { + "name": "current_status", + "type": "string", + "required": true, + "values": ["needs_review", "confirmed", "non_issues"], + "json_path": "/current_status", + "description": "The issue's status now, rule_issues[].status.", + "example": "needs_review" + }, + { + "name": "moved_status", + "type": "string", + "required": true, + "values": ["confirmed", "non_issues", "needs_review"], + "json_path": "/moved_status", + "description": "confirmed: it is an issue; non_issues: it is not; needs_review: undo an earlier decision.", + "example": "confirmed" + } + ], + "intent": "Decide one needs-review issue in a manual App Accessibility report: confirm it as an issue, mark it not an issue, or undo the decision.", + "guidance": [ + "APPROVAL FIRST: before calling, tell the user exactly what will change (which needs-review issue is decided, and to what, in which report, and how many issues, from list_manual_app_accessibility_report_issues with includeNeedsReviewIndex true) and wait for an explicit yes in their own words ('yes', 'go ahead'). A request to make the change, however specific, is not that yes: ask first, and send user_permission granted only after it.", + "Moves one issue: needs_review to confirmed (it is an issue) or to non_issues (it is not), or back to needs_review (undo). Take snapshot_id, rule_id, uid, the current status and duplication_count from list_manual_app_accessibility_report_issues with includeNeedsReviewIndex true.", + "A 403 'Review issue feature is not enabled' means needs-review is off for this report; 'Issue can only be reviewed by author' means only its author may review in this account.", + "Undo is the same call with moved_status needs_review and current_status the status it was moved to.", + "403 AGENT_REPORT_ACTIONS_DISABLED means BrowserStack has switched off agent writes for this user or group. Nothing changed. Tell the user to do it on the App Accessibility dashboard; do not retry, a retry is refused too." + ], + "returns": ["success"], + "paginated": false, + "responses": { + "200": { + "description": "Decided.", + "schema": { + "type": "object", + "properties": { "success": { "type": "boolean" } } + } + }, + "400": { "$response": "DashboardBadRequest" }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "count_manual_app_accessibility_issues_to_hide", + "method": "POST", + "path": "/api/v1/app_scanner/{report_id}/get-hide-count", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "issue", + "path_params": [ + { + "name": "report_id", + "type": "string", + "required": true, + "description": "The manual report's UUID, from list_manual_app_accessibility_reports or the report's dashboard link.", + "example": "ce941692-14e0-4ef2-a0f4-198d27684a20" + } + ], + "body": [ + { + "name": "rule_id", + "type": "string", + "required": true, + "json_path": "/rule_id", + "description": "The rule's id, aggregated_results[].rule_id of the issue read.", + "example": "text-color-contrast" + }, + { + "name": "uid", + "type": "string", + "json_path": "/uid", + "description": "The issue's uid, rule_issues[].uid. Required for hide_level issue and component.", + "example": "1210624664-9929a318-5969-4626-a2cb-1630c4b09efc_40" + }, + { + "name": "snapshot_id", + "type": "integer", + "json_path": "/snapshot_id", + "description": "The screen's id, details[].meta.snapshot_id. Required for hide_level issue and component.", + "example": 12345 + } + ], + "intent": "Count how many issues hiding a rule, or an element, in a manual App Accessibility report would change - the preview the Hide dialog shows.", + "guidance": [ + "Reads only; use it to say how many issues a hide or unhide would change before asking for approval.", + "hide_rule_count is how many issues the rule-level action would change; hide_issue_count how many on this element in this screen." + ], + "returns": ["hide_rule_count", "hide_issue_count"], + "paginated": false, + "responses": { + "200": { + "description": "Counts.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "hide_rule_count": { "type": "integer" }, + "hide_issue_count": { "type": "integer" } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "count_manual_app_accessibility_issues_to_unhide", + "method": "POST", + "path": "/api/v1/app_scanner/{report_id}/get-unhide-count", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "issue", + "path_params": [ + { + "name": "report_id", + "type": "string", + "required": true, + "description": "The manual report's UUID, from list_manual_app_accessibility_reports or the report's dashboard link.", + "example": "ce941692-14e0-4ef2-a0f4-198d27684a20" + } + ], + "body": [ + { + "name": "rule_id", + "type": "string", + "required": true, + "json_path": "/rule_id", + "description": "The rule's id, aggregated_results[].rule_id of the issue read.", + "example": "text-color-contrast" + }, + { + "name": "uid", + "type": "string", + "json_path": "/uid", + "description": "The issue's uid, rule_issues[].uid. Required for hide_level issue and component.", + "example": "1210624664-9929a318-5969-4626-a2cb-1630c4b09efc_40" + }, + { + "name": "snapshot_id", + "type": "integer", + "json_path": "/snapshot_id", + "description": "The screen's id, details[].meta.snapshot_id. Required for hide_level issue and component.", + "example": 12345 + } + ], + "intent": "Count how many hidden issues unhiding a rule, or an element, in a manual App Accessibility report would bring back.", + "guidance": [ + "Reads only; use it to say how many issues a hide or unhide would change before asking for approval.", + "hide_rule_count is how many issues the rule-level action would change; hide_issue_count how many on this element in this screen." + ], + "returns": ["hide_rule_count", "hide_issue_count"], + "paginated": false, + "responses": { + "200": { + "description": "Counts.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "hide_rule_count": { "type": "integer" }, + "hide_issue_count": { "type": "integer" } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "list_app_accessibility_screen_reader_builds", + "method": "GET", + "path": "/automate/api/v1/screen_reader/project/{project_id}/build", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "screen_reader_build", + "path_params": [ + { + "name": "project_id", + "type": "integer", + "required": true, + "minimum": 1, + "description": "The project's integer id, from list_app_accessibility_projects.", + "example": 123456 + } + ], + "query": [ + { + "name": "build_name", + "type": "string", + "description": "Keeps builds whose build or app name contains this text.", + "example": "Nightly" + }, + { + "name": "user_id", + "type": "integer", + "minimum": 1, + "description": "Keeps the builds one person started: their BrowserStack user id.", + "example": 1234567 }, { "name": "bundle_id", "type": "string", - "description": "Keeps reports of one app: its Android package name or iOS bundle id.", + "description": "Keeps builds of one app: its package name or bundle id.", "example": "com.example.checkout" }, { @@ -196,37 +2820,256 @@ "name": "page_size", "type": "integer", "minimum": 1, - "maximum": 100, "default": 10, - "description": "Reports per page, at most 100. A larger value is refused, with a 404 that names the limit.", - "example": 50 + "description": "Rows per page." } ], - "intent": "List manual App Accessibility reports (App Live sessions scanned with Workflow Analyzer) newest first, with each report's id, app, status and issue counts - use this to find a report QA shared or the latest manual scan of an app.", + "intent": "List an App Accessibility project's Screen Reader Automation builds newest first - automated runs that checked the app with TalkBack or VoiceOver - with each build's id, status and issue counts.", "guidance": [ - "id is a UUID: the accessibility issue tools read a manual report by it, or by its dashboard link.", - "issue_summary.total is the dashboard's count, duplicates left out; severity_count.duplicate_issues counts the repeats.", - "An empty result answers 404 with the message 'No reports found': that is an empty list, not an error. A refused parameter also answers 404, with the reason.", - "There is no date filter that works, and narrowing to one person's reports is not available to most callers: page through newest first, or search by report_name." + "Screen Reader Automation builds are listed apart from list_app_accessibility_builds; th_build_id is the id the other screen reader capabilities take.", + "An empty list can mean the account has no Screen Reader Automation, not only that nothing ran.", + "info.next is the following page, null on the last." ], "returns": [ - "reports.id", - "reports.name", - "reports.created_at", - "reports.status", - "reports.app_details", - "reports.issue_summary", - "reports.a11y_score", + "builds.th_build_id", + "builds.name", + "builds.status", + "builds.report_status", + "builds.created_at", + "builds.app_details", + "builds.issue_summary", "info.next" ], "paginated": true, - "max_page_size": 100, "responses": { - "200": { "$response": "ListManualAppAccessibilityReports" }, - "401": { "$response": "Unauthorized" }, - "403": { "$response": "Forbidden" }, - "404": { "$response": "ManualReportsRefusedOrEmpty" }, - "500": { "$response": "InternalServerError" } + "200": { + "description": "A page of the project's Screen Reader Automation builds.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "info": { "$schema": "PageInfo" }, + "filters": { "type": "object" }, + "builds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "th_build_id": { "type": "string" }, + "build_number": { "type": "integer" }, + "name": { "type": "string" }, + "status": { "type": "string" }, + "report_status": { "type": "string" }, + "created_at": { "type": "string" }, + "app_details": { "type": "object" }, + "test_health": { "type": "object" }, + "issue_summary": { "$schema": "IssueSummary" } + } + } + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "get_app_accessibility_screen_reader_build", + "method": "GET", + "path": "/automate/api/v1/screen_reader/build/{th_build_id}", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "screen_reader_build", + "path_params": [ + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The Screen Reader Automation build's th_build_id, from list_app_accessibility_screen_reader_builds.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "intent": "Read one Screen Reader Automation build's header: project, creator, devices, app and framework, WCAG version, test configuration and issue counts.", + "guidance": [ + "meta_data.eligible_rules is large; read it only when the question is which rules ran." + ], + "returns": [ + "meta_data.name", + "meta_data.project_name", + "meta_data.created_at", + "meta_data.issue_summary", + "meta_data.app_details", + "meta_data.devices" + ], + "paginated": false, + "responses": { + "200": { + "description": "The build's header.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "meta_data": { "type": "object" } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "get_app_accessibility_screen_reader_build_overview", + "method": "GET", + "path": "/automate/api/v1/screen_reader/project/{project_id}/build/{th_build_id}/overview", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "screen_reader_build", + "path_params": [ + { + "name": "project_id", + "type": "integer", + "required": true, + "minimum": 1, + "description": "The project's integer id, from list_app_accessibility_projects.", + "example": 123456 + }, + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The Screen Reader Automation build's th_build_id, from list_app_accessibility_screen_reader_builds.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "query": [ + { + "name": "test_case_uuid", + "type": "string", + "description": "Limits the overview to one test, by its uuid.", + "example": "57ce30d9-13b5-48aa-bae8-deaa4bc88b36" + } + ], + "intent": "Read a Screen Reader Automation build's overview: issue counts by severity and category, test health, and the trend over the last same-named builds.", + "guidance": [ + "data.trend_data holds the last same-named builds, each with its own issue_summary and test_health." + ], + "returns": [ + "data.issue_summary", + "data.issue_category", + "data.test_health", + "data.trend_data", + "data.report_status" + ], + "paginated": false, + "responses": { + "200": { + "description": "The build's overview.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { "type": "object" } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } + } + }, + { + "name": "list_app_accessibility_screen_reader_build_issues", + "method": "GET", + "path": "/automate/api/v1/screen_reader/build/{th_build_id}/snapshot", + "host": "dashboard", + "auth": { "type": "oauth2" }, + "mode": "read", + "entity": "screen_reader_build", + "path_params": [ + { + "name": "th_build_id", + "type": "string", + "required": true, + "description": "The Screen Reader Automation build's th_build_id, from list_app_accessibility_screen_reader_builds.", + "example": "oplk236dalltvafvsmyxgexhguzjlgo7kushur2o" + } + ], + "query": [ + { + "name": "scanWithIssuesOnly", + "type": "boolean", + "description": "true leaves out screens with no issues." + }, + { + "name": "page", + "type": "integer", + "minimum": 1, + "default": 1, + "description": "Page number, from 1." + }, + { + "name": "page_size", + "type": "integer", + "minimum": 1, + "default": 10, + "description": "Rows per page." + } + ], + "intent": "List a Screen Reader Automation build's scanned screens with the issues the screen reader pass found on each.", + "guidance": [ + "Each data.details[] is one screen: meta has the screenshot and device, aggregated_results groups its issues by rule.", + "info.next is the following page, null on the last." + ], + "returns": ["data.details", "data.info"], + "paginated": true, + "responses": { + "200": { + "description": "A page of the build's screens with their issues.", + "schema": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "data": { + "type": "object", + "properties": { + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "meta": { + "type": "object", + "description": "snapshot_id, screenshot_url and the screen's device." + }, + "aggregated_results": { + "type": "array", + "items": { + "type": "object", + "description": "One rule: rule_id, label, severity and rule_issues[] (uid, status, duplication_count)." + } + }, + "bounding_boxes": { "type": "object" } + } + } + }, + "info": { "$schema": "PageInfo" } + } + } + } + } + }, + "401": { "$response": "DashboardUnauthorized" }, + "403": { "$response": "DashboardForbidden" }, + "404": { "$response": "DashboardNotFound" }, + "500": { "$response": "DashboardUpstreamFailure" } } } ], @@ -246,7 +3089,11 @@ "relations": [ { "entity": "build", "via": "groups the automated builds reported under its name" } ], - "capabilities": ["list_app_accessibility_projects"], + "capabilities": [ + "list_app_accessibility_projects", + "list_app_accessibility_build_names", + "list_app_accessibility_bundle_ids" + ], "key_facts": [ "Projects are shared across the whole account, so a large account lists thousands; searching by name finds one faster than paging.", "A project is created by the first automated run reported under its name; there is nothing to create or delete here." @@ -262,14 +3109,24 @@ "automated accessibility build", "accessibility run", "app automate accessibility build", - "testhub build" + "testhub build", + "app accessibility project build" ], "id_convention": "th_build_id, a 40-character string, is the id the accessibility issue tools read; the SDK prints it as the testhub id. build_number counts per build name and the integer id is internal. Discover ids through the build list.", "parents": ["project"], "relations": [ - { "entity": "project", "via": "belongs to one project" } + { "entity": "project", "via": "belongs to one project" }, + { "entity": "test_case", "via": "holds the tests the run executed" } + ], + "capabilities": [ + "list_app_accessibility_builds", + "get_app_accessibility_build", + "get_app_accessibility_build_overview", + "get_app_accessibility_build_conformance_summary", + "list_app_accessibility_comparable_builds", + "compare_app_accessibility_builds", + "list_app_accessibility_build_issues" ], - "capabilities": ["list_app_accessibility_builds"], "key_facts": [ "A build appears only if its tests ran with accessibility checks on; one without them is not listed.", "Its issue counts are the dashboard's, with duplicates left out and hidden issues counted apart.", @@ -292,11 +3149,113 @@ "id_convention": "A UUID, discovered through the manual report list or read from the report's dashboard link.", "parents": [], "relations": [], - "capabilities": ["list_manual_app_accessibility_reports"], + "capabilities": [ + "list_manual_app_accessibility_reports", + "count_manual_app_accessibility_reports", + "list_manual_app_accessibility_devices", + "get_manual_app_accessibility_report", + "get_manual_app_accessibility_report_overview", + "list_manual_app_accessibility_report_rules", + "list_manual_app_accessibility_report_wcag_levels", + "get_manual_app_accessibility_report_conformance_summary", + "list_manual_app_accessibility_report_issues" + ], "key_facts": [ - "A report is in_progress while its session is still recording, and completed once it has ended.", + "A report is in_progress while its session is still recording, and complete once it has ended.", "Its issue counts are the dashboard's, duplicates left out; the duplicate count says how many repeats were folded in." ] + }, + "test_case": { + "entity": "test_case", + "title": "Test", + "description": "One automated test in an App Accessibility build, with the screens it scanned and their issues.", + "aliases": [ + "test", + "test case", + "app accessibility test", + "automated test" + ], + "id_convention": "A uuid, discovered through the build's test list.", + "parents": ["build"], + "relations": [{ "entity": "build", "via": "belongs to one build" }], + "capabilities": [ + "list_app_accessibility_build_tests", + "list_app_accessibility_test_issues" + ], + "key_facts": [ + "Its issue counts are the dashboard's per-test counts, duplicates left out." + ] + }, + "user": { + "entity": "user", + "title": "User", + "description": "A person in the account who runs App Accessibility tests or manual sessions.", + "aliases": ["person", "teammate", "member", "app accessibility user"], + "id_convention": "user_id is the BrowserStack user id; id is App Accessibility's own. Discover both through the user list.", + "parents": [], + "relations": [], + "capabilities": ["list_app_accessibility_users"], + "key_facts": ["Only people in the caller's own account are listed."] + }, + "issue": { + "entity": "issue", + "title": "Issue", + "description": "One accessibility issue on an app screen, which can be hidden, unhidden or reviewed as on the dashboard.", + "aliases": [ + "accessibility issue", + "app accessibility issue", + "violation", + "hide issue", + "hidden issue", + "needs review issue" + ], + "id_convention": "Named by its screen (details[].meta.snapshot_id), its rule (rule_id) and its uid, read from the build or report issue lists.", + "parents": ["build", "manual_report"], + "relations": [ + { "entity": "build", "via": "found in an automated build" }, + { "entity": "manual_report", "via": "found in a manual report" } + ], + "capabilities": [ + "hide_app_accessibility_issues", + "unhide_app_accessibility_issues", + "review_app_accessibility_issue", + "count_app_accessibility_issues_to_hide", + "count_app_accessibility_issues_to_unhide", + "hide_manual_app_accessibility_issues", + "unhide_manual_app_accessibility_issues", + "review_manual_app_accessibility_issue", + "count_manual_app_accessibility_issues_to_hide", + "count_manual_app_accessibility_issues_to_unhide" + ], + "key_facts": [ + "Hiding or reviewing changes the counts and score every viewer of the report sees.", + "A hide applies to this report only; persistent hides are dashboard-only." + ] + }, + "screen_reader_build": { + "entity": "screen_reader_build", + "title": "Screen Reader Automation build", + "description": "One automated run that checked an app with a screen reader (TalkBack or VoiceOver), and the issues it found.", + "aliases": [ + "screen reader build", + "screen reader automation build", + "sra build", + "screen reader report", + "talkback report", + "voiceover report" + ], + "id_convention": "th_build_id, a 40-character string, discovered through the project's screen reader build list.", + "parents": ["project"], + "relations": [{ "entity": "project", "via": "belongs to one project" }], + "capabilities": [ + "list_app_accessibility_screen_reader_builds", + "get_app_accessibility_screen_reader_build", + "get_app_accessibility_screen_reader_build_overview", + "list_app_accessibility_screen_reader_build_issues" + ], + "key_facts": [ + "Needs Screen Reader Automation on the account's plan; it is listed apart from ordinary builds." + ] } }, "schemas": { @@ -436,12 +3395,12 @@ "ManualReport": { "type": "object", "properties": { - "id": { "type": "string", "format": "uuid", "description": "The report id the accessibility issue tools read." }, - "name": { "type": "string" }, + "report_id": { "type": "string", "format": "uuid", "description": "The report id the accessibility issue tools read." }, + "report_name": { "type": "string" }, "created_at": { "type": "string", "format": "date-time" }, - "started_at": { "type": "string", "format": "date-time" }, - "created_by": { "$schema": "User" }, - "status": { "type": "string", "description": "in_progress while the session records, completed once it has ended." }, + "end_time": { "type": "string", "format": "date-time", "nullable": true, "description": "Null while the session is still recording." }, + "status": { "type": "string", "description": "in_progress while the session records, complete once it has ended." }, + "report_type": { "type": "string", "description": "standard, or consolidated for a report merged from others." }, "app_details": { "type": "object", "properties": { @@ -451,8 +3410,10 @@ "framework": { "type": "string" } } }, - "issue_summary": { "$schema": "IssueSummary" }, - "a11y_score": { "$schema": "AccessibilityScore" } + "device": { "type": "object", "description": "The device the session ran on." }, + "user": { "type": "object", "description": "The report's owner." }, + "issues": { "type": "object", "description": "The dashboard's counts: total (duplicates left out), per severity, needs_review, hidden_issues and duplicate_issues." }, + "snapshots": { "type": "object", "description": "scan_count: how many screens were scanned." } } }, "Failure": { @@ -461,6 +3422,17 @@ "success": { "type": "boolean" }, "message": { "type": "string" } } + }, + "DashboardFailure": { + "type": "object", + "properties": { + "success": { "type": "boolean" }, + "message": { "type": "string" }, + "error_code": { + "type": "string", + "description": "Set when the caller can act on it, e.g. ACTION_NOT_ALLOWED_FOR_SCOPE." + } + } } }, "responses": { @@ -499,12 +3471,8 @@ "type": "object", "properties": { "success": { "type": "boolean" }, - "reports": { "type": "array", "items": { "$schema": "ManualReport" } }, - "info": { "$schema": "PageInfo" }, - "filters": { - "type": "object", - "description": "An open map echoing the filters the request sent, keyed by parameter name." - } + "data": { "type": "array", "items": { "$schema": "ManualReport" } }, + "info": { "$schema": "PageInfo" } } } }, @@ -512,39 +3480,41 @@ "description": "A filter value was refused; message names the allowed values.", "schema": { "$schema": "Failure" } }, - "Unauthorized": { - "description": "The username or access key was not accepted.", - "schema": { "$schema": "Failure" } - }, - "Forbidden": { - "description": "The account's plan or the caller's role does not include this list.", - "schema": { "$schema": "Failure" } - }, "EmptyList": { "description": "Nothing matched: message is 'No builds found'. An empty list, not a missing project.", "schema": { "$schema": "Failure" } }, - "ManualReportsRefusedOrEmpty": { - "description": "Nothing matched (message 'No reports found'), or a parameter was refused: message, or errors for a refused status, says why.", - "schema": { - "allOf": [{ "$schema": "Failure" }], - "properties": { - "errors": { - "type": "array", - "items": { - "type": "object", - "properties": { - "key": { "type": "string" }, - "message": { "type": "string" } - } - } - } - } - } + "DashboardUnauthorized": { + "description": "The token was not accepted, or the user could not be found. Credentials are re-minted on the next call; a persistent 401 means the account itself was refused.", + "schema": { "$schema": "DashboardFailure" } }, - "InternalServerError": { - "description": "The service failed to answer.", - "schema": { "$schema": "Failure" } + "DashboardForbidden": { + "description": "The account's plan, license, role or feature flags refuse this, exactly as they would on the dashboard. error_code ACTION_NOT_ALLOWED_FOR_SCOPE instead means the route is not on the ai_agent allowlist. error_code AGENT_REPORT_ACTIONS_DISABLED means BrowserStack has switched off agent writes for this user or group: nothing changed, and a retry is refused too.", + "schema": { "$schema": "DashboardFailure" } + }, + "DashboardScopeNotAllowed": { + "description": "ACTION_NOT_ALLOWED_FOR_SCOPE: this route is not on the ai_agent allowlist. Not fixable by retrying; it needs a backend allowlist change.", + "schema": { "$schema": "DashboardFailure" } + }, + "DashboardNotFound": { + "description": "No such record for this account, or the feature is not enabled for it (the message says which).", + "schema": { "$schema": "DashboardFailure" } + }, + "DashboardBadRequest": { + "description": "A parameter was missing or malformed.", + "schema": { "$schema": "DashboardFailure" } + }, + "DashboardUnprocessable": { + "description": "The parameters were understood but not usable.", + "schema": { "$schema": "DashboardFailure" } + }, + "DashboardUpstreamFailure": { + "description": "A service behind the dashboard did not answer; retry shortly.", + "schema": { "$schema": "DashboardFailure" } + }, + "CompareInProgress": { + "description": "The comparison is still being computed; call again in a few seconds.", + "schema": { "$schema": "DashboardFailure" } } } } diff --git a/src/tools/accessibility.ts b/src/tools/accessibility.ts index 508fd5e2..6dbad8d1 100644 --- a/src/tools/accessibility.ts +++ b/src/tools/accessibility.ts @@ -881,10 +881,8 @@ async function appBuildMessages( } /** - * A manual report's issues come inline from its scanned screens: the dashboard's own, with - * its duplicates left out, when its route takes the access key; else every occurrence the - * Manual Reports API lists, which does not mark duplicates, so the dashboard's count is - * stated next to the total rather than reproduced. + * A manual report's issues come inline from the dashboard's scanned screens, with its + * duplicates left out as the dashboard leaves them out of its count. */ async function appReportMessages( reportFetcher: AccessibilityReportFetcher, @@ -920,20 +918,19 @@ async function appReportMessages( report.device ? ` on ${report.device}` : "" }`; const dashboardNote = - report.duplicate_occurrences === 0 - ? [] - : report.deduplicated - ? [ - `${report.duplicate_occurrences} duplicate occurrences are left out, as the dashboard leaves them out of its count.`, - ] + report.duplicate_occurrences === null || report.hidden_issues === null + ? [ + "The dashboard's duplicate and hidden issue counts could not be read for this report.", + ] + : report.duplicate_occurrences === 0 + ? [] : [ - `The dashboard counts ${report.dashboard_count} issues for this report: ${report.duplicate_occurrences} of the occurrences are duplicates it folds, which the API does not mark.`, + `${report.duplicate_occurrences} duplicate occurrences are left out, as the dashboard leaves them out of its count.`, ]; - const counted = report.deduplicated ? "issues" : "issue occurrences"; return [ ...preface, ...processingNote(processing), - `Retrieved ${page_length} accessibility ${counted} (Total: ${total_issues}) from the App Accessibility manual report below (${where})`, + `Retrieved ${page_length} accessibility issues (Total: ${total_issues}) from the App Accessibility manual report below (${where})`, details, ...(cursor === 0 ? summaryNote(report.summary, total_issues) : []), ...(report.screens_read !== undefined diff --git a/src/tools/accessiblity-utils/app-report-fetcher.ts b/src/tools/accessiblity-utils/app-report-fetcher.ts index d381694f..9a487fa6 100644 --- a/src/tools/accessiblity-utils/app-report-fetcher.ts +++ b/src/tools/accessiblity-utils/app-report-fetcher.ts @@ -1,4 +1,15 @@ import { apiClient } from "../../lib/apiClient.js"; +import { + fetchTokenTransport, + invalidateToken, + type TokenTransport, +} from "../../lib/central-oauth.js"; +import { namedHostUrl } from "../capability-registry/config.js"; +import { + authHeaders, + type Credentials, +} from "../capability-registry/egress.js"; +import { resolveScope, resolveTokenUrl } from "../capability-registry/oauth.js"; import { SessionType } from "../../lib/constants.js"; import { sessionsListUrl } from "../automate-utils/list-session-ids.js"; import { getAutomationBaseUrl } from "../rca-agent-utils/constants.js"; @@ -14,12 +25,20 @@ import { CallerError } from "../../lib/error.js"; * accessibility on. Unlike the web products there is no CSV export behind an access key, * so the issues come inline, one API page per batch of scanned screens. */ -export const appApiBase = () => - `${getRegionalHost("appAccessibilityApi")}/automate/api/v1`; -export const appDashboard = () => getRegionalHost("appAccessibilityDashboard"); -/** Manual (Workflow Analyzer) reports recorded on the dashboard: a separate, older route. */ -export const manualApiBase = () => - `${getRegionalHost("appAccessibilityApi")}/api/v1`; +const APP_ACCESSIBILITY = "app_accessibility"; +/** The dashboard's routes take a central-auth token minted with the ai_agent scope. */ +const AGENT_AUTH = { type: "oauth2" } as const; +/** + * The App Accessibility dashboard, the host its registry capabilities call: their host + * override and regional rules apply here too. + */ +export const appDashboard = () => + namedHostUrl(APP_ACCESSIBILITY, "dashboard", () => + getRegionalHost("appAccessibilityDashboard"), + ); +export const appApiBase = () => `${appDashboard()}/automate/api/v1`; +/** Manual (Workflow Analyzer) reports, on the dashboard's own routes. */ +export const manualApiBase = () => `${appDashboard()}/api/v1`; /** Screens per API page, and how many pages a build or report is read across (1,000 screens). */ const SNAPSHOT_PAGE_SIZE = 50; @@ -34,13 +53,22 @@ const MANUAL_REPORT_PAGE_SIZE = 100; /** A manual report as the report list gives it. */ interface ManualReportRow { - id: string; + report_id: string; created_at?: string; - /** complete | in_progress */ - status?: string; + /** Unset while the session is still recording. */ + end_time?: string | null; app_details?: { name?: string; package_name?: string }; } +/** A manual report's details, as the dashboard's report page reads them. */ +export interface ManualReportDetail extends ManualReportRow { + /** The session is still recording: the route answers with its raw session row. */ + recording?: boolean; + report_name?: string; + scan_count?: number; + device?: { model?: string; os?: string; os_version?: string }; +} + /** An earlier manual report of the same app. */ export interface EarlierManualReport { reportId: string; @@ -200,20 +228,15 @@ export interface AppBuildReport extends AppIssuePageContext { export interface AppManualReport extends AppIssuePageContext { records: AppIssueRow[]; page_length: number; - /** - * The issues, duplicates left out as the dashboard leaves them out when `deduplicated`; - * else every occurrence the Manual Reports API lists, which does not mark duplicates. - */ + /** The issues, duplicates left out as the dashboard leaves them out. */ total_issues: number; - /** Read from the dashboard's own screens: duplicates left out, issues with their element. */ - deduplicated: boolean; next_page: number | null; /** How many issues the pages after this one hold. */ remaining: number; summary: AppIssueSummary; - dashboard_count: number; - duplicate_occurrences: number; - hidden_issues: number; + /** Null when the dashboard's overview could not be read. */ + duplicate_occurrences: number | null; + hidden_issues: number | null; scan_count: number; /** complete | in_progress */ status: string; @@ -732,18 +755,25 @@ function appAutomateIds( }; } +/** A regional dashboard host, or this deployment's own, which its answers link to. */ +function isAppDashboardHost(hostname: string): boolean { + if (isRegionalHostname("appAccessibilityDashboard", hostname)) return true; + try { + return new URL(appDashboard()).hostname === hostname; + } catch { + return false; + } +} + /** The id a manual report's dashboard link names (`/report/{uuid}`), if it is one. */ export function manualReportIdFromDashboardLink(url: URL): string | undefined { - if (!isRegionalHostname("appAccessibilityDashboard", url.hostname)) - return undefined; + if (!isAppDashboardHost(url.hostname)) return undefined; return url.pathname.match(/^\/report\/([0-9a-f-]{36})\/?$/i)?.[1]; } /** A manual report has no status of its own; it is complete once it has ended. */ -export function manualReportStatus(detail: { - meta_data?: { ended_at?: string | null }; -}): string { - return detail.meta_data?.ended_at ? "complete" : "in_progress"; +export function manualReportStatus(detail: ManualReportDetail): string { + return !detail.recording && detail.end_time ? "complete" : "in_progress"; } /** A link's CGI-escaped name ("+" for a space), read the same however it was escaped. */ @@ -786,19 +816,52 @@ export class BuildLookupError extends Error { export class AppAccessibilityApi { constructor( + /** Basic access-key headers, for App Automate's own API. */ private readonly headers: () => Record | undefined, + /** The caller's username and access key, from which the dashboard token is minted. */ + private readonly credentials: () => Credentials | undefined = () => + undefined, + private readonly tokenTransport: TokenTransport = fetchTokenTransport(), ) {} + /** + * A GET on the App Accessibility dashboard with a minted ai_agent token, minted again + * once when the dashboard refuses it (401), as the capability registry does. + */ + private async dashboardGet(url: string) { + const credentials = this.credentials(); + const send = async () => + apiClient.get({ + url, + // Without credentials this throws "not authenticated" before anything is sent. + headers: await authHeaders( + credentials as Credentials, + AGENT_AUTH, + APP_ACCESSIBILITY, + this.tokenTransport, + ), + raise_error: false, + }); + let resp = await send(); + if (resp.status === 401 && credentials) { + invalidateToken( + resolveTokenUrl(APP_ACCESSIBILITY, AGENT_AUTH), + resolveScope(AGENT_AUTH), + credentials, + ); + resp = await send(); + } + return resp; + } + /** * The build's details, or undefined when the API does not know the id (its 404, which * it also gives a malformed id). Any other failure is thrown with its status. */ async buildMeta(buildId: string): Promise { - const resp = await apiClient.get({ - url: `${appApiBase()}/build/${encodeURIComponent(buildId)}`, - headers: this.headers(), - raise_error: false, - }); + const resp = await this.dashboardGet( + `${appApiBase()}/build/${encodeURIComponent(buildId)}`, + ); if (resp.status === 404) return undefined; if (!resp.ok) { throw new Error( @@ -814,8 +877,7 @@ export class AppAccessibilityApi { * carries TestHub's name for the build, which the filter does not match.) */ async buildIdFromDashboardLink(url: URL): Promise { - if (!isRegionalHostname("appAccessibilityDashboard", url.hostname)) - return undefined; + if (!isAppDashboardHost(url.hostname)) return undefined; const build = buildOfDashboardLink(url); if (!build) return undefined; // The name in the link is TestHub's, which can differ from the build's own: with no @@ -1045,16 +1107,12 @@ export class AppAccessibilityApi { } /** - * A listing's page. The API answers an empty list with 404 ("No builds found") for - * access-key callers, which is not an error here; any other failure is, a 404 from a - * wrong route or a missing permission included. + * A listing's page. The dashboard answers an empty build list with 404 ("No builds + * found"), which is not an error here; any other failure is, a 404 from a wrong route or + * a missing permission included. */ private async listing(url: string, what: string): Promise { - const resp = await apiClient.get({ - url, - headers: this.headers(), - raise_error: false, - }); + const resp = await this.dashboardGet(url); if (resp.ok) return resp.data ?? {}; if (resp.status === 404 && /^No .+ found/i.test(resp.data?.message ?? "")) { return {}; @@ -1065,22 +1123,43 @@ export class AppAccessibilityApi { } /** - * A manual report's details, or undefined when the API does not know the id (its 404); - * any other failure is thrown with its status. + * A manual report's details (name, app, device, scan count, end time), or undefined when + * the id is not a report of the caller's group (its 404). Any other failure is thrown with + * its status. */ - async manualReport(reportId: string): Promise { - const resp = await apiClient.get({ - url: `${manualApiBase()}/reports/${encodeURIComponent(reportId)}`, - headers: this.headers(), - raise_error: false, - }); + async manualReport( + reportId: string, + ): Promise { + const resp = await this.dashboardGet( + `${manualApiBase()}/app_scanner/${encodeURIComponent(reportId)}/meta_data`, + ); if (resp.status === 404) return undefined; if (!resp.ok) { throw new Error( `Could not read App Accessibility manual report ${reportId}: HTTP ${resp.status}`, ); } - return resp.data; + // A session still recording answers success false, with its raw session row. + return { + ...(resp.data?.data ?? {}), + recording: resp.data?.success === false, + }; + } + + /** A manual report's issue counts as the dashboard shows them; none when unreadable. */ + /** The dashboard's counts, or undefined when its overview could not be read. */ + private async manualReportCounts(reportId: string): Promise< + | { + total?: number; + hidden_issues?: number; + duplicate_issues?: number; + } + | undefined + > { + const resp = await this.dashboardGet( + `${manualApiBase()}/app_scanner/${encodeURIComponent(reportId)}/overview`, + ).catch(() => undefined); + return (resp?.ok && resp.data?.data?.issues) || undefined; } /** The manual reports whose name, app or package contains `search`, newest first, a page at a time. */ @@ -1089,31 +1168,23 @@ export class AppAccessibilityApi { ): AsyncGenerator { for (let page = 1; page <= MAX_MANUAL_REPORT_PAGES; page++) { const data = await this.listing( - `${manualApiBase()}/reports?report_name=${encodeURIComponent(search)}&page_size=${MANUAL_REPORT_PAGE_SIZE}&page=${page}`, + `${manualApiBase()}/app_scanner?report_name=${encodeURIComponent(search)}&page_size=${MANUAL_REPORT_PAGE_SIZE}&page=${page}`, `page ${page} of the manual App Accessibility reports`, ); - yield data.reports ?? []; + yield data.data ?? []; if (!data.info?.next) return; } } /** * The newest finished manual report of the same app recorded before this one, or - * undefined when none is among the newest. The report's details do not name its app: the - * report list does, where the report is found by its name; the app's reports are then - * listed by its package (or, without one, its name). + * undefined when none is among the newest. The app's reports are listed by its package + * (or, without one, its name), which the list's search matches. */ async previousManualReport( reportId: string, ): Promise { - const name: string | undefined = (await this.manualReport(reportId)) - ?.meta_data?.name; - if (!name) return undefined; - let own: ManualReportRow | undefined; - for await (const rows of this.manualReports(name)) { - own = rows.find((row) => row.id === reportId); - if (own) break; - } + const own = await this.manualReport(reportId); const pkg = own?.app_details?.package_name; const app = pkg ?? own?.app_details?.name; if (!own || !app) return undefined; @@ -1125,16 +1196,16 @@ export class AppAccessibilityApi { for await (const rows of this.manualReports(app)) { const earlier = rows.find( (row) => - row.id !== reportId && + row.report_id !== reportId && sameApp(row) && - row.status !== "in_progress" && + Boolean(row.end_time) && recorded(row) < recorded(own), ); if (earlier) { return { - reportId: earlier.id, + reportId: earlier.report_id, time: earlier.created_at, - link: `${appDashboard()}/report/${earlier.id}`, + link: `${appDashboard()}/report/${earlier.report_id}`, }; } } @@ -1143,70 +1214,32 @@ export class AppAccessibilityApi { /** * A manual report's screens as the dashboard reads them, duplicates left out and each - * issue with its element, fix and measurements; undefined while that route answers an - * access key with a login redirect, as it does until it takes one (the redirect names - * no Location, so nothing follows it), and undefined too when a later page fails, so - * the Manual Reports API is read in full rather than part of this read as the whole. + * issue with its element, fix and measurements. A page that cannot be read fails the + * read: a count over some of the screens would read as the report's. */ - private async dashboardScreens( + private async reportScreens( reportId: string, - ): Promise<{ details: AppSnapshot[]; more: boolean } | undefined> { + ): Promise<{ details: AppSnapshot[]; more: boolean }> { const details: AppSnapshot[] = []; let more = false; for (let page = 1; page <= MAX_SNAPSHOT_PAGES; page++) { - const resp = await apiClient - .get({ - url: `${manualApiBase()}/app_scanner/${encodeURIComponent(reportId)}/snapshot?hide_duplicate_issues=true&page_size=${SNAPSHOT_PAGE_SIZE}&page=${page}`, - headers: this.headers(), - raise_error: false, - }) - .catch(() => undefined); - const data = resp?.ok && resp.data?.success ? resp.data.data : undefined; - if (!Array.isArray(data?.details)) return undefined; - details.push(...data.details); - more = Boolean(data.info?.next); - if (!more) break; - } - return { details, more }; - } - - /** Every occurrence the Manual Reports API lists, and the device the report ran on. */ - private async manualApiScreens(reportId: string): Promise<{ - details: AppSnapshot[]; - more: boolean; - device?: { model?: string; os?: string; os_version?: string }; - }> { - const details: AppSnapshot[] = []; - let more = false; - let device: - | { model?: string; os?: string; os_version?: string } - | undefined; - for (let page = 1; page <= MAX_SNAPSHOT_PAGES; page++) { - const resp = await apiClient.get({ - url: `${manualApiBase()}/reports/${encodeURIComponent(reportId)}/issues?page_size=${SNAPSHOT_PAGE_SIZE}&page=${page}`, - headers: this.headers(), - raise_error: false, - }); - // A count over some of the pages would read as the report's. - if (!resp.ok) { + const resp = await this.dashboardGet( + `${manualApiBase()}/app_scanner/${encodeURIComponent(reportId)}/snapshot?hide_duplicate_issues=true&page_size=${SNAPSHOT_PAGE_SIZE}&page=${page}`, + ); + const data = resp.ok && resp.data?.success ? resp.data.data : undefined; + if (!Array.isArray(data?.details)) { throw new Error( - `Could not read page ${page} of manual report ${reportId}'s issues from the Manual Reports API: HTTP ${resp.status}`, + `Could not read page ${page} of manual report ${reportId}'s scanned screens from the App Accessibility dashboard: HTTP ${resp.status}`, ); } - device ??= resp.data?.device; - details.push(...(resp.data?.data ?? [])); - more = Boolean(resp.data?.pagination?.next); + details.push(...data.details); + more = Boolean(data.info?.next); if (!more) break; } - return { details, more, device }; + return { details, more }; } - /** - * A manual report's issues, most severe first: from the dashboard's own screens when the - * route takes the access key, so the count is the dashboard's and each issue names its - * element; else every occurrence the Manual Reports API lists, which marks neither - * duplicates nor elements, with the dashboard's count stated next to it. - */ + /** A manual report's issues, most severe first, as the dashboard counts them. */ async appReportIssues( reportId: string, cursor = 0, @@ -1218,26 +1251,22 @@ export class AppAccessibilityApi { `No App Accessibility manual report with id "${reportId}". Pass the report's dashboard link (app-accessibility.browserstack.com/report/…) as reportUrl, or an id from the capability functions' list of manual App Accessibility reports`, ); } - const dashboard = await this.dashboardScreens(reportId); - const { details, more, device } = dashboard - ? { ...dashboard, device: undefined } - : await this.manualApiScreens(reportId); - const summary = detail.data?.issue_summary ?? {}; + const counts = await this.manualReportCounts(reportId); + const { details, more } = await this.reportScreens(reportId); const all = flattenAppSnapshots(details); const { rows, context } = compactAppIssues(all); const page = appIssuePage(rows, context, cursor, maxCharacterLength); + const device = detail.device; return { ...page, ...contextOf(page.records, context), total_issues: all.length, summary: summarizeAppIssues(all), - deduplicated: dashboard !== undefined, - dashboard_count: summary.total ?? all.length, - duplicate_occurrences: summary.severity_count?.duplicate_issues ?? 0, - hidden_issues: summary.severity_count?.hidden_issues ?? 0, - scan_count: summary.scan_count ?? details.length, + duplicate_occurrences: counts ? (counts.duplicate_issues ?? 0) : null, + hidden_issues: counts ? (counts.hidden_issues ?? 0) : null, + scan_count: detail.scan_count ?? details.length, status: manualReportStatus(detail), - report_name: detail.meta_data?.name ?? reportId, + report_name: detail.report_name ?? reportId, ...(device?.model ? { device: `${device.model}, ${device.os} ${device.os_version}` } : {}), @@ -1367,16 +1396,14 @@ export class AppAccessibilityApi { let hidden = 0; let more = false; for (let page = 1; page <= MAX_SNAPSHOT_PAGES; page++) { - const resp = await apiClient.get({ - url: `${appApiBase()}/build/${encodeURIComponent(buildId)}/snapshot?hide_duplicate_issues=true&page_size=${SNAPSHOT_PAGE_SIZE}&page=${page}`, - headers: this.headers(), - raise_error: false, - }); + const resp = await this.dashboardGet( + `${appApiBase()}/build/${encodeURIComponent(buildId)}/snapshot?hide_duplicate_issues=true&page_size=${SNAPSHOT_PAGE_SIZE}&page=${page}`, + ); // A count over some of the screens would read as the build's, so a page that // cannot be read fails the read. if (!resp.ok) { throw new Error( - `Could not read page ${page} of build ${buildId}'s scanned screens from the App Accessibility API: HTTP ${resp.status}`, + `Could not read page ${page} of build ${buildId}'s scanned screens from the App Accessibility dashboard: HTTP ${resp.status}`, ); } const data = resp.data?.data; diff --git a/src/tools/accessiblity-utils/report-fetcher.ts b/src/tools/accessiblity-utils/report-fetcher.ts index 07b2d256..260125e5 100644 --- a/src/tools/accessiblity-utils/report-fetcher.ts +++ b/src/tools/accessiblity-utils/report-fetcher.ts @@ -512,7 +512,13 @@ function automateIds( export class AccessibilityReportFetcher { private auth: { username: string; password: string } | undefined; - private readonly app = new AppAccessibilityApi(() => this.authHeaders()); + private readonly app = new AppAccessibilityApi( + () => this.authHeaders(), + () => + this.auth + ? { username: this.auth.username, accessKey: this.auth.password } + : undefined, + ); /** Web builds whose overview was read, by id, so a status check need not read it again. */ private readonly webBuilds = new Map(); /** Web builds' dashboard metadata, by id: their name, project, number, start and status. */ diff --git a/src/tools/appautomate-utils/native-execution/appautomate.ts b/src/tools/appautomate-utils/native-execution/appautomate.ts index 940bbae3..bdd3ae47 100644 --- a/src/tools/appautomate-utils/native-execution/appautomate.ts +++ b/src/tools/appautomate-utils/native-execution/appautomate.ts @@ -277,6 +277,29 @@ export async function uploadXcuiTestSuite( export interface NativeBuildOptions { /** Run App Accessibility checks during the tests (the build API's `accessibility` flag). */ accessibility?: boolean; + /** With accessibility on, also run Screen Reader Automation and report it. */ + screenReader?: { linearNavigation?: boolean }; +} + +/** How long linear navigation may swipe through a screen, as the SR test configs use. */ +const LINEAR_NAVIGATION_TIMEOUT_MS = 300000; + +/** App Automate forwards these to the accessibility run only when accessibility is on. */ +function screenReaderOptions( + options: NativeBuildOptions, +): Record { + if (!options.accessibility || !options.screenReader) return {}; + const linear = options.screenReader.linearNavigation + ? { + linearNavigation: true, + linearNavigationTimeout: LINEAR_NAVIGATION_TIMEOUT_MS, + } + : {}; + return { + accessibilityOptions: { + screenReaderAutomation: { autoReport: true, ...linear }, + }, + }; } function buildRequestBody( @@ -292,6 +315,7 @@ function buildRequestBody( devices, project, ...(options.accessibility ? { accessibility: true } : {}), + ...screenReaderOptions(options), }; } diff --git a/src/tools/appautomate-utils/native-execution/constants.ts b/src/tools/appautomate-utils/native-execution/constants.ts index 16781a06..014c1e87 100644 --- a/src/tools/appautomate-utils/native-execution/constants.ts +++ b/src/tools/appautomate-utils/native-execution/constants.ts @@ -37,17 +37,25 @@ export const RUN_APP_AUTOMATE_SCHEMA = { .string() .optional() .default("BStack-AppAutomate-Suite") - .describe("Project name for organizing test runs on BrowserStack."), + .describe("BrowserStack project for these runs."), detectedAutomationFramework: z .nativeEnum(AppTestPlatform) - .describe( - "The automation framework used in the project, such as 'espresso' (Android) or 'xcuitest' (iOS).", - ), + .describe("'espresso' (Android) or 'xcuitest' (iOS)."), accessibility: z .boolean() .optional() .default(false) .describe( - "App Accessibility checks on screens the tests touch (Android 11+, iOS 14+); suite must be built with BrowserStack's SDK.", + "App Accessibility checks on touched screens (Android 11+, iOS 14+); suite needs BrowserStack's SDK.", ), + screenReader: z + .boolean() + .optional() + .default(false) + .describe("Also run Screen Reader Automation; turns accessibility on."), + screenReaderLinearNavigation: z + .boolean() + .optional() + .default(false) + .describe("Screen reader swipes every screen in order."), }; diff --git a/src/tools/appautomate.ts b/src/tools/appautomate.ts index d84ab9a8..0e4aa112 100644 --- a/src/tools/appautomate.ts +++ b/src/tools/appautomate.ts @@ -194,12 +194,16 @@ function runStartedMessage( buildId: string, accessibility: boolean, devices: string, + screenReader = false, ): string { const link = `https://app-automate.browserstack.com/builds/${buildId}`; const a11y = accessibility ? `\n\n♿ App Accessibility checks are on. ${NATIVE_ACCESSIBILITY_SETUP[framework] ?? ""}\nWhen the build finishes (typically 10–20 minutes), read the issues with fetchAccessibilityIssues, reportUrl: ${link} — it maps the build to its accessibility report and waits while the report is still processing.` : ""; - return `✅ ${framework} run started successfully!\n\n🔧 Build ID: ${buildId}\n🔗 View your build: ${link}${devices}${a11y}`; + const sr = screenReader + ? `\n\n🔊 Screen Reader Automation is on. Its report is listed apart from ordinary builds: read it with list_app_accessibility_screen_reader_builds (product app_accessibility) under the build's project. It needs Screen Reader Automation on the account's plan; without it the build runs with the accessibility checks only.` + : ""; + return `✅ ${framework} run started successfully!\n\n🔧 Build ID: ${buildId}\n🔗 View your build: ${link}${devices}${a11y}${sr}`; } /** @@ -239,10 +243,26 @@ async function runAppTestsOnBrowserStack( project: string; detectedAutomationFramework: string; accessibility?: boolean; + screenReader?: boolean; + screenReaderLinearNavigation?: boolean; }, config: BrowserStackConfig, ): Promise { - const accessibility = args.accessibility === true; + // Linear navigation is a screen reader option, so asking for it turns the screen reader on. + const screenReader = + args.screenReader === true || args.screenReaderLinearNavigation === true; + // Screen Reader Automation runs inside the accessibility run, so it turns the checks on. + const accessibility = args.accessibility === true || screenReader; + const nativeOptions = { + accessibility, + ...(screenReader + ? { + screenReader: { + linearNavigation: args.screenReaderLinearNavigation === true, + }, + } + : {}), + }; // Validate that either paths or URLs are provided for both app and test suite if (!args.browserstackAppUrl && !args.appPath) { throw new CallerError( @@ -298,7 +318,7 @@ async function runAppTestsOnBrowserStack( deviceStrings, args.project, config, - { accessibility }, + nativeOptions, ); return { @@ -310,6 +330,7 @@ async function runAppTestsOnBrowserStack( build_id, accessibility, devices, + screenReader, ), }, ], @@ -350,7 +371,7 @@ async function runAppTestsOnBrowserStack( deviceStrings, args.project, config, - { accessibility }, + nativeOptions, ); return { content: [ @@ -361,6 +382,7 @@ async function runAppTestsOnBrowserStack( build_id, accessibility, devices, + screenReader, ), }, ], diff --git a/src/tools/capability-registry/config.ts b/src/tools/capability-registry/config.ts index 9f033573..49def46d 100644 --- a/src/tools/capability-registry/config.ts +++ b/src/tools/capability-registry/config.ts @@ -79,7 +79,12 @@ const REGIONAL_HOSTS: Record< > = { tm: { base: "testManagement" }, tra: { base: "observabilityApi" }, - app_accessibility: { base: "appAccessibilityApi" }, + // `dashboard`: as for web_accessibility below, read with an ai_agent token on the routes + // app-accessibility's allowlist admits. + app_accessibility: { + base: "appAccessibilityApi", + hosts: { dashboard: "appAccessibilityDashboard" }, + }, // `dashboard`: the dashboard's own routes, which never read Basic auth; those capabilities // declare oauth2 themselves and the backend admits only what its ai_agent scope allows. web_accessibility: { @@ -163,6 +168,7 @@ function credentialsFrom(config: BrowserStackConfig): Credentials { */ const STRICT_NAMED_HOST_PRODUCTS: ReadonlySet = new Set([ "web_accessibility", + "app_accessibility", ]); /** @@ -230,6 +236,30 @@ function resolveNamedHost( ); } +/** + * A product's named host for code outside the registry that calls the same routes: the same + * override, strict check and regional rules as a capability on that host. `declared` stands + * in for the index's `hosts` entry, the US default; it is only called when no override or + * regional host answers first, so an override works even while the account region is unknown. + */ +export function namedHostUrl( + product: string, + host: string, + declared: () => string, +): string { + const hosts = Object.defineProperty({}, host, { + get: declared, + enumerable: true, + }); + return resolveNamedHost( + product, + product.toUpperCase(), + host, + { hosts } as HostSource, + selectedEnvironment(), + ); +} + export async function resolveBaseUrl( product: string, config: BrowserStackConfig, diff --git a/src/tools/capability-registry/search.ts b/src/tools/capability-registry/search.ts index feb19f08..c2376903 100644 --- a/src/tools/capability-registry/search.ts +++ b/src/tools/capability-registry/search.ts @@ -103,6 +103,8 @@ const WRITE_VERBS = new Set([ "upload", "import", "clone", + "hide", + "unhide", ]); // Words that mean "give me many", which is what makes a single-record getter the wrong answer. diff --git a/tests/tools/accessibilityAppCompare.test.ts b/tests/tools/accessibilityAppCompare.test.ts index 53104dd7..6656a427 100644 --- a/tests/tools/accessibilityAppCompare.test.ts +++ b/tests/tools/accessibilityAppCompare.test.ts @@ -5,7 +5,14 @@ import { beforeEach, describe, expect, it, Mock, vi } from "vitest"; // Espresso / XCUITest run. vi.mock("../../src/lib/apiClient.js", () => ({ - apiClient: { get: vi.fn() }, + apiClient: { + get: vi.fn(), + // The App Accessibility dashboard's token. + post: vi.fn(async () => ({ + status: 200, + data: { access_token: "agent-token", expires_in: 3600 }, + })), + }, })); import { apiClient } from "../../src/lib/apiClient.js"; @@ -18,7 +25,7 @@ import { const get = apiClient.get as Mock; const APP_API = - "https://api-app-accessibility.browserstack.com/automate/api/v1"; + "https://app-accessibility.browserstack.com/automate/api/v1"; const DASHBOARD = "https://app-accessibility.browserstack.com"; const BUILD_ID = "m3k8p2q7w1x5c9v4b6n0z2r8t3y7u1i5o9a4s2df"; const EARLIER_ID = "c4v8b2n6m0z3x7q1w5e9r2t6y0u4i8o3p7a1s5dg"; diff --git a/tests/tools/accessibilityAppIssueRows.test.ts b/tests/tools/accessibilityAppIssueRows.test.ts index 9247f963..2addb9b2 100644 --- a/tests/tools/accessibilityAppIssueRows.test.ts +++ b/tests/tools/accessibilityAppIssueRows.test.ts @@ -6,7 +6,14 @@ import { beforeEach, describe, expect, it, Mock, vi } from "vitest"; // fix and each screen's screenshot, which were two thirds of an issue's length. vi.mock("../../src/lib/apiClient.js", () => ({ - apiClient: { get: vi.fn() }, + apiClient: { + get: vi.fn(), + // The App Accessibility dashboard's token. + post: vi.fn(async () => ({ + status: 200, + data: { access_token: "agent-token", expires_in: 3600 }, + })), + }, })); import { apiClient } from "../../src/lib/apiClient.js"; diff --git a/tests/tools/accessibilityAppReport.test.ts b/tests/tools/accessibilityAppReport.test.ts index dcdb7d4f..bbe6f1dd 100644 --- a/tests/tools/accessibilityAppReport.test.ts +++ b/tests/tools/accessibilityAppReport.test.ts @@ -4,15 +4,31 @@ import { afterEach, beforeEach, describe, expect, it, Mock, vi } from "vitest"; // Accessibility API's per-screen snapshots, not from a CSV export. vi.mock("../../src/lib/apiClient.js", () => ({ - apiClient: { get: vi.fn() }, + apiClient: { + get: vi.fn(), + // The App Accessibility dashboard's token. + post: vi.fn(async () => ({ + status: 200, + data: { access_token: "agent-token", expires_in: 3600 }, + })), + }, })); // Web builds are looked up on the Accessibility dashboard with a minted token; no auth server here. -vi.mock("../../src/tools/capability-registry/egress.js", async (original) => ({ - ...(await original()), - authHeaders: vi.fn(async () => ({ Authorization: "Bearer test-token" })), -})); +// App Accessibility keeps the real minting, through the apiClient.post stub above. +vi.mock("../../src/tools/capability-registry/egress.js", async (original) => { + const actual = await original(); + return { + ...actual, + authHeaders: vi.fn(async (...args: Parameters) => + args[2] === "app_accessibility" + ? actual.authHeaders(...args) + : { Authorization: "Bearer test-token" }, + ), + }; +}); import { apiClient } from "../../src/lib/apiClient.js"; +import { resetTokenCache } from "../../src/lib/central-oauth.js"; import { AccessibilityReportFetcher, MAX_APP_BUILD_LIST_PAGES, @@ -25,7 +41,7 @@ import { const get = apiClient.get as Mock; const APP_API = - "https://api-app-accessibility.browserstack.com/automate/api/v1"; + "https://app-accessibility.browserstack.com/automate/api/v1"; const DASHBOARD = "https://app-accessibility.browserstack.com"; /** Where a web build is looked up: the Accessibility dashboard's build metadata. */ const WEB_BUILD_META = (id: string) => @@ -37,12 +53,6 @@ const ok = (body: Record) => ({ status: 200, data: { success: true, ...body }, }); -/** What the dashboard's routes answer an access key with until they take one. */ -const REDIRECT_TO_LOGIN = { - ok: false, - status: 302, - data: { success: false, message: "redirect_to_login" }, -}; const missing = () => ({ ok: false, status: 404, @@ -829,31 +839,37 @@ describe("AccessibilityReportFetcher and App Automate links", () => { describe("AccessibilityReportFetcher and App Accessibility manual reports", () => { const REPORT_ID = "6d1f0a2b-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; + const MANUAL_API = `${DASHBOARD}/api/v1`; + const META_URL = `${MANUAL_API}/app_scanner/${REPORT_ID}/meta_data`; + const OVERVIEW_URL = `${MANUAL_API}/app_scanner/${REPORT_ID}/overview`; + const screensUrl = (page: number) => + `${MANUAL_API}/app_scanner/${REPORT_ID}/snapshot?hide_duplicate_issues=true&page_size=50&page=${page}`; + /** The report page's details (meta_data). */ const DETAIL = { - meta_data: { - name: "Checkout walkthrough", - created_at: "2026-10-21T18:54:05.374Z", - ended_at: "2026-10-21T18:57:22.487Z", - }, - wcag_version: "WCAG 2.2 AA", - data: { - issue_summary: { - total: 2, - severity_count: { critical: 1, serious: 1, hidden_issues: 1, duplicate_issues: 1 }, - scan_count: 2, - }, - }, + report_id: REPORT_ID, + report_name: "Checkout walkthrough", + created_at: "2026-10-21T18:54:05.374Z", + end_time: "2026-10-21T18:57:22.487Z", + status: "complete", + scan_count: 2, + app_details: { name: "Checkout", package_name: "com.example.checkout" }, + device: { model: "iPhone 15 Pro", os: "ios", os_version: "17.0" }, }; - /** A manual snapshot keeps its rules under meta, belongs to no test, and its issues carry no status. */ - const manualSnapshot = (snapshot: (typeof SNAPSHOTS)[number]) => ({ - meta: { - snapshot_id: snapshot.meta.snapshot_id, - screenshot_url: snapshot.meta.screenshot_url, - aggregated_results: snapshot.aggregated_results, - }, - }); + /** The report's overview: the dashboard's counts. */ + const OVERVIEW = { + report_id: REPORT_ID, + status: "complete", + issues: { total: 2, critical: 1, serious: 1, hidden_issues: 1, duplicate_issues: 1 }, + }; + const screens = (snapshot: (typeof SNAPSHOTS)[number], next: number | null) => + ok({ data: { details: [snapshot], info: { next } } }); + const failed = (status: number) => ({ ok: false, status, data: {} }); + const post = apiClient.post as Mock; - beforeEach(() => vi.clearAllMocks()); + beforeEach(() => { + vi.clearAllMocks(); + resetTokenCache(); + }); it("resolves a manual report's dashboard link to the report", async () => { await expect( @@ -862,92 +878,92 @@ describe("AccessibilityReportFetcher and App Accessibility manual reports", () = expect(get).not.toHaveBeenCalled(); }); - it("reads a manual report's status from whether it has ended", async () => { - get.mockResolvedValueOnce(ok({ ...DETAIL, meta_data: { ...DETAIL.meta_data, ended_at: null } })); + it("takes a link on this deployment's own dashboard host, the one its answers link to", async () => { + const host = "https://app-accessibility-preprod.example.com"; + vi.stubEnv("CAPABILITY_REGISTRY_BASE_URL_APP_ACCESSIBILITY_HOST_DASHBOARD", host); + try { + await expect( + fetcher().sourceFromReportUrl(`${host}/report/${REPORT_ID}`), + ).resolves.toEqual({ kind: "appReport", reportId: REPORT_ID }); + } finally { + vi.unstubAllEnvs(); + } + }); + + it("reads a manual report's status from whether its session has ended", async () => { + // A session still recording answers with its raw session row. + get.mockResolvedValueOnce({ + ok: true, + status: 200, + data: { success: false, data: { session_id: "s1", status: "running" } }, + }); await expect( fetcher().reportStatus({ kind: "appReport", reportId: REPORT_ID }), ).resolves.toBe("in_progress"); - get.mockResolvedValueOnce(ok(DETAIL)); + get.mockResolvedValueOnce(ok({ data: { ...DETAIL, end_time: null } })); + await expect( + fetcher().reportStatus({ kind: "appReport", reportId: REPORT_ID }), + ).resolves.toBe("in_progress"); + + get.mockResolvedValueOnce(ok({ data: DETAIL })); await expect( fetcher().reportStatus({ kind: "appReport", reportId: REPORT_ID }), ).resolves.toBe("complete"); - expect(urls()).toEqual([ - `${APP_API.replace("/automate/api/v1", "")}/api/v1/reports/${REPORT_ID}`, - `${APP_API.replace("/automate/api/v1", "")}/api/v1/reports/${REPORT_ID}`, - ]); + expect(urls()).toEqual([META_URL, META_URL, META_URL]); }); - it("falls back to the Manual Reports API's occurrences, with the dashboard's own count, while the dashboard's screens refuse the key", async () => { - const MANUAL_API = `${APP_API.replace("/automate/api/v1", "")}/api/v1`; + it("reads a manual report from the dashboard with a minted ai_agent token, never the access key", async () => { get - .mockResolvedValueOnce(ok(DETAIL)) - .mockResolvedValueOnce(REDIRECT_TO_LOGIN) - .mockResolvedValueOnce( - ok({ - device: { model: "iPhone 15 Pro", os: "ios", os_version: "17.0" }, - data: [manualSnapshot(SNAPSHOTS[0])], - pagination: { page: 1, next: 2 }, - }), - ) - .mockResolvedValueOnce( - ok({ - device: { model: "iPhone 15 Pro", os: "ios", os_version: "17.0" }, - data: [manualSnapshot(SNAPSHOTS[1])], - pagination: { page: 2, next: null }, - }), - ); + .mockResolvedValueOnce(ok({ data: DETAIL })) + .mockResolvedValueOnce(ok({ data: OVERVIEW })) + .mockResolvedValueOnce(screens(SNAPSHOTS[0], 2)) + .mockResolvedValueOnce(screens(SNAPSHOTS[1], null)); const report = await fetcher().appReportIssues(REPORT_ID); - expect(urls()).toEqual([ - `${MANUAL_API}/reports/${REPORT_ID}`, - `${MANUAL_API}/app_scanner/${REPORT_ID}/snapshot?hide_duplicate_issues=true&page_size=50&page=1`, - `${MANUAL_API}/reports/${REPORT_ID}/issues?page_size=50&page=1`, - `${MANUAL_API}/reports/${REPORT_ID}/issues?page_size=50&page=2`, - ]); + expect(urls()).toEqual([META_URL, OVERVIEW_URL, screensUrl(1), screensUrl(2)]); + for (const [options] of get.mock.calls) { + expect(options.headers.Authorization).toBe("Bearer agent-token"); + } + expect(post).toHaveBeenCalledTimes(1); + expect(post.mock.calls[0][0].body).toContain("scope=ai_agent+oauth_user_profile"); expect(report).toMatchObject({ - deduplicated: false, report_name: "Checkout walkthrough", status: "complete", scan_count: 2, device: "iPhone 15 Pro, ios 17.0", - // Every occurrence the API lists; the hidden one is left out as its status says. total_issues: 3, - page_length: 3, next_page: null, - dashboard_count: 2, duplicate_occurrences: 1, hidden_issues: 1, dashboard_link: `${DASHBOARD}/report/${REPORT_ID}`, }); - expect(report.records[0].screen).toBe("Screen 1"); - expect(report.records.map((r) => r.severity)).toEqual([ - "critical", - "serious", - "moderate", - ]); + }); + + it("leaves the dashboard's counts unset when its overview can't be read", async () => { + get + .mockResolvedValueOnce(ok({ data: DETAIL })) + .mockResolvedValueOnce(failed(500)) + .mockResolvedValueOnce(screens(SNAPSHOTS[0], 2)) + .mockResolvedValueOnce(screens(SNAPSHOTS[1], null)); + + const report = await fetcher().appReportIssues(REPORT_ID); + + expect(report.total_issues).toBe(3); + expect(report.duplicate_occurrences).toBeNull(); + expect(report.hidden_issues).toBeNull(); }); it("reads a manual report's screens as the dashboard does: duplicates left out, each issue with its element and fix", async () => { - const MANUAL_API = `${APP_API.replace("/automate/api/v1", "")}/api/v1`; get - .mockResolvedValueOnce(ok(DETAIL)) - .mockResolvedValueOnce( - ok({ data: { details: [SNAPSHOTS[0]], info: { page: 1, next: 2 } } }), - ) - .mockResolvedValueOnce( - ok({ data: { details: [SNAPSHOTS[1]], info: { page: 2, next: null } } }), - ); + .mockResolvedValueOnce(ok({ data: DETAIL })) + .mockResolvedValueOnce(ok({ data: OVERVIEW })) + .mockResolvedValueOnce(screens(SNAPSHOTS[0], 2)) + .mockResolvedValueOnce(screens(SNAPSHOTS[1], null)); const report = await fetcher().appReportIssues(REPORT_ID); - expect(urls()).toEqual([ - `${MANUAL_API}/reports/${REPORT_ID}`, - `${MANUAL_API}/app_scanner/${REPORT_ID}/snapshot?hide_duplicate_issues=true&page_size=50&page=1`, - `${MANUAL_API}/app_scanner/${REPORT_ID}/snapshot?hide_duplicate_issues=true&page_size=50&page=2`, - ]); - expect(report.deduplicated).toBe(true); expect(report.total_issues).toBe(3); const pay = report.records.find((r) => r.component === "com.example:id/btn_pay"); expect(pay?.element).toMatchObject({ className: "android.widget.Button" }); @@ -964,46 +980,27 @@ describe("AccessibilityReportFetcher and App Accessibility manual reports", () = ); }); - // Checked live: an unknown report is a 404 on its details and its issues, a bad key 401. - const failed = (status: number) => ({ ok: false, status, data: {} }); - const MANUAL = `${APP_API.replace("/automate/api/v1", "")}/api/v1`; - it("reports a failed report lookup as the failure, not as an unknown report", async () => { - get.mockResolvedValueOnce(failed(401)); + get.mockResolvedValueOnce(failed(500)); const failure = fetcher().appReportIssues(REPORT_ID); - await expect(failure).rejects.toThrow(/HTTP 401/); + await expect(failure).rejects.toThrow(/HTTP 500/); await expect(failure).rejects.not.toThrow(/No App Accessibility manual report/); }); - it("reads the whole report from the Manual Reports API when a later dashboard page fails, rather than a part as the whole", async () => { - get - .mockResolvedValueOnce(ok(DETAIL)) - .mockResolvedValueOnce( - ok({ data: { details: [SNAPSHOTS[0]], info: { page: 1, next: 2 } } }), - ) - .mockResolvedValueOnce(failed(500)) - .mockResolvedValueOnce( - ok({ - data: [manualSnapshot(SNAPSHOTS[0]), manualSnapshot(SNAPSHOTS[1])], - pagination: { page: 1, next: null }, - }), - ); - - const report = await fetcher().appReportIssues(REPORT_ID); + it("mints again once when the dashboard refuses the token, and reports a second refusal", async () => { + get.mockResolvedValueOnce(failed(401)).mockResolvedValueOnce(failed(401)); - expect(urls()[3]).toBe(`${MANUAL}/reports/${REPORT_ID}/issues?page_size=50&page=1`); - expect(report.deduplicated).toBe(false); - expect(report.total_issues).toBe(3); + await expect(fetcher().appReportIssues(REPORT_ID)).rejects.toThrow(/HTTP 401/); + expect(urls()).toEqual([META_URL, META_URL]); + expect(post).toHaveBeenCalledTimes(2); }); - it("fails with the page and status when an issues page cannot be read, rather than counting fewer issues", async () => { + it("fails with the page and status when a screens page cannot be read, rather than counting fewer issues", async () => { get - .mockResolvedValueOnce(ok(DETAIL)) - .mockResolvedValueOnce(REDIRECT_TO_LOGIN) - .mockResolvedValueOnce( - ok({ data: [manualSnapshot(SNAPSHOTS[0])], pagination: { page: 1, next: 2 } }), - ) + .mockResolvedValueOnce(ok({ data: DETAIL })) + .mockResolvedValueOnce(ok({ data: OVERVIEW })) + .mockResolvedValueOnce(screens(SNAPSHOTS[0], 2)) .mockResolvedValueOnce(failed(502)); await expect(fetcher().appReportIssues(REPORT_ID)).rejects.toThrow( @@ -1013,12 +1010,47 @@ describe("AccessibilityReportFetcher and App Accessibility manual reports", () = it("says how many screens it read when the report has more than the page limit", async () => { get.mockImplementation(async ({ url }: { url: string }) => { - if (url.endsWith(REPORT_ID)) return ok(DETAIL); - return ok({ data: { details: [SNAPSHOTS[0]], info: { next: 2 } } }); + if (url === META_URL) return ok({ data: DETAIL }); + if (url === OVERVIEW_URL) return ok({ data: OVERVIEW }); + return screens(SNAPSHOTS[0], 2); }); const report = await fetcher().appReportIssues(REPORT_ID); expect(report.screens_read).toBe(MAX_SNAPSHOT_PAGES); }); + + it("finds the earlier finished report of the same app through the dashboard's report list", async () => { + const row = (id: string, extra: Record) => ({ + report_id: id, + created_at: "2026-10-20T10:00:00Z", + end_time: "2026-10-20T10:05:00Z", + app_details: { name: "Checkout", package_name: "com.example.checkout" }, + ...extra, + }); + get + .mockResolvedValueOnce(ok({ data: DETAIL })) + .mockResolvedValueOnce( + ok({ + data: [ + row(REPORT_ID, { created_at: DETAIL.created_at }), + row("recording", { end_time: null }), + row("other-app", { app_details: { package_name: "com.example.other" } }), + row("earlier", {}), + ], + info: { next: null }, + }), + ); + + await expect(fetcher().previousManualReport(REPORT_ID)).resolves.toEqual({ + reportId: "earlier", + time: "2026-10-20T10:00:00Z", + link: `${DASHBOARD}/report/earlier`, + }); + expect(urls()).toEqual([ + META_URL, + `${MANUAL_API}/app_scanner?report_name=com.example.checkout&page_size=100&page=1`, + ]); + }); }); + diff --git a/tests/tools/accessibilityAutomateBuildId.test.ts b/tests/tools/accessibilityAutomateBuildId.test.ts index 44750a52..c46fcbc0 100644 --- a/tests/tools/accessibilityAutomateBuildId.test.ts +++ b/tests/tools/accessibilityAutomateBuildId.test.ts @@ -7,7 +7,14 @@ import { beforeEach, describe, expect, it, Mock, vi } from "vitest"; // and is named if nothing knows the id; once a session is found, what it says is the answer. vi.mock("../../src/lib/apiClient.js", () => ({ - apiClient: { get: vi.fn() }, + apiClient: { + get: vi.fn(), + // The App Accessibility dashboard's token. + post: vi.fn(async () => ({ + status: 200, + data: { access_token: "agent-token", expires_in: 3600 }, + })), + }, })); // Web builds are looked up on the Accessibility dashboard with a minted token; no auth server here. vi.mock("../../src/tools/capability-registry/egress.js", async (original) => ({ diff --git a/tests/tools/accessibilityScanOutput.test.ts b/tests/tools/accessibilityScanOutput.test.ts index 4cd724e4..decd7f14 100644 --- a/tests/tools/accessibilityScanOutput.test.ts +++ b/tests/tools/accessibilityScanOutput.test.ts @@ -722,8 +722,6 @@ describe("fetchAccessibilityIssues and App Accessibility manual reports", () => next_page: 140, remaining: 143, summary: { by_severity: { serious: 144 }, by_rule: [], by_screen: [] }, - deduplicated: false, - dashboard_count: 97, duplicate_occurrences: 47, hidden_issues: 0, scan_count: 7, @@ -745,8 +743,6 @@ describe("fetchAccessibilityIssues and App Accessibility manual reports", () => next_page: 140, remaining: 96, summary: { by_severity: { serious: 97 }, by_rule: [], by_screen: [] }, - deduplicated: true, - dashboard_count: 97, duplicate_occurrences: 47, hidden_issues: 0, scan_count: 7, @@ -776,6 +772,18 @@ describe("fetchAccessibilityIssues and App Accessibility manual reports", () => expect(body).toContain("Make the target at least 48dp."); }); + it("says the dashboard's counts could not be read rather than dropping them", async () => { + const base = await m.appReportIssues(); + m.appReportIssues.mockResolvedValue({ ...base, duplicate_occurrences: null, hidden_issues: null }); + + const body = text(await handlers.fetchAccessibilityIssues({ appReportId: REPORT_ID }, CONTEXT)); + + expect(body).toContain( + "The dashboard's duplicate and hidden issue counts could not be read for this report.", + ); + expect(body).not.toContain("duplicate occurrences are left out"); + }); + it("says how many screens it read when the report has more than it reads", async () => { const base = await m.appReportIssues(); m.appReportIssues.mockResolvedValue({ ...base, scan_count: 1200, screens_read: 1000 }); @@ -797,10 +805,10 @@ describe("fetchAccessibilityIssues and App Accessibility manual reports", () => expect(m.appReportIssues).toHaveBeenCalledWith(REPORT_ID, 0); const body = text(result); expect(body).toContain( - "Retrieved 1 accessibility issue occurrences (Total: 144) from the App Accessibility manual report below (7 screens scanned on iPhone 15 Pro, ios 17.0)", + "Retrieved 1 accessibility issues (Total: 144) from the App Accessibility manual report below (7 screens scanned on iPhone 15 Pro, ios 17.0)", ); expect(body).toContain( - "The dashboard counts 97 issues for this report: 47 of the occurrences are duplicates it folds, which the API does not mark.", + "47 duplicate occurrences are left out, as the dashboard leaves them out of its count.", ); const block = body.indexOf("«UNTRUSTED App Accessibility manual report"); expect(block).toBeGreaterThan(-1); diff --git a/tests/tools/accessibilityWebBuildCompare.test.ts b/tests/tools/accessibilityWebBuildCompare.test.ts index 2e813263..792e4285 100644 --- a/tests/tools/accessibilityWebBuildCompare.test.ts +++ b/tests/tools/accessibilityWebBuildCompare.test.ts @@ -42,7 +42,7 @@ const LATEST: Build = { id: "c4latestbuildeeeeeeeeeeeeeeeeeeeeeeeeeee", name: "c const BUILDS = [LATEST, EMPTY, OTHER, NEW, OLD]; // the project's build list: newest first const PROJECT = "Shop"; const APP_BUILD = "a9appbuildgggggggggggggggggggggggggggggg"; -const APP_API = "https://api-app-accessibility.browserstack.com/automate/api/v1"; +const APP_API = "https://app-accessibility.browserstack.com/automate/api/v1"; const PAGE_A = "http://localhost:8765/home.html"; const PAGE_B = "http://localhost:8765/usage.html"; diff --git a/tests/tools/appautomate-native-accessibility.test.ts b/tests/tools/appautomate-native-accessibility.test.ts index cfb05cfd..7901c8f3 100644 --- a/tests/tools/appautomate-native-accessibility.test.ts +++ b/tests/tools/appautomate-native-accessibility.test.ts @@ -163,6 +163,134 @@ describe("runAppTestsOnBrowserStack and App Accessibility", () => { }); }); +// Screen Reader Automation rides on the same build request: App Automate forwards +// accessibilityOptions to the accessibility run when accessibility is on. +describe("Screen Reader Automation on native builds", () => { + beforeEach(() => { + vi.clearAllMocks(); + m.post.mockResolvedValue({ data: { build_id: "b1" } }); + }); + + it.each([ + ["Espresso", triggerEspressoBuild], + ["XCUITest", triggerXcuiBuild], + ])("asks for a Screen Reader report on an %s build", async (_f, trigger) => { + await trigger("bs://app", "bs://suite", ["Google Pixel 8-14.0"], "p", CONFIG, { + accessibility: true, + screenReader: {}, + }); + + expect(m.post.mock.calls[0][0].body).toMatchObject({ + accessibility: true, + accessibilityOptions: { screenReaderAutomation: { autoReport: true } }, + }); + expect( + m.post.mock.calls[0][0].body.accessibilityOptions.screenReaderAutomation, + ).not.toHaveProperty("linearNavigation"); + }); + + it("adds linear navigation with its timeout when asked", async () => { + await triggerEspressoBuild("bs://app", "bs://suite", ["Google Pixel 8-14.0"], "p", CONFIG, { + accessibility: true, + screenReader: { linearNavigation: true }, + }); + + expect(m.post.mock.calls[0][0].body.accessibilityOptions).toEqual({ + screenReaderAutomation: { + autoReport: true, + linearNavigation: true, + linearNavigationTimeout: 300000, + }, + }); + }); + + it("sends no screen reader options without accessibility", async () => { + await triggerEspressoBuild("bs://app", "bs://suite", ["Google Pixel 8-14.0"], "p", CONFIG, { + screenReader: {}, + }); + + expect(m.post.mock.calls[0][0].body).not.toHaveProperty("accessibilityOptions"); + }); +}); + +describe("runAppTestsOnBrowserStack and Screen Reader Automation", () => { + let handlers: Record any>; + + beforeEach(async () => { + vi.clearAllMocks(); + m.post.mockResolvedValue({ data: { build_id: "b1" } }); + const { default: addAppAutomationTools } = await import( + "../../src/tools/appautomate.js" + ); + handlers = {}; + const server: any = { + tool: vi.fn((...args: any[]) => { + handlers[args[0]] = args[args.length - 1]; + }), + server: { getClientVersion: vi.fn().mockReturnValue({ version: "1.0" }) }, + }; + addAppAutomationTools(server, CONFIG); + }); + + const run = (extra: Record) => + handlers.runAppTestsOnBrowserStack({ + browserstackAppUrl: "bs://app", + browserstackTestSuiteUrl: "bs://suite", + devices: [{ platform: "android", deviceName: "Google Pixel 8", osVersion: "14.0" }], + project: "p", + detectedAutomationFramework: "espresso", + ...extra, + }); + + it("turns the accessibility checks on with the screen reader, which needs them", async () => { + await run({ screenReader: true }); + + expect(m.post.mock.calls[0][0].body).toMatchObject({ + accessibility: true, + accessibilityOptions: { screenReaderAutomation: { autoReport: true } }, + }); + }); + + it("passes linear navigation through", async () => { + await run({ screenReader: true, screenReaderLinearNavigation: true }); + + expect( + m.post.mock.calls[0][0].body.accessibilityOptions.screenReaderAutomation, + ).toMatchObject({ linearNavigation: true }); + }); + + it("turns the screen reader on when only linear navigation is asked for", async () => { + await run({ screenReaderLinearNavigation: true }); + + const body = m.post.mock.calls[0][0].body; + expect(body.accessibility).toBe(true); + expect(body.accessibilityOptions.screenReaderAutomation).toMatchObject({ + autoReport: true, + linearNavigation: true, + }); + }); + + it("tells the agent where the Screen Reader report lands and what it needs", async () => { + const result = await run({ screenReader: true }); + + const body = result.content.map((c: any) => c.text).join("\n"); + expect(body).toContain("Screen Reader Automation is on"); + expect(body).toContain("list_app_accessibility_screen_reader_builds"); + expect(body).toMatch(/plan/); + }); + + it("keeps the argument descriptions within budget", async () => { + const { RUN_APP_AUTOMATE_SCHEMA } = await import( + "../../src/tools/appautomate-utils/native-execution/constants.js" + ); + for (const key of ["screenReader", "screenReaderLinearNavigation"]) { + const description = (RUN_APP_AUTOMATE_SCHEMA as any)[key].description ?? ""; + expect(description.length, key).toBeGreaterThan(0); + expect(description.length, key).toBeLessThanOrEqual(60); + } + }); +}); + // A native suite records App Accessibility scans only when it was built with BrowserStack's // instrumentation; saying so where the agent chooses the flag lets it check before a run // that would otherwise finish, 10 to 20 minutes later, with no scans. diff --git a/tests/tools/capabilityAppAccessibility.test.ts b/tests/tools/capabilityAppAccessibility.test.ts index 1be73a5c..9573dd2a 100644 --- a/tests/tools/capabilityAppAccessibility.test.ts +++ b/tests/tools/capabilityAppAccessibility.test.ts @@ -8,8 +8,8 @@ import { } from "../../src/tools/capability-registry/search.js"; // App Accessibility's lists (its projects, a project's builds, manual reports) are reached -// through the capability registry rather than a dedicated tool: they are documented, -// access-key reads with nothing to add on top. What has to hold is that an agent finds +// through the capability registry rather than a dedicated tool, on the dashboard's routes +// like every other App Accessibility capability. What has to hold is that an agent finds // them from the words users say, and that they do not pull other products' questions in. const DIR = new URL("../../capability/", import.meta.url); @@ -33,14 +33,14 @@ const products = shipped(); const app = products.app_accessibility; describe("the App Accessibility capability index", () => { - it("ships the three lists, as reads, each on an entity that names it", () => { - const names = app.capabilities.map((c: any) => c.name).sort(); - expect(names).toEqual([ + // Host and auth for every capability are covered in capabilityAppAccessibilityDashboard. + it("ships the three lists, as paginated reads, each on an entity that names it", () => { + const lists = [ "list_app_accessibility_builds", "list_app_accessibility_projects", "list_manual_app_accessibility_reports", - ]); - for (const capability of app.capabilities) { + ].map((name) => app.capabilities.find((c: any) => c.name === name)); + for (const capability of lists) { expect(capability.mode).toBe("read"); expect(capability.paginated).toBe(true); expect(app.entities[capability.entity].capabilities).toContain( @@ -57,12 +57,18 @@ describe("the App Accessibility capability index", () => { const manual = app.capabilities.find( (c: any) => c.name === "list_manual_app_accessibility_reports", ); - // created_between is echoed back but never narrows the list, and user_id applies to - // account admins only: offered, either would return a wider list that looks filtered. - expect(manual.query.map((q: any) => q.name)).not.toContain( - "created_between", - ); - expect(manual.query.map((q: any) => q.name)).not.toContain("user_id"); + // app_package_names is parsed and then ignored by the dashboard's list: offered, it + // would return the whole list looking filtered. report_name covers the package. + const names = manual.query.map((q: any) => q.name); + expect(names).not.toContain("app_package_names"); + expect(names).toContain("report_name"); + // Without both, the list comes back whole and unpaged. + for (const name of ["page", "page_size"]) { + expect( + manual.query.find((q: any) => q.name === name).required, + name, + ).toBe(true); + } const projects = app.capabilities.find( (c: any) => c.name === "list_app_accessibility_projects", ); diff --git a/tests/tools/capabilityAppAccessibilityDashboard.test.ts b/tests/tools/capabilityAppAccessibilityDashboard.test.ts new file mode 100644 index 00000000..fb2fffce --- /dev/null +++ b/tests/tools/capabilityAppAccessibilityDashboard.test.ts @@ -0,0 +1,465 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { readdirSync, readFileSync } from "node:fs"; +import { fileURLToPath } from "node:url"; + +import { authHeaders } from "../../src/tools/capability-registry/egress.js"; +import { searchCapabilities } from "../../src/tools/capability-registry/search.js"; +import type { TokenTransport } from "../../src/lib/central-oauth.js"; + +// The App Accessibility dashboard's own routes read the dashboard session cookie, or a +// central-auth Bearer carrying the `ai_agent` scope for the routes on app-accessibility's +// allowlist (SCOPED_BEARER_SCOPE_POLICIES in browserstack/app-accessibility). Every App +// Accessibility capability lives on them, with `host: dashboard` and `auth: oauth2`; none is +// left on the access-key public API. What has to hold: they mint, they reach the regional +// DASHBOARD host, and they stay on the backend's allowlist. + +vi.mock("../../src/logger.js", () => ({ + default: { error: vi.fn(), info: vi.fn(), debug: vi.fn(), warn: vi.fn() }, +})); + +const DIR = new URL("../../capability/", import.meta.url); + +function shipped(): Record { + const products: Record = {}; + for (const file of readdirSync(fileURLToPath(DIR))) { + if (!file.endsWith(".capability-index.json")) continue; + const raw = JSON.parse( + readFileSync(fileURLToPath(new URL(file, DIR)), "utf8"), + ); + const [name] = Object.keys(raw).filter( + (k) => !["schema_version", "version", "build_id"].includes(k), + ); + products[name] = raw[name]; + } + return products; +} + +const products = shipped(); +const app = products.app_accessibility; +const dash = app.capabilities.filter((c: any) => c.host === "dashboard"); +const byName = (name: string) => + app.capabilities.find((c: any) => c.name === name); + +// Mirror of the ai_agent allowlist in app-accessibility (config/initializers/constants.rb), +// as routes. A capability outside it would answer 403 ACTION_NOT_ALLOWED_FOR_SCOPE. +const BACKEND_ALLOWLIST = new Set([ + "GET /automate/api/v1/project", + "GET /automate/api/v1/project/{project_id}/build_names", + "GET /automate/api/v1/project/{project_id}/bundle_ids", + "GET /automate/api/v1/project/{project_id}/build", + "GET /automate/api/v1/build/{th_build_id}", + "GET /automate/api/v1/project/{project_id}/build/{th_build_id}/overview", + "GET /automate/api/v1/build/{th_build_id}/snapshot", + "GET /automate/api/v1/build/{th_build_id}/test/{test_case_id}/snapshot", + "GET /automate/api/v1/build/{th_build_id}/conformance-summary", + "GET /automate/api/v1/project/{project_id}/build/{th_build_id}/test", + "GET /automate/api/v1/project/{project_id}/build/{th_build_id}/comparable-builds", + "GET /automate/api/v1/project/{project_id}/build/{th_build_id}/compare/{base_build_id}", + "GET /api/v1/user", + "GET /api/v1/app_scanner", + "GET /api/v1/app_scanner/total", + "GET /api/v1/app_scanner/devices", + "GET /api/v1/app_scanner/{report_id}/meta_data", + "GET /api/v1/app_scanner/{report_id}/overview", + "GET /api/v1/app_scanner/{report_id}/snapshot", + "GET /api/v1/app_scanner/{report_id}/rules", + "GET /api/v1/app_scanner/{report_id}/wcag_levels", + "GET /api/v1/app_scanner/{report_id}/conformance-summary", + "GET /automate/api/v1/screen_reader/project/{project_id}/build", + "GET /automate/api/v1/screen_reader/build/{th_build_id}", + "GET /automate/api/v1/screen_reader/project/{project_id}/build/{th_build_id}/overview", + "GET /automate/api/v1/screen_reader/build/{th_build_id}/snapshot", + "POST /automate/api/v1/scan/{th_build_id}/hide-issue", + "POST /automate/api/v1/scan/{th_build_id}/unhide-issue", + "POST /automate/api/v1/scan/{th_build_id}/get-hide-count", + "POST /automate/api/v1/scan/{th_build_id}/get-unhide-count", + "POST /automate/api/v1/build/{th_build_id}/review-issue", + "POST /api/v1/app_scanner/{report_id}/hide-issue", + "POST /api/v1/app_scanner/{report_id}/unhide-issue", + "POST /api/v1/app_scanner/{report_id}/get-hide-count", + "POST /api/v1/app_scanner/{report_id}/get-unhide-count", + "POST /api/v1/app_scanner/{report_id}/review-issue", +]); + +const WRITES = [ + "hide_app_accessibility_issues", + "hide_manual_app_accessibility_issues", + "review_app_accessibility_issue", + "review_manual_app_accessibility_issue", + "unhide_app_accessibility_issues", + "unhide_manual_app_accessibility_issues", +]; + +describe("the App Accessibility dashboard capabilities", () => { + it("ship every App Accessibility capability on the dashboard", () => { + expect(dash).toHaveLength(app.capabilities.length); + expect(dash.map((c: any) => c.name).sort()).toEqual([ + "compare_app_accessibility_builds", + "count_app_accessibility_issues_to_hide", + "count_app_accessibility_issues_to_unhide", + "count_manual_app_accessibility_issues_to_hide", + "count_manual_app_accessibility_issues_to_unhide", + "count_manual_app_accessibility_reports", + "get_app_accessibility_build", + "get_app_accessibility_build_conformance_summary", + "get_app_accessibility_build_overview", + "get_app_accessibility_screen_reader_build", + "get_app_accessibility_screen_reader_build_overview", + "get_manual_app_accessibility_report", + "get_manual_app_accessibility_report_conformance_summary", + "get_manual_app_accessibility_report_overview", + "hide_app_accessibility_issues", + "hide_manual_app_accessibility_issues", + "list_app_accessibility_build_issues", + "list_app_accessibility_build_names", + "list_app_accessibility_build_tests", + "list_app_accessibility_builds", + "list_app_accessibility_bundle_ids", + "list_app_accessibility_comparable_builds", + "list_app_accessibility_projects", + "list_app_accessibility_screen_reader_build_issues", + "list_app_accessibility_screen_reader_builds", + "list_app_accessibility_test_issues", + "list_app_accessibility_users", + "list_manual_app_accessibility_devices", + "list_manual_app_accessibility_report_issues", + "list_manual_app_accessibility_report_rules", + "list_manual_app_accessibility_report_wcag_levels", + "list_manual_app_accessibility_reports", + "review_app_accessibility_issue", + "review_manual_app_accessibility_issue", + "unhide_app_accessibility_issues", + "unhide_manual_app_accessibility_issues", + ]); + }); + + it("each sign in with a minted token, so none falls back to the product's access key", () => { + for (const c of app.capabilities) { + expect(c.host, c.name).toBe("dashboard"); + expect(c.auth, c.name).toEqual({ type: "oauth2" }); + } + }); + + it("stay on the backend's ai_agent allowlist and never delete", () => { + for (const c of dash) { + expect(["GET", "POST"], c.name).toContain(c.method); + expect(BACKEND_ALLOWLIST.has(`${c.method} ${c.path}`), c.name).toBe(true); + } + }); + + it("mark only hide, unhide and review as writes; the hide counts only read", () => { + const writes = dash + .filter((c: any) => c.mode !== "read") + .map((c: any) => c.name) + .sort(); + expect(writes).toEqual(WRITES); + for (const c of dash.filter((c: any) => c.mode !== "read")) + expect(c.mode, c.name).toBe("write"); + for (const c of dash.filter( + (c: any) => c.name.startsWith("count_") && c.method === "POST", + )) + expect(c.mode, c.name).toBe("read"); + }); + + it("wire each issue action to its own route, never to its inverse", () => { + const routes = Object.fromEntries( + WRITES.map((name) => [ + name, + `${byName(name).method} ${byName(name).path}`, + ]), + ); + expect(routes).toEqual({ + hide_app_accessibility_issues: + "POST /automate/api/v1/scan/{th_build_id}/hide-issue", + hide_manual_app_accessibility_issues: + "POST /api/v1/app_scanner/{report_id}/hide-issue", + review_app_accessibility_issue: + "POST /automate/api/v1/build/{th_build_id}/review-issue", + review_manual_app_accessibility_issue: + "POST /api/v1/app_scanner/{report_id}/review-issue", + unhide_app_accessibility_issues: + "POST /automate/api/v1/scan/{th_build_id}/unhide-issue", + unhide_manual_app_accessibility_issues: + "POST /api/v1/app_scanner/{report_id}/unhide-issue", + }); + }); + + it("never offer a persistent hide, which the backend refuses an agent", () => { + for (const c of app.capabilities) { + const names = [...(c.body ?? []), ...(c.query ?? [])].map( + (p: any) => p.name, + ); + expect(names, c.name).not.toContain("persistence"); + } + }); + + it("ask for approval before every write, and say how to undo a hide", () => { + for (const name of WRITES) { + expect(byName(name).guidance.join(" "), name).toMatch(/APPROVAL FIRST/); + } + expect(byName("hide_app_accessibility_issues").guidance.join(" ")).toMatch( + /unhide_app_accessibility_issues/, + ); + expect( + byName("hide_manual_app_accessibility_issues").guidance.join(" "), + ).toMatch(/unhide_manual_app_accessibility_issues/); + }); + + it("tell an agent a switched-off write is final, not something to retry", () => { + // 403 AGENT_REPORT_ACTIONS_DISABLED: agent writes are switched off for the account; + // nothing changed and a retry is refused too. + expect(app.responses.DashboardForbidden.description).toMatch( + /AGENT_REPORT_ACTIONS_DISABLED/, + ); + for (const name of WRITES) { + const guidance = byName(name).guidance.join(" "); + expect(guidance, name).toMatch(/AGENT_REPORT_ACTIONS_DISABLED/); + expect(guidance, name).toMatch(/do not retry/i); + } + }); + + it("point issue actions at the reads that carry uid and snapshot_id", () => { + // fetchAccessibilityIssues does not return them, so an agent must read these first. + expect(byName("hide_app_accessibility_issues").guidance.join(" ")).toMatch( + /list_app_accessibility_build_issues/, + ); + expect( + byName("hide_manual_app_accessibility_issues").guidance.join(" "), + ).toMatch(/list_manual_app_accessibility_report_issues/); + }); + + it("ship one capability per route, each on an entity that names it", () => { + const routes = app.capabilities.map( + (c: any) => `${c.host ?? "api"} ${c.method} ${c.path}`, + ); + expect(new Set(routes).size).toBe(routes.length); + for (const c of app.capabilities) { + expect(app.entities[c.entity]?.capabilities, c.name).toContain(c.name); + } + for (const entity of Object.values(app.entities)) { + expect(entity.description.length).toBeLessThanOrEqual(140); + } + expect(app.summary.length).toBeLessThanOrEqual(900); + }); + + it("declare every path parameter the path names, and no other", () => { + for (const c of dash) { + const inPath = [...c.path.matchAll(/\{([a-z_]+)\}/g)].map((m) => m[1]); + const declared = (c.path_params ?? []).map((p: any) => p.name); + expect(declared.sort(), c.name).toEqual(inPath.sort()); + for (const p of c.path_params ?? []) + expect(p.required, `${c.name}.${p.name}`).toBe(true); + } + }); + + it("never reach the access-key Reports API, which takes no agent token", () => { + for (const c of app.capabilities) { + expect(c.path, c.name).not.toMatch(/^\/api\/v1\/reports/); + } + }); + + it("declare no object-typed query parameter, which cannot reach the wire", () => { + for (const c of dash) { + for (const q of c.query ?? []) { + expect(q.type, `${c.name}.${q.name}`).not.toBe("object"); + } + } + }); + + it("name only capabilities that exist", () => { + const own = new Set(app.capabilities.map((c: any) => c.name)); + const text = + JSON.stringify(app.capabilities) + JSON.stringify(app.entities); + const referenced = text.match( + /\b(?:list|get|count|compare|hide|unhide|review)_(?:manual_)?app_accessibility(?:_[a-z]+)*\b/g, + ); + for (const name of new Set(referenced)) { + expect(own.has(name), name).toBe(true); + } + }); + + it("tell an agent why a refused route is refused", () => { + expect(app.responses.DashboardScopeNotAllowed.description).toMatch( + /ACTION_NOT_ALLOWED_FOR_SCOPE/, + ); + for (const c of dash) { + expect(c.responses?.["401"], c.name).toBeDefined(); + expect(c.responses?.["403"], c.name).toBeDefined(); + } + }); + + it("say a feature the account lacks is refused, not missing", () => { + // On a group without the feature these answer 404 / 403 with a 'not enabled' message, + // exactly as the dashboard does. + expect( + byName("get_app_accessibility_build_conformance_summary").guidance.join( + " ", + ), + ).toMatch(/not enabled/); + expect( + byName("list_app_accessibility_comparable_builds").guidance.join(" "), + ).toMatch(/not enabled/); + }); +}); + +describe("minting for the App Accessibility dashboard", () => { + it("sends a Bearer minted with the ai_agent scope, never Basic", async () => { + const forms: Record[] = []; + const transport: TokenTransport = async (_url, form) => { + forms.push(form); + return { + status: 200, + body: { access_token: "minted-app-dashboard", expires_in: 3600 }, + }; + }; + const headers = await authHeaders( + { username: "app_dash_user_unique", accessKey: "SECRET" }, + byName("get_app_accessibility_build_overview").auth, + "app_accessibility", + transport, + ); + expect(headers.Authorization).toBe("Bearer minted-app-dashboard"); + expect(forms[0].scope.split(" ")).toEqual( + expect.arrayContaining(["ai_agent", "oauth_user_profile"]), + ); + }); +}); + +describe("the App Accessibility dashboard follows the account's region", () => { + const CONFIG = { + "browserstack-username": "app_dash_region_user", + "browserstack-access-key": "SECRET", + } as any; + const OVERRIDE = + "CAPABILITY_REGISTRY_BASE_URL_APP_ACCESSIBILITY_HOST_DASHBOARD"; + const PRODUCT_OVERRIDE = "CAPABILITY_REGISTRY_BASE_URL_APP_ACCESSIBILITY"; + + async function resolveIn(region: string | undefined, host?: string) { + const { resolveBaseUrl } = + await import("../../src/tools/capability-registry/config.js"); + const { withAccountRegion } = + await import("../../src/lib/region-context.js"); + return withAccountRegion(region as any, () => + resolveBaseUrl("app_accessibility", CONFIG, app, undefined, host), + ); + } + + // The deployment's own settings must not choose the host under test. + const ISOLATED = [OVERRIDE, PRODUCT_OVERRIDE, "CAPABILITY_REGISTRY_ENV"]; + let saved: Record = {}; + beforeEach(() => { + vi.resetModules(); + saved = Object.fromEntries(ISOLATED.map((k) => [k, process.env[k]])); + for (const k of ISOLATED) delete process.env[k]; + }); + afterEach(() => { + for (const k of ISOLATED) { + if (saved[k] === undefined) delete process.env[k]; + else process.env[k] = saved[k]; + } + }); + + it.each([ + ["us", "https://app-accessibility.browserstack.com"], + ["eu", "https://app-accessibility-eu.browserstack.com"], + ["in", "https://app-accessibility-in.browserstack.com"], + ])("sends a %s account's dashboard calls to %s", async (region, host) => { + expect(await resolveIn(region, "dashboard")).toBe(host); + }); + + it("takes the dashboard override for report reads even when the account region is unknown", async () => { + process.env[OVERRIDE] = "https://app-accessibility-preprod.example.com"; + const { withAccountRegion } = + await import("../../src/lib/region-context.js"); + const { appDashboard } = + await import("../../src/tools/accessiblity-utils/app-report-fetcher.js"); + + expect(withAccountRegion("unknown" as any, () => appDashboard())).toBe( + "https://app-accessibility-preprod.example.com", + ); + }); + + it("still refuses report reads for an unknown region without an override", async () => { + const { withAccountRegion } = + await import("../../src/lib/region-context.js"); + const { appDashboard } = + await import("../../src/tools/accessiblity-utils/app-report-fetcher.js"); + + expect(() => + withAccountRegion("unknown" as any, () => appDashboard()), + ).toThrow(/region/i); + }); + + it("keeps the product's own base host on the API host", async () => { + expect(await resolveIn("eu")).toBe( + "https://api-app-accessibility-eu.browserstack.com", + ); + }); + + it("refuses when the account's region is unknown, instead of guessing", async () => { + await expect(resolveIn("unknown", "dashboard")).rejects.toThrow( + /Could not confirm your BrowserStack account's region/, + ); + }); + + // A lower-env session that overrides only the product host must not send its dashboard + // calls to production. + it("refuses the dashboard host when only the product host is overridden", async () => { + process.env[PRODUCT_OVERRIDE] = + "https://app-accessibility-staging.example.com"; + await expect(resolveIn("us", "dashboard")).rejects.toThrow( + /overrides product 'app_accessibility', but not its 'dashboard' host/, + ); + }); + + it("lets an override reach a non-production dashboard", async () => { + process.env[OVERRIDE] = "https://app-accessibility-staging.example.com"; + expect(await resolveIn("us", "dashboard")).toBe( + "https://app-accessibility-staging.example.com", + ); + }); +}); + +describe("finding the dashboard reads", () => { + it.each([ + [ + "overview of an app accessibility build", + "get_app_accessibility_build_overview", + ], + [ + "list the tests in an app accessibility build", + "list_app_accessibility_build_tests", + ], + [ + "compare two app accessibility builds", + "compare_app_accessibility_builds", + ], + [ + "wcag conformance summary of an app accessibility build", + "get_app_accessibility_build_conformance_summary", + ], + [ + "issue counts by rule for a manual app accessibility report", + "list_manual_app_accessibility_report_rules", + ], + [ + "hide an issue in an app accessibility build", + "hide_app_accessibility_issues", + ], + [ + "mark a needs review issue in a manual app accessibility report as not an issue", + "review_manual_app_accessibility_issue", + ], + [ + "list screen reader automation builds of an app accessibility project", + "list_app_accessibility_screen_reader_builds", + ], + ])("finds %j as %s", (query, expected) => { + const { hits } = searchCapabilities(products, query, { + product: "app_accessibility", + }); + expect(hits.slice(0, 3).map((h: any) => h.capability.name)).toContain( + expected, + ); + }); +});