"""C12 — IME composition Enter behaviour. Runs `c12_ime.mjs` via Node (no jsdom dep, just Node ≥ 18). Records PASS/FAIL into results/C12.json so build_report picks it up. Test cases covered: 1. Plain Enter → send 2. Shift+Enter → no send (newline) 3. Enter during IME composition → no send 4. Enter on compositionend tick → no send (deferred flag) 5. Enter after composition tick → send 6. Cmd+Enter still sends (backwards compat) 7. Non-Enter key → no send The test reads static/app.js and asserts the production handler still contains the three guards (Enter check, shift check, _composing check). If app.js drifts the test fails — drift-proof regression guard. """ from __future__ import annotations import subprocess import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[1])) from verify_v04._common import record # noqa: E402 _HERE = Path(__file__).resolve().parent _TEST_JS = _HERE / "c12_ime.mjs" def main() -> int: print("\n[C12] IME composition Enter behaviour") try: proc = subprocess.run( ["node", str(_TEST_JS)], capture_output=True, text=True, timeout=30, check=False, ) except FileNotFoundError: record("C12", False, "node binary not found in PATH") return 1 except subprocess.TimeoutExpired: record("C12", False, "node test timed out (>30s)") return 1 out = proc.stdout.strip() err = proc.stderr.strip() if out: print(out) if err: print(err, file=sys.stderr) ok = proc.returncode == 0 summary = out.splitlines()[-1] if out else "(no output)" record("C12", ok, summary) return 0 if ok else 1 if __name__ == "__main__": sys.exit(main())