new migration in apps.applets to seed wallet applet models; many expanded styles in wallet.js, chiefly concerned w. wallet-oriented FTs tbh; some intermittent Windows cache errors quashed in dash view ITs; apps.dash.views & .urls now support wallet applets; apps.lyric.models now discerns tithe coins (available for purchase soon); new styles across many scss files, again many concerning wallet applets but also applets more generally and also unorthodox media query parameters to make UX more usable; a slew of new wallet partials
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:
@@ -2,6 +2,7 @@ import lxml.html
|
||||
|
||||
from django.test import override_settings, TestCase
|
||||
|
||||
from apps.applets.models import Applet, UserApplet
|
||||
from apps.lyric.models import Token, User, Wallet
|
||||
|
||||
|
||||
@@ -47,4 +48,95 @@ class WalletViewTest(TestCase):
|
||||
bundles = self.parsed.cssselect("#id_tithe_token_shop .token-bundle")
|
||||
self.assertGreater(len(bundles), 0)
|
||||
|
||||
|
||||
|
||||
@override_settings(COMPRESS_ENABLED=False)
|
||||
class WalletViewAppletContextTest(TestCase):
|
||||
def setUp(self):
|
||||
self.user = User.objects.create(email="walletctx@test.io")
|
||||
Applet.objects.get_or_create(
|
||||
slug="wallet-balances",
|
||||
defaults={"name": "Wallet Balances", "grid_cols": 3, "grid_rows": 3, "context": "wallet"},
|
||||
)
|
||||
Applet.objects.get_or_create(
|
||||
slug="wallet-tokens",
|
||||
defaults={"name": "Wallet Tokens", "grid_cols": 3, "grid_rows": 3, "context": "wallet"},
|
||||
)
|
||||
Applet.objects.get_or_create(
|
||||
slug="wallet-payment",
|
||||
defaults={"name": "Payment Methods", "grid_cols": 6, "grid_rows": 2, "context": "wallet"},
|
||||
)
|
||||
self.client.force_login(self.user)
|
||||
|
||||
def test_wallet_view_passes_applets_context(self):
|
||||
response = self.client.get("/dashboard/wallet/")
|
||||
slugs = [e["applet"].slug for e in response.context["applets"]]
|
||||
self.assertIn("wallet-balances", slugs)
|
||||
self.assertIn("wallet-tokens", slugs)
|
||||
self.assertIn("wallet-payment", slugs)
|
||||
|
||||
def test_wallet_page_renders_applets_container(self):
|
||||
response = self.client.get("/dashboard/wallet/")
|
||||
parsed = lxml.html.fromstring(response.content)
|
||||
[_] = parsed.cssselect("#id_wallet_applets_container")
|
||||
|
||||
def test_wallet_page_renders_gear_button(self):
|
||||
response = self.client.get("/dashboard/wallet/")
|
||||
parsed = lxml.html.fromstring(response.content)
|
||||
[_] = parsed.cssselect(".gear-btn")
|
||||
|
||||
|
||||
@override_settings(COMPRESS_ENABLED=False)
|
||||
class ToggleWalletAppletsTest(TestCase):
|
||||
def setUp(self):
|
||||
self.user = User.objects.create(email="wallettoggle@test.io")
|
||||
self.balances = Applet.objects.get_or_create(
|
||||
slug="wallet-balances",
|
||||
defaults={"name": "Wallet Balances", "grid_cols": 3, "grid_rows": 3, "context": "wallet"},
|
||||
)[0]
|
||||
self.tokens = Applet.objects.get_or_create(
|
||||
slug="wallet-tokens",
|
||||
defaults={"name": "Wallet Tokens", "grid_cols": 3, "grid_rows": 3, "context": "wallet"},
|
||||
)[0]
|
||||
Applet.objects.get_or_create(
|
||||
slug="wallet-payment",
|
||||
defaults={"name": "Payment Methods", "grid_cols": 6, "grid_rows": 2, "context": "wallet"},
|
||||
)
|
||||
self.client.force_login(self.user)
|
||||
|
||||
def test_toggle_requires_login(self):
|
||||
self.client.logout()
|
||||
response = self.client.post("/dashboard/wallet/toggle-applets", {})
|
||||
self.assertRedirects(
|
||||
response, "/?next=/dashboard/wallet/toggle-applets",
|
||||
fetch_redirect_response=False,
|
||||
)
|
||||
|
||||
def test_toggle_redirects_to_wallet(self):
|
||||
response = self.client.post(
|
||||
"/dashboard/wallet/toggle-applets", {"applets": ["wallet-balances"]}
|
||||
)
|
||||
self.assertRedirects(response, "/dashboard/wallet/", fetch_redirect_response=False)
|
||||
|
||||
def test_toggle_hides_unchecked_applet(self):
|
||||
self.client.post(
|
||||
"/dashboard/wallet/toggle-applets", {"applets": ["wallet-balances"]}
|
||||
)
|
||||
ua = UserApplet.objects.get(user=self.user, applet=self.tokens)
|
||||
self.assertFalse(ua.visible)
|
||||
|
||||
def test_toggle_shows_checked_applet(self):
|
||||
UserApplet.objects.create(user=self.user, applet=self.balances, visible=False)
|
||||
self.client.post(
|
||||
"/dashboard/wallet/toggle-applets", {"applets": ["wallet-balances"]}
|
||||
)
|
||||
ua = UserApplet.objects.get(user=self.user, applet=self.balances)
|
||||
self.assertTrue(ua.visible)
|
||||
|
||||
def test_toggle_htmx_returns_container_partial(self):
|
||||
response = self.client.post(
|
||||
"/dashboard/wallet/toggle-applets",
|
||||
{"applets": ["wallet-balances"]},
|
||||
HTTP_HX_REQUEST="true",
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "id_wallet_applets_container")
|
||||
|
||||
Reference in New Issue
Block a user