Skip to content

Commit

Permalink
Add regression test for #2229.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigogiraoserrao committed Apr 17, 2023
1 parent f8b51ea commit c8fe8ed
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/snapshot_tests/snapshot_apps/quickly_change_tabs.py
Original file line number Diff line number Diff line change
@@ -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()
5 changes: 5 additions & 0 deletions tests/snapshot_tests/test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

0 comments on commit c8fe8ed

Please sign in to comment.