diff --git a/tests/playwright/shiny/components/MarkdownStream/basic/app.py b/tests/playwright/shiny/components/MarkdownStream/basic/app.py index b3837d500..6cb5e9cb9 100644 --- a/tests/playwright/shiny/components/MarkdownStream/basic/app.py +++ b/tests/playwright/shiny/components/MarkdownStream/basic/app.py @@ -2,24 +2,40 @@ from shiny.express import ui +# Read in the py-shiny README.md file readme = Path(__file__).parent / "README.md" with open(readme, "r") as f: readme_chunks = f.read().replace("\n", " \n ").split(" ") -# Generate words from the README.md file (with a small delay) -def chunk_generator(): +stream = ui.MarkdownStream("shiny-readme") +stream2 = ui.MarkdownStream("shiny-readme-err") + + +def readme_generator(): + for chunk in readme_chunks: + yield chunk + " " + + +def readme_generator_err(): for chunk in readme_chunks: yield chunk + " " + if chunk == "Shiny": + raise RuntimeError("boom!") -md = ui.MarkdownStream("shiny-readme") +stream.stream(readme_generator()) +stream2.stream(readme_generator_err()) + with ui.card( height="400px", class_="mt-3", ): ui.card_header("Shiny README.md") - md.ui() + stream.ui() + -md.stream(chunk_generator()) +with ui.card(class_="mt-3"): + ui.card_header("Shiny README.md with error") + stream2.ui() diff --git a/tests/playwright/shiny/components/MarkdownStream/basic/test_stream_basic.py b/tests/playwright/shiny/components/MarkdownStream/basic/test_stream_basic.py index 0f7705038..6a34b0731 100644 --- a/tests/playwright/shiny/components/MarkdownStream/basic/test_stream_basic.py +++ b/tests/playwright/shiny/components/MarkdownStream/basic/test_stream_basic.py @@ -35,3 +35,11 @@ def test_validate_stream_basic(page: Page, local_app: ShinyAppProc) -> None: # all the way to the bottom is_scrolled = is_element_scrolled_to_bottom(page, ".card-body") assert is_scrolled, "The card body container should be scrolled to the bottom" + + stream2 = page.locator("#shiny-readme-err") + expect(stream2).to_be_visible(timeout=30 * 1000) + expect(stream2).to_contain_text("Shiny") + + notification = page.locator(".shiny-notification-error") + expect(notification).to_be_visible(timeout=30 * 1000) + expect(notification).to_contain_text("boom!")