3535 Tab ,
3636 Tabs ,
3737 TextArea ,
38+ TabbedContent ,
39+ TabPane ,
3840)
3941from textual .widgets .text_area import BUILTIN_LANGUAGES , Selection , TextAreaTheme
4042from textual .theme import Theme
@@ -2752,7 +2754,6 @@ async def run_before(pilot: Pilot) -> None:
27522754 snap_compare (TallSelectApp (), run_before = run_before )
27532755
27542756
2755-
27562757def test_markup_command_list (snap_compare ):
27572758 """Regression test for https://github.com/Textualize/textual/issues/5276
27582759 You should see a command list, with console markup applied to the action name and help text."""
@@ -2769,6 +2770,7 @@ def on_mount(self) -> None:
27692770
27702771 snap_compare (MyApp ())
27712772
2773+
27722774def test_app_resize_order (snap_compare ):
27732775 """Regression test for https://github.com/Textualize/textual/issues/5284
27742776 You should see a placeholder with text "BAR", focused and scrolled down so it fills the screen.
@@ -2810,3 +2812,32 @@ def on_resize(self) -> None:
28102812
28112813 snap_compare (SCApp ())
28122814
2815+
2816+ def test_add_remove_tabs (snap_compare ):
2817+ """Regression test for https://github.com/Textualize/textual/issues/5215
2818+ You should see a TabbedContent with two panes, entitled 'tab-2' and 'tab-3'"""
2819+
2820+ class ExampleApp (App ):
2821+ BINDINGS = [
2822+ ("r" , "remove_pane" , "Remove first pane" ),
2823+ ("a" , "add_pane" , "Add pane" ),
2824+ ]
2825+
2826+ def compose (self ) -> ComposeResult :
2827+ with TabbedContent (initial = "tab-2" ):
2828+ with TabPane ("tab-1" ):
2829+ yield Label ("tab-1" )
2830+ with TabPane ("tab-2" ):
2831+ yield Label ("tab-2" )
2832+ yield Footer ()
2833+
2834+ def action_remove_pane (self ) -> None :
2835+ tabbed_content = self .query_one (TabbedContent )
2836+ tabbed_content .remove_pane ("tab-1" )
2837+
2838+ def action_add_pane (self ) -> None :
2839+ tabbed_content = self .query_one (TabbedContent )
2840+ new_pane = TabPane ("tab-3" , Label ("tab-3" ))
2841+ tabbed_content .add_pane (new_pane )
2842+
2843+ snap_compare (ExampleApp (), press = ["a" , "r" ])
0 commit comments