Skip to content

Commit be9d8df

Browse files
kamal-kaur04claude
andcommitted
Warn only for platforms that requested Accessibility
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 35ed697 commit be9d8df

2 files changed

Lines changed: 33 additions & 5 deletions

File tree

‎bin/commands/runs.js‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,19 @@ module.exports = function run(args, rawArgs) {
135135

136136
// Headless mode and non-Chrome browsers cannot run Accessibility scans; if no platform can,
137137
// drop accessibility before build start so no Accessibility build is registered.
138-
// Resolve with accessibility on at the root, as checkAndSetAccessibility will set it, so a
139-
// request made only on a browser entry survives a --browser override.
138+
// Decide with accessibility on at the root, as checkAndSetAccessibility will set it, so a
139+
// request made only on a browser entry survives a --browser override. Warn only for the
140+
// platforms the user asked for: entries without a flag count only when no entry sets one.
140141
if (isAccessibilitySession && isBrowserstackInfra) {
141142
try {
142-
const resolvedConfig = Object.assign({}, bsConfig, {
143-
run_settings: Object.assign({}, bsConfig.run_settings, { accessibility: true }),
143+
const withRootAccessibility = (accessibility) => Object.assign({}, bsConfig, {
144+
run_settings: Object.assign({}, bsConfig.run_settings, { accessibility }),
144145
});
145-
if (!capabilityHelper.getAccessibilityPlatforms(resolvedConfig).some((platform) => String(platform) === 'true')) {
146+
const rootAccessibility = bsConfig.run_settings.accessibility;
147+
const hasBrowserLevelFlag = (bsConfig.browsers || []).some((browser) => browser.accessibility !== undefined);
148+
const requestedRoot = (rootAccessibility === undefined || rootAccessibility === null) ? !hasBrowserLevelFlag : rootAccessibility;
149+
capabilityHelper.getAccessibilityPlatforms(withRootAccessibility(requestedRoot));
150+
if (!capabilityHelper.getAccessibilityPlatforms(withRootAccessibility(true), false).some((platform) => String(platform) === 'true')) {
146151
logger.debug('Accessibility disabled for the build as no platform supports it');
147152
isAccessibilitySession = false;
148153
}

‎test/unit/bin/commands/runs.js‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,29 @@ describe("runs", () => {
16951695
});
16961696
});
16971697

1698+
it("warns only for browsers that requested accessibility when the request is per-browser", () => {
1699+
perBrowserAccessibility = true;
1700+
return run({ headless: false }, [
1701+
{ browser: "chrome", os: "Windows 10", versions: ["latest"], accessibility: true },
1702+
{ browser: "firefox", os: "Windows 10", versions: ["latest"] },
1703+
]).then(() => {
1704+
sinon.assert.notCalled(logger.warn);
1705+
sinon.assert.calledOnceWithExactly(checkAndSetAccessibilityStub, sinon.match.object, true);
1706+
});
1707+
});
1708+
1709+
it("warns for a --browser override when a per-browser request cannot scan", () => {
1710+
perBrowserAccessibility = true;
1711+
utilsStub.setBrowsers = sandbox.stub().callsFake((bsConfig) => {
1712+
bsConfig.browsers = [{ browser: "chrome", os: "Windows 10", versions: ["latest"] }];
1713+
return Promise.resolve();
1714+
});
1715+
return run({}, [{ browser: "chrome", os: "Windows 10", versions: ["latest"], accessibility: true }], { browser: "chrome" }).then(() => {
1716+
sinon.assert.calledWithMatch(logger.warn, /disabled for Windows 10-chrome/);
1717+
sinon.assert.calledOnceWithExactly(checkAndSetAccessibilityStub, sinon.match.object, false);
1718+
});
1719+
});
1720+
16981721
it("does not resolve platforms when accessibility is not requested", () => {
16991722
return run({}, chrome).then(() => {
17001723
sinon.assert.notCalled(capabilityHelperStub.getAccessibilityPlatforms);

0 commit comments

Comments
 (0)