role select channels FTs: get_or_create DeckVariant in _equip_earthman_deck — fixes CI flush wipe

TransactionTestCase.flush() wipes all rows (incl. migration-seeded DeckVariants)
after every test. Landscape runs first (alphabetically), consumes the seeded deck,
then flush removes it. Subsequent tests called filter().first() → None → silently
skipped → data-equipped-deck="" → JS no-deck warning instead of opening fan.

Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Disco DeDisco
2026-04-28 11:46:47 -04:00
parent 4b8e02b698
commit c399afa26d

View File

@@ -14,9 +14,12 @@ from apps.lyric.models import User
def _equip_earthman_deck(user):
"""Equip the Earthman DeckVariant so the role-select no-deck guard passes."""
deck = DeckVariant.objects.filter(name__icontains="Earthman").first()
if deck:
# get_or_create: TransactionTestCase.flush() wipes migration-seeded DeckVariants
# between tests, so subsequent tests in the same run can't find it via filter().
deck, _ = DeckVariant.objects.get_or_create(
slug="earthman",
defaults={"name": "Earthman", "card_count": 106, "is_default": True},
)
user.equipped_deck = deck
user.save(update_fields=["equipped_deck"])