diff --git a/tests/e2e/_helpers.py b/tests/e2e/_helpers.py index f231b406..de376ca3 100644 --- a/tests/e2e/_helpers.py +++ b/tests/e2e/_helpers.py @@ -6,12 +6,30 @@ import sqlite3 import uuid +from datetime import date, timedelta def rid() -> str: return uuid.uuid4().hex[:8] +def next_sunday_iso() -> str: + """Return the ISO date of a Sunday at least 7 days from today. + + The open-shift, swap, and decline-reopen flows seed a "Sunday 10am + Service" event and expect it to appear on `/v/open` (which filters + out past events). Hard-coded dates rot the suite as time passes — + this keeps the seed event safely in the future on every run. + """ + today = date.today() + # weekday(): Monday=0 ... Sunday=6. Days until next Sunday after at + # least a 7-day cushion. + days_until_sunday = (6 - today.weekday()) % 7 + if days_until_sunday < 7: + days_until_sunday += 7 + return (today + timedelta(days=days_until_sunday)).isoformat() + + def signup_admin( page, base_url, *, org="Hope Chapel", name="Admin Dana", email=None, password="HopePass123!" ): diff --git a/tests/e2e/test_decline_reopen.py b/tests/e2e/test_decline_reopen.py index ac33ae65..a012b135 100644 --- a/tests/e2e/test_decline_reopen.py +++ b/tests/e2e/test_decline_reopen.py @@ -8,7 +8,14 @@ import pytest -from tests.e2e._helpers import accept_invitation, invite_token, no_js_errors, rid, signup_admin +from tests.e2e._helpers import ( + accept_invitation, + invite_token, + next_sunday_iso, + no_js_errors, + rid, + signup_admin, +) pytestmark = pytest.mark.e2e @@ -39,7 +46,7 @@ def test_decline_reopens_slot(live_server, new_context, page, db_path): page.click("button:has-text('New event')") page.wait_for_selector("#ev_type", state="visible") page.fill("#ev_type", "Sunday 10am Service") - page.fill("#ev_date", "2026-06-07") + page.fill("#ev_date", next_sunday_iso()) page.fill("#ev_start", "10:00") page.fill("#ev_end", "11:30") page.fill("input[name=role_name]", "volunteer") diff --git a/tests/e2e/test_event_roster_fill.py b/tests/e2e/test_event_roster_fill.py index 6e0c6fc8..d180b3f8 100644 --- a/tests/e2e/test_event_roster_fill.py +++ b/tests/e2e/test_event_roster_fill.py @@ -4,7 +4,14 @@ import pytest -from tests.e2e._helpers import accept_invitation, invite_token, no_js_errors, rid, signup_admin +from tests.e2e._helpers import ( + accept_invitation, + invite_token, + next_sunday_iso, + no_js_errors, + rid, + signup_admin, +) pytestmark = pytest.mark.e2e @@ -28,7 +35,7 @@ def test_admin_fills_roster_gap(live_server, new_context, page, db_path): page.click("button:has-text('New event')") page.wait_for_selector("#ev_type", state="visible") page.fill("#ev_type", "Sunday 10am Service") - page.fill("#ev_date", "2026-06-07") + page.fill("#ev_date", next_sunday_iso()) page.fill("#ev_start", "10:00") page.fill("#ev_end", "11:30") page.fill("input[name=role_name]", "usher") diff --git a/tests/e2e/test_open_shifts.py b/tests/e2e/test_open_shifts.py index aae41b0b..09a935c2 100644 --- a/tests/e2e/test_open_shifts.py +++ b/tests/e2e/test_open_shifts.py @@ -4,7 +4,14 @@ import pytest -from tests.e2e._helpers import accept_invitation, invite_token, no_js_errors, rid, signup_admin +from tests.e2e._helpers import ( + accept_invitation, + invite_token, + next_sunday_iso, + no_js_errors, + rid, + signup_admin, +) pytestmark = pytest.mark.e2e @@ -32,7 +39,7 @@ def test_volunteer_claims_open_shift(live_server, new_context, page, db_path): page.click("button:has-text('New event')") page.wait_for_selector("#ev_type", state="visible") page.fill("#ev_type", "Sunday 10am Service") - page.fill("#ev_date", "2026-06-07") + page.fill("#ev_date", next_sunday_iso()) page.fill("#ev_start", "10:00") page.fill("#ev_end", "11:30") page.fill("input[name=role_name]", "volunteer") diff --git a/tests/e2e/test_swap_marketplace.py b/tests/e2e/test_swap_marketplace.py index bc09196b..a8eaa280 100644 --- a/tests/e2e/test_swap_marketplace.py +++ b/tests/e2e/test_swap_marketplace.py @@ -4,7 +4,14 @@ import pytest -from tests.e2e._helpers import accept_invitation, invite_token, no_js_errors, rid, signup_admin +from tests.e2e._helpers import ( + accept_invitation, + invite_token, + next_sunday_iso, + no_js_errors, + rid, + signup_admin, +) pytestmark = pytest.mark.e2e @@ -36,7 +43,7 @@ def test_cover_a_swap_end_to_end(live_server, new_context, page, db_path): page.click("button:has-text('New event')") page.wait_for_selector("#ev_type", state="visible") page.fill("#ev_type", "Sunday 10am Service") - page.fill("#ev_date", "2026-06-07") + page.fill("#ev_date", next_sunday_iso()) page.fill("#ev_start", "10:00") page.fill("#ev_end", "11:30") page.fill("input[name=role_name]", "volunteer")