test_1992923_godotfest_com.py (1461B)
1 import pytest 2 3 URL = "https://godotfest.com/talks" 4 5 TOP_BAR_BLUR_CSS = "#menu-blur" 6 7 8 async def are_blurs_working(client): 9 # to test, we take a screenshot of the top menu bar, which ought to be blurred, 10 # and then hide its blur element and compare the after-screenshot. If they're the 11 # same, then the blur would not have actually been working. 12 await client.navigate(URL) 13 14 # hide SVGs and text which might interfere with the screenshot. 15 client.add_stylesheet( 16 """ 17 * { color: transparent !important; } 18 #test { position: fixed; color: white !important; } 19 svg { display: none; } 20 """ 21 ) 22 23 top_bar_blur = client.await_css(TOP_BAR_BLUR_CSS) 24 25 client.execute_script( 26 """ 27 const test = document.createElement("div"); 28 test.innerText = test.id = "test"; 29 document.body.insertBefore(test, document.body.firstElementChild); 30 window.scrollTo({ top: 200, behavior: 'instant' }); 31 """ 32 ) 33 34 # now take a screenshot, remove the blur element, and compare. 35 await client.stall(0.5) 36 pre = client.find_css("body").screenshot() 37 client.execute_script("arguments[0].remove()", top_bar_blur) 38 await client.stall(0.5) 39 post = client.find_css("body").screenshot() 40 return pre != post 41 42 43 @pytest.mark.only_platforms("android") 44 @pytest.mark.asyncio 45 @pytest.mark.without_interventions 46 async def test_regression(client): 47 assert await are_blurs_working(client)