A.5-polish FLIP-to-back for non-polarized image-equipped decks — TDD. User-spec'd feature 2026-05-25 PM after browser-verifying A.5: the FLIP button on my_sign.html cycles polarity for polarized decks (Earthman) — gravity/levity swap w. a 3D-spin animation, stat block updates to the new polarity's emanation/reversal qualifiers. For non-polarized decks (Minchiate today, future RWS-with-images, future classic-playing decks), polarity has no meaning — clicking FLIP just runs an animation that doesn't change anything content-wise. User wants FLIP repurposed for non-polarized decks: reveal the card-back image while leaving the stat block untouched, so the gesture has visible payoff w/o forcing a meaningless polarity-state change. Implementation thread: server-side page wrapper carries a new data-deck-polarized="{{ user.equipped_deck.is_polarized|yesno:'true,false' }}" attr so the in-page JS can branch on it without making an API call or guessing from card data; stage-card scaffold conditionally renders a hidden <img.sig-stage-card-back-img> element when equipped_deck.has_card_images AND NOT is_polarized (image-equipped polarized decks would still cycle polarity per existing flow — back-image element absent for them, no resource waste). JS branch in flipBtn.click: if (pageEl.dataset.deckPolarized === 'false') { stageCard.classList.toggle('is-flipped-to-back') } else { _flipPolarityAnimated() } — same .is-reversed class toggle on the btn itself so visual feedback is consistent across both modes (btn rotates to signal "flipped state on"). SCSS: .sig-stage-card-back-img joins the existing .sig-stage-card-img filter chain (same contour stroke + silhouette black shadow — back image gets identical visual treatment to the front so the flip reads as same-deck consistency); default display: none; .sig-stage-card.is-flipped-to-back flips visibility — hides front, shows back. Stat block + arcana-key stroke color stay put per user spec — FLIP for non-polarized is purely a visual reveal, no polarity-cycle or content swap. 3 new ITs in MySignViewTest: data-deck-polarized="true" for default Earthman; data-deck-polarized="false" + back-img element present w. correct v2-convention back asset URL when user switches to Minchiate; polarized deck omits the back-img element. No JS unit test (Jasmine spec) for the flipBtn branch — visual verify covers the hover/click interaction; the IT covers the server-side conditional render that determines whether the branch can fire. No FT (the existing my_sign FTs cover the polarized-flip flow already; non-polarized-flip is a CSS class toggle, low-risk for regression). Tests: 3 new green; 9/9 MySignViewTest class green; 1303/1303 IT+UT total green (71s; +3 from 82813e9's 1300). Out of scope: my_sea's central sig card doesn't have a FLIP btn (no analogous behavior to add there); room.html FLIP behavior will be covered in A.8 if applicable; Sea Stage modal FLIP behavior (if any) lands in the my-sea fetch-endpoint extension later in A.5

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Disco DeDisco
2026-05-25 01:31:42 -04:00
parent 82813e9fc1
commit 1963ad4c71
3 changed files with 82 additions and 2 deletions

View File

@@ -860,6 +860,49 @@ class MySignViewTest(TestCase):
{"card_id": 999999, "reversed": "0"},
)
self.assertEqual(response.status_code, 403)
def test_page_carries_data_deck_polarized_attr(self):
"""Sprint A.5-polish — the my_sign page wrapper exposes the equipped
deck's `is_polarized` state via `data-deck-polarized` so the FLIP-btn
JS can branch: polarized decks cycle polarity (existing behavior);
non-polarized decks flip to the deck card-back (new)."""
import lxml.html
# Default Earthman = is_polarized=True per A.0 migration.
response = self.client.get(reverse("billboard:my_sign"))
parsed = lxml.html.fromstring(response.content)
[page] = parsed.cssselect(".my-sign-page")
self.assertEqual(page.get("data-deck-polarized"), "true")
def test_image_deck_renders_back_img_in_stage_scaffold(self):
"""Image-equipped non-polarized decks (Minchiate) render a hidden
<img.sig-stage-card-back-img> inside the stage card; toggled visible
by the FLIP-btn JS handler via the .is-flipped-to-back class."""
from apps.epic.models import DeckVariant
import lxml.html
minchiate = DeckVariant.objects.get(slug="minchiate-fiorentine-1860-1890")
self.user.unlocked_decks.add(minchiate)
self.user.equipped_deck = minchiate
self.user.save(update_fields=["equipped_deck"])
response = self.client.get(reverse("billboard:my_sign"))
parsed = lxml.html.fromstring(response.content)
[page] = parsed.cssselect(".my-sign-page")
self.assertEqual(page.get("data-deck-polarized"), "false")
[back_img] = parsed.cssselect(".sig-stage-card .sig-stage-card-back-img")
self.assertIn(
"minchiate-fiorentine-1860-1890-back.png",
back_img.get("src", ""),
)
def test_polarized_deck_omits_back_img(self):
"""Earthman (polarized) keeps the existing polarity-cycle FLIP — no
back-image element needed in the scaffold."""
import lxml.html
response = self.client.get(reverse("billboard:my_sign"))
parsed = lxml.html.fromstring(response.content)
self.assertEqual(
len(parsed.cssselect(".sig-stage-card .sig-stage-card-back-img")), 0,
"Polarized deck must not render the back-image element",
)
self.user.refresh_from_db()
self.assertIsNone(self.user.significator_id)