"""A log mirror view is a second view on the same emitter: history is copied on creation, live lines reach both views, and clear() empties them all.""" from aare.gui.panels.log_panel import LogPanel def test_log_mirror_view_and_clear(qtbot): panel = LogPanel() qtbot.addWidget(panel) panel.emitter.message.emit("first line") assert "first line" in panel.view.toPlainText() mirror = panel.make_mirror_view() qtbot.addWidget(mirror) # History copied on creation, live lines reach both views. assert "first line" in mirror.toPlainText() panel.emitter.message.emit("second line") assert "second line" in panel.view.toPlainText() assert "second line" in mirror.toPlainText() panel.clear() assert panel.view.toPlainText() == "" assert mirror.toPlainText() == "" def test_notification_requests_reveal(qtbot): panel = LogPanel() qtbot.addWidget(panel) with qtbot.waitSignal(panel.reveal_requested, timeout=1000): panel.show_notification(title="Boom", message="it broke") assert panel.notification._title.text() == "Boom" def test_sticky_notification_is_dismissable(qtbot): # Sticky means "no auto-clear timer", not "undismissable": the Clear # button must stay so users can get rid of stale warnings by hand. panel = LogPanel() qtbot.addWidget(panel) panel.show_notification(title="Warn", message="stuck", level="warning", sticky=True) assert not panel.notification._clear_button.isHidden() panel.notification._clear_button.click() assert not panel.notification.isVisible()