mirror of
https://github.com/apache/superset.git
synced 2026-08-12 11:11:01 +00:00
fix(deckgl): show dashboard filter badges for multi-layer charts (#40003)
Co-authored-by: Evan Rusackas <evan@rusackas.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Evan Rusackas
Claude Opus 4.8
parent
d1b523b97f
commit
a57b5f6078
@@ -27,7 +27,7 @@ import tests.integration_tests.test_app # noqa: F401
|
||||
import superset.viz as viz
|
||||
from flask import current_app
|
||||
from superset.exceptions import QueryObjectValidationError, SpatialException
|
||||
from superset.utils.core import DTTM_ALIAS
|
||||
from superset.utils.core import DTTM_ALIAS, ExtraFiltersReasonType
|
||||
from superset.utils.pandas_postprocessing.utils import FLAT_COLUMN_SEPARATOR
|
||||
from tests.conftest import with_config
|
||||
|
||||
@@ -1849,6 +1849,79 @@ class TestDeckGLMultiLayer(SupersetTestCase):
|
||||
assert len(result["slices"]) == 1
|
||||
assert result["slices"][0] == slice_1.data
|
||||
|
||||
@with_config({"MAPBOX_API_KEY": "test_key"})
|
||||
@patch("superset.viz.viz_types")
|
||||
@patch("superset.db.session")
|
||||
def test_get_payload_includes_subslice_filter_metadata(
|
||||
self,
|
||||
mock_db_session,
|
||||
mock_viz_types,
|
||||
):
|
||||
"""Test deck.gl multi-layer payload includes child filter metadata."""
|
||||
datasource = self.get_datasource_mock()
|
||||
|
||||
slice_1 = Mock()
|
||||
slice_1.form_data = {"viz_type": "deck_scatter"}
|
||||
slice_1.data = {"features": [{"type": "Feature"}]}
|
||||
slice_1.datasource = datasource
|
||||
|
||||
slice_2 = Mock()
|
||||
slice_2.form_data = {"viz_type": "deck_path"}
|
||||
slice_2.data = {"features": [{"type": "Feature"}]}
|
||||
slice_2.datasource = datasource
|
||||
|
||||
mock_db_session.query.return_value.filter.return_value.all.return_value = [
|
||||
slice_1,
|
||||
slice_2,
|
||||
]
|
||||
|
||||
mock_scatter_viz_class = Mock()
|
||||
mock_scatter_viz_instance = Mock()
|
||||
mock_scatter_viz_instance.get_payload.return_value = {
|
||||
"data": {"features": [{"id": 1}]},
|
||||
"applied_filters": [{"column": "Latitude"}],
|
||||
"rejected_filters": [],
|
||||
}
|
||||
mock_scatter_viz_class.return_value = mock_scatter_viz_instance
|
||||
|
||||
mock_path_viz_class = Mock()
|
||||
mock_path_viz_instance = Mock()
|
||||
mock_path_viz_instance.get_payload.return_value = {
|
||||
"data": {"features": [{"id": 2}]},
|
||||
"applied_filters": [
|
||||
{"column": "Latitude"},
|
||||
{"column": "Longitude"},
|
||||
],
|
||||
"rejected_filters": [
|
||||
{
|
||||
"column": "Country",
|
||||
"reason": ExtraFiltersReasonType.COL_NOT_IN_DATASOURCE,
|
||||
},
|
||||
],
|
||||
}
|
||||
mock_path_viz_class.return_value = mock_path_viz_instance
|
||||
|
||||
mock_viz_types.get.side_effect = lambda viz_type: {
|
||||
"deck_scatter": mock_scatter_viz_class,
|
||||
"deck_path": mock_path_viz_class,
|
||||
}.get(viz_type)
|
||||
|
||||
test_viz = viz.DeckGLMultiLayer(datasource, {"deck_slices": [1, 2]})
|
||||
test_viz.get_df_payload = Mock(return_value={"df": pd.DataFrame()})
|
||||
|
||||
result = test_viz.get_payload()
|
||||
|
||||
assert result["applied_filters"] == [
|
||||
{"column": "Latitude"},
|
||||
{"column": "Longitude"},
|
||||
]
|
||||
assert result["rejected_filters"] == [
|
||||
{
|
||||
"column": "Country",
|
||||
"reason": ExtraFiltersReasonType.COL_NOT_IN_DATASOURCE,
|
||||
},
|
||||
]
|
||||
|
||||
@with_config({"MAPBOX_API_KEY": "test_key"})
|
||||
def test_get_data_empty_deck_slices(self):
|
||||
"""Test get_data method with empty deck_slices."""
|
||||
|
||||
Reference in New Issue
Block a user