Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/e2e/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
):
Expand Down
11 changes: 9 additions & 2 deletions tests/e2e/test_decline_reopen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand Down
11 changes: 9 additions & 2 deletions tests/e2e/test_event_roster_fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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")
Expand Down
11 changes: 9 additions & 2 deletions tests/e2e/test_open_shifts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand Down
11 changes: 9 additions & 2 deletions tests/e2e/test_swap_marketplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand Down
Loading