45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
import re
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
if os.getenv("STACKCHAIN_RUN_RELEASE_E2E") != "1":
|
|
pytest.skip("rendered mobile quiet-hours checks run only in the browser gate", allow_module_level=True)
|
|
pytest.importorskip("playwright.sync_api")
|
|
from playwright.sync_api import expect, sync_playwright
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
FRONTEND = ROOT / "frontend"
|
|
|
|
|
|
@pytest.mark.parametrize("viewport", [
|
|
{"width": 320, "height": 568},
|
|
{"width": 390, "height": 844},
|
|
])
|
|
def test_notification_quiet_hours_are_phone_usable_without_horizontal_scroll(viewport):
|
|
html = re.sub(r'<script src="static/[^"]+"></script>', "", (FRONTEND / "index.html").read_text())
|
|
with sync_playwright() as playwright:
|
|
browser = playwright.chromium.launch(headless=True)
|
|
page = browser.new_page(viewport=viewport)
|
|
page.set_content(html)
|
|
page.add_style_tag(path=FRONTEND / "dashboard.css")
|
|
page.locator("#work-settings-toggle").click()
|
|
|
|
toggle = page.locator('label[for="push-quiet-hours"]')
|
|
start = page.locator("#push-quiet-start")
|
|
end = page.locator("#push-quiet-end")
|
|
expect(toggle).to_be_visible()
|
|
expect(start).to_be_visible()
|
|
expect(end).to_be_visible()
|
|
expect(start).to_have_value("22:00")
|
|
expect(end).to_have_value("07:00")
|
|
for control in (toggle, start, end):
|
|
bounds = control.bounding_box()
|
|
assert bounds and bounds["height"] >= 44
|
|
assert page.evaluate("document.documentElement.scrollWidth <= window.innerWidth")
|
|
browser.close()
|