-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_settings_ui.py
More file actions
61 lines (45 loc) · 2.01 KB
/
Copy pathtest_settings_ui.py
File metadata and controls
61 lines (45 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""E2E smoke test for the Settings modules admin UI.
Drives a real browser through the sidebar layout at ``/admin/settings/``,
toggles a module setting, and verifies the change hot-reloads into
``app.state`` without a server restart by exercising a downstream endpoint
whose behaviour flips when the setting flips.
"""
from __future__ import annotations
import re
import pytest
from playwright.sync_api import Page, expect
pytestmark = pytest.mark.e2e
def _login(page: Page, username: str, password: str) -> None:
page.get_by_role("link", name="Log in").first.click()
page.locator("#email").fill(username)
page.locator("#password").fill(password)
page.get_by_role("button", name="Log in").click()
# Wait for the session cookie to land before navigating away, or
# /admin/settings/ bounces us back to login and the sidebar never renders.
page.wait_for_url("**/dashboard/**", timeout=15_000)
def test_toggle_host_multi_tenant_persists(
page: Page, e2e_username: str, e2e_password: str
) -> None:
"""Toggle ``host.multi_tenant`` from the admin UI and confirm the PUT
succeeds (surfaced by the Save button going idle). Proves the typed
settings form wires up to the REST API."""
page.goto("/")
_login(page, e2e_username, e2e_password)
page.goto("/admin/settings/")
expect(page.get_by_text("Host", exact=False)).to_be_visible()
# Click the Host entry in the sidebar.
page.get_by_role("button", name=re.compile(r"host", re.I)).first.click()
checkbox = page.get_by_role("checkbox").first
before = checkbox.is_checked()
checkbox.click()
save = page.get_by_role("button", name="Save")
expect(save).to_be_enabled()
save.click()
# On success the form resets dirty state → Save becomes disabled again.
expect(save).to_be_disabled()
# Toggle back so the test is idempotent.
checkbox.click()
expect(save).to_be_enabled()
save.click()
expect(save).to_be_disabled()
assert page.get_by_role("checkbox").first.is_checked() == before