From c57757ac8177ffc2e2771a14a9601a3331b2c111 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Thu, 26 Sep 2024 20:37:57 +0100 Subject: [PATCH] snapshot --- tests/snapshot_tests/test_snapshots.py | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 427e55a82a..fb5baeba31 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -22,6 +22,7 @@ Footer, Log, OptionList, + Placeholder, SelectionList, ) from textual.widgets import ProgressBar, Label, Switch @@ -2019,3 +2020,35 @@ def action_toggle_console(self) -> None: app = MRE() assert snap_compare(app, press=["space", "space", "z"]) + + +def test_updates_with_auto_refresh(snap_compare): + """Regression test for https://github.com/Textualize/textual/issues/5056""" + + class MRE(App): + BINDINGS = [ + ("z", "toggle_widget('RichLog')", "Console"), + ("x", "toggle_widget('ProgressBar')", "Progress bar"), + ] + CSS = """ + Placeholder { height: 15; } + RichLog { border-top: dashed blue; height: 6; } + .hidden { display: none; } + """ + + def compose(self): + with VerticalScroll(): + for i in range(10): + yield Placeholder() + yield ProgressBar(classes="hidden") + yield RichLog(classes="hidden") + yield Footer() + + def on_ready(self) -> None: + self.query_one(RichLog).write("\n".join(f"line #{i}" for i in range(5))) + + def action_toggle_widget(self, widget_type: str) -> None: + self.query_one(widget_type).toggle_class("hidden") + + app = MRE() + assert snap_compare(app, press=["z", "z"])