Commit 140294b
Release 3.11.1 (#58)
* 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>1 parent 0b9f0e5 commit 140294b
7 files changed
Lines changed: 665 additions & 34 deletions
File tree
- nightwatch
- src
- utils
- test/src
- test-observability
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
31 | | - | |
32 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
| |||
115 | 121 | | |
116 | 122 | | |
117 | 123 | | |
118 | | - | |
119 | | - | |
| 124 | + | |
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
| |||
139 | 144 | | |
140 | 145 | | |
141 | 146 | | |
142 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
143 | 151 | | |
144 | 152 | | |
145 | 153 | | |
| |||
153 | 161 | | |
154 | 162 | | |
155 | 163 | | |
156 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
157 | 182 | | |
158 | 183 | | |
159 | 184 | | |
160 | 185 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
168 | 191 | | |
169 | 192 | | |
170 | 193 | | |
| |||
177 | 200 | | |
178 | 201 | | |
179 | 202 | | |
180 | | - | |
| 203 | + | |
| 204 | + | |
181 | 205 | | |
182 | 206 | | |
183 | 207 | | |
184 | 208 | | |
185 | | - | |
| 209 | + | |
186 | 210 | | |
187 | | - | |
188 | | - | |
| 211 | + | |
| 212 | + | |
189 | 213 | | |
190 | | - | |
| 214 | + | |
191 | 215 | | |
192 | 216 | | |
193 | 217 | | |
| |||
196 | 220 | | |
197 | 221 | | |
198 | 222 | | |
199 | | - | |
| 223 | + | |
200 | 224 | | |
201 | 225 | | |
202 | 226 | | |
| |||
211 | 235 | | |
212 | 236 | | |
213 | 237 | | |
214 | | - | |
| 238 | + | |
| 239 | + | |
215 | 240 | | |
216 | 241 | | |
217 | 242 | | |
218 | 243 | | |
219 | 244 | | |
220 | | - | |
| 245 | + | |
221 | 246 | | |
222 | 247 | | |
223 | 248 | | |
| |||
226 | 251 | | |
227 | 252 | | |
228 | 253 | | |
229 | | - | |
| 254 | + | |
230 | 255 | | |
231 | | - | |
| 256 | + | |
232 | 257 | | |
233 | 258 | | |
234 | 259 | | |
| |||
250 | 275 | | |
251 | 276 | | |
252 | 277 | | |
253 | | - | |
254 | | - | |
| 278 | + | |
| 279 | + | |
255 | 280 | | |
256 | 281 | | |
257 | 282 | | |
| |||
561 | 586 | | |
562 | 587 | | |
563 | 588 | | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
564 | 593 | | |
565 | 594 | | |
566 | 595 | | |
| |||
659 | 688 | | |
660 | 689 | | |
661 | 690 | | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
662 | 694 | | |
663 | 695 | | |
664 | 696 | | |
| |||
667 | 699 | | |
668 | 700 | | |
669 | 701 | | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
670 | 746 | | |
671 | 747 | | |
672 | 748 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
440 | | - | |
441 | 440 | | |
442 | | - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
443 | 460 | | |
444 | 461 | | |
445 | 462 | | |
| |||
458 | 475 | | |
459 | 476 | | |
460 | 477 | | |
461 | | - | |
| 478 | + | |
462 | 479 | | |
463 | 480 | | |
464 | 481 | | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
465 | 489 | | |
466 | 490 | | |
467 | 491 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
871 | 871 | | |
872 | 872 | | |
873 | 873 | | |
874 | | - | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
875 | 879 | | |
876 | 880 | | |
877 | | - | |
| 881 | + | |
878 | 882 | | |
879 | 883 | | |
880 | 884 | | |
881 | | - | |
| 885 | + | |
882 | 886 | | |
883 | 887 | | |
884 | 888 | | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
885 | 979 | | |
886 | 980 | | |
887 | 981 | | |
| |||
0 commit comments