diff --git a/tests/snapshot_tests/snapshot_apps/quickly_change_tabs.py b/tests/snapshot_tests/snapshot_apps/quickly_change_tabs.py new file mode 100644 index 0000000000..3db143f820 --- /dev/null +++ b/tests/snapshot_tests/snapshot_apps/quickly_change_tabs.py @@ -0,0 +1,29 @@ +"""Regression test for https://github.com/Textualize/textual/issues/2229.""" +from textual.app import App, ComposeResult +from textual.widgets import TabbedContent, TabPane, Tabs, DirectoryTree + + +class QuicklyChangeTabsApp(App[None]): + CSS = """ + DirectoryTree { + min-height: 10; + }""" + + def compose(self) -> ComposeResult: + with TabbedContent(): + with TabPane("one"): + yield DirectoryTree("./") + with TabPane("two"): + yield DirectoryTree("./") + with TabPane("three", id="three"): + yield DirectoryTree("./") + + def key_p(self) -> None: + self.query_one(Tabs).action_next_tab() + self.query_one(Tabs).action_next_tab() + + +app = QuicklyChangeTabsApp() + +if __name__ == "__main__": + app.run() diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index e8bde50c72..d84d2c84a4 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -429,3 +429,8 @@ def test_scroll_to_center(snap_compare): # scrolled so that the red string >>bullseye<< is centered on the screen. # When this snapshot "breaks" because #2254 is fixed, this snapshot can be updated. assert snap_compare(SNAPSHOT_APPS_DIR / "scroll_to_center.py", press=["s"]) + + +def test_quickly_change_tabs(snap_compare): + # https://github.com/Textualize/textual/issues/2229 + assert snap_compare(SNAPSHOT_APPS_DIR / "quickly_change_tabs.py", press=["p"])