aminghadersohi commented on code in PR #41698:
URL: https://github.com/apache/superset/pull/41698#discussion_r3572335375


##########
tests/unit_tests/mcp_service/utils/test_token_utils.py:
##########
@@ -677,3 +677,44 @@ def test_progressive_truncation(self) -> None:
         assert isinstance(result, dict)
         assert result["id"] == 1  # Scalar fields preserved
         assert len(notes) > 0
+
+    @staticmethod
+    def _build_large_dashboard_response() -> dict[str, Any]:
+        """A dashboard with 463 charts and 48 native_filters, shared by the
+        default- and custom-max_list_items regression tests below."""
+        return {
+            "id": 1,
+            "dashboard_title": "x" * 2000,  # forces Phase 2 to trigger
+            "charts": [{"id": i, "slice_name": f"chart_{i}"} for i in 
range(463)],
+            "native_filters": [{"id": i, "name": f"filter_{i}"} for i in 
range(48)],
+        }
+
+    def test_large_dashboard_respects_default_max_list_items(self) -> None:
+        """Regression test for the Medialab large-dashboard report.
+
+        A dashboard with 463 charts and 48 native_filters should have
+        native_filters (48 items) left untouched under the new default cap
+        of 100, while charts (463 items) is truncated to 100 — a clear
+        improvement over the old flat 30-item cap, which truncated both.
+        """
+        response = self._build_large_dashboard_response()
+        result, was_truncated, notes = truncate_oversized_response(response, 
3000)
+        assert was_truncated is True
+        assert isinstance(result, dict)
+        assert len(result["charts"]) == 100
+        assert len(result["native_filters"]) == 48
+        assert any("charts" in n and "463" in n for n in notes)
+        assert not any("native_filters" in n for n in notes)
+
+    def test_large_dashboard_respects_custom_max_list_items(self) -> None:
+        """A custom max_list_items below both list sizes should truncate both 
fields."""
+        response = self._build_large_dashboard_response()
+        result, was_truncated, notes = truncate_oversized_response(
+            response, 3000, max_list_items=30
+        )

Review Comment:
   Added explicit type annotations for `response`, `result`, `was_truncated`, 
and `notes` in db3aa712dd.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to