feat: persistent Library tab in ScanResultsPanel (survives per-file rebuilds)

This commit is contained in:
2026-07-04 00:20:23 +02:00
parent 5dc7499d7f
commit f32d303d26
2 changed files with 55 additions and 5 deletions
+30
View File
@@ -869,3 +869,33 @@ def test_audio_library_edit_emits(win, tmp_path):
lib.edit_requested.connect(lambda p: got.append(p))
lib._on_edit()
assert got == [str(a)]
def test_scan_panel_library_tab_persists(win):
import main as m
from PyQt6.QtWidgets import QTableWidget
sp = win._scan_panel
assert isinstance(sp._library, m.AudioLibraryTab)
titles = [sp._tabs.tabText(i) for i in range(sp._tabs.count())]
assert "Library" in titles
# add a fake model tab, then clear model tabs -> library survives
sp._tabs.addTab(QTableWidget(), "EAT_LARGE (3)")
sp._clear_model_tabs()
titles2 = [sp._tabs.tabText(i) for i in range(sp._tabs.count())]
assert titles2 == ["Library"] # only the library remains
assert sp._library is sp._tabs.widget(0)
def test_scan_reload_selects_model_tab_not_library(win):
# Reloading a scanned file must leave a MODEL tab current (index 1), not the
# Library at index 0 — otherwise _current_table() is None and the timeline
# shows no scan regions until the user manually clicks a model tab.
sp = win._scan_panel
sp._filename = "clip.mp4"
sp._profile = "prof"
results = {"EAT_LARGE": [(1, 0.0, 1.0, 0.9, False, 0.0, 1.0)]}
sp._on_scan_bundle_loaded("clip.mp4", "prof", set(), [], results)
assert sp._library is sp._tabs.widget(0) # Library stays at index 0
assert sp._tabs.currentIndex() == 1 # a model tab is selected
assert sp._current_table() is not None # regions resolve immediately
assert sp.current_model_name() == "EAT_LARGE"