fitzee commented on code in PR #44114:
URL: https://github.com/apache/superset/pull/44114#discussion_r3978651387


##########
tests/unit_tests/utils/webdriver_test.py:
##########
@@ -1494,6 +1529,77 @@ def 
test_report_readiness_uses_shared_deadline_and_phase_reserves(self):
 
         assert page.wait_for_function.call_args.kwargs["timeout"] == 590_000
 
+    def test_capture_readiness_wires_stable_predicate_and_timeout(self):
+        page = MagicMock()
+        element = MagicMock()
+        page.screenshot.return_value = _png("white")
+        page.evaluate.return_value = False
+
+        def signature_checked_wait(
+            expression,
+            *,
+            arg=None,
+            timeout=None,
+            polling=None,
+        ):
+            assert "__supersetCaptureReadiness" in expression
+            assert arg["stabilityMs"] == REPORT_CAPTURE_READINESS_STABILITY_MS
+
+        page.wait_for_function.side_effect = signature_checked_wait
+
+        result = WebDriverPlaywright._get_validated_screenshot(
+            page,
+            element,
+            "standalone",
+            "execution_id=test",
+            report_execution_context=_report_context(),
+        )
+
+        assert result == _png("white")
+        readiness_call = page.wait_for_function.call_args
+        assert "__supersetCaptureReadiness" in readiness_call.args[0]
+        assert (
+            readiness_call.kwargs["arg"]["stabilityMs"]
+            == REPORT_CAPTURE_READINESS_STABILITY_MS
+        )
+        assert readiness_call.kwargs["timeout"] == 690_000
+
+    def test_chart_capture_uses_chart_container_stable_predicate(self):
+        page = MagicMock()
+        element = MagicMock()
+        element.screenshot.return_value = _png("white")
+        page.evaluate.return_value = False
+
+        WebDriverPlaywright._get_validated_screenshot(
+            page,
+            element,
+            "chart-container",
+            "execution_id=test",
+            report_execution_context=_report_context(chart_id=7),
+        )
+
+        predicate = page.wait_for_function.call_args.args[0]
+        assert "document.querySelector('.chart-container')" in predicate
+
+    def test_capture_skips_stability_dwell_when_budget_is_too_short(self):
+        page = MagicMock()
+        element = MagicMock()
+        page.screenshot.return_value = _png("white")
+        page.evaluate.return_value = False
+        context = _report_context()
+        context.deadline._clock = lambda: 689.6

Review Comment:
   Agreed. Fixed in d7d4c4dca4 by rebuilding both frozen dataclasses with the 
existing `replace` import. The test now reaches the intended 0.4s 
available-budget path, skips `wait_for_function`, and proceeds to capture. Ruff 
formatting, Ruff lint, syntax compilation, and diff checks pass.



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