2026-06-19 08:06:09 +00:00
|
|
|
# retoor <retoor@molodetz.nl>
|
|
|
|
|
|
|
|
|
|
from playwright.sync_api import expect
|
2026-11-12 15:29:27 +01:00
|
|
|
from tests.conftest import BASE_URL, open_action_menu
|
2026-06-19 08:06:09 +00:00
|
|
|
|
|
|
|
|
MUTE = "form[action='/mute/bob_test'] button"
|
|
|
|
|
UNMUTE = "form[action='/mute/unmute/bob_test'] button"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _confirm(page):
|
|
|
|
|
page.locator(".dialog-overlay.visible .dialog-confirm").click()
|
|
|
|
|
|
|
|
|
|
|
2026-11-05 17:59:21 +01:00
|
|
|
def _has(page, selector):
|
2026-11-12 15:29:27 +01:00
|
|
|
loc = page.locator(selector)
|
|
|
|
|
if loc.count() == 0:
|
|
|
|
|
return False
|
|
|
|
|
return open_action_menu(loc).is_visible()
|
2026-11-05 17:59:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def _pick(page, selector):
|
2026-11-12 15:29:27 +01:00
|
|
|
open_action_menu(page.locator(selector)).click()
|
2026-11-05 17:59:21 +01:00
|
|
|
|
|
|
|
|
|
2026-06-19 08:06:09 +00:00
|
|
|
def _reset_mute(page):
|
|
|
|
|
page.goto(f"{BASE_URL}/profile/bob_test", wait_until="domcontentloaded")
|
2026-11-05 17:59:21 +01:00
|
|
|
if _has(page, UNMUTE):
|
|
|
|
|
_pick(page, UNMUTE)
|
2026-06-19 08:06:09 +00:00
|
|
|
_confirm(page)
|
|
|
|
|
page.wait_for_url("**/profile/bob_test", wait_until="domcontentloaded")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mute_and_unmute_buttons_toggle(alice):
|
|
|
|
|
page, _ = alice
|
|
|
|
|
_reset_mute(page)
|
2026-11-05 17:59:21 +01:00
|
|
|
assert _has(page, MUTE)
|
2026-06-19 08:06:09 +00:00
|
|
|
|
2026-11-05 17:59:21 +01:00
|
|
|
_pick(page, MUTE)
|
2026-06-19 08:06:09 +00:00
|
|
|
_confirm(page)
|
|
|
|
|
page.wait_for_url("**/profile/bob_test", wait_until="domcontentloaded")
|
2026-11-05 17:59:21 +01:00
|
|
|
assert _has(page, UNMUTE)
|
2026-06-19 08:06:09 +00:00
|
|
|
|
2026-11-05 17:59:21 +01:00
|
|
|
_pick(page, UNMUTE)
|
2026-06-19 08:06:09 +00:00
|
|
|
_confirm(page)
|
|
|
|
|
page.wait_for_url("**/profile/bob_test", wait_until="domcontentloaded")
|
2026-11-05 17:59:21 +01:00
|
|
|
assert _has(page, MUTE)
|
2026-06-19 08:06:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mute_button_opens_confirmation_dialog(alice):
|
|
|
|
|
page, _ = alice
|
|
|
|
|
_reset_mute(page)
|
2026-11-05 17:59:21 +01:00
|
|
|
_pick(page, MUTE)
|
2026-06-19 08:06:09 +00:00
|
|
|
expect(page.locator(".dialog-overlay.visible")).to_be_visible()
|
|
|
|
|
expect(page.locator(".dialog-overlay.visible .dialog-message")).to_contain_text(
|
|
|
|
|
"Mute"
|
|
|
|
|
)
|
|
|
|
|
page.locator(".dialog-overlay.visible .dialog-cancel").click()
|
|
|
|
|
expect(page.locator(".dialog-overlay")).not_to_be_visible()
|
2026-11-05 17:59:21 +01:00
|
|
|
assert _has(page, MUTE)
|