Skip to content

Commit 2713a72

Browse files
committed
igloo: fix the global time picker E2E tests
The suite has failed since it landed: the panel's window sits in `.graphing-graph-header__timestamp`, not in the figure's `.graphing-graph-timestamp`, and `ServicePage.navigate` raises, so returning to the page walks the host's service list instead. JIRA-Ref: CMK-37024 Change-Id: I326dd4baa3c5145938bc4fd5d985a137f7406678
1 parent 2bfcfa3 commit 2713a72

3 files changed

Lines changed: 35 additions & 22 deletions

File tree

tests/system/gui/test_graph_global_time_picker.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
import re
1616
from typing import Final
1717

18-
import pytest
1918
from playwright.sync_api import expect
2019

20+
from tests.system.gui.testlib.playwright.pom.graphing.fixtures import open_service_graphs
2121
from tests.system.gui.testlib.playwright.pom.graphing.timeseries_graph import ServiceGraphs
2222
from tests.system.gui.testlib.playwright.pom.monitor.dashboard import MainDashboard
2323

@@ -40,7 +40,6 @@ def _document_survived(graphs: ServiceGraphs) -> bool:
4040
return bool(graphs.page.evaluate("window.__cmkGlobalTimePickerMarker === true"))
4141

4242

43-
@pytest.mark.skip(reason="CMK-37024; the panel's timestamp is addressed by the wrong class.")
4443
def test_one_preset_selection_moves_every_graph_on_the_page(
4544
service_graphs: ServiceGraphs, javascript_errors: list[str]
4645
) -> None:
@@ -80,7 +79,6 @@ def test_one_preset_selection_moves_every_graph_on_the_page(
8079
assert not javascript_errors, f"JavaScript errors were raised: {javascript_errors}"
8180

8281

83-
@pytest.mark.skip(reason="CMK-37024; `ServicePage.navigate` raises, so the return trip fails.")
8482
def test_selected_range_is_not_restored_after_navigating_away(
8583
service_graphs: ServiceGraphs, javascript_errors: list[str]
8684
) -> None:
@@ -102,11 +100,10 @@ def test_selected_range_is_not_restored_after_navigating_away(
102100

103101
# Constructing the page object navigates to it.
104102
MainDashboard(service_page.page)
105-
service_page.navigate()
106-
service_graphs.wait_until_rendered()
103+
reopened = open_service_graphs(service_page.page, service_page.host_name)
107104

108105
expect(
109-
service_graphs.time_picker.active_preset_chip,
106+
reopened.time_picker.active_preset_chip,
110107
"Returning to the page restored the previous range instead of the default",
111108
).to_have_text(DEFAULT_PRESET)
112109
assert not javascript_errors, f"JavaScript errors were raised: {javascript_errors}"

tests/system/gui/testlib/playwright/pom/graphing/fixtures.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from collections.abc import Iterator
1414

1515
import pytest
16+
from playwright.sync_api import Page
1617

1718
from tests.system.gui.testlib.playwright.pom.graphing.timeseries_graph import ServiceGraphs
1819
from tests.system.gui.testlib.playwright.pom.monitor.dashboard import MainDashboard
@@ -89,6 +90,29 @@ def fixture_javascript_errors(dashboard_page: MainDashboard) -> Iterator[list[st
8990
yield errors
9091

9192

93+
def open_service_graphs(page: Page, host_name: str) -> ServiceGraphs:
94+
"""Open the service detail page holding the graphs and wait for them to render.
95+
96+
Public because `ServicePage.navigate` cannot be: a service page is reached through the
97+
host's service list rather than by a route of its own, so a test returning to it after
98+
navigating away has to walk the same list again.
99+
"""
100+
services_of_host = ServicesOfHostPage(page, host_name=host_name)
101+
services_of_host.services_table.host_services_table(host_name).get_by_role(
102+
"link", name=SERVICE_WITH_GRAPHS, exact=True
103+
).click()
104+
graphs = ServiceGraphs(
105+
ServicePage(
106+
page,
107+
host_name=host_name,
108+
service_name=SERVICE_WITH_GRAPHS,
109+
navigate_to_page=False,
110+
)
111+
)
112+
graphs.wait_until_rendered()
113+
return graphs
114+
115+
92116
@pytest.fixture(name="service_graphs")
93117
def fixture_service_graphs(
94118
dashboard_page: MainDashboard,
@@ -99,17 +123,4 @@ def fixture_service_graphs(
99123
100124
Depends on `javascript_errors` so the listener is attached before this navigates.
101125
"""
102-
host_name = graph_hosts_with_varying_data[0]
103-
services_of_host = ServicesOfHostPage(dashboard_page.page, host_name=host_name)
104-
services_of_host.services_table.host_services_table(host_name).get_by_role(
105-
"link", name=SERVICE_WITH_GRAPHS, exact=True
106-
).click()
107-
service_page = ServicePage(
108-
dashboard_page.page,
109-
host_name=host_name,
110-
service_name=SERVICE_WITH_GRAPHS,
111-
navigate_to_page=False,
112-
)
113-
graphs = ServiceGraphs(service_page)
114-
graphs.wait_until_rendered()
115-
yield graphs
126+
yield open_service_graphs(dashboard_page.page, graph_hosts_with_varying_data[0])

tests/system/gui/testlib/playwright/pom/graphing/timeseries_graph.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,13 @@ def resolution_note(self) -> Locator:
201201

202202
@property
203203
def timestamp(self) -> Locator:
204-
"""The drawn window, e.g. ``2026-08-06 — 2026-08-07 @ 5min``; one date within a day."""
205-
return self.root.locator(".graphing-graph-timestamp")
204+
"""The drawn window, e.g. ``for 2026-08-06 — 2026-08-07, resolution: 5 min``.
205+
206+
Collapses to a single date whenever the window stays within one day. Not the
207+
``.graphing-graph-timestamp`` of `GraphTimestamp.vue`: that one belongs to the
208+
figure the dashboard widgets render, not to the panel's header.
209+
"""
210+
return self.root.locator(".graphing-graph-header__timestamp")
206211

207212
@property
208213
def peak_zoom_switch(self) -> Locator:

0 commit comments

Comments
 (0)