fix(main_app): switch views by their registered ids so the startup view is checked

This commit is contained in:
wyzula_j authored and Jan Wyzula committed 2026-11-24 14:45:31 +01:00
1 parent b632a35611
commit be557f2c39
4 files changed
+42 -17

No files matched your search

+9 -5
View File
@@ -149,7 +149,7 @@ class BECMainApp(BECMainWindow):
mini_text="Stack",
)
self.set_current("dock_area")
self.set_current(self.dock_area.view_id)
self.sidebar.add_dark_mode_item()
# Add guided tour to Help menu
@@ -162,7 +162,7 @@ class BECMainApp(BECMainWindow):
def show_dock_area(self) -> None:
"""Switch to the dock area view."""
self.set_current("dock_area")
self.set_current(self.dock_area.view_id)
# --- Public API ------------------------------------------------------
def add_section(self, title: str, id: str, position: int | None = None):
@@ -287,7 +287,7 @@ class BECMainApp(BECMainWindow):
tour_steps.append(toggle_step)
# Register the sidebar icons
sidebar_dock_area = self.sidebar.components.get("dock_area")
sidebar_dock_area = self.sidebar.components.get(self.dock_area.view_id)
if sidebar_dock_area:
dock_step = self.guided_tour.register_widget(
widget=sidebar_dock_area,
@@ -296,7 +296,7 @@ class BECMainApp(BECMainWindow):
)
tour_steps.append(dock_step)
sidebar_device_manager = self.sidebar.components.get("device_manager")
sidebar_device_manager = self.sidebar.components.get(self.device_manager.view_id)
if sidebar_device_manager:
device_manager_step = self.guided_tour.register_widget(
widget=sidebar_device_manager,
@@ -305,7 +305,11 @@ class BECMainApp(BECMainWindow):
)
tour_steps.append(device_manager_step)
sidebar_developer_view = self.sidebar.components.get("developer_view")
sidebar_developer_view = (
self.sidebar.components.get(self.developer_view.view_id)
if self.developer_view is not None
else None
)
if sidebar_developer_view:
developer_view_step = self.guided_tour.register_widget(
widget=sidebar_developer_view,
@@ -37,7 +37,7 @@ class DeveloperView(ViewBase):
# IDE Toolbar
def get_ide_toolbar():
main_app.set_current("developer_view")
main_app.set_current(self.view_id)
return (dev_widget.toolbar, None)
step_id = guided_tour.register_widget(
@@ -49,7 +49,7 @@ class DeveloperView(ViewBase):
# IDE Explorer
def get_ide_explorer():
main_app.set_current("developer_view")
main_app.set_current(self.view_id)
return (dev_widget.explorer_dock.widget(), None)
step_id = guided_tour.register_widget(
@@ -61,7 +61,7 @@ class DeveloperView(ViewBase):
# IDE Editor
def get_ide_editor():
main_app.set_current("developer_view")
main_app.set_current(self.view_id)
return (dev_widget.monaco_dock.widget(), None)
step_id = guided_tour.register_widget(
@@ -73,7 +73,7 @@ class DeveloperView(ViewBase):
# IDE Console
def get_ide_console():
main_app.set_current("developer_view")
main_app.set_current(self.view_id)
return (dev_widget.console_dock.widget(), None)
step_id = guided_tour.register_widget(
@@ -85,7 +85,7 @@ class DeveloperView(ViewBase):
# IDE Plotting Area
def get_ide_plotting():
main_app.set_current("developer_view")
main_app.set_current(self.view_id)
return (dev_widget.plotting_ads, None)
step_id = guided_tour.register_widget(
@@ -63,7 +63,7 @@ class DeviceManagerView(ViewBase):
# Register Load Current Config button
def get_load_current():
main_app.set_current("device_manager")
main_app.set_current(self.view_id)
if dm_widget._initialized is True:
return (None, None)
return (dm_widget.button_load_current_config, None)
@@ -77,7 +77,7 @@ class DeviceManagerView(ViewBase):
# Register Load Config From File button
def get_load_file():
main_app.set_current("device_manager")
main_app.set_current(self.view_id)
if dm_widget._initialized is True:
return (None, None)
return (dm_widget.button_load_config_from_file, None)
@@ -92,7 +92,7 @@ class DeviceManagerView(ViewBase):
## Register steps for the initialized state
# Register main device table
def get_device_table():
main_app.set_current("device_manager")
main_app.set_current(self.view_id)
if dm_widget._initialized is False:
return (None, None)
return (dm_widget.device_manager_display.device_table_view, None)
@@ -120,7 +120,7 @@ class DeviceManagerView(ViewBase):
# We have at least one device registered
def get_device_table_row(column: int):
main_app.set_current("device_manager")
main_app.set_current(self.view_id)
if dm_widget._initialized is False:
return (None, None)
table = dm_widget.device_manager_display.device_table_view.table
+24 -3
View File
@@ -161,10 +161,31 @@ def app_with_spies(qtbot, mocked_client):
app.add_view(icon="widgets", title="Veto View", view_id="vv", widget=vv, mini_text="vv")
# Start from dock_area (default) to avoid extra enter/exit counts on spies
assert app.stack.currentIndex() == app._view_index["Docks"]
assert app.stack.currentIndex() == app._view_index[app.dock_area.view_id]
return app, v1, v2, vv
def test_dock_area_nav_item_is_active_on_startup(app_with_spies):
app, _, _, _ = app_with_spies
dock_id = app.dock_area.view_id
assert app.sidebar.components[dock_id].is_active()
assert app._current_view_id == dock_id
assert app.sidebar._active_id == dock_id
def test_show_dock_area_switches_back_and_checks_its_nav_item(app_with_spies, qtbot):
app, v1, _, _ = app_with_spies
v1.activate()
qtbot.wait(10)
assert app.stack.currentIndex() == app._view_index["v1"]
app.show_dock_area()
qtbot.wait(10)
dock_id = app.dock_area.view_id
assert app.stack.currentIndex() == app._view_index[dock_id]
assert app.sidebar.components[dock_id].is_active()
assert not app.sidebar.components["v1"].is_active()
def test_viewbase_initializes(viewbase):
assert viewbase.on_enter() is None
assert viewbase.on_exit() is True
@@ -236,7 +257,7 @@ def test_added_view_gets_short_object_name(app_with_spies):
def test_view_switch_method_switches_to_target(app_with_spies, qtbot):
app, v1, _, _ = app_with_spies
app.set_current("dock_area")
app.set_current(app.dock_area.view_id)
qtbot.wait(10)
v1.activate()
qtbot.wait(10)
@@ -419,6 +440,6 @@ def test_status_pill_opens_its_widget_in_the_dock_area_view(
qtbot.mouseDClick(item.pill, Qt.MouseButton.LeftButton)
after = [w for w in dock_area.widget_list() if isinstance(w, BECQueue)]
assert len(after) == len(before) + 1
assert switched == ["dock_area"]
assert switched == [app.dock_area.view_id]
qtbot.mouseDClick(item.pill, Qt.MouseButton.LeftButton)
assert [w for w in dock_area.widget_list() if isinstance(w, BECQueue)] == after