Skip to content

Commit

Permalink
test: Wait for tooltips after scrolling stuff into view
Browse files Browse the repository at this point in the history
Scrolling might trigger a tooltip (or popup) and thus we should wait
for their animation to be over after scrolling.
  • Loading branch information
mvollmer committed Sep 7, 2023
1 parent ff5be4c commit 7bc002e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/common/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,8 @@ def assert_pixels_in_current_layout(self, selector: str, key: str,
mock: Optional[Dict[str, str]] = None,
sit_after_mock: bool = False,
scroll_into_view: Optional[str] = None,
wait_animations: bool = True):
wait_animations: bool = True,
wait_delay: float = 0.5):
"""Compare the given element with its reference in the current layout"""

if ignore is None:
Expand Down Expand Up @@ -1033,6 +1034,7 @@ def assert_pixels_in_current_layout(self, selector: str, key: str,
# wait half a second to and side-step all that complexity.

if wait_animations:
time.sleep(wait_delay)
self.wait_js_cond('ph_count_animations(%s) == 0' % jsquote(selector))

rect = self.call_js_func('ph_element_clip', selector)
Expand Down Expand Up @@ -1178,13 +1180,13 @@ def assert_pixels(self, selector: str, key: str,
for layout in self.layouts:
if layout["name"] not in skip_layouts:
self.set_layout(layout["name"])
time.sleep(wait_delay)
if "rtl" in self.current_layout["name"]:
self._set_direction("rtl")
self.assert_pixels_in_current_layout(selector, key, ignore=ignore,
mock=mock, sit_after_mock=sit_after_mock,
scroll_into_view=scroll_into_view,
wait_animations=wait_animations)
wait_animations=wait_animations,
wait_delay=wait_delay)

if "rtl" in self.current_layout["name"]:
self._set_direction("ltr")
Expand Down

0 comments on commit 7bc002e

Please sign in to comment.