Skip to content

Commit

Permalink
Update playwright test to include error notification
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Jan 30, 2025
1 parent 0afcb87 commit 1d17a35
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
26 changes: 21 additions & 5 deletions tests/playwright/shiny/components/MarkdownStream/basic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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!")

0 comments on commit 1d17a35

Please sign in to comment.