LTS reg-env: redirect nightwatch-plugin-browserstack endpoints to bsstag.com#1
Open
MihirR-BS wants to merge 5 commits into
Open
LTS reg-env: redirect nightwatch-plugin-browserstack endpoints to bsstag.com#1MihirR-BS wants to merge 5 commits into
MihirR-BS wants to merge 5 commits into
Conversation
) Adds an env-var-gated mode that lets the plugin emit per-test rows correctly when the user's suite is running on BrowserStack's load- testing infrastructure (where the test runs against a local Selenium hub rather than the Automate hub). src/utils/helper.js - isLoadTestingSession() + getLtsSessionId() helpers, driven by the BROWSERSTACK_LTS_SESSION_ID env var (or BROWSERSTACK_LTS=true|1 for local testing). - getCloudProvider() returns 'browserstack' under LTS so events flow through the integrations.browserstack.* path. - getIntegrationsObject() overrides session_id with the LTS env id and forces product='loadTesting' under LTS. src/testObservability.js - getProductMapForBuildStartCall() sets automate=false + lts=true under LTS so build.source aligns with the LTS contract. All LTS code paths are gated on helper.isLoadTestingSession(). Non-LTS Nightwatch runs see zero behavior change.
* fix(observability): correlate cucumber finishes by unique attempt id and sweep open entities at teardown
Key the cucumber _tests map by the unique testCaseStartedId instead of the
non-unique testCaseId, so reruns/retries/parallel-interleaved attempts of the
same scenario no longer clobber each other and every attempt emits its own
TestRunFinished. Harden TestCaseFinished to reconstruct a minimal payload and
still emit a terminal finish when the map entry is missing.
Add a teardown sweep (run before queue drain / build stop in both the main and
worker teardown paths) that emits terminal failed finishes for any scenario,
hook, or native run left open, so nothing is left running to be reaped as a
timeout. Make getCucumberHookType always return a known hook_type, and let
TestMap.getUUID fall back to the most recent unfinished run.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(observability): make cucumber TestCaseFinished idempotent and drop fresh-uuid reconstruct
A duplicate/out-of-order TestCaseFinished for the same attempt used to find the
entry already deleted, hit the reconstruct branch, mint a fresh uuid, and emit a
phantom TestRunFinished for a run the backend never saw started. And the
reconstruct branch was dead code for the genuine start-never-recorded orphan: the
unguarded _testCasesData read threw before it ran (and the reconstruct itself threw
on undefined), all silently swallowed.
Track handled attempt ids in a Set and early-return on a duplicate finish, guard
the _testCasesData read so an unknown finish no-ops cleanly, and remove the
fresh-uuid reconstruct branch entirely. True orphans (started, never finished) are
owned solely by the teardown sweep, which holds the real stored uuid. The Set is
per-process and bounded by attempt count (same bound as _testCasesData).
Also: per-hook try/catch in sweepOpenHooks so one bad upload no longer aborts the
remaining hook sweeps; fix the synthetic native finish lang to 'nightwatch'; and
document the single-open-run-per-process assumption behind the TestMap.getUUID
fallback. Add tests for the duplicate-finish and never-started-finish cases.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(accessibility): patch prototype command for class-based Nightwatch commands
commandWrapper() patched `originalCommand.command` directly, which only works
for web-element commands that export a plain object (`module.exports.command = fn`).
executeScript/executeAsyncScript (and the protocol/client/appium commands) export
a class with `command` on the prototype, so the patch landed on a non-existent
static method and the real prototype command Nightwatch invokes stayed unpatched.
As a result `performScan` never ran for `browser.execute('mobile:scroll', ...)`
(and all other class-based commands listed in commands.json) on App Accessibility
sessions — no accessibility scan was captured for those interactions.
Detect whether `command` lives as an own property (object export) or on the
prototype (class export) and patch the correct target, mirroring how the
`protocolAction` branch already handles class-based commands. The existing
`shouldPatchExecuteScript` recursion guard now becomes effective and prevents the
plugin's own `browserstack_executor` scan scripts from re-triggering a scan.
Verified on a real-device Android App Accessibility session: `mobile:scroll` now
triggers exactly one performScan, with no recursion, and the test passes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(accessibility): scan function-form execute/executeAsyncScript user scripts
shouldPatchExecuteScript() treated any non-string script as a script to skip
(`!script || typeof script !== 'string'` -> return true), so user scripts passed
as functions — `browser.execute(function(){...})` / `executeAsyncScript(fn)` — never
triggered performScan, even though they can mutate page/screen state just like a
string script.
The plugin's own scan scripts are always strings carrying the `browserstack_executor`
token (verified: every internal execute* call in the SDK passes a string), so a
non-string script is always a user script and is safe to scan — the string-based
recursion guard is unaffected.
Treat an empty/undefined script as skip (unchanged) and a function script as a user
script to scan.
Verified on a real-device Android App Accessibility session: executeAsyncScript(fn)
now triggers exactly one performScan; the 18 internal browserstack_executor scan
scripts are still skipped (no recursion); test passes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(accessibility): cover commandWrapper prototype patching + executeScript guard
Adds unit tests for the two accessibility command-wrapping fixes:
- shouldPatchExecuteScript: empty -> skip, internal browserstack_executor /
accessibility scripts -> skip, user string scripts -> scan, and (regression)
function-form user scripts -> scan.
- commandWrapper: wraps the own `command` of object-export (web-element) commands
and the prototype `command` of class-export commands (executeScript) without
creating a phantom static; verifies the wrapped command triggers performScan,
delegates to the original, honours the recursion guard, and scans function-form
scripts. Drives commandWrapper deterministically by stubbing
require.resolve('nightwatch') and injecting fake command modules via require.cache.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Kamalpreet Kaur <kmlkaur73@gmail.com>
…tag.com Mirror of browserstack-python-sdk PR #977 (Lts tra python reg-env) and browserstack-javaagent LTS-SDK-changes-for-reg-env, applied on top of latest upstream nightwatchjs/nightwatch-plugin-browserstack main. Swaps every production browserstack.com endpoint the nightwatch plugin talks to over to the LTS regression environment on bsstag.com. All target hosts DNS-resolve and respond over HTTPS (verified). Files: - src/utils/constants.js: API_URL, ACCESSIBILITY_URL, APP_ALLY_ENDPOINT - src/testorchestration/testOrderingServer.js: ORCHESTRATION_API_URL - src/testorchestration/requestUtils.js: inline ORCHESTRATION_API_URL Endpoint mapping (DNS-verified against the reg-env cluster): collector-observability.browserstack.com -> collector-observability-k8s.bsstag.com accessibility.browserstack.com/api -> accessibility-k8s.bsstag.com/api app-accessibility.browserstack.com -> app-accessibility-k8s.bsstag.com Note: Python PR #977 and Java LTS-SDK-changes-for-reg-env use `accessibility-qa.bsstag.com` for the accessibility endpoint — that hostname has no DNS. This branch uses `accessibility-k8s.bsstag.com` which is the working reg-env host. Revert before merging to main. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Mirror of browserstack-python-sdk PR #977 and browserstack-javaagent branch
LTS-SDK-changes-for-reg-env, applied on top of latest upstreamnightwatchjs/nightwatch-plugin-browserstackmain (3.11.1).Swaps every production
browserstack.comendpoint the plugin talks to over to the LTS regression environment onbsstag.com, so the Nightwatch plugin can be exercised end-to-end against reg-env alongside the Java agent, Python SDK, and WDIO service.Endpoint mapping
All target hosts DNS-resolve and respond over HTTPS (verified locally before commit):
collector-observability.browserstack.comcollector-observability-k8s.bsstag.comaccessibility.browserstack.com/apiaccessibility-k8s.bsstag.com/apiapp-accessibility.browserstack.comapp-accessibility-k8s.bsstag.comFiles touched
src/utils/constants.js—API_URL,ACCESSIBILITY_URL,APP_ALLY_ENDPOINTsrc/testorchestration/testOrderingServer.js—ORCHESTRATION_API_URLsrc/testorchestration/requestUtils.js— inlineORCHESTRATION_API_URLNote on
accessibility-qa.bsstag.comPython PR #977 and Java
LTS-SDK-changes-for-reg-envuseaccessibility-qa.bsstag.comfor the accessibility endpoint — that hostname has no DNS. This branch usesaccessibility-k8s.bsstag.comwhich is the working reg-env host. The Python/Java branches likely need the same correction.Integrating this fork branch (no CI pipeline exists)
Nightwatch has no binary-side sanity pipeline like WDIO does. To use this branch in a sample project, add to the sample's
package.json:Then
rm -rf node_modules package-lock.json && npm install.Related
browserstack-javaagentbranchLTS-SDK-changes-for-reg-envNot for merge
Reg-env branch only. Revert (or don't merge upstream) before shipping.
🤖 Generated with Claude Code