Skip to content

Commit 1d17a35

Browse files
committed
Update playwright test to include error notification
1 parent 0afcb87 commit 1d17a35

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

tests/playwright/shiny/components/MarkdownStream/basic/app.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,40 @@
22

33
from shiny.express import ui
44

5+
# Read in the py-shiny README.md file
56
readme = Path(__file__).parent / "README.md"
67
with open(readme, "r") as f:
78
readme_chunks = f.read().replace("\n", " \n ").split(" ")
89

910

10-
# Generate words from the README.md file (with a small delay)
11-
def chunk_generator():
11+
stream = ui.MarkdownStream("shiny-readme")
12+
stream2 = ui.MarkdownStream("shiny-readme-err")
13+
14+
15+
def readme_generator():
16+
for chunk in readme_chunks:
17+
yield chunk + " "
18+
19+
20+
def readme_generator_err():
1221
for chunk in readme_chunks:
1322
yield chunk + " "
23+
if chunk == "Shiny":
24+
raise RuntimeError("boom!")
1425

1526

16-
md = ui.MarkdownStream("shiny-readme")
27+
stream.stream(readme_generator())
28+
stream2.stream(readme_generator_err())
29+
1730

1831
with ui.card(
1932
height="400px",
2033
class_="mt-3",
2134
):
2235
ui.card_header("Shiny README.md")
23-
md.ui()
36+
stream.ui()
37+
2438

25-
md.stream(chunk_generator())
39+
with ui.card(class_="mt-3"):
40+
ui.card_header("Shiny README.md with error")
41+
stream2.ui()

tests/playwright/shiny/components/MarkdownStream/basic/test_stream_basic.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,11 @@ def test_validate_stream_basic(page: Page, local_app: ShinyAppProc) -> None:
3535
# all the way to the bottom
3636
is_scrolled = is_element_scrolled_to_bottom(page, ".card-body")
3737
assert is_scrolled, "The card body container should be scrolled to the bottom"
38+
39+
stream2 = page.locator("#shiny-readme-err")
40+
expect(stream2).to_be_visible(timeout=30 * 1000)
41+
expect(stream2).to_contain_text("Shiny")
42+
43+
notification = page.locator(".shiny-notification-error")
44+
expect(notification).to_be_visible(timeout=30 * 1000)
45+
expect(notification).to_contain_text("boom!")

0 commit comments

Comments
 (0)