File tree 2 files changed +46
-0
lines changed
tests/playwright/shiny/components/MarkdownStream/stream-result
2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ import asyncio
2
+
3
+ from shiny import reactive
4
+ from shiny .express import input , render , ui
5
+
6
+ stream = ui .MarkdownStream ("stream_id" )
7
+ stream .ui ()
8
+
9
+
10
+ ui .input_action_button ("do_stream" , "Do stream" )
11
+
12
+
13
+ async def gen ():
14
+ yield "Hello "
15
+ await asyncio .sleep (0.1 )
16
+ yield "world!"
17
+
18
+
19
+ @reactive .effect
20
+ @reactive .event (input .do_stream )
21
+ async def _ ():
22
+ await stream .stream (gen ())
23
+
24
+
25
+ @render .code
26
+ def stream_result ():
27
+ res = stream .latest_stream .result ()
28
+ return f"Stream result: { res } "
Original file line number Diff line number Diff line change
1
+ from playwright .sync_api import Page , expect
2
+
3
+ from shiny .playwright import controller
4
+ from shiny .run import ShinyAppProc
5
+
6
+
7
+ def test_latest_stream_result (page : Page , local_app : ShinyAppProc ) -> None :
8
+ page .goto (local_app .url )
9
+
10
+ stream = page .locator ("#stream_id" )
11
+ stream_result = controller .OutputCode (page , "stream_result" )
12
+ stream_result .expect_value ("" )
13
+
14
+ btn = controller .InputActionButton (page , "do_stream" )
15
+ btn .click ()
16
+
17
+ expect (stream ).to_contain_text ("Hello world!" )
18
+ stream_result .expect_value ("Stream result: Hello world!" )
You can’t perform that action at this time.
0 commit comments