aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_gui.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/test_gui.py b/tests/test_gui.py
index ca51c3c..a25be37 100644
--- a/tests/test_gui.py
+++ b/tests/test_gui.py
@@ -36,6 +36,7 @@ from PyQt6.QtWidgets import QApplication # noqa: E402
from sb_builder import VERSION, config # noqa: E402
from sb_builder import hints as hintlib # noqa: E402
+from sb_builder import hints_tab # noqa: E402
from sb_builder import packages as pk # noqa: E402
from sb_builder.mainwindow import MainWindow # noqa: E402
from sb_builder.remote import DOWN, MISSING, parse # noqa: E402
@@ -534,7 +535,7 @@ class SmokeTest(unittest.TestCase):
"Dashboard": (["Refresh"], []),
"Packages": (["Build", "Update", "Rebuild", "Remove", "Update all", "New hint", "Publish"],
["Select visible", "Clear", "Refresh"]),
- "Hints": (["Check upstream", "Update selected", "Delete hint"],
+ "Hints": (["Check upstream", "Update selected", "Delete hint", "Phantom deps…"],
["Select visible", "Clear", "No download", "Refresh"]),
"Results": (["Show build log"], ["Refresh"]),
"Jobs": (["Pull overlay", "Check shadowing", "Run it", "Kill"], []),
@@ -620,6 +621,43 @@ class SmokeTest(unittest.TestCase):
self.assertEqual(len(w.hint_dialogs), 1) # Revert lives there
self.assertIn("-A=1", w.hint_dialogs[0].diff.toPlainText())
+ def test_phantom_deps_dialog(self):
+ listed = ["rust-opt"]
+
+ def change(args, _stdin):
+ if args[0] == "phantom-add":
+ listed.extend(n for n in args[1:] if n not in listed)
+ else:
+ listed[:] = [n for n in listed if n not in args[1:]]
+ return {"deps": list(listed)}, None
+ w, remote = self.window(**{
+ "phantom-list": lambda args, _stdin: ({"deps": list(listed), "suggestions": [
+ {"name": n, "needed_by": ["marco", "steam"]} for n in ("jq", "zenity") if n not in listed]}, # sorted, as the helper
+ None),
+ "phantom-add": change, "phantom-remove": change,
+ "job-start": ({"id": "20260101-000001-fix-current"}, None)})
+ w.poll_jobs()
+ tab = w.open_hints()
+ tab.actions[-1].trigger()
+ d = tab.phantom_dialog
+ self.assertEqual(d.deps.item(0).text(), "rust-opt")
+ self.assertEqual(d.suggestions.count(), 2)
+ self.assertEqual(d.suggestions.item(1).text(), "zenity needed by marco, steam")
+ d.suggestions.itemClicked.emit(d.suggestions.item(1)) # tick zenity by its row
+ d.add_ticked()
+ self.assertIn(("phantom-add", "zenity"), remote.calls)
+ self.assertEqual([d.deps.item(i).text() for i in range(d.deps.count())], ["rust-opt", "zenity"])
+ self.assertEqual(d.suggestions.count(), 1) # zenity left the suggestions
+ d.name.setText("spdlog")
+ d.add_name()
+ d.deps.item(0).setSelected(True)
+ d.remove_selected()
+ self.assertEqual(listed, ["zenity", "spdlog"])
+ d.apply()
+ self.assertIn(("job-start", "fix-current"), remote.calls)
+ self.assertIsNone(tab.phantom_dialog)
+ self.assertIn("fix-current", hints_tab.HINT_JOBS) # its end opens the diff dialog
+
def test_hint_job_end_opens_diff(self):
job = dict(JOB, id="20260101-000000-hint-update", kind="hint-update", args=["nuclei=3.12.0"])
w, remote = self.window(jobs=({"jobs": [job]}, None),