From 8b36d29e74412729d67d1da151d7a3532a83d83f Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Thu, 4 May 2023 16:22:39 +0100 Subject: [PATCH] Add a test for a radio set getting focus when a button gets clicked --- tests/toggles/test_radioset.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/toggles/test_radioset.py b/tests/toggles/test_radioset.py index b2869eb5a..95025bf37 100644 --- a/tests/toggles/test_radioset.py +++ b/tests/toggles/test_radioset.py @@ -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: