T11.6 follow-up: fix autosave_check.py regression from the retired tracker
Found running the full tests/*_check.py suite as part of a deployability
check on feat/waves-11-13: autosave_check.py's "section 7" asserted that
calling trackStepDwell() still wrote an event into wp-usage.js's
localStorage log (wp_suite_analytics_v1). That assertion predates CR-019
and was checking that the autosave guard hadn't accidentally clobbered
the pre-existing analytics dwell listener - a real concern at the time.
T11.6 (previous commit b2a083a) retired that listener on purpose: track()
is now a documented no-op and wp-usage.js is gone, so the localStorage key
is never written to any more. The test was still asserting the old
behavior, so it now correctly failed (0 -> 0) - this was a gap in T11.6's
own verification (only tests/baseline_shots.py was run for it at the
time; the full suite wasn't).
Fix: rewrote section 7 to check what's actually still true - autosave's
own registration (WPAutosave / sopDraftId), and that the retired
trackStepDwell() is a harmless no-op (exists, doesn't throw) rather than
missing or broken - instead of asserting it still records anywhere.
Verified: tests/autosave_check.py now passes 33/33 (was 33/34, exit 1).
Also ran the complete tests/*_check.py suite (39 scripts) as a
deployability check for the whole feat/waves-11-13 branch:
- 38/39 exit 0 after this fix
- token_check.py exits 2 when run with no arguments by design (it needs
--out or --compare) - a harness-invocation detail, not a test failure;
already confirmed non-regression in wave 10
- generalinfo_check.py has one known pre-existing failure (a raw colour
literal check against html/wp-creation-styles.css, a file untouched by
any wave 11/13 work) - already diagnosed as pre-existing in wave 10,
unrelated to CR-019/D18
Also re-verified the usage_events migration (T11.1) round-trips cleanly
on SQLite (upgrade/downgrade/upgrade) and renders clean, valid DDL for
Postgres via `alembic upgrade ... --sql` (TIMESTAMP WITH TIME ZONE / JSON,
no SQLite-only syntax) - no BL-027-class defect.
Backend smoke test (27/27) and seed_demo.py still pass.
This commit is contained in:
@@ -254,27 +254,23 @@ def main():
|
||||
if ("el.textContent = '" in ln or "el.innerHTML = '" in ln)
|
||||
and "the project" not in ln and ("✓" in ln or "⚠" in ln or "↻" in ln or "✕" in ln)])
|
||||
|
||||
print("\n7. the analytics dwell listener still fires")
|
||||
print("\n7. autosave's own registration survives the retired analytics tracker")
|
||||
# This section used to also assert the per-browser usage-analytics dwell
|
||||
# listener (wp-usage.js) still fired alongside autosave, to catch autosave
|
||||
# accidentally replacing it. CR-019/T11.6 (2026-09-23) retired that tracker
|
||||
# on purpose - track() is now a documented no-op and wp-usage.js is gone -
|
||||
# so asserting it still records an event would be asserting the wrong
|
||||
# thing. What's still worth checking here is autosave's own registration,
|
||||
# which is what this section actually guards.
|
||||
boot(page, base, tok, "/work-package-suite.html?project=projA&tab=sop")
|
||||
time.sleep(0.8)
|
||||
chk("the wizard still has its analytics dwell tracker",
|
||||
page.eval("typeof trackStepDwell === 'function'"))
|
||||
chk("...and the wizard registered autosave too",
|
||||
chk("the wizard registered autosave",
|
||||
page.eval("typeof WPAutosave === 'object' && typeof sopDraftId === 'function'"))
|
||||
before = page.eval("""(() => {
|
||||
try { return (JSON.parse(localStorage.getItem('wp_suite_analytics_v1')||'{}').events||[]).length; }
|
||||
catch(e){ return -1; }
|
||||
})()""")
|
||||
# trackStepDwell only records a dwell longer than 400ms, so give it one.
|
||||
time.sleep(0.9)
|
||||
page.eval("typeof trackStepDwell==='function' && trackStepDwell()")
|
||||
time.sleep(0.4)
|
||||
after_n = page.eval("""(() => {
|
||||
try { return (JSON.parse(localStorage.getItem('wp_suite_analytics_v1')||'{}').events||[]).length; }
|
||||
catch(e){ return -1; }
|
||||
})()""")
|
||||
chk("calling it records an event (it was not replaced by the guard)",
|
||||
after_n > before, "%s -> %s" % (before, after_n))
|
||||
chk("...and the retired dwell tracker is a harmless no-op, not missing or throwing",
|
||||
page.eval("""(() => {
|
||||
if (typeof trackStepDwell !== 'function') return false;
|
||||
try { trackStepDwell(); return true; } catch (e) { return false; }
|
||||
})()"""))
|
||||
finally:
|
||||
page.close()
|
||||
browser.close()
|
||||
|
||||
Reference in New Issue
Block a user