64 lines
2.5 KiB
Python
64 lines
2.5 KiB
Python
"""Playwright E2E: настройки /recipes — sync panel, credentials, logout."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
pytestmark = pytest.mark.e2e
|
|
|
|
|
|
def test_settings_panel_open_close(authenticated_page) -> None:
|
|
page = authenticated_page
|
|
page.set_viewport_size({"width": 1280, "height": 800})
|
|
open_btn = page.locator('[data-action="open-settings"]')
|
|
assert open_btn.count() >= 1, "open-settings должен быть в навигации"
|
|
open_btn.first.click(force=True)
|
|
page.wait_for_selector('[data-action="close-settings"]', timeout=5000)
|
|
assert page.locator('[data-action="toggle-sync-form"]').is_visible()
|
|
page.locator('#settingsModal [data-action="close-settings"]').first.click()
|
|
page.wait_for_timeout(300)
|
|
|
|
|
|
def test_toggle_sync_form(authenticated_page) -> None:
|
|
page = authenticated_page
|
|
page.set_viewport_size({"width": 1280, "height": 800})
|
|
page.locator('[data-action="open-settings"]').first.click()
|
|
page.wait_for_selector('[data-action="toggle-sync-form"]', timeout=5000)
|
|
page.locator('[data-action="toggle-sync-form"]').click()
|
|
page.wait_for_timeout(200)
|
|
|
|
|
|
def test_toggle_credentials_form(authenticated_page) -> None:
|
|
page = authenticated_page
|
|
page.set_viewport_size({"width": 1280, "height": 800})
|
|
page.locator('[data-action="open-settings"]').first.click(force=True)
|
|
cred = page.locator('[data-action="toggle-credentials-form"]')
|
|
cred.wait_for(state="visible", timeout=5000)
|
|
cred.click()
|
|
page.wait_for_timeout(200)
|
|
|
|
|
|
def test_logout_clears_session(authenticated_page, live_server_url) -> None:
|
|
page = authenticated_page
|
|
page.set_viewport_size({"width": 1280, "height": 800})
|
|
with page.expect_response(
|
|
lambda r: r.url.endswith("/api/auth/logout") and r.request.method == "POST",
|
|
timeout=10000,
|
|
):
|
|
page.locator('[data-action="logout"]').first.click()
|
|
page.wait_for_url(f"{live_server_url}/", timeout=10000)
|
|
check = page.request.get(f"{live_server_url}/api/auth/check")
|
|
assert check.ok
|
|
assert check.json().get("authenticated") is False
|
|
|
|
|
|
def test_mobile_dashboard_back(authenticated_page) -> None:
|
|
page = authenticated_page
|
|
page.set_viewport_size({"width": 390, "height": 844})
|
|
from tests.e2e.conftest import E2E_MILL_ID
|
|
|
|
page.locator(f'[data-action="select-dispenser"][data-dispenser-id="{E2E_MILL_ID}"]').click()
|
|
page.wait_for_selector('[data-action="mobile-dashboard-back"]', timeout=10000)
|
|
page.locator('[data-action="mobile-dashboard-back"]').click()
|
|
page.wait_for_timeout(400)
|