from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]


def test_staff_shells_are_magic_link_only():
    runtime = ROOT / "src" / "domain" / "codegen" / "runtime"
    for name in ("staff-admin.vue", "staff-admin.html", "P2hsStaffDashboard.jsx"):
        source = (runtime / name).read_text(encoding="utf-8")
        assert "password" not in source.lower()
        assert "AUTH_MODE" not in source
        assert "requestMagicLink" in source


def test_browser_adapter_does_not_store_session_tokens():
    source = (ROOT / "src" / "domain" / "codegen" / "runtime" / "p2hs-app-client.js").read_text(
        encoding="utf-8"
    )
    assert "localStorage" not in source
    assert "sessionStorage" not in source
    assert "return \"\"" in source


def test_email_template_scaffolds_are_present_for_all_starters():
    for starter in ("nuxt_app", "react_app", "html"):
        path = ROOT / "boilerplates" / starter / "p2hs" / "email-templates.json"
        assert path.is_file()
