69 lines
2.3 KiB
Python
Executable File
69 lines
2.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Offscreen GUI smoke test — instantiates the full window, lets the
|
|
probe thread settle, populates a demo queue, and grabs a screenshot.
|
|
|
|
Run: QT_QPA_PLATFORM=offscreen python3 scripts/smoke_gui.py
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
|
|
from PySide6.QtCore import QTimer
|
|
from PySide6.QtWidgets import QApplication
|
|
|
|
from thicket.ui_window import ThicketWindow
|
|
|
|
OUT = Path("/tmp/thicket_smoke.png")
|
|
|
|
|
|
def main() -> int:
|
|
app = QApplication(sys.argv)
|
|
|
|
# Demo input dir with a few plausible documents so the queue table
|
|
# shows real rows in the screenshot.
|
|
demo = Path(tempfile.mkdtemp(prefix="bf_smoke_"))
|
|
(demo / "attention-is-all-you-need.pdf").write_bytes(b"%PDF-1.4 stub")
|
|
(demo / "thinking-fast-and-slow.epub").write_bytes(b"PK stub")
|
|
(demo / "zettelkasten-method.md").write_text("# Zettelkasten\n\nnotes.\n")
|
|
(demo / "reading backlog.txt").write_text("todo list\n")
|
|
|
|
window = ThicketWindow()
|
|
window.in_path_edit.setText(str(demo))
|
|
window.show()
|
|
|
|
def settle():
|
|
window._scan()
|
|
window._on_file_status(str(demo / "zettelkasten-method.md"), "DONE")
|
|
window._on_file_detail(str(demo / "zettelkasten-method.md"), "14 chunks indexed")
|
|
window._on_file_status(str(demo / "thinking-fast-and-slow.epub"), "EXTRACT")
|
|
window._on_file_detail(str(demo / "thinking-fast-and-slow.epub"), "extracting text")
|
|
window.query_edit.setText("how do transformers handle attention?")
|
|
window.log_box.append("> [1] 0.873 Attention Is All You Need § Page 3")
|
|
|
|
QTimer.singleShot(1500, settle)
|
|
|
|
def finish():
|
|
ok_run = window.btn_run.isEnabled()
|
|
window.grab().save(str(OUT))
|
|
print(f"btn_run enabled: {ok_run}")
|
|
print(f"status bar: {window.status_label.text()!r}")
|
|
print(f"queue rows: {window.queue_table.rowCount()}")
|
|
print(f"screenshot: {OUT}")
|
|
results["ok"] = bool(ok_run and window.queue_table.rowCount() == 4)
|
|
window.close()
|
|
QTimer.singleShot(0, app.quit)
|
|
|
|
results = {}
|
|
QTimer.singleShot(3000, finish)
|
|
app.exec()
|
|
return 0 if results.get("ok") else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|