from pathlib import Path import pytest sync_api = pytest.importorskip("playwright.sync_api") FRONTEND = Path(__file__).parents[2] / "frontend" @pytest.mark.parametrize("width,height", [(320, 568), (390, 844)]) def test_search_week_plan_sheet_fits_small_phones_with_touch_safe_controls(width, height): html = (FRONTEND / "index.html").read_text() with sync_api.sync_playwright() as playwright: try: browser = playwright.chromium.launch(headless=True) except Exception as error: pytest.skip(f"Chromium unavailable: {error}") page = browser.new_page(viewport={"width": width, "height": height}) page.set_content(html) page.add_style_tag(path=FRONTEND / "dashboard.css") page.locator("#search-week-plan-days").evaluate( """node => node.innerHTML = Array.from({length:7}, (_, index) => ``).join('')""" ) page.locator("#search-week-plan-sheet").evaluate("node => node.hidden = false") page.locator("#search-week-plan-estimate").fill("45") expect = sync_api.expect expect(page.locator("#search-week-plan-sheet")).to_be_visible() expect(page.locator("#confirm-search-week-plan")).to_be_visible() for button in page.locator("#search-week-plan-days button").all(): bounds = button.bounding_box() assert bounds and bounds["height"] >= 44 assert page.locator("#confirm-search-week-plan").bounding_box()["height"] >= 44 assert page.locator("#cancel-search-week-plan").bounding_box()["height"] >= 44 assert page.evaluate("document.documentElement.scrollWidth <= window.innerWidth") assert page.locator(".search-week-plan-panel").evaluate( "node => node.scrollWidth <= node.clientWidth" ) browser.close() @pytest.mark.parametrize("width,height", [(320, 568), (390, 844)]) def test_search_week_batch_review_fits_small_phones_without_horizontal_overflow(width, height): html = (FRONTEND / "index.html").read_text() with sync_api.sync_playwright() as playwright: try: browser = playwright.chromium.launch(headless=True) except Exception as error: pytest.skip(f"Chromium unavailable: {error}") page = browser.new_page(viewport={"width": width, "height": height}) page.set_content(html) page.add_style_tag(path=FRONTEND / "dashboard.css") page.locator("#search-week-batch-list").evaluate( """node => node.innerHTML = Array.from({length:4}, (_, index) => `