"""Phase 01 smoke E2E: the app boots, serves the local frontend, and the placeholder chat round-trips without a stale button. Run: uv run pytest tests/e2e/test_smoke.py -v """ from __future__ import annotations import re import httpx from playwright.sync_api import Page, expect def test_health_endpoint(app_url: str) -> None: r = httpx.get(f"{app_url}/api/health", timeout=5) assert r.status_code == 200 assert r.json()["status"] == "ok" def test_index_page_loads_locally(page: Page, app_url: str) -> None: page.goto(app_url) assert page.title() == "Brain of Reese" assert page.locator(".brand").is_visible() # No external (CDN) resources in the document. html = page.content() assert 'src="http' not in html assert 'href="http' not in html.replace('href="http://www.w3.org', "") def test_placeholder_chat_roundtrip(page: Page, app_url: str) -> None: page.goto(app_url) page.locator("#message-input").fill("hello brain") page.locator("#send-btn").click() # User bubble appears, then the Brain placeholder answer arrives. page.locator(".msg.user .bubble").first.wait_for(state="visible", timeout=10_000) brain_bubble = page.locator(".msg.brain .bubble").first brain_bubble.wait_for(state="visible", timeout=10_000) # to_have_text retries until the async fetch resolves (no stale read). expect(brain_bubble).to_have_text(re.compile("neurons"), timeout=10_000) # Button is never left stuck: back to "Send" and enabled. btn = page.locator("#send-btn") assert btn.is_enabled() assert "Send" in btn.inner_text()