Add Playwright e2e tests for all 8 spec acceptance scenarios
All checks were successful
Deploy / deploy (push) Successful in 1m49s
All checks were successful
Deploy / deploy (push) Successful in 1m49s
Implement browser-based e2e tests covering: - Tests 1-5: Stats progression (cohort, feed, eggs, moves, backdating) - Test 6: Event viewing and deletion UI - Test 7: Harvest outcomes with yield items - Test 8: Optimistic lock selection validation Includes page objects for reusable form interactions and fresh_db fixtures for tests requiring isolated database state. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
72
tests/e2e/pages/animals.py
Normal file
72
tests/e2e/pages/animals.py
Normal file
@@ -0,0 +1,72 @@
|
||||
# ABOUTME: Page object for animal-related pages (cohort creation, registry).
|
||||
# ABOUTME: Encapsulates navigation and form interactions for animal management.
|
||||
|
||||
from playwright.sync_api import Page, expect
|
||||
|
||||
|
||||
class AnimalsPage:
|
||||
"""Page object for animal management pages."""
|
||||
|
||||
def __init__(self, page: Page, base_url: str):
|
||||
self.page = page
|
||||
self.base_url = base_url
|
||||
|
||||
def goto_cohort_form(self):
|
||||
"""Navigate to the create cohort form."""
|
||||
self.page.goto(f"{self.base_url}/actions/cohort")
|
||||
expect(self.page.locator("body")).to_be_visible()
|
||||
|
||||
def create_cohort(
|
||||
self,
|
||||
*,
|
||||
species: str,
|
||||
location_name: str,
|
||||
count: int,
|
||||
life_stage: str,
|
||||
sex: str,
|
||||
origin: str = "purchased",
|
||||
notes: str = "",
|
||||
):
|
||||
"""Fill and submit the create cohort form.
|
||||
|
||||
Args:
|
||||
species: "duck" or "goose"
|
||||
location_name: Human-readable location name (e.g., "Strip 1")
|
||||
count: Number of animals
|
||||
life_stage: "hatchling", "juvenile", or "adult"
|
||||
sex: "unknown", "female", or "male"
|
||||
origin: "hatched", "purchased", "rescued", or "unknown"
|
||||
notes: Optional notes
|
||||
"""
|
||||
self.goto_cohort_form()
|
||||
|
||||
# Fill form fields
|
||||
self.page.select_option("#species", species)
|
||||
self.page.select_option("#location_id", label=location_name)
|
||||
self.page.fill("#count", str(count))
|
||||
self.page.select_option("#life_stage", life_stage)
|
||||
self.page.select_option("#sex", sex)
|
||||
self.page.select_option("#origin", origin)
|
||||
|
||||
if notes:
|
||||
self.page.fill("#notes", notes)
|
||||
|
||||
# Submit the form
|
||||
self.page.click('button[type="submit"]')
|
||||
|
||||
# Wait for navigation/response
|
||||
self.page.wait_for_load_state("networkidle")
|
||||
|
||||
def goto_registry(self, filter_str: str = ""):
|
||||
"""Navigate to the animal registry with optional filter."""
|
||||
url = f"{self.base_url}/registry"
|
||||
if filter_str:
|
||||
url += f"?filter={filter_str}"
|
||||
self.page.goto(url)
|
||||
expect(self.page.locator("body")).to_be_visible()
|
||||
|
||||
def get_animal_count_in_registry(self) -> int:
|
||||
"""Get the count of animals currently displayed in registry."""
|
||||
# Registry shows animal rows - count them
|
||||
rows = self.page.locator("table tbody tr")
|
||||
return rows.count()
|
||||
Reference in New Issue
Block a user