Skip to content

Commit

Permalink
Add a unit test for Textualize#2807
Browse files Browse the repository at this point in the history
  • Loading branch information
davep committed Jun 19, 2023
1 parent bb9cc62 commit 516262e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/test_tabbed_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,44 @@ def on_tabbed_content_cleared(self) -> None:
assert tabbed_content.active == ""


@pytest.mark.xfail(
reason="https://github.com/Textualize/textual/issues/2807", strict=True
)
async def test_tabbed_content_reversed_removal():
class TabbedApp(App[None]):
cleared: var[int] = var(0)

def compose(self) -> ComposeResult:
with TabbedContent():
yield TabPane("Test 1", id="initial-1")
yield TabPane("Test 2", id="initial-2")
yield TabPane("Test 3", id="initial-3")

def on_tabbed_content_cleared(self) -> None:
self.cleared += 1

async with TabbedApp().run_test() as pilot:
tabbed_content = pilot.app.query_one(TabbedContent)
assert tabbed_content.tab_count == 3
assert pilot.app.cleared == 0
assert tabbed_content.active == "initial-1"
await tabbed_content.remove_pane("initial-3")
await pilot.pause()
assert tabbed_content.tab_count == 2
assert pilot.app.cleared == 0
assert tabbed_content.active == "initial-1"
await tabbed_content.remove_pane("initial-2")
await pilot.pause()
assert tabbed_content.tab_count == 1
assert pilot.app.cleared == 0
assert tabbed_content.active == "initial-1"
await tabbed_content.remove_pane("initial-1")
await pilot.pause()
assert tabbed_content.tab_count == 0
assert pilot.app.cleared == 1
assert tabbed_content.active == ""


async def test_tabbed_content_clear():
class TabbedApp(App[None]):
cleared: var[int] = var(0)
Expand Down

0 comments on commit 516262e

Please sign in to comment.