mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add some unit testing of the new navigation
This commit is contained in:
@@ -52,6 +52,34 @@ async def test_radio_sets_toggle():
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
async def test_radioset_inner_navigation():
|
||||||
|
"""Using the cursor keys should navigate between buttons in a set."""
|
||||||
|
async with RadioSetApp().run_test() as pilot:
|
||||||
|
assert pilot.app.screen.focused is None
|
||||||
|
await pilot.press("tab")
|
||||||
|
assert (
|
||||||
|
pilot.app.screen.focused == pilot.app.query_one("#from_buttons").children[0]
|
||||||
|
)
|
||||||
|
for key, landing in (("down", 1), ("up", 0), ("right", 1), ("left", 0)):
|
||||||
|
await pilot.press(key)
|
||||||
|
assert (
|
||||||
|
pilot.app.screen.focused
|
||||||
|
== pilot.app.query_one("#from_buttons").children[landing]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_radioset_breakout_navigation():
|
||||||
|
"""Shift/Tabbing while in a radioset should move to the previous/next focsuable after the set itself."""
|
||||||
|
async with RadioSetApp().run_test() as pilot:
|
||||||
|
assert pilot.app.screen.focused is None
|
||||||
|
await pilot.press("tab")
|
||||||
|
assert pilot.app.screen.focused.parent is pilot.app.query_one("#from_buttons")
|
||||||
|
await pilot.press("tab")
|
||||||
|
assert pilot.app.screen.focused.parent is pilot.app.query_one("#from_strings")
|
||||||
|
await pilot.press("shift+tab")
|
||||||
|
assert pilot.app.screen.focused.parent is pilot.app.query_one("#from_buttons")
|
||||||
|
|
||||||
|
|
||||||
class BadRadioSetApp(App[None]):
|
class BadRadioSetApp(App[None]):
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
with RadioSet():
|
with RadioSet():
|
||||||
|
|||||||
Reference in New Issue
Block a user