Add a test for a radio set getting focus when a button gets clicked

This commit is contained in:
Dave Pearson
2023-05-04 16:22:39 +01:00
parent 19f4f64d96
commit 8b36d29e74

View File

@@ -11,7 +11,7 @@ class RadioSetApp(App[None]):
def compose(self) -> ComposeResult:
with RadioSet(id="from_buttons"):
yield RadioButton()
yield RadioButton(id="clickme")
yield RadioButton()
yield RadioButton(value=True)
yield RadioSet("One", "True", "Three", id="from_strings")
@@ -36,6 +36,14 @@ async def test_radio_sets_initial_state():
assert pilot.app.events_received == []
async def test_click_sets_focus():
"""Clicking within a radio set should set focus."""
async with RadioSetApp().run_test() as pilot:
assert pilot.app.screen.focused is None
await pilot.click("#clickme")
assert pilot.app.screen.focused == pilot.app.query_one("#from_buttons")
async def test_radio_sets_toggle():
"""Test the status of the radio sets after they've been toggled."""
async with RadioSetApp().run_test() as pilot: