posit-dev / posit-dev/py-shiny
[Bug]: out-of-order values cause expect_selected() to fail for shiny.playwright.controller.InputCheckboxGroup
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 135
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 21
Description
Component
Other
Severity
P3 - Low (minor inconvenience)
Shiny Version
1.5.0
Python Version
3.13.7
Minimal Reproducible Example
from shiny import App, ui
app_ui = ui.page_fluid(
ui.input_checkbox_group(
"parameters",
"Parameters",
choices={"A": "a", "B": "b", "C": "c", "D": "d"},
selected=["A"],
inline=True,
),
)
def server(input, output, session):
pass
app = App(app_ui, server)
## test_checkboxgroup.py
from playwright.sync_api import Page
from shiny.playwright import controller
from shiny.run import ShinyAppProc
def test_cbg_works(page: Page, local_app: ShinyAppProc):
page.goto(local_app.url)
input_control = controller.InputCheckboxGroup(page, "parameters")
input_control.expect_selected(["A"])
def test_cbg_works_with_values_in_same_order(page: Page, local_app: ShinyAppProc):
page.goto(local_app.url)
input_control = controller.InputCheckboxGroup(page, "parameters")
input_control.set(["B", "C"]) # works
input_control.expect_selected(["B", "C"]) # works
def test_cbg_works_with_values_in_different_order(page: Page, local_app: ShinyAppProc):
page.goto(local_app.url)
input_control = controller.InputCheckboxGroup(page, "parameters")
input_control.set(["B", "A"]) # works
input_control.expect_selected(["B", "A"]) # does not work
Behavior
Current: Verifying selected checkboxes in a InputCheckboxGroup fails if the list of values is not in the same order as in the checkbox definition.
Expected: Regardless of ordering, the .expect_selected() method should verify and assert that the checkboxes are selected.
Error Messages (if any)
=========================== short test summary info ===========================
FAILED tests/features/test_checkboxgroup.py::test_cbg_works_with_values_in_different_order[chromium] - AssertionError: Locator expected to have attribute 'B'
Actual value: A
Call log:
- Expect "to_have_attribute" with timeout 5000ms
- waiting for locator("div#parameters.shiny-input-checkboxgroup.shiny-bound-input").locator(locator("input[type=checkbox]:checked")).first
9 × locator resolved to <input value="A" type="checkbox" name="parameters" checked="checked"/>
- unexpected value "A"
======================== 1 failed, 2 passed in 13.85s =========================
Finished running tests!
Environment
OS: win11
Browser: Chromium 140
uv: 0.9.10
pytest: 8.4.2
playwright: 1.55.0
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with shiny.playwright.controller.InputCheckboxGroup.expect_selected and the reproduced tests in tests/features/test_checkboxgroup.py. Run test_cbg_works_with_values_in_different_order and compare it with the passing same-order case. Done means expect_selected(["B", "A"]) verifies the selected checkboxes regardless of their definition order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- playwright, python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100