"""The whole window builds (catches errors that only show when the app starts).""" import os os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") def test_main_window_builds_with_all_tabs(): from PySide6.QtWidgets import QApplication from kota_tech.ui.main_window import MainWindow app = QApplication.instance() or QApplication([]) w = MainWindow() tabs = w.centralWidget() assert [tabs.tabText(i) for i in range(tabs.count())] == \ ["Quick start", "Serial monitor", "Flash firmware", "Wi-Fi (USB)", "SD card"] assert not w.wifi_tab.write_btn.isEnabled() # nothing connected, nothing typed settings = [a.text() for m in w.menuBar().actions() for a in m.menu().actions()] assert "InfluxDB access..." in settings w.serial_tab.shutdown() app.processEvents() def test_serial_tab_checklist_and_test_strip(): from PySide6.QtWidgets import QApplication from kota_tech.core.logline import parse_line from kota_tech.service import influx from kota_tech.ui.main_window import INFLUX_ROW, MainWindow app = QApplication.instance() or QApplication([]) w = MainWindow() st = w.serial_tab assert st.test_btn.text().endswith("Test box") assert [st.side_tabs.tabText(i) for i in range(st.side_tabs.count())] == \ ["Live log", "Guided troubleshooting", "Box details"] st.influx_config = lambda: None # no token (never touch real settings) rows = st._cloud_rows() assert rows[0][0] == "off" and "not set up" in rows[0][1] st.influx_config = lambda: influx.InfluxConfig("t") # pretend access is set up assert st._cloud_rows()[0] == ("pending", f"{INFLUX_ROW} - press Test box") st._on_influx(influx.InfluxCheck(influx.SENSORS_MISSING, "Status arrives, sensor data does not", details=["SEN66 (air quality): no data"])) rows = st._cloud_rows() assert rows[0][0] == "bad" and rows[1][0] == "note" st._engine.feed(parse_line("ESP-ROM:esp32s3-20210327")) st._diag_dirty = True st._refresh_diag() texts = [st.diag.milestones.item(i).text() for i in range(st.diag.milestones.count())] assert any(INFLUX_ROW in t for t in texts) assert "Test box" in st.test_status.text() st.shutdown() app.processEvents()