diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-20 11:16:23 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-20 11:16:23 +0200 |
| commit | bafab248a348e861511c8a984bdafa48fc32215f (patch) | |
| tree | c67d14bb0b32464676f38e43c3f6e1abd4ef9dcd /tests/test_gui.py | |
| parent | 2989606c3c0bcf08e99468067b0ab73c6810aa1c (diff) | |
| download | sb-builder-bafab248a348e861511c8a984bdafa48fc32215f.tar.gz sb-builder-bafab248a348e861511c8a984bdafa48fc32215f.zip | |
Hints screen: upstream check, hint jobs, diff and revert
Check upstream fills the upstream column and ticks the outdated hints,
Update selected starts hint-update, Delete hint acts on the VM. When a
hint job ends its SBB-RESULT opens a dialog with each changed hint's
diff, Revert per package (once) and Build these. The Packages detail
pane gets New hint and Open in Hints.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_gui.py')
| -rw-r--r-- | tests/test_gui.py | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/tests/test_gui.py b/tests/test_gui.py index 0da4243..aa9c03b 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -450,13 +450,82 @@ class SmokeTest(unittest.TestCase): w, _ = self.window() w.poll_jobs() self.assertEqual([a.text() for a in w.ribbon.actions()], - ["Dashboard", "Packages", "Results", "Jobs"]) + ["Dashboard", "Packages", "Hints", "Results", "Jobs"]) self.assertEqual([m.text() for m in w.menuBar().actions()], ["&File"]) w.ribbon.actions()[1].trigger() self.assertIs(w.tabs.currentWidget(), w.packages_tab) w.ribbon.actions()[0].trigger() self.assertIs(w.tabs.currentWidget(), w.dashboard) + def test_hints_tab(self): + w, remote = self.window(**{"job-start": ({"id": "20260101-000001-hint-update"}, None), + "hint-delete": ({"ok": True}, None)}) + w.poll_jobs() + tab = w.open_hints() + with tempfile.NamedTemporaryFile("w", suffix=".toml", delete=False) as f: + f.write('[nuclei]\nsource = "manual"\n[curl]\nsource = "manual"\n') + self.addCleanup(os.unlink, f.name) + tab.stanzas = f.name + tab.reload() + self.assertEqual(sorted(r["name"] for r in tab.rows), ["curl", "foo", "nuclei"]) # foo: hint only + states = {tab.table.item(i, 1).text(): tab.table.item(i, 5).text() for i in range(3)} + self.assertEqual(states, {"curl": "not checked", "foo": "no stanza", "nuclei": "not checked"}) + tab._checked({"nuclei": "3.12.0", "curl": "1.0"}, {}, "") + self.assertEqual(tab.checked(), ["nuclei"]) # outdated rows come checked + tab.chips["current"].setChecked(True) + visible = [tab.table.item(i, 1).text() for i in range(3) if not tab.table.isRowHidden(i)] + self.assertEqual(visible, ["curl"]) + tab.no_dl.setChecked(True) + tab.update_selected() + self.assertIn(("job-start", "hint-update", "nuclei=3.12.0", "--no-dl"), remote.calls) + tab._checked({}, {"curl": "HTTPError(404)"}, "") + row = next(i for i in range(3) if tab.table.item(i, 1).text() == "curl") + self.assertEqual(tab.table.item(row, 5).toolTip(), "HTTPError(404)") + self.assertIs(w.open_hints("foo"), tab) + self.assertEqual(tab.current(), "foo") + + 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), + **{"job-result": ({"ok": ["nuclei"], "failed": [["curl", "HTTP 404"]]}, None), + "hint-diff": ({"bak": 'VERSION="3.11.1"\n', "current": 'VERSION="3.12.0"\n'}, + None), + "hint-revert": ({"ok": True}, None), + "job-start": ({"id": "20260101-000001-slackrepo"}, None)}) + w.poll_jobs() + remote.answers["jobs"] = ({"jobs": [dict(job, status="failed", end=5, exit=1)]}, None) + w.poll_jobs() + self.assertEqual(len(w.hint_dialogs), 1) + d = w.hint_dialogs[0] + self.assertIn('-VERSION="3.11.1"\n+VERSION="3.12.0"', d.diff.toPlainText()) + d.revert() + d.revert() # a second revert must not reach the helper: it would delete the hint + self.assertEqual([c for c in remote.calls if c[0] == "hint-revert"], [("hint-revert", "nuclei")]) + self.assertEqual(d.list.item(0).text(), "nuclei (reverted)") + d.build() # nothing left to build + self.assertFalse(any(c[0] == "job-start" for c in remote.calls)) + self.assertEqual(w.hint_dialogs, []) + w.show_hint_result({"ok": ["nuclei"], "failed": []}) + w.hint_dialogs[0].build() + self.assertIn(("job-start", "slackrepo", "update", "--preview", "nuclei"), remote.calls) + + def test_packages_new_hint(self): + w, remote = self.window(**{"job-start": ({"id": "20260101-000001-hint-new"}, None)}) + w.poll_jobs() + tab = w.open_packages() + tab.table.setCurrentIndex(tab.proxy.index(1, 1)) # foo, has a hint + self.assertFalse(tab.new_hint_btn.isVisibleTo(tab)) + tab.open_hint_btn.click() + self.assertIs(w.tabs.currentWidget(), w.hints_tab) + tab.table.setCurrentIndex(tab.proxy.index(3, 1)) # curl, no hint + self.assertTrue(tab.new_hint_btn.isVisibleTo(tab)) + tab.ask_new_hint = lambda name: None + tab.new_hint() + self.assertFalse(any(c[0] == "job-start" for c in remote.calls)) + tab.ask_new_hint = lambda name: ("8.0", True) + tab.new_hint() + self.assertIn(("job-start", "hint-new", "curl", "8.0", "--no-dl"), remote.calls) + def test_tab_shortcuts_wrap(self): w, _ = self.window() w.poll_jobs() |
