1- import os
2-
3- import pytest
41from conftest import ShinyAppProc
52from controls import OutputTextVerbatim
63from playwright .sync_api import Page
74
8- on_ci = os .environ .get ("CI" , "False" ) == "true"
9-
105
116def test_output_image_kitchen (page : Page , local_app : ShinyAppProc ) -> None :
127
13- if on_ci :
14- # 2024-03-22: The tests pass locally, but do not pass on CI. It started with
15- # https://github.com/posit-dev/py-shiny/commit/2f75a9076c567690f2a6a647ec07cfa9e558ff9c
16- # , but the changes in that commit were unrelated. We had believe it was an
17- # update in uvicorn, but removing all other debug statements did not fix the
18- # issue.
19- # 2024-03-22 Barret: When inspecting the issue, we found that many log
20- # INFO entries have different port values. This is concerning.
21- # https://github.com/posit-dev/py-shiny/pull/1236
22- pytest .skip ("Error with stdout / stderr on CI. Related #1236" )
23-
248 page .goto (local_app .url )
259
2610 OutputTextVerbatim (page , "all_txt" ).expect_value (
@@ -37,23 +21,10 @@ def test_output_image_kitchen(page: Page, local_app: ShinyAppProc) -> None:
3721 "('a-3-flushed', 'bx-3-first-flushed', 'by-3-first-flushed', "
3822 "'bx-3-second-flushed', 'by-3-second-flushed', 'c-3-flushed')"
3923 )
40-
41- # Verify `on_ended` callbacks are called in the correct order (and cancelled)
42- local_app .close ()
43-
44- # Wait up to 3 seconds for the app to close and print the logs. (Should be ~ instant)
45- local_app .stdout .wait_for (lambda x : "test4" in x , 3 )
46- stdout = str (local_app .stdout )
47- out_indexes = [
48- stdout .index ("session ended - sync - test1" ),
49- stdout .index ("session ended - async - test2" ),
50- stdout .index ("session ended - async - test3" ),
51- stdout .index ("session ended - sync - test4" ),
52- ]
53- for i in range (len (out_indexes )):
54- index = out_indexes [i ]
55- assert index >= 0
56- # Make sure they are ordered correctly
57- if i > 0 :
58- prev_index = out_indexes [i - 1 ]
59- assert index > prev_index
24+ # Session end messages have not flushed yet
25+ OutputTextVerbatim (page , "session_end_txt" ).expect_value ("[]" )
26+ page .reload ()
27+ # Session end messages have flushed
28+ OutputTextVerbatim (page , "session_end_txt" ).expect_value (
29+ "['session ended - sync - test1', 'session ended - async - test2', 'session ended - async - test3', 'session ended - sync - test4']"
30+ )
0 commit comments