From 7f6c0c2883dd80c2739bf4f956711a370afc7a28 Mon Sep 17 00:00:00 2001 From: Disco DeDisco Date: Tue, 26 May 2026 15:18:18 -0400 Subject: [PATCH] =?UTF-8?q?FT=20fix=20CI=20#340:=20re-seed=20Earthman=20de?= =?UTF-8?q?ck=20in=20GameboardNavigationTest=20setUp=20=E2=80=94=20Transac?= =?UTF-8?q?tionTestCase=20flush=20trap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `test_game_kit_panel_shows_token_inventory` (a133a9c's polish-9 FT fix) was looking for `id_kit_earthman_deck` in the Game Kit applet. CI #340 surfaced that the selector wasn't rendering — same `TransactionTestCase` migration-seed flush trap documented in `feedback_transactiontestcase_flush.md`: 1. `LiveServerTestCase` derives from `TransactionTestCase` → DB flushed between tests → migration-seeded `DeckVariant(slug="earthman")` row vanishes. 2. `apps/lyric/models.py:537`'s `DeckVariant.objects.filter(slug="earthman").first()` returns None in the post_save signal → `unlocked_decks.add(earthman)` silently skipped. 3. Gameboard view passes `request.user.unlocked_decks.all()` as `deck_variants` → empty → applet partial falls through to `{% empty %}` `id_kit_card_deck` placeholder instead of the per-deck `id_kit_{{ deck.short_key }}_deck` element the FT expects. Fix mirrors the 14+ other FTs already using this helper: call `_seed_earthman_sig_pile()` in `setUp` before `create_pre_authenticated_session` fires the signal. The helper is `get_or_create`-based + idempotent. Selector itself was NOT renamed — `short_key = slug.split('-')[0]` still yields `"earthman"` from slug `"earthman"`, so `id_kit_earthman_deck` is correct. Verified locally: the test runs green w. the seed call in place. Pre-existing in `git status`, bundled per project commit-everything rule: - `src/.coveragerc` — add `*/delete_stale_my_sea_draws.py` to coverage omit list (one-off management script doesn't need coverage measurement) Code architected by Disco DeDisco Git commit message Co-Authored-By: Claude Sonnet 4.6 --- src/.coveragerc | 1 + src/functional_tests/test_gameboard.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/.coveragerc b/src/.coveragerc index e517db2..d5929ea 100644 --- a/src/.coveragerc +++ b/src/.coveragerc @@ -5,6 +5,7 @@ omit = */tests/* */routing.py */reset_staging_db.py + */delete_stale_my_sea_draws.py [report] show_missing = true \ No newline at end of file diff --git a/src/functional_tests/test_gameboard.py b/src/functional_tests/test_gameboard.py index 159ef0d..7a8be3d 100644 --- a/src/functional_tests/test_gameboard.py +++ b/src/functional_tests/test_gameboard.py @@ -3,6 +3,7 @@ from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.by import By from .base import FunctionalTest +from .sig_page import _seed_earthman_sig_pile from apps.applets.models import Applet from apps.epic.models import DeckVariant, Room from apps.lyric.models import Token, User @@ -11,6 +12,17 @@ from apps.lyric.models import Token, User class GameboardNavigationTest(FunctionalTest): def setUp(self): super().setUp() + # Re-seed the Earthman DeckVariant up front — TransactionTestCase + # flushes migration data between tests, so by the time the user + # is created (`create_pre_authenticated_session` inside each test + # method), the post_save signal in `apps/lyric/models.py:537`'s + # `DeckVariant.objects.filter(slug="earthman").first()` would + # return None + skip `unlocked_decks.add(earthman)`. That left + # `test_game_kit_panel_shows_token_inventory`'s `id_kit_earthman_ + # deck` selector unrenderable (applet falls through to the + # `{% empty %}` `id_kit_card_deck` placeholder). CI #340 trap. + # See [[feedback-transactiontestcase-flush]]. + _seed_earthman_sig_pile() Applet.objects.get_or_create(slug="new-game", defaults={"name": "New Game", "context": "gameboard"}) Applet.objects.get_or_create(slug="my-games", defaults={"name": "My Games", "context": "gameboard"}) Applet.objects.get_or_create(slug="game-kit", defaults={"name": "Game Kit", "context": "gameboard"})