fix(AlertsReports): untie filters from alerts reports tabs flag (#38722)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
(cherry picked from commit 5263abdc60)
This commit is contained in:
Mehmet Salih Yavuz
2026-04-09 11:11:43 +03:00
committed by Michael S. Molina
parent ccfe29e83f
commit 7ee70d9aba
3 changed files with 72 additions and 3 deletions

View File

@@ -413,6 +413,55 @@ def test_get_tab_url(
assert result == urllib.parse.urljoin(base_url, "superset/dashboard/p/uri/")
@patch(
"superset.commands.dashboard.permalink.create.CreateDashboardPermalinkCommand.run"
)
@with_feature_flags(ALERT_REPORT_TABS=False)
def test_get_dashboard_urls_native_filters_without_tabs(
mock_run,
mocker: MockerFixture,
app,
) -> None:
"""Native filters should be applied even when ALERT_REPORT_TABS is disabled."""
mock_report_schedule: ReportSchedule = mocker.Mock(spec=ReportSchedule)
mock_report_schedule.chart = False
mock_report_schedule.chart_id = None
mock_report_schedule.dashboard_id = 123
mock_report_schedule.force_screenshot = False
extra = {
"dashboard": {
"nativeFilters": [
{
"nativeFilterId": "NATIVE_FILTER-abc",
"filterType": "filter_select",
"columnName": "col1",
"filterValues": ["val1"],
}
]
}
}
mock_report_schedule.extra = extra # type: ignore[assignment]
mock_report_schedule.get_native_filters_params.return_value = ( # type: ignore
"(NATIVE_FILTER-abc:!(val1))",
[],
)
mock_dashboard = mocker.MagicMock()
mock_dashboard.uuid = UUID("12345678-1234-1234-1234-123456789abc")
mock_report_schedule.dashboard = mock_dashboard
class_instance: BaseReportState = BaseReportState(
mock_report_schedule, "January 1, 2021", "execution_id_example"
)
class_instance._report_schedule = mock_report_schedule
mock_run.return_value = "permalink_key"
result: list[str] = class_instance.get_dashboard_urls()
assert len(result) == 1
assert "permalink_key" in result[0]
def create_report_schedule(
mocker: MockerFixture,
custom_width: int | None = None,
@@ -429,6 +478,7 @@ def create_report_schedule(
schedule.database = None
schedule.custom_width = custom_width
schedule.custom_height = custom_height
schedule.get_native_filters_params = mocker.MagicMock(return_value=("", []))
return schedule