2022-08-04 17:37:16 +00:00
|
|
|
from django.test import TestCase
|
|
|
|
from django.urls import reverse
|
|
|
|
|
|
|
|
from bookmarks.tests.helpers import BookmarkFactoryMixin
|
|
|
|
|
|
|
|
|
|
|
|
class NavMenuTestCase(TestCase, BookmarkFactoryMixin):
|
|
|
|
|
|
|
|
def setUp(self) -> None:
|
|
|
|
user = self.get_or_create_test_user()
|
|
|
|
self.client.force_login(user)
|
|
|
|
|
|
|
|
def test_should_respect_share_profile_setting(self):
|
|
|
|
self.user.profile.enable_sharing = False
|
|
|
|
self.user.profile.save()
|
2024-01-27 10:29:16 +00:00
|
|
|
response = self.client.get(reverse("bookmarks:index"))
|
2022-08-04 17:37:16 +00:00
|
|
|
html = response.content.decode()
|
|
|
|
|
2024-01-27 10:29:16 +00:00
|
|
|
self.assertInHTML(
|
|
|
|
f"""
|
2022-08-04 17:37:16 +00:00
|
|
|
<a href="{reverse('bookmarks:shared')}" class="btn btn-link">Shared</a>
|
2024-01-27 10:29:16 +00:00
|
|
|
""",
|
|
|
|
html,
|
|
|
|
count=0,
|
|
|
|
)
|
2022-08-04 17:37:16 +00:00
|
|
|
|
|
|
|
self.user.profile.enable_sharing = True
|
|
|
|
self.user.profile.save()
|
2024-01-27 10:29:16 +00:00
|
|
|
response = self.client.get(reverse("bookmarks:index"))
|
2022-08-04 17:37:16 +00:00
|
|
|
html = response.content.decode()
|
|
|
|
|
2024-01-27 10:29:16 +00:00
|
|
|
self.assertInHTML(
|
|
|
|
f"""
|
2022-08-04 17:37:16 +00:00
|
|
|
<a href="{reverse('bookmarks:shared')}" class="btn btn-link">Shared</a>
|
2024-01-27 10:29:16 +00:00
|
|
|
""",
|
|
|
|
html,
|
|
|
|
count=2,
|
|
|
|
)
|