summaryrefslogtreecommitdiffstats
path: root/testing/webcompat/interventions/tests/test_1610344_directv_com_co.py
blob: d832eb33d21cc381790d6df9c95e9ae139a8abcb (plain)
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
import pytest

URL = "https://www.directv.com.co/"
IFRAME_CSS = "#main-iframe"
INCOMPATIBLE_CSS = ".browser-compatible.compatible.incompatible"
BLOCKED_TEXT = "blocked by the security rules"
DENIED_TEXT = "not available in your region"
FORBIDDEN_TEXT = "403 Forbidden"


async def check_unsupported_visibility(client, should_show):
    await client.navigate(URL)

    # their region-block page sometimes wraps the content in an iframe
    frame = client.find_css(IFRAME_CSS)
    if frame:
        client.switch_frame(frame)

    denied, blocked, forbidden, incompatible = client.await_first_element_of(
        [
            client.text(DENIED_TEXT),
            client.text(BLOCKED_TEXT),
            client.text(FORBIDDEN_TEXT),
            client.css(INCOMPATIBLE_CSS),
        ]
    )

    if denied or blocked or forbidden:
        pytest.skip("Region-locked, cannot test. Try using a VPN set to USA.")
        return

    shown = client.is_displayed(incompatible)
    assert (should_show and shown) or (not should_show and not shown)


@pytest.mark.skip_platforms("android")
@pytest.mark.asyncio
@pytest.mark.with_interventions
async def test_enabled(client):
    await check_unsupported_visibility(client, should_show=False)


@pytest.mark.skip_platforms("android")
@pytest.mark.asyncio
@pytest.mark.without_interventions
async def test_disabled(client):
    await check_unsupported_visibility(client, should_show=True)