File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,8 +40,49 @@ def assert_no_server_error(page: Page) -> None:
4040 assert not page .locator ("text=Internal Server Error" ).is_visible ()
4141
4242
43+ def wait_for_reward_animation (page : Page ) -> None :
44+ """Wait for donation reward card transitions to settle."""
45+ page .evaluate (
46+ """
47+ () => new Promise((resolve) => {
48+ const rewards = document.querySelector(".rewards");
49+ if (!rewards) {
50+ resolve();
51+ return;
52+ }
53+
54+ let resolved = false;
55+ const finish = () => {
56+ if (resolved) {
57+ return;
58+ }
59+ resolved = true;
60+ requestAnimationFrame(() => requestAnimationFrame(resolve));
61+ };
62+
63+ requestAnimationFrame(() => {
64+ const animations = rewards
65+ .getAnimations({ subtree: true })
66+ .filter((animation) =>
67+ ["pending", "running"].includes(animation.playState),
68+ );
69+ if (!animations.length) {
70+ finish();
71+ return;
72+ }
73+ Promise.allSettled(
74+ animations.map((animation) => animation.finished),
75+ ).then(finish);
76+ window.setTimeout(finish, 1000);
77+ });
78+ })
79+ """ ,
80+ )
81+
82+
4383def capture_step (page : Page , name : str ) -> None :
4484 """Capture a full-page screenshot for important donation flow steps."""
85+ wait_for_reward_animation (page )
4586 page .screenshot (path = f"test-results/donation-{ name } .png" , full_page = True )
4687
4788
You can’t perform that action at this time.
0 commit comments