feat(browserstack-service): stamp hook_run_uuid on App A11y scans fired inside hooks [APPA11Y-5542]#48
feat(browserstack-service): stamp hook_run_uuid on App A11y scans fired inside hooks [APPA11Y-5542]#48AakashHotchandani wants to merge 3 commits into
Conversation
…ed inside hooks [APPA11Y-5542] App A11y scans fired inside test hooks (before/after, beforeEach/afterEach) were dropped or misattributed. The SDK now stamps the hook's run UUID (thHookRunUuid) on scans fired inside a supported hook, so SeleniumHub (appAllyHandler, PR #14162) relays it as hook_run_uuid and app-accessibility reconciles the scan onto the wrapping test case. Additive: in-test scans are unchanged (field dropped when absent). - util: _getParamsForAppAccessibility / performA11yScan thread optional hookRunUuid (thHookRunUuid) - insights-handler: expose getCurrentHook() so a11y reuses the HookRunStarted uuid (= hook BTCER uuid) - accessibility-handler: beforeHook/afterHook set _currentHookRunUuid + enable the scan gate during mocha hook windows (per-test hooks honour include/exclude scope; suite hooks use autoScanning) - service: wire accessibilityHandler.beforeHook/afterHook, passing the shared hook uuid - tests: cover hook-uuid stamp/clear + unsupported-framework no-op Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… change [APPA11Y-5542]
- afterHook: drop unused params (no-unused-vars) — it only resets the hook-uuid stamp
- beforeHook: add `@ts-expect-error fix type` on the shouldScanTestForAccessibility call,
matching the existing beforeTest call (v9 types the 3rd arg as { [key: string]: string })
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…the v9 CLI runtime path [APPA11Y-5542] The earlier commits fixed accessibility-handler.ts (the classic/non-CLI path), but v9 App Automate runs through the CLI observer runtime (cli/modules/accessibilityModule.ts), where the hook-scan change was inert. This ports the same contract into the active v9 path. - Register hook-lifecycle observers (BEFORE_ALL / BEFORE_EACH / AFTER_EACH / AFTER_ALL, PRE + POST). PRE (onHookStart) captures the hook's run uuid from KEY_HOOK_ID — the same uuid reported to TestHub as the hook run — and opens the scan gate for the hook window so DOM-changing commands inside hooks trigger scans. POST (onHookEnd) clears the uuid so subsequent test-body scans are not mis-stamped. - Thread currentHookRunUuid through every scan entry point: the web per-command commandWrapper and both manual performScan() patches, into performScanCli(..., hookRunUuid) -> _getParamsForAppAccessibility, which emits thHookRunUuid (dropped when undefined, so in-test and lifecycle scans are unchanged). Matches SeleniumHub #14162 appAllyScan -> hook_run_uuid. - Add 6 unit tests for the hook-scan logic in the CLI module. Verified end-to-end on real BrowserStack sessions (web + Android App Automate): scans fired inside before/beforeEach/afterEach carry the correct per-hook uuid; test-body and end-of-test lifecycle scans carry none. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up: ported the change into the active v9 CLI runtime pathThe initial commits changed What the CLI-path change does
Verified end-to-end on real BrowserStack sessions (file-write probe, since removed):
Scope note for reviewers (App Automate per-command): the v9 CLI deliberately does not install per-command |
What
App A11y scans fired inside test hooks (
before/after,beforeEach/afterEach) are dropped or misattributed today. This makes the SDK stamp the hook's run UUID (thHookRunUuid) on scans fired inside a supported hook.How
util.ts—_getParamsForAppAccessibility(commandName, testName, hookRunUuid?)addsthHookRunUuid(dropped byJSON.stringifywhen undefined, so in-test scans are byte-for-byte unchanged);performA11yScan(…, hookRunUuid?)threads it.insights-handler.ts— exposegetCurrentHook()so a11y reuses the same UUID reported to TestHub asHookRunStarted(= the hook's BTCERuuid).accessibility-handler.ts—beforeHook/afterHookset_currentHookRunUuidfor the hook window and, for mocha, enable the scan gate during hooks (per-test hooks honour include/exclude scope; suite hooks useautoScanning);commandWrapperpasses the hook uuid intoperformA11yScan.service.ts— wireaccessibilityHandler.beforeHook/afterHook, passing the shared hook uuid.Backend contract
SeleniumHub
appAllyHandler(PR #14162,APPA11Y-5542-hook-run-uuid) destructuresthHookRunUuidand relays it ashook_run_uuid; app-accessibility reconciles the scan onto the wrapping test via the BTCER self-join. Additive at every hop — no field ⇒ unchanged in-test behaviour.Scope
Gated on
frameworkSupportsHook(mocha before/after/beforeEach/afterEach; cucumber uuid-stamped, its scan gate stays owned bybeforeScenario).Tests
Added hook-scan unit tests (stamp/clear + unsupported-framework no-op). Note: local
tsccouldn't fully run against a v8node_moduleson the v9mainbase — CI validates on v9 deps.Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
🤖 Generated with Claude Code