Skip to content

Appa11 y 5542 hook scans main#75

Merged
Dalwin-Barnard merged 7 commits into
sdk_v9_pre_prodfrom
APPA11Y-5542-hook-scans-main
Jul 22, 2026
Merged

Appa11 y 5542 hook scans main#75
Dalwin-Barnard merged 7 commits into
sdk_v9_pre_prodfrom
APPA11Y-5542-hook-scans-main

Conversation

@Dalwin-Barnard

Copy link
Copy Markdown

What is this about?

Related Jira task/s

Release (mandatory for every PR — required for the ready-for-review label)

Version bump: (required — tick exactly one)

  • minor (backwards-compatible feature)
  • patch (bug fix or other small change)

Release notes type: (optional)

  • New Feature
  • Bug Fix
  • Other Improvement

Release notes (customer-facing): (optional but encouraged)

Release notes (internal): (required — engineer-facing; what actually changed / why)

Checklist

  • Ready to review
  • Has it been tested locally?

PR Validations

Run Tests: Comment RUN_TESTS to trigger sanity tests.

AakashHotchandani and others added 7 commits July 15, 2026 17:23
…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>
…5542]

Addresses review comment (accessibility-handler.ts beforeHook): when the hook's run uuid
cannot be resolved (KEY_HOOK_ID absent), do NOT open the accessibility scan gate for the
hook window. A hook scan with no hook uuid would land as a NULL-attributed row on the
backend — the exact problem this feature avoids — so the gate stays closed and behaviour is
unchanged for such an untracked hook.

Applied to both the active v9 CLI path (cli/modules/accessibilityModule.onHookStart) and the
classic handler path (accessibility-handler.beforeHook). Adds a unit test asserting the gate
is not opened when the hook run uuid is null. Accessibility suite: 74/74 green; tsc clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ent [APPA11Y-5542]

Reverts f9abbf5. A missing hook run uuid must NOT block the accessibility scan: hook-window
commands should always be scanned for coverage; when the hook uuid cannot be resolved the scan
simply goes out without thHookRunUuid (unstamped) instead of being skipped. Restores the
original onHookStart / beforeHook behaviour (scan gate opens regardless; thHookRunUuid dropped
only when undefined) on both the CLI and handler paths, and removes the null-guard unit test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ork instance [APPA11Y-5542]

onHookStart gated the currentHookRunUuid capture behind `!testInstance || !autoInstance`,
but the automation-framework instance is not always resolvable at hook time on the App
Automate CLI path — so an explicit browser.performScan() fired inside a beforeEach/afterEach
hook was never stamped (thHookRunUuid dropped) even though the hook uuid (KEY_HOOK_ID) was
tracked. Capture the uuid from the test instance first; keep the autoInstance gate only for
the web per-command scan gate below. Adds temporary onHookStart/performScan debug logs
(to be removed) to confirm on the wire.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop the onHookStart/performScan debug logs added to confirm hook_run_uuid stamping on the
wire. Verified on a live prod App Automate session (WebdriverIO v9, mocha): beforeEach and
afterEach performScan() scans carry distinct thHookRunUuid; test-body scans carry none.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Dalwin-Barnard
Dalwin-Barnard requested a review from a team as a code owner July 22, 2026 15:56
@Dalwin-Barnard
Dalwin-Barnard requested review from vivianludrick and xxshubhamxx and removed request for a team July 22, 2026 15:56
@Dalwin-Barnard
Dalwin-Barnard merged commit 8342d23 into sdk_v9_pre_prod Jul 22, 2026
14 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants