From c275274e45cb54caed699daa47e359e3f01e47f1 Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Fri, 17 May 2024 11:16:52 -0700 Subject: [PATCH 1/2] Add wait till pulse animation has started --- .../shiny/components/busy_indicators/app.py | 7 ++++++- .../busy_indicators/test_busy_indicators.py | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/playwright/shiny/components/busy_indicators/app.py b/tests/playwright/shiny/components/busy_indicators/app.py index 3c65b8b87..5c02e4bdf 100644 --- a/tests/playwright/shiny/components/busy_indicators/app.py +++ b/tests/playwright/shiny/components/busy_indicators/app.py @@ -45,6 +45,7 @@ def plot(): inline=True, ), ui.input_task_button("rerender", "Re-render"), + ui.output_text_verbatim("counter", placeholder=True), ui.layout_columns( card_ui("ring", "ring", "red", "10px"), card_ui("bars", "bars", "green", "20px"), @@ -76,5 +77,9 @@ def indicator_types_ui(): pulse=(selected_busy_indicator_type != "spinners"), ) + @render.text + def counter(): + return str(rerender()) -app = App(app_ui, server, debug=True) + +app = App(app_ui, server) diff --git a/tests/playwright/shiny/components/busy_indicators/test_busy_indicators.py b/tests/playwright/shiny/components/busy_indicators/test_busy_indicators.py index 7ecb487f9..bb720acf3 100644 --- a/tests/playwright/shiny/components/busy_indicators/test_busy_indicators.py +++ b/tests/playwright/shiny/components/busy_indicators/test_busy_indicators.py @@ -2,7 +2,7 @@ from urllib.parse import urlparse from conftest import ShinyAppProc -from controls import InputRadioButtons, InputTaskButton, expect_not_to_have_class +from controls import InputRadioButtons, InputTaskButton, OutputTextVerbatim from playwright.sync_api import Page, expect @@ -46,11 +46,21 @@ def test_busy_indicators(page: Page, local_app: ShinyAppProc) -> None: assert get_spinner_computed_property(page, element_id, "width") == height # Verify pulse indicator behavior - expect_not_to_have_class(page.locator("html"), "shiny-busy", timeout=8000) + output_txt = OutputTextVerbatim(page, "counter") + output_txt.expect_value("0") spinner_type.set("pulse") render_button.click() + # since we are not using locators wait for up to 2 secs + for _ in range(200): + if get_pulse_computed_property(page, "height") != "auto": + break + page.wait_for_timeout(10) assert get_pulse_computed_property(page, "height") == "100px" assert ( get_pulse_computed_property(page, "background-image") == "linear-gradient(45deg, rgb(0, 0, 255), rgb(255, 0, 0))" ) + output_txt.expect_value("1") + # since output value is 1, nothing is computing + # verify the pulse indicator is removed + assert get_pulse_computed_property(page, "height") == "auto" From 739a4d2098a6012d7ba605ec25fb94838ca62acd Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Fri, 17 May 2024 14:23:19 -0400 Subject: [PATCH 2/2] Comment --- .../shiny/components/busy_indicators/test_busy_indicators.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/playwright/shiny/components/busy_indicators/test_busy_indicators.py b/tests/playwright/shiny/components/busy_indicators/test_busy_indicators.py index bb720acf3..8156e719b 100644 --- a/tests/playwright/shiny/components/busy_indicators/test_busy_indicators.py +++ b/tests/playwright/shiny/components/busy_indicators/test_busy_indicators.py @@ -50,7 +50,8 @@ def test_busy_indicators(page: Page, local_app: ShinyAppProc) -> None: output_txt.expect_value("0") spinner_type.set("pulse") render_button.click() - # since we are not using locators wait for up to 2 secs + # `::after` is not an implemented selector in playwright + # Since we are not using locators wait for up to 2 secs for _ in range(200): if get_pulse_computed_property(page, "height") != "auto": break