from pathlib import Path


ROOT = Path(__file__).parents[1]


def test_week_reschedule_journey_closes_only_a_visible_issue_sheet():
    journey = (
        ROOT / "tests" / "e2e" / "test_mobile_today_week_reschedule_release.py"
    ).read_text()

    assert 'issue_sheet = page.locator("#issue-sheet")' in journey
    assert "if issue_sheet.is_visible():" in journey
    guarded_close = journey.split("if issue_sheet.is_visible():", 1)[1].split("\n", 2)[1]
    assert 'page.locator("#close-issue-sheet").click()' in guarded_close
    assert "expect(issue_sheet).to_be_hidden()" in journey
