"""Source regressions for the compiled Vue dashboard. Components are expanded at their mount sites so conditional ancestry remains visible. Browser tests complement these checks with real navigation and event handling. """ from __future__ import annotations import re from pathlib import Path import pytest from treg import api from dashboard_source import dashboard_source INDEX = dashboard_source() TUTORIAL = (Path(api.__file__).parent / "web" / "tutorial.html").read_text(encoding="utf-8") # Dialogs reachable from more than one view. Each is opened by a button that exists on both the # marketplace list and an integration page. SHARED_DIALOGS = ["tokenAsk", "capAsk", "methodAsk", "resPick"] def test_paid_key_probe_warning_is_rendered_from_typed_provider_data(): assert 'v-if="tokenAsk.provider.probe_cost_micro"' in INDEX assert "money(tokenAsk.provider.probe_cost_micro)" in INDEX assert "treg will not reuse this paid request for health checks" in INDEX def test_oauth_entry_opens_the_existing_sign_in_modal_without_minting_a_sandbox(): assert "qs.get('signin')==='oauth'" in INDEX assert "else this.demo.signin=true; // OAuth returns, use-case CTA arrivals (?ref=)" in INDEX assert "Sign in to continue connecting Treg" in INDEX assert "After sign-in, review the requested access before you approve it." in INDEX assert '
' in INDEX def test_ref_entry_opens_sign_in_without_minting_a_sandbox(): boot = INDEX[INDEX.index("const qs = new URLSearchParams(location.search)") :] assert "ref = qs.get('ref')" in boot assert "ref || oauthSignin" in boot assert "else this.demo.signin=true; // OAuth returns, use-case CTA arrivals (?ref=)" in boot assert "sbxInit" not in boot assert "/demo/sandbox" not in INDEX assert '
' not in INDEX assert "localStorage.getItem('treg-sbx')" not in INDEX # Every ` # that would otherwise be read as closing the view. (Corollary: don't write a literal `[^>]*)>|") _VIEW_ATTR = re.compile(r"""v-if="view==='(\w+)'""") def _enclosing_views(needle: str) -> list[str]: """Which `