Skip to content

Commit

Permalink
snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Sep 24, 2024
1 parent c025124 commit 3632fef
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/textual/_compositor.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,9 @@ def full_map(self) -> CompositorMap:
return {}
if self._full_map_invalidated:
self._full_map_invalidated = False
old = self._full_map.keys()
old_widgets = self._full_map.keys()
map, widgets = self._arrange_root(self.root, self.size, visible_only=False)
self._new_widgets.update(map.keys() - old)
self._new_widgets.update(map.keys() - old_widgets)
self._full_map = map
self._visible_widgets = None
self._visible_map = None
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 30 additions & 3 deletions tests/snapshot_tests/test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from textual import events
from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.containers import Vertical
from textual.containers import Vertical, VerticalScroll
from textual.pilot import Pilot
from textual.screen import Screen
from textual.widgets import (
Expand All @@ -24,8 +24,7 @@
OptionList,
SelectionList,
)
from textual.widgets import Switch
from textual.widgets import Label
from textual.widgets import ProgressBar, Label, Switch
from textual.widgets.text_area import BUILTIN_LANGUAGES, Selection, TextAreaTheme

# These paths should be relative to THIS directory.
Expand Down Expand Up @@ -1992,3 +1991,31 @@ def on_mount(self) -> None:

app = DisabledApp()
assert snap_compare(app)


def test_missing_new_widgets(snap_compare):
"""Regression test for https://github.com/Textualize/textual/issues/5024"""

class MRE(App):
BINDINGS = [("z", "toggle_console", "Console")]
CSS = """
RichLog { border-top: dashed blue; height: 6; }
.hidden { display: none; }
"""

def compose(self):
yield VerticalScroll()
yield ProgressBar(
classes="hidden"
) # removing or displaying this widget prevents the bug
yield Footer() # clicking "Console" in the footer prevents the bug
yield RichLog(classes="hidden")

def on_ready(self) -> None:
self.query_one(RichLog).write("\n".join(f"line #{i}" for i in range(5)))

def action_toggle_console(self) -> None:
self.query_one(RichLog).toggle_class("hidden")

app = MRE()
assert snap_compare(app, press=["space", "space", "z"])

0 comments on commit 3632fef

Please sign in to comment.