diff --git a/tests/autosave_check.py b/tests/autosave_check.py index 000cbfe..a7e0ee1 100644 --- a/tests/autosave_check.py +++ b/tests/autosave_check.py @@ -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()