new _applets partial to govern applet list; home.html updated accordingly to incl partial; fixed seed migrations for palette convention from last commit; new text_view ITs & views to govern applet visibility/toggling
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:
@@ -210,7 +210,11 @@ class ShareListTest(TestCase):
|
||||
f"/dashboard/list/{our_list.id}/share_list",
|
||||
data={"recipient": "nobody@example.com"},
|
||||
)
|
||||
self.assertRedirects(response, f"/dashboard/list/{our_list.id}/")
|
||||
self.assertRedirects(
|
||||
response,
|
||||
f"/dashboard/list/{our_list.id}/",
|
||||
fetch_redirect_response=False,
|
||||
)
|
||||
|
||||
def test_share_list_does_not_add_owner_as_recipient(self):
|
||||
owner = User.objects.create(email="owner@example.com")
|
||||
@@ -374,3 +378,27 @@ class ToggleAppletsViewTest(TestCase):
|
||||
HTTP_HX_REQUEST="true",
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_htmx_post_renders_visible_applets_only(self):
|
||||
response = self.client.post(
|
||||
self.url,
|
||||
{"applets": ["username"]},
|
||||
HTTP_HX_REQUEST="true",
|
||||
)
|
||||
parsed = lxml.html.fromstring(response.content)
|
||||
self.assertEqual(len(parsed.cssselect("#id_applet_username")), 1)
|
||||
self.assertEqual(len(parsed.cssselect("#id_applet_palette")), 0)
|
||||
|
||||
class AppletVisibilityContextTest(TestCase):
|
||||
def setUp(self):
|
||||
self.user = User.objects.create(email="disco@test.io")
|
||||
self.client.force_login(self.user)
|
||||
self.username_applet, _ = Applet.objects.get_or_create(slug="username", defaults={"name": "Username"})
|
||||
self.palette_applet, _ = Applet.objects.get_or_create(slug="palette", defaults={"name": "Palette"})
|
||||
UserApplet.objects.create(user=self.user, applet=self.palette_applet, visible=False)
|
||||
|
||||
def test_dash_reflects_user_applet_visibility(self):
|
||||
response = self.client.get("/")
|
||||
applet_map = {entry["applet"].slug: entry["visible"] for entry in response.context["applets"]}
|
||||
self.assertFalse(applet_map["palette"])
|
||||
self.assertTrue(applet_map["username"])
|
||||
|
||||
Reference in New Issue
Block a user