diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr index 1883f87a2..90173650b 100644 --- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr +++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr @@ -12380,6 +12380,164 @@ ''' # --- +# name: test_label_widths + ''' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LabelWrap + + + + + + + + + + + + + + + + Apple Banana Cherry Mango Fig Guava Pineapple:Dragon Unicorn Centaur Phoenix Ch + + + Apple Banana Cherry Mango Fig Guava Pineapple:Dragon Unicorn Centaur Phoenix  + Chimera Castle + + + ╭────────────────────────────────────────────────────────────────────────────╮ + Apple Banana Cherry Mango Fig Guava Pineapple:Dragon Unicorn Centaur  + Phoenix Chimera Castle + ╰────────────────────────────────────────────────────────────────────────────╯ + + + + + + + + + + + + ''' +# --- # name: test_layers ''' diff --git a/tests/snapshot_tests/snapshot_apps/label_widths.py b/tests/snapshot_tests/snapshot_apps/label_widths.py new file mode 100644 index 000000000..2cc49d2f9 --- /dev/null +++ b/tests/snapshot_tests/snapshot_apps/label_widths.py @@ -0,0 +1,45 @@ +from textual.app import App +from textual.widgets import Label, Static +from rich.panel import Panel + + +class LabelWrap(App): + CSS = """Screen { + align: center middle; + } + + #l_data { + border: blank; + background: lightgray; + } + + #s_data { + border: blank; + background: lightgreen; + } + + #p_data { + border: blank; + background: lightgray; + }""" + + def __init__(self): + super().__init__() + + self.data = ( + "Apple Banana Cherry Mango Fig Guava Pineapple:" + "Dragon Unicorn Centaur Phoenix Chimera Castle" + ) + + def compose(self): + yield Label(self.data, id="l_data") + yield Static(self.data, id="s_data") + yield Label(Panel(self.data), id="p_data") + + def on_mount(self): + self.dark = False + + +if __name__ == "__main__": + app = LabelWrap() + app.run() diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 8aa2b6514..20bf6001d 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -193,3 +193,7 @@ def test_demo(snap_compare): press=["down", "down", "down"], terminal_size=(100, 30), ) + + +def test_label_widths(snap_compare): + assert snap_compare(SNAPSHOT_APPS_DIR / "label_widths.py")