Skip to content

Commit dd8c8bc

Browse files
committed
Test that modal shows up and the url isn't updated
1 parent 44e4811 commit dd8c8bc

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from starlette.requests import Request
2+
3+
from shiny import App, Inputs, Outputs, Session, reactive, ui
4+
5+
6+
def app_ui(request: Request):
7+
return ui.page_fluid(
8+
ui.input_radio_buttons("letter", "Choose a letter", choices=["A", "B", "C"]),
9+
)
10+
11+
12+
def server(input: Inputs, ouput: Outputs, session: Session):
13+
14+
@reactive.effect
15+
@reactive.event(input.letter, ignore_init=True)
16+
async def _():
17+
await session.bookmark()
18+
19+
20+
app = App(app_ui, server, bookmark_store="url")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import re
2+
3+
from playwright.sync_api import Page, expect
4+
5+
from shiny.playwright.controller import InputRadioButtons
6+
from shiny.run import ShinyAppProc
7+
8+
9+
def test_bookmark_modules(page: Page, local_app: ShinyAppProc):
10+
11+
page.goto(local_app.url)
12+
13+
letter = InputRadioButtons(page, "letter")
14+
letter.expect_selected("A")
15+
letter.set("C")
16+
17+
expect(page.locator("div.modal-body > textarea")).to_have_value(
18+
re.compile(r"letter=%22C%22")
19+
)
20+
21+
assert "?" not in page.url

0 commit comments

Comments
 (0)