test_q3_desktop_integration.py python
66 lines 2.2 KB
Raw
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83 chore(governance): sync handover+roadmap to 84db8c8 (drift:… Human 9 hours ago
1 """Integration tests for Track Q / Q3 Tauri desktop packaging."""
2
3 from __future__ import annotations
4
5 import urllib.request
6 from pathlib import Path
7
8 from tests.fixtures.app import AppHttpClient
9 from tests.fixtures.desktop import make_desktop_launcher
10 from tests.support import KIT_ROOT
11 from tools.desktop.init_script import build_auth_bootstrap_script
12
13
14 def test_desktop_launcher_starts_ok_app_and_serves_ui(tmp_path: Path) -> None:
15 launcher = make_desktop_launcher(tmp_path)
16 try:
17 banner = launcher.start()
18 assert banner.url.startswith("http://127.0.0.1:")
19 assert len(banner.session_credential) >= 32
20 assert len(banner.csrf_token) >= 32
21
22 client = AppHttpClient(banner.url.rstrip("/"), banner.session_credential, banner.csrf_token)
23 status, health = client.get("/api/health")
24 assert status == 200
25 assert health["result"]["status"] == "ok"
26
27 request = urllib.request.Request(
28 f"{banner.url.rstrip('/')}/",
29 headers={"Authorization": f"Bearer {banner.session_credential}"},
30 )
31 with urllib.request.urlopen(request, timeout=5) as response:
32 html = response.read().decode("utf-8")
33 assert "Overseer Kit" in html
34 assert "/assets/app.js" in html
35 finally:
36 launcher.stop()
37
38
39 def test_launch_argv_matches_canonical_shim(tmp_path: Path) -> None:
40 launcher = make_desktop_launcher(tmp_path)
41 assert launcher.argv[0] == str(KIT_ROOT / "cli" / "ok")
42 assert launcher.argv[1] == "app"
43
44
45 def test_auth_bootstrap_script_is_non_persisting(tmp_path: Path) -> None:
46 launcher = make_desktop_launcher(tmp_path)
47 try:
48 banner = launcher.start()
49 script = build_auth_bootstrap_script(
50 session_credential=banner.session_credential,
51 csrf_token=banner.csrf_token,
52 )
53 assert "session-input" in script
54 assert "csrf-input" in script
55 assert "auth-save" in script
56 assert "localStorage" not in script
57 assert "document.cookie" not in script
58 finally:
59 launcher.stop()
60
61
62 def test_desktop_launcher_stop_is_idempotent(tmp_path: Path) -> None:
63 launcher = make_desktop_launcher(tmp_path)
64 launcher.start()
65 launcher.stop()
66 launcher.stop()
File History 1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199 fix(ISR): default require_independent_second_reviewer to require Human minor 9 hours ago