From 0830217963048cf9cea6121215e545ec3c832e75 Mon Sep 17 00:00:00 2001 From: niccoloalexander Date: Fri, 10 Jul 2026 16:16:17 +0200 Subject: [PATCH 1/2] fix(alerts): route test alert deep links to test-results (cold-load safe) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test alert deep links point at #/report/test-runs/. On a cold page load (opening the link from a Slack alert in a fresh tab) the detail route's redirect guard fires while report data is still fetching (empty array) and navigates to the parent Test Performance list, so the alert never opens the specific failing test. Pasting the same URL into an already-open report tab works, which is why this only reproduces from alerts. The test-results/ route does not hit this guard and cold-loads to the correct test (it also surfaces the run history), so reroute test alert deep links there. This is a link-layer fix for the symptom; the underlying redirect-guard bug lives in the report UI. Fixing the guard directly (e.g. gating the redirect useEffect on isFetching, or falling back to embedded report data during fetch) would let test-runs/ keep working — maintainers may prefer that. Refs #2283 Co-Authored-By: Claude Opus 4.8 (1M context) --- .../data_monitoring/alerts/integrations/utils/report_link.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/elementary/monitor/data_monitoring/alerts/integrations/utils/report_link.py b/elementary/monitor/data_monitoring/alerts/integrations/utils/report_link.py index 14be06820..dea7842d3 100644 --- a/elementary/monitor/data_monitoring/alerts/integrations/utils/report_link.py +++ b/elementary/monitor/data_monitoring/alerts/integrations/utils/report_link.py @@ -15,7 +15,8 @@ class ReportLinkData(BaseModel): class ReportPath(Enum): - TEST_RUNS = "test-runs" + # test-runs/ cold-loads to the parent list, not the test (see #2283) + TEST_RUNS = "test-results" MODEL_RUNS = "model-runs" From d78e6c46953acf532b4a21fb8387f34af7f56e70 Mon Sep 17 00:00:00 2001 From: niccoloalexander Date: Fri, 10 Jul 2026 16:24:10 +0200 Subject: [PATCH 2/2] test(alerts): cover report link URL routing Assert test alert deep links resolve to /report/test-results// (the cold-load-safe route, #2283) and never /report/test-runs/, that the button label is unchanged, that model-run links are untouched, and the None cases. Refs #2283 Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/unit/alerts/test_report_link.py | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/unit/alerts/test_report_link.py diff --git a/tests/unit/alerts/test_report_link.py b/tests/unit/alerts/test_report_link.py new file mode 100644 index 000000000..a61f768a5 --- /dev/null +++ b/tests/unit/alerts/test_report_link.py @@ -0,0 +1,44 @@ +from elementary.monitor.data_monitoring.alerts.integrations.utils.report_link import ( + ReportPath, + get_model_runs_link, + get_model_test_runs_link, + get_test_runs_link, +) + +REPORT_URL = "https://elementary.example.com/#" +TEST_UNIQUE_ID = "test.my_project.my_test.abc123.row_count" +MODEL_UNIQUE_ID = "model.my_project.my_model" + + +def test_get_test_runs_link_routes_to_test_results(): + # Regression for #2283: the test-runs/ detail route redirects to the + # parent list on a cold page load, so test alert deep links must target the + # cold-load-safe test-results/ route instead. + link = get_test_runs_link(REPORT_URL, TEST_UNIQUE_ID) + + assert link is not None + assert link.url == f"{REPORT_URL}/report/test-results/{TEST_UNIQUE_ID}/" + assert "/report/test-runs/" not in link.url + # Only the URL changes — the button label is unaffected. + assert link.text == "View test runs" + + +def test_get_test_runs_link_returns_none_without_url_or_id(): + assert get_test_runs_link(None, TEST_UNIQUE_ID) is None + assert get_test_runs_link(REPORT_URL, None) is None + + +def test_get_model_runs_link_unchanged(): + link = get_model_runs_link(REPORT_URL, MODEL_UNIQUE_ID) + + assert link is not None + assert link.url == f"{REPORT_URL}/report/model-runs/{MODEL_UNIQUE_ID}/" + assert link.text == "View model runs" + + +def test_get_model_test_runs_link_routes_to_test_results(): + link = get_model_test_runs_link(REPORT_URL, MODEL_UNIQUE_ID) + + assert link is not None + assert link.url.startswith(f"{REPORT_URL}/report/test-results/?treeNode=") + assert ReportPath.TEST_RUNS.value == "test-results"