my-sea slot: render the 5+-char numeral squeeze (--rank-long) server-side so it survives a refresh — TDD
sea.js's _fillSlot adds .sea-card-slot--rank-long on draw (corner_rank length >= 5) to squeeze long Roman numerals (XVIII, XLVIII, ...) into the slot, but _my_sea_slot.html didn't — so a saved hand stretched the numeral back out on refresh (server render). Add the same length>=5 class server-side. Fixes both the owner picker + the spectator cross (shared partial). +3 ITs (long / short / boundary). Code architected by Disco DeDisco <discodedisco@outlook.com> Git commit message Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -459,3 +459,32 @@ class MySeaVoiceContextTest(TestCase):
|
||||
self.client.force_login(self.owner)
|
||||
ctx = self.client.get(reverse("my_sea")).context
|
||||
self.assertFalse(ctx["voice_active"])
|
||||
|
||||
|
||||
class MySeaSlotRankLongTest(TestCase):
|
||||
"""The 5+-char Roman-numeral squeeze (`--rank-long`) is now rendered
|
||||
server-side in `_my_sea_slot.html`, matching sea.js's `_fillSlot` length>=5
|
||||
rule — so a saved hand keeps the narrowed numeral across a refresh instead
|
||||
of stretching back out (user-reported 2026-05-29)."""
|
||||
|
||||
def _render(self, corner_rank):
|
||||
from django.template.loader import render_to_string
|
||||
return render_to_string("apps/gameboard/_partials/_my_sea_slot.html", {
|
||||
"position": "lay",
|
||||
"crossing": False,
|
||||
"saved": {
|
||||
"card_id": 1, "polarity": "gravity", "reversed": False,
|
||||
"has_card_images": False, "corner_rank": corner_rank,
|
||||
"suit_icon": "", "arcana": "", "image_url": "", "name": "",
|
||||
},
|
||||
})
|
||||
|
||||
def test_long_numeral_gets_rank_long(self):
|
||||
self.assertIn("sea-card-slot--rank-long", self._render("XLVIII"))
|
||||
|
||||
def test_short_numeral_has_no_rank_long(self):
|
||||
self.assertNotIn("sea-card-slot--rank-long", self._render("IV"))
|
||||
|
||||
def test_exactly_five_chars_gets_rank_long(self):
|
||||
# Boundary matches the JS (length >= 5).
|
||||
self.assertIn("sea-card-slot--rank-long", self._render("XVIII"))
|
||||
|
||||
Reference in New Issue
Block a user