mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
fix refresh on remove (#2008)
* fix refresh on remove * changelog * optimization * added snapshot
This commit is contained in:
File diff suppressed because one or more lines are too long
38
tests/snapshot_tests/snapshot_apps/remove_auto.py
Normal file
38
tests/snapshot_tests/snapshot_apps/remove_auto.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Vertical
|
||||
from textual.widgets import Header, Footer, Label
|
||||
|
||||
|
||||
class VerticalRemoveApp(App[None]):
|
||||
CSS = """
|
||||
Vertical {
|
||||
border: round green;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
Label {
|
||||
border: round yellow;
|
||||
background: red;
|
||||
color: yellow;
|
||||
}
|
||||
"""
|
||||
BINDINGS = [
|
||||
("a", "add", "Add"),
|
||||
("d", "del", "Delete"),
|
||||
]
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header()
|
||||
yield Vertical()
|
||||
yield Footer()
|
||||
|
||||
def action_add(self) -> None:
|
||||
self.query_one(Vertical).mount(Label("This is a test label"))
|
||||
|
||||
def action_del(self) -> None:
|
||||
if self.query_one(Vertical).children:
|
||||
self.query_one(Vertical).children[-1].remove()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
VerticalRemoveApp().run()
|
||||
@@ -170,9 +170,11 @@ def test_content_switcher_example_initial(snap_compare):
|
||||
|
||||
|
||||
def test_content_switcher_example_switch(snap_compare):
|
||||
assert snap_compare(WIDGET_EXAMPLES_DIR / "content_switcher.py", press=[
|
||||
"tab", "tab", "enter", "wait:500"
|
||||
], terminal_size=(50, 50))
|
||||
assert snap_compare(
|
||||
WIDGET_EXAMPLES_DIR / "content_switcher.py",
|
||||
press=["tab", "tab", "enter", "wait:500"],
|
||||
terminal_size=(50, 50),
|
||||
)
|
||||
|
||||
|
||||
# --- CSS properties ---
|
||||
@@ -234,6 +236,7 @@ def test_programmatic_scrollbar_gutter_change(snap_compare):
|
||||
# --- CLI Preview Apps ---
|
||||
# For our CLI previews e.g. `textual easing`, `textual colors` etc, we have snapshots
|
||||
|
||||
|
||||
def test_borders_preview(snap_compare):
|
||||
assert snap_compare(CLI_PREVIEWS_DIR / "borders.py", press=["tab", "enter"])
|
||||
|
||||
@@ -296,3 +299,9 @@ def test_focus_component_class(snap_compare):
|
||||
|
||||
def test_line_api_scrollbars(snap_compare):
|
||||
assert snap_compare(SNAPSHOT_APPS_DIR / "line_api_scrollbars.py")
|
||||
|
||||
|
||||
def test_remove_with_auto_height(snap_compare):
|
||||
assert snap_compare(
|
||||
SNAPSHOT_APPS_DIR / "remove_auto.py", press=["a", "a", "a", "d", "d"]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user