From ec80f24b8ddaa6cbc1736327cabf545884c0f05b Mon Sep 17 00:00:00 2001
From: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com>
Date: Tue, 7 Jan 2025 01:51:51 -0800
Subject: [PATCH] tests: add tag category tests
---
tagstudio/tests/qt/test_field_containers.py | 57 +++++++++++++++++++++
tagstudio/tests/qt/test_preview_panel.py | 6 ---
2 files changed, 57 insertions(+), 6 deletions(-)
diff --git a/tagstudio/tests/qt/test_field_containers.py b/tagstudio/tests/qt/test_field_containers.py
index 3f15dcd8..fb2cd9ba 100644
--- a/tagstudio/tests/qt/test_field_containers.py
+++ b/tagstudio/tests/qt/test_field_containers.py
@@ -113,3 +113,60 @@ def test_add_tag_to_selection_multiple(qt_driver, library):
assert tag_present_on_some
assert not tag_absent_on_some
+
+
+def test_meta_tag_category(qt_driver, library, entry_full):
+ panel = PreviewPanel(library, qt_driver)
+
+ # Ensure the Favorite tag is on entry_full
+ library.add_tags_to_entry(1, entry_full.id)
+
+ # Select the single entry
+ qt_driver.select_item(entry_full.id, append=False, bridge=False)
+ panel.update_widgets()
+
+ # FieldContainer should hide all containers
+ assert len(panel.fields.containers) == 3
+ for i, container in enumerate(panel.fields.containers):
+ match i:
+ case 0:
+ # Check if the container is the Meta Tags category
+ assert container.title == f"
{library.get_tag(2).name}
"
+ case 1:
+ # Check if the container is the Tags category
+ assert container.title == "Tags
"
+ case 2:
+ # Make sure the container isn't a duplicate Tags category
+ assert container.title != "Tags
"
+
+
+def test_custom_tag_category(qt_driver, library, entry_full):
+ panel = PreviewPanel(library, qt_driver)
+
+ # Set tag 1000 (foo) as a category
+ tag = library.get_tag(1000)
+ tag.is_category = True
+ library.update_tag(
+ tag,
+ )
+
+ # Ensure the Favorite tag is on entry_full
+ library.add_tags_to_entry(1, entry_full.id)
+
+ # Select the single entry
+ qt_driver.select_item(entry_full.id, append=False, bridge=False)
+ panel.update_widgets()
+
+ # FieldContainer should hide all containers
+ assert len(panel.fields.containers) == 3
+ for i, container in enumerate(panel.fields.containers):
+ match i:
+ case 0:
+ # Check if the container is the Meta Tags category
+ assert container.title == f"{library.get_tag(2).name}
"
+ case 1:
+ # Check if the container is the custom "foo" category
+ assert container.title == f"{tag.name}
"
+ case 2:
+ # Make sure the container isn't a plain Tags category
+ assert container.title != "Tags
"
diff --git a/tagstudio/tests/qt/test_preview_panel.py b/tagstudio/tests/qt/test_preview_panel.py
index c4ba91c7..569fb80d 100644
--- a/tagstudio/tests/qt/test_preview_panel.py
+++ b/tagstudio/tests/qt/test_preview_panel.py
@@ -1,9 +1,3 @@
-from pathlib import Path
-from tempfile import TemporaryDirectory
-import pytest
-from src.core.library import Entry
-from src.core.library.alchemy.enums import FieldTypeEnum
-from src.core.library.alchemy.fields import TextField, _FieldID
from src.qt.widgets.preview_panel import PreviewPanel