|
| 1 | +from conftest import ShinyAppProc, x_create_doc_example_fixture |
| 2 | +from controls import OutputTextVerbatim, Sidebar |
| 3 | +from playwright.sync_api import Page |
| 4 | + |
| 5 | +app = x_create_doc_example_fixture("sidebar") |
| 6 | + |
| 7 | + |
| 8 | +def test_autoresize(page: Page, app: ShinyAppProc) -> None: |
| 9 | + page.goto(app.url) |
| 10 | + |
| 11 | + left_sidebar = Sidebar(page, "sidebar_left") |
| 12 | + output_txt_left = OutputTextVerbatim(page, "state_left") |
| 13 | + left_sidebar.expect_title("Left sidebar content") |
| 14 | + output_txt_left.expect_value("input.sidebar_left(): True") |
| 15 | + left_sidebar.expect_handle(True) |
| 16 | + left_sidebar.expect_open(True) |
| 17 | + left_sidebar.loc_handle.click() |
| 18 | + left_sidebar.expect_open(False) |
| 19 | + output_txt_left.expect_value("input.sidebar_left(): False") |
| 20 | + |
| 21 | + right_sidebar = Sidebar(page, "sidebar_right") |
| 22 | + output_txt_right = OutputTextVerbatim(page, "state_right") |
| 23 | + right_sidebar.expect_title("Right sidebar content") |
| 24 | + output_txt_right.expect_value("input.sidebar_right(): True") |
| 25 | + right_sidebar.expect_handle(True) |
| 26 | + right_sidebar.expect_open(True) |
| 27 | + right_sidebar.loc_handle.click() |
| 28 | + right_sidebar.expect_open(False) |
| 29 | + output_txt_right.expect_value("input.sidebar_right(): False") |
| 30 | + |
| 31 | + closed_sidebar = Sidebar(page, "sidebar_closed") |
| 32 | + output_txt_closed = OutputTextVerbatim(page, "state_closed") |
| 33 | + output_txt_closed.expect_value("input.sidebar_closed(): False") |
| 34 | + closed_sidebar.expect_handle(True) |
| 35 | + closed_sidebar.expect_open(False) |
| 36 | + closed_sidebar.loc_handle.click() |
| 37 | + closed_sidebar.expect_title("Closed sidebar content") |
| 38 | + closed_sidebar.expect_open(True) |
| 39 | + output_txt_closed.expect_value("input.sidebar_closed(): True") |
| 40 | + |
| 41 | + always_sidebar = Sidebar(page, "sidebar_always") |
| 42 | + output_txt_always = OutputTextVerbatim(page, "state_always") |
| 43 | + always_sidebar.expect_title("Always sidebar content") |
| 44 | + output_txt_always.expect_value("input.sidebar_always(): False") |
| 45 | + always_sidebar.expect_handle(False) |
0 commit comments