From db5a06b221d192ab0841ec0317055dc311443947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20I=C3=9Fbr=C3=BCcker?= Date: Sun, 14 Apr 2024 14:31:16 +0200 Subject: [PATCH] disable create snapshot button when there is a pending snapshot --- .../templates/bookmarks/details/assets.html | 4 ++- .../tests/test_bookmark_details_modal.py | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bookmarks/templates/bookmarks/details/assets.html b/bookmarks/templates/bookmarks/details/assets.html index 40ef9a63..d8576572 100644 --- a/bookmarks/templates/bookmarks/details/assets.html +++ b/bookmarks/templates/bookmarks/details/assets.html @@ -36,7 +36,9 @@ {% if details.is_editable %}
- +
{% endif %} \ No newline at end of file diff --git a/bookmarks/tests/test_bookmark_details_modal.py b/bookmarks/tests/test_bookmark_details_modal.py index 83c79830..849402f2 100644 --- a/bookmarks/tests/test_bookmark_details_modal.py +++ b/bookmarks/tests/test_bookmark_details_modal.py @@ -1,3 +1,4 @@ +import re from unittest.mock import patch from django.test import TestCase, override_settings @@ -792,3 +793,27 @@ def test_create_snapshot(self): self.assertEqual(response.status_code, 302) self.assertEqual(bookmark.bookmarkasset_set.count(), 1) + + @override_settings(LD_ENABLE_SNAPSHOTS=True) + def test_create_snapshot_is_disabled_when_having_pending_asset(self): + bookmark = self.setup_bookmark() + asset = self.setup_asset(bookmark, status=BookmarkAsset.STATUS_COMPLETE) + + # no pending asset + soup = self.get_details(bookmark) + files_section = self.find_section(soup, "Files") + create_button = files_section.find( + "button", string=re.compile("Create HTML snapshot") + ) + self.assertFalse(create_button.has_attr("disabled")) + + # with pending asset + asset.status = BookmarkAsset.STATUS_PENDING + asset.save() + + soup = self.get_details(bookmark) + files_section = self.find_section(soup, "Files") + create_button = files_section.find( + "button", string=re.compile("Create HTML snapshot") + ) + self.assertTrue(create_button.has_attr("disabled"))