"""Smoke tests — verify the page loads and basic elements exist."""

import pytest


@pytest.mark.frontend
def test_page_loads(page, live_server):
    """Verify the SPA loads and the login overlay appears."""
    # The page should have loaded from the live_server
    assert page.title() == "Canteen Asset Tracker"

    # Login overlay should be visible (initAuth → checkAuthGate → showLogin)
    overlay = page.locator("#loginOverlay")
    assert overlay.is_visible(), "Login overlay should be visible on load"

    # Check for key elements
    assert "Canteen Assets" in page.locator("h1").inner_text()
    assert page.locator("#loginUsername").is_visible()
    assert page.locator("#loginPassword").is_visible()
    assert page.locator("button:has-text('Sign In')").is_visible()
