import pytest from playwright.sync_api import Page, expect # A list of UI routes to check, with their URL, expected title, and a key heading text. UI_ROUTES = [ ("/", "CalMiner Dashboard", "Dashboard"), ("/ui/dashboard", "CalMiner Dashboard", "Dashboard"), ("/ui/scenarios", "CalMiner Scenarios", "Scenarios"), ("/ui/parameters", "CalMiner Parameters", "Parameters"), ("/ui/costs", "CalMiner Costs", "Costs"), ("/ui/consumption", "CalMiner Consumption", "Consumption"), ("/ui/production", "CalMiner Production", "Production"), ("/ui/equipment", "CalMiner Equipment", "Equipment"), ("/ui/maintenance", "CalMiner Maintenance", "Maintenance"), ("/ui/simulations", "CalMiner Simulations", "Simulations"), ("/ui/reporting", "CalMiner Reporting", "Reporting"), ] @pytest.mark.usefixtures("live_server") @pytest.mark.parametrize("url, title, heading", UI_ROUTES) def test_ui_pages_load_correctly(page: Page, url: str, title: str, heading: str): """Verify that all UI pages load with the correct title and a visible heading.""" page.goto(url) expect(page).to_have_title(title) # The app uses a mix of h1 and h2 for main page headings. heading_locator = page.locator( f"h1:has-text('{heading}'), h2:has-text('{heading}')") expect(heading_locator.first).to_be_visible()