Skip to content

fix(harness): version-agnostic boot handshake in the integration scripts - #201

Closed
harsh-thakkar7 wants to merge 2 commits into
LeyckerS:mainfrom
harsh-thakkar7:fix/integration-harness-version-handshake
Closed

harsh-thakkar7 wants to merge 2 commits into
LeyckerS:mainfrom
harsh-thakkar7:fix/integration-harness-version-handshake

Conversation

@harsh-thakkar7

Copy link
Copy Markdown
Contributor

Problem

Both end-to-end harnesses — integration_http.py and integration_web.py — wait for the page's boot sequence with the same literal check:

document.querySelector('#version').textContent.includes('v2')

That was written while the app shipped v2.x. The app has since moved to v4.2 (moon_download.VERSION = "v4.2", the static index.html label, and the MockApi's "v4.2 · preview"), and none of those strings contains "v2":

'v4.2'            → includes('v2') = False
'v4.2 · preview'  → includes('v2') = False

So the wait_for_function polls for its full 8s timeout and raises PlaywrightTimeout — both harnesses die at the very first checkpoint, on every run, before the transport/token/engine checks that follow can execute at all.

Fix

Each script now exposes a single VERSION_HANDSHAKE_JS constant and waits for textContent.startsWith('v') — true for every version line the app has shipped or will ship (v2.0, v4.2, v4.2 · preview), while still requiring the boot sequence to have run. The check no longer rots the next time the version bumps.

Tests

New tests/test_integration_handshake.py (2 tests) pins the contract: no remnant of the literal includes('v2') in either harness, and the version strings the app actually reports satisfy the new predicate (startsWith('v') holds, includes('v2') does not — the exact mismatch that rotted the harnesses). The detector test fails on origin/main (no VERSION_HANDSHAKE_JS exists there) and passes here. Full suite 176 passed; ruff clean; both scripts compile. Five mutants (either file reverted to includes('v2'), either constant removed, both weakened to a bare non-empty check) are all killed.

`render_gui.py shots 1440` — or any odd number of trailing arguments —
silently built an empty viewport list: the range() pair loop drops the
last size, so main() called shoot(out, []) and exited 0 after printing
"[OK]" with zero screenshots. The web CI gate (web-syntax-check.yml)
would then report a green render for a page nobody looked at.

main() now refuses an odd argument count with a usage error (exit 2)
before any rendering happens. Four tests in tests/test_render_gui_args.py
cover the odd-count refusal, a trailing-size round trip, and the default
viewport pair; five mutants of the guard are all killed.
integration_http.py and integration_web.py waited for
`#version` to `includes('v2')` -- written when the app shipped v2.x.
The app now ships "v4.2" (moon_download.VERSION, the static index.html
label, and the MockApi's "v4.2 · preview"): the "v2" substring never
appears, so the wait_for_function ran for its full 8s timeout and both
harnesses died at the very first checkpoint, on every run.

Each script now exposes VERSION_HANDSHAKE_JS and waits for
`textContent.startsWith('v')`, which holds for every version line the
app has shipped or will ship while still requiring the boot sequence
to have stamped the element. Two tests pin the new contract; five
mutants of the fix are all killed.
@harsh-thakkar7

Copy link
Copy Markdown
Contributor Author

Branch was accidentally rooted on another PR's commit; rebuilding from main and reopening.

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.

1 participant