11from playwright .sync_api import Page , expect
2- from utils .deploy_utils import skip_on_webkit
32
4- from shiny .playwright import controller
53from shiny .run import ShinyAppProc
64
75
8- async def is_element_scrolled_to_bottom (page : Page , selector : str ) -> bool :
9- return await page .evaluate (
6+ def is_element_scrolled_to_bottom (page : Page , selector : str ) -> bool :
7+ return page .evaluate (
108 """(selector) => {
119 const element = document.querySelector(selector);
1210 if (!element) return false;
@@ -16,23 +14,24 @@ async def is_element_scrolled_to_bottom(page: Page, selector: str) -> bool:
1614 const scrollHeight = Math.round(element.scrollHeight);
1715 const clientHeight = Math.round(element.clientHeight);
1816
17+ // Check if the element is scrollable
18+ if (scrollHeight <= clientHeight) return false;
19+
1920 // Check if we're at the bottom (allowing for 1px difference due to rounding)
2021 return Math.abs((scrollTop + clientHeight) - scrollHeight) <= 1;
2122 }""" ,
2223 selector ,
2324 )
2425
2526
26- @skip_on_webkit
27- async def test_validate_stream_basic (page : Page , local_app : ShinyAppProc ) -> None :
27+ def test_validate_stream_basic (page : Page , local_app : ShinyAppProc ) -> None :
2828 page .goto (local_app .url )
2929
30- stream = controller .MarkdownStream (page , "shiny-readme" )
31-
32- expect (stream .loc ).to_be_visible (timeout = 30 * 1000 )
33- stream .expect_content ("pip install shiny" )
30+ stream = page .locator ("#shiny-readme" )
31+ expect (stream ).to_be_visible (timeout = 30 * 1000 )
32+ expect (stream ).to_contain_text ("pip install shiny" )
3433
3534 # Check that the card body container (the parent of the markdown stream) is scrolled
3635 # all the way to the bottom
37- is_scrolled = await is_element_scrolled_to_bottom (page , ".card-body" )
36+ is_scrolled = is_element_scrolled_to_bottom (page , ".card-body" )
3837 assert is_scrolled , "The card body container should be scrolled to the bottom"
0 commit comments