new migrations in apps.lyric ensure new users start only w. Earthman card deck unlocked; FTs.test_component_cards_tarot.py updated to assert that user specifically has Fiorentine deck unlocked as well
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
24
src/apps/lyric/migrations/0016_backfill_unlocked_decks.py
Normal file
24
src/apps/lyric/migrations/0016_backfill_unlocked_decks.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
def backfill_unlocked_decks(apps, schema_editor):
|
||||||
|
User = apps.get_model("lyric", "User")
|
||||||
|
DeckVariant = apps.get_model("epic", "DeckVariant")
|
||||||
|
try:
|
||||||
|
earthman = DeckVariant.objects.get(slug="earthman")
|
||||||
|
except DeckVariant.DoesNotExist:
|
||||||
|
return
|
||||||
|
for user in User.objects.filter(unlocked_decks__isnull=True):
|
||||||
|
user.unlocked_decks.add(earthman)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("lyric", "0015_user_unlocked_decks"),
|
||||||
|
("epic", "0010_seed_deck_variants_and_earthman"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(backfill_unlocked_decks, migrations.RunPython.noop),
|
||||||
|
]
|
||||||
@@ -231,9 +231,11 @@ class GameKitDeckSelectionTest(FunctionalTest):
|
|||||||
defaults={"name": "Fiorentine Minchiate", "card_count": 78, "is_default": False},
|
defaults={"name": "Fiorentine Minchiate", "card_count": 78, "is_default": False},
|
||||||
)
|
)
|
||||||
self.gamer = User.objects.create(email="gamer@deck.io")
|
self.gamer = User.objects.create(email="gamer@deck.io")
|
||||||
# Signal sets equipped_deck = earthman (now it exists); put gamer on
|
# Signal sets equipped_deck = earthman and unlocked_decks = [earthman].
|
||||||
# Fiorentine so the test can exercise switching back to Earthman.
|
# Explicitly grant fiorentine too, then switch equipped_deck to it so
|
||||||
|
# the test can exercise switching back to Earthman.
|
||||||
self.gamer.refresh_from_db()
|
self.gamer.refresh_from_db()
|
||||||
|
self.gamer.unlocked_decks.add(self.fiorentine)
|
||||||
self.gamer.equipped_deck = self.fiorentine
|
self.gamer.equipped_deck = self.fiorentine
|
||||||
self.gamer.save(update_fields=["equipped_deck"])
|
self.gamer.save(update_fields=["equipped_deck"])
|
||||||
|
|
||||||
@@ -321,3 +323,22 @@ class GameKitDeckSelectionTest(FunctionalTest):
|
|||||||
game_kit.get_attribute("data-equipped-deck-id"), ""
|
game_kit.get_attribute("data-equipped-deck-id"), ""
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ #
|
||||||
|
# Test 6 — new user's Game Kit shows only the default Earthman deck #
|
||||||
|
# ------------------------------------------------------------------ #
|
||||||
|
|
||||||
|
def test_new_user_game_kit_shows_only_earthman_deck(self):
|
||||||
|
"""A fresh user's game kit contains only the Earthman deck card;
|
||||||
|
the Fiorentine deck is not visible because it has not been unlocked."""
|
||||||
|
newcomer = User.objects.create(email="newcomer@deck.io")
|
||||||
|
newcomer.unlocked_decks.add(self.earthman)
|
||||||
|
self.create_pre_authenticated_session("newcomer@deck.io")
|
||||||
|
self.browser.get(self.live_server_url + "/gameboard/")
|
||||||
|
self.wait_for(lambda: self.browser.find_element(By.ID, "id_game_kit"))
|
||||||
|
|
||||||
|
deck_cards = self.browser.find_elements(By.CSS_SELECTOR, "#id_game_kit .deck-variant")
|
||||||
|
self.assertEqual(len(deck_cards), 1)
|
||||||
|
self.browser.find_element(By.ID, "id_kit_earthman_deck")
|
||||||
|
fiorentine_cards = self.browser.find_elements(By.ID, "id_kit_fiorentine_deck")
|
||||||
|
self.assertEqual(len(fiorentine_cards), 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user