Add recent events and stats to eggs, feed, and move forms
All checks were successful
Deploy / deploy (push) Successful in 2m40s
All checks were successful
Deploy / deploy (push) Successful in 2m40s
- Create recent_events.py helper for rendering event lists with humanized timestamps and deleted event styling (line-through + opacity) - Query events with ORDER BY ts_utc DESC to show newest first - Join event_tombstones to detect deleted events - Fix move form to read animal_ids (not resolved_ids) from entity_refs - Fix feed purchase format to use total_kg from entity_refs - Use hx_get with #event-panel-content target for slide-over panel - Add days-since-last stats for move and feed forms 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -211,3 +211,60 @@ class TestEggCollection:
|
||||
# The response should contain the form with the location pre-selected
|
||||
# Check for "selected" attribute on the option with our location_id
|
||||
assert "selected" in resp.text and location_strip1_id in resp.text
|
||||
|
||||
|
||||
class TestEggsRecentEvents:
|
||||
"""Tests for recent events display on eggs page."""
|
||||
|
||||
def test_harvest_tab_shows_recent_events_section(self, client):
|
||||
"""Harvest tab shows Recent Harvests section."""
|
||||
resp = client.get("/")
|
||||
assert resp.status_code == 200
|
||||
assert "Recent Harvests" in resp.text
|
||||
|
||||
def test_sell_tab_shows_recent_events_section(self, client):
|
||||
"""Sell tab shows Recent Sales section."""
|
||||
resp = client.get("/?tab=sell")
|
||||
assert resp.status_code == 200
|
||||
assert "Recent Sales" in resp.text
|
||||
|
||||
def test_harvest_event_appears_in_recent(
|
||||
self, client, seeded_db, location_strip1_id, ducks_at_strip1
|
||||
):
|
||||
"""Newly created harvest event appears in recent events list."""
|
||||
resp = client.post(
|
||||
"/actions/product-collected",
|
||||
data={
|
||||
"location_id": location_strip1_id,
|
||||
"quantity": "12",
|
||||
"nonce": "test-nonce-recent-1",
|
||||
},
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
# Recent events should include the newly created event
|
||||
# Check for event link pattern
|
||||
assert "/events/" in resp.text
|
||||
|
||||
def test_harvest_event_links_to_detail(
|
||||
self, client, seeded_db, location_strip1_id, ducks_at_strip1
|
||||
):
|
||||
"""Harvest events in recent list link to event detail page."""
|
||||
# Create an event
|
||||
resp = client.post(
|
||||
"/actions/product-collected",
|
||||
data={
|
||||
"location_id": location_strip1_id,
|
||||
"quantity": "8",
|
||||
"nonce": "test-nonce-recent-2",
|
||||
},
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
|
||||
# Get the event ID from DB
|
||||
event_row = seeded_db.execute(
|
||||
"SELECT id FROM events WHERE type = 'ProductCollected' ORDER BY id DESC LIMIT 1"
|
||||
).fetchone()
|
||||
event_id = event_row[0]
|
||||
|
||||
# The response should contain a link to the event detail
|
||||
assert f"/events/{event_id}" in resp.text
|
||||
|
||||
Reference in New Issue
Block a user