Repository navigation
[APS-22894] Cypress 16: TestHub and Accessibility support files read plugin values via Cypress.expose() (Cypress.env removed) #1206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
0c1bfd8
6268462
585ae8d
a40ac2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,14 @@ const logger = require("./logger").winstonLogger, | |
| Utils = require("./utils"), | ||
| testhubUtils = require("../testhub/utils"); | ||
|
|
||
| const isAccessibilityOn = (bsConfig) => | ||
| process.env.BROWSERSTACK_TEST_ACCESSIBILITY === 'true' || String(bsConfig.run_settings.accessibility) === 'true'; | ||
|
|
||
| const isAboveAccessibilityCypressMajor = (cypressVersion) => { | ||
| const major = String(cypressVersion).match(/^(\d+)/); | ||
| return !!major && Number(major[1]) > Constants.MAX_CYPRESS_MAJOR_FOR_ACCESSIBILITY; | ||
|
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| }; | ||
|
|
||
| const caps = (bsConfig, zip) => { | ||
| return new Promise(function (resolve, reject) { | ||
| let user = undefined; | ||
|
|
@@ -128,8 +136,18 @@ const caps = (bsConfig, zip) => { | |
| bsConfig.run_settings["accessibilityPlatforms"] = getAccessibilityPlatforms(bsConfig); | ||
| } | ||
|
|
||
| // Tells Rails this CLI's support files read Cypress.expose(), so it may run Cypress 16+. | ||
| bsConfig.run_settings["cypressExposeSupport"] = true; | ||
|
|
||
| // send run_settings as is for other capabilities | ||
| obj.run_settings = JSON.stringify(bsConfig.run_settings); | ||
| let runSettings = bsConfig.run_settings; | ||
| // Rails defaults to its newest Cypress, which accessibility does not support yet, so an | ||
| // accessibility build without a version asks for the newest major accessibility supports. | ||
| if (isAccessibilityOn(bsConfig) && Utils.isUndefined(runSettings.cypress_version)) { | ||
| runSettings = Object.assign({}, runSettings, { cypress_version: String(Constants.MAX_CYPRESS_MAJOR_FOR_ACCESSIBILITY) }); | ||
| logger.info(Constants.userMessages.ACCESSIBILITY_CYPRESS_VERSION_PINNED); | ||
| } | ||
| obj.run_settings = JSON.stringify(runSettings); | ||
| } | ||
|
|
||
| // The only route by which a cypress session can name its TestHub build: every session | ||
|
|
@@ -220,6 +238,10 @@ const validate = (bsConfig, args) => { | |
|
|
||
| if (!bsConfig.run_settings) reject(Constants.validationMessages.EMPTY_RUN_SETTINGS); | ||
|
|
||
| if (bsConfig.run_settings && isAccessibilityOn(bsConfig) && isAboveAccessibilityCypressMajor(bsConfig.run_settings.cypress_version)) { | ||
| reject(Constants.validationMessages.ACCESSIBILITY_CYPRESS_VERSION_UNSUPPORTED); | ||
| } | ||
|
|
||
| if (!bsConfig.run_settings.cypressConfigFilePath && !bsConfig.run_settings.userProvidedCypessConfigFile) { | ||
| reject(Constants.validationMessages.EMPTY_CYPRESS_CONFIG_FILE); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: browserstack/browserstack-cypress-cli
Length of output: 4674
Script executed:
Repository: browserstack/browserstack-cypress-cli
Length of output: 5401
Script executed:
Repository: browserstack/browserstack-cypress-cli
Length of output: 3006
Detect browser-level accessibility when validating and pinning Cypress versions.
isAccessibilityOnignores per-browseraccessibility: true.getAccessibilityPlatformsandcheckAccessibilityPlatformtreat that setting as accessibility-enabled. Nobin/path setsBROWSERSTACK_TEST_ACCESSIBILITYfrom browser-level config beforevalidateorcapsruns. With rootaccessibilityfalse and the flag unset, both entrypoints take the disabled branch. The accessibility Cypress version guard is then skipped, and no version is pinned whencypress_versionis omitted.Require that both
validateandcapsapply the accessibility version rules to any build with browser-level accessibility enabled. Keep the existing root-level and environment-flag checks.Decide whether
capsshould also setaccessibilityPlatformsfor browser-level configuration. The current assignment atbin/helpers/capabilityHelper.js:133-136runs only when the flag is set.