extends SceneTree var failures := 0 func _initialize() -> void: call_deferred("_run") func _run() -> void: var service = root.get_node("LegalService") var auth = root.get_node("AuthState") var terms: Dictionary = service.get_document("terms") var privacy: Dictionary = service.get_document("privacy") _assert(str(terms.get("version", "")) == "2026-07-20", "the embedded Terms version should match the Auth API policy") _assert(str(privacy.get("version", "")) == "2026-07-20", "the embedded Privacy version should match the Auth API policy") _assert(not terms.get("sections", []).is_empty() and not privacy.get("sections", []).is_empty(), "both embedded legal documents should contain reviewable sections") auth.set_session("tester", "token", "refresh", "USER", "", { "requiresLegalAcceptance": true, "termsVersion": "2026-07-20", "privacyVersion": "2026-07-20", "termsUrl": "https://doctor.ranaze.com/terms.html", "privacyUrl": "https://doctor.ranaze.com/privacy.html" }) _assert(auth.requires_legal_acceptance, "an existing account with stale consent should be gated") _assert(auth.terms_url.ends_with("/terms.html"), "legal metadata should retain the public Terms URL") auth.set_legal_state({"requiresLegalAcceptance": false}) _assert(not auth.requires_legal_acceptance, "successful acceptance should release the account gate") auth.clear_session() var login = load("res://scripts/ui/login_screen.gd").new() root.add_child(login) await process_frame _assert(login.registration_legal_check != null, "password registration should require explicit legal consent") _assert(login.steam_legal_check != null, "new Steam-backed accounts should require explicit legal consent") _assert(login.panel_gutter.get_theme_constant("margin_right") >= 28, "registration content should have a gutter beside the scrollbar") login.queue_free() await process_frame quit(1 if failures > 0 else 0) func _assert(condition: bool, message: String) -> void: if condition: return failures += 1 push_error(message)