new apps/dashboard/wallet.html for stripe payment integration and user's consumables; nav added to _footer.html & also dynamic copyright year with django now Y template; new apps.dash.tests ITs & UTs reflect new wallet functionality in .urls & .views
This commit is contained in:
@@ -414,3 +414,28 @@ class AppletVisibilityContextTest(TestCase):
|
||||
applet_map = {entry["applet"].slug: entry["visible"] for entry in response.context["applets"]}
|
||||
self.assertFalse(applet_map["palette"])
|
||||
self.assertTrue(applet_map["username"])
|
||||
|
||||
class FooterNavTest(TestCase):
|
||||
def setUp(self):
|
||||
self.user = User.objects.create(email="disco@test.io")
|
||||
self.client.force_login(self.user)
|
||||
|
||||
def test_footer_nav_present_on_dashboard(self):
|
||||
response = self.client.get("/")
|
||||
parsed = lxml.html.fromstring(response.content)
|
||||
[nav] = parsed.cssselect("#id_footer_nav")
|
||||
self.assertIsNotNone(nav)
|
||||
|
||||
def test_footer_nav_has_dashboard_link(self):
|
||||
response = self.client.get("/")
|
||||
parsed = lxml.html.fromstring(response.content)
|
||||
[nav] = parsed.cssselect("#id_footer_nav")
|
||||
links = [a.get("href") for a in nav.cssselect("a")]
|
||||
self.assertIn("/", links)
|
||||
|
||||
def test_footer_nav_has_gameboard_link(self):
|
||||
response = self.client.get("/")
|
||||
parsed = lxml.html.fromstring(response.content)
|
||||
[nav] = parsed.cssselect("#id_footer_nav")
|
||||
links = [a.get("href") for a in nav.cssselect("a")]
|
||||
self.assertIn("/gameboard/", links)
|
||||
|
||||
49
src/apps/dashboard/tests/integrated/test_wallet_views.py
Normal file
49
src/apps/dashboard/tests/integrated/test_wallet_views.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import lxml.html
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.lyric.models import Token, User, Wallet
|
||||
|
||||
|
||||
class WalletViewTest(TestCase):
|
||||
def setUp(self):
|
||||
self.user = User.objects.create(email="capman@test.io")
|
||||
self.client.force_login(self.user)
|
||||
response = self.client.get("/dashboard/wallet/")
|
||||
self.parsed = lxml.html.fromstring(response.content)
|
||||
|
||||
def test_wallet_page_requires_login(self):
|
||||
self.client.logout()
|
||||
response = self.client.get("/dashboard/wallet/")
|
||||
self.assertRedirects(
|
||||
response, "/?next=/dashboard/wallet/", fetch_redirect_response=False
|
||||
)
|
||||
|
||||
def test_wallet_page_renders(self):
|
||||
[el] = self.parsed.cssselect("#id_writs_balance")
|
||||
self.assertEqual(el.text_content().strip(), "144")
|
||||
|
||||
def test_wallet_page_shows_esteem_balance(self):
|
||||
[el] = self.parsed.cssselect("#id_esteem_balance")
|
||||
self.assertEqual(el.text_content().strip(), "0")
|
||||
|
||||
def test_wallet_page_shows_coin_on_a_string(self):
|
||||
[_] = self.parsed.cssselect("#id_coin_on_a_string")
|
||||
|
||||
def test_wallet_page_shows_free_token(self):
|
||||
[_] = self.parsed.cssselect("#id_free_token_0")
|
||||
|
||||
def test_wallet_page_shows_payment_methods_section(self):
|
||||
[_] = self.parsed.cssselect("#id_add_payment_method")
|
||||
|
||||
def test_wallet_page_shows_stripe_payment_element(self):
|
||||
[_] = self.parsed.cssselect("#id_stripe_payment_element")
|
||||
|
||||
def test_wallet_page_shows_tithe_token_shop(self):
|
||||
[_] = self.parsed.cssselect("#id_tithe_token_shop")
|
||||
|
||||
def test_tithe_token_shop_shows_bundle(self):
|
||||
bundles = self.parsed.cssselect("#id_tithe_token_shop .token-bundle")
|
||||
self.assertGreater(len(bundles), 0)
|
||||
|
||||
|
||||
9
src/apps/dashboard/tests/unit/test_templates.py
Normal file
9
src/apps/dashboard/tests/unit/test_templates.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from datetime import date
|
||||
from django.test import SimpleTestCase
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
|
||||
class FooterTemplateTest(SimpleTestCase):
|
||||
def test_footer_shows_current_year(self):
|
||||
rendered = render_to_string("core/_partials/_footer.html")
|
||||
self.assertIn(str(date.today().year), rendered)
|
||||
Reference in New Issue
Block a user