A.3-polish: cross-deck sig picker (MINOR + MIDDLE courts) + My Sea applet sig-decoupling — TDD. Two user-reported bugs caught during A.3 visual verify (2026-05-25 PM). Bug 1: my_sign picker shows only 2 cards (Major 0 + 1) for Minchiate-equipped users since _sig_unique_cards_for_deck filters by arcana=MIDDLE which Minchiate (and any non-Earthman tarot family) doesn't classify its courts as — Minchiate courts are MINOR per its standard structure. User spec confirmed: my_sign picker = courts + Major 0/1 for EVERY deck (NOT segment-limited, NOT arcana-classification-limited). Fix: broaden the filter to arcana__in=[MIDDLE, MINOR] so courts qualify regardless of how the deck classifies them. For Earthman, behavior unchanged (no MINOR 11-14 cards exist in seed — its courts are exclusively MIDDLE); for Minchiate + RWS, picker expands from 2 → 18 cards as designed. Two side-by-side suit queries (brands_crowns + blades_grails) collapse to a single 4-suit query since the union was already covering all 4 — that was historical artifact, not segment-limiting in effect. Bug 2: deleting the user's sig on /billboard/my-sign/ blanks the My Sea applet on /gameboard/ even though the saved MySeaDraw spread is still in the DB (visible on /billboard/my-sea/), reappearing only when any sig is re-selected. Root cause: _applet-my-sea.html gated the slot-render branch on {% if not request.user.significator_id %} first, treating no-sig as "no draws yet" regardless of actual draw state. But MySeaDraw rows carry their own significator_id snapshot at first-draw time (gameboard.models.MySeaDraw doc lines 130-132) precisely so user-sig clearing doesn't invalidate saved draws — the template ignored that contract. Fix: invert the template branches — slot render now keys solely on my_sea_slots; the sig-gate Brief banner only fires in the empty-state branch when ALSO not request.user.significator_id (the "fresh user, no draws, no sig" case). MySeaDraw display now correctly decoupled from current sig state — sig deletion only matters for users who haven't drawn yet. Companion code: _sig_unique_cards_for_deck docstring updated to articulate the cross-deck symmetry rule ("courts recognized by rank 11-14 regardless of arcana classification") + the spec-confirmed non-segment-limitation. 1 new regression IT in GameboardViewTest.test_my_sea_applet_renders_slots_even_when_user_significator_cleared locks Bug 2's fix: creates a MySeaDraw row w. one filled slot, then sets User.significator=None, GETs /gameboard/, asserts the filled slot still renders + "No draws yet" empty state is absent. Tests: 1 new IT green; 810/810 epic+gameboard+billboard ITs green; 1290/1290 IT+UT total green (70s, +1 from A.3's 1289). No FT changes needed — Bug 1's fix changes the count of cards in the picker grid; existing FTs that count cards target Earthman where the count is unchanged. Visual verify still pending; user will confirm both fixes via Claudezilla browser session

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Disco DeDisco
2026-05-25 00:16:55 -04:00
parent 5e78e6b832
commit 50a12bccab
3 changed files with 73 additions and 20 deletions

View File

@@ -130,6 +130,51 @@ class GameboardViewTest(TestCase):
empty_positions = {e.get("data-position") for e in empties}
self.assertEqual(empty_positions, {"cover", "crown"})
def test_my_sea_applet_renders_slots_even_when_user_significator_cleared(self):
"""Regression (user bug 2026-05-25 PM): deleting User.significator
(via my-sign DEL) must NOT blank the My Sea applet on the gameboard
when the user has saved MySeaDraw slots. The MySeaDraw row carries
its own significator_id snapshot at first-draw-time so the saved
draw is durable even after the user clears their sig. Applet display
is now decoupled from `request.user.significator_id` — the sig-gate
Brief banner only fires for users with NO draws AND no sig."""
from apps.epic.models import personal_sig_cards, TarotCard
from apps.gameboard.models import MySeaDraw
sig_pile = personal_sig_cards(self.user)
snapshot_sig = sig_pile[0]
card = TarotCard.objects.first()
MySeaDraw.objects.create(
user=self.user,
spread="situation-action-outcome",
hand=[
{"position": "lay", "card_id": card.id,
"reversed": False, "polarity": "gravity"},
],
significator_id=snapshot_sig.id,
)
# User clears their sig AFTER the draw was saved (the bug repro).
self.user.significator = None
self.user.significator_reversed = False
self.user.save(update_fields=["significator", "significator_reversed"])
self.assertIsNone(self.user.significator_id)
response = self.client.get("/gameboard/")
parsed = lxml.html.fromstring(response.content)
# Slots render despite no current sig — the MySeaDraw row owns the
# display, not the user's live sig state.
filled = parsed.cssselect("#id_applet_my_sea .my-sea-slot--filled")
self.assertEqual(
len(filled), 1,
"Filled slot must persist even when User.significator_id is None",
)
self.assertEqual(filled[0].get("data-card-id"), str(card.id))
# And the "No draws yet" empty state must NOT render.
empties = parsed.cssselect("#id_applet_my_sea .my-sea-empty")
self.assertEqual(
len(empties), 0,
"Applet must not render 'No draws yet' when slots exist",
)
def test_my_sea_applet_labels_match_locked_spread(self):
"""SAO label per spec: lay='Situation', cover='Action',
crown='Outcome'. Empty slots still carry their label so the