codeant-ai-for-open-source[bot] commented on code in PR #44336:
URL: https://github.com/apache/superset/pull/44336#discussion_r4058346585


##########
tests/unit_tests/utils/test_screenshot_utils.py:
##########
@@ -430,6 +475,147 @@ def 
test_report_mode_rejects_partial_first_tile_fallback(self):
 
 
 class TestTakeTiledScreenshot:
+    def test_per_tile_diagnostics_failure_does_not_discard_capture(self, 
mock_page):
+        """Diagnostics must not discard valid tiles: a non-timeout evaluate
+        failure on the per-tile diagnostics path logs a warning and the
+        capture still succeeds."""
+        final_states = [{"chartId": "1", "state": "rendered"}]
+        diagnostics_calls = 0
+
+        def evaluate(script, _arg=None):
+            nonlocal diagnostics_calls
+            if "scrollWidth" in script:
+                return {"height": 1000, "top": 100, "left": 50, "width": 800}
+            if script == CONTENTFUL_CHART_HOLDERS_IN_CLIP_JS:
+                return {"total": 1, "contentful": 1}
+            if script == FIND_CHART_HOLDER_STATES_JS:
+                diagnostics_calls += 1
+                if diagnostics_calls == 1:
+                    raise RuntimeError("Execution context was destroyed")
+                return final_states
+            return None
+
+        mock_page.wait_for_function.side_effect = None
+        mock_page.wait_for_function.return_value = None
+        mock_page.evaluate.side_effect = evaluate
+        combined = self._create_chart_like_tile()
+        mock_page.screenshot.return_value = combined
+
+        with patch("superset.utils.screenshot_utils.logger") as mock_logger:
+            with patch(
+                "superset.utils.screenshot_utils.combine_screenshot_tiles",
+                return_value=combined,
+            ):
+                result = take_tiled_screenshot(
+                    mock_page,
+                    "dashboard",
+                    tile_height=2000,
+                    load_wait=30,
+                    report_execution_context=_report_context(),
+                )
+
+        assert result == combined
+        assert mock_page.screenshot.call_count == 1
+        assert any(
+            call.args
+            and call.args[0].startswith(
+                "Unable to collect per-tile chart-holder diagnostics"
+            )
+            for call in mock_logger.warning.call_args_list
+        )
+
+    def test_final_semantic_status_fires_exactly_once_for_error_holders(
+        self, mock_page
+    ):
+        """One error chart spanning every tile emits ONE report_semantic_status
+        WARNING for the capture (final block), not one per tile โ€” the per-tile
+        INFO lines already carry error_holders."""
+        with_error = [
+            {"chartId": "1", "state": "rendered"},
+            {"chartId": "2", "state": "error"},
+        ]
+        mock_page.wait_for_function.side_effect = None
+        mock_page.wait_for_function.return_value = None
+        mock_page.evaluate.side_effect = [
+            {"height": 5000, "top": 100, "left": 50, "width": 800},
+            None,
+            with_error,
+            None,
+            with_error,
+            None,
+            with_error,
+            with_error,

Review Comment:
   **Suggestion:** The mocked evaluation list omits each per-tile 
contentful-holder evaluation, shifting later results and preventing the test 
from observing the expected final semantic warning.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Often` ยท ๐Ÿท๏ธ `Logic error`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0ca952474b094b09852736c49f10931d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=0ca952474b094b09852736c49f10931d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/utils/test_screenshot_utils.py
   **Line:** 539:547
   **Comment:**
        *Logic Error: The mocked evaluation list omits each per-tile 
contentful-holder evaluation, shifting later results and preventing the test 
from observing the expected final semantic warning.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44336&comment_hash=c454828b9387db4aa2840356e027349fea5f030366436b769d176bf384cb21e7&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44336&comment_hash=c454828b9387db4aa2840356e027349fea5f030366436b769d176bf384cb21e7&reaction=dislike'>๐Ÿ‘Ž</a>



-- 
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