stackchain-dashboard/tests/e2e/test_mobile_search_week_plan.py
timmy ea1b5a77f5
Some checks failed
CI / lint (pull_request) Successful in 3m30s
CI / build-release (pull_request) Successful in 7s
CI / browser-journey (pull_request) Failing after 4m48s
CI / release-candidate (pull_request) Has been skipped
feat: plan Search results into Week Ahead (Closes #1194)
2026-08-20 20:39:53 +00:00

44 lines
2.0 KiB
Python

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) =>
`<button type="button" data-search-week-date="2026-08-${21+index}" aria-pressed="${index===0}">
<strong>Day ${index+1}</strong><small>${index*30} of 120 min · ${index} planned</small>
</button>`).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()