From 48ce1a149d5ba39a6a96c4344f860d478c276fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+rodrigogiraoserrao@users.noreply.github.com> Date: Mon, 13 Mar 2023 11:18:33 +0000 Subject: [PATCH] Add snapshot test for Center/Middle. --- .../__snapshots__/test_snapshots.ambr | 163 ++++++++++++++++++ .../snapshot_apps/alignment_containers.py | 29 ++++ tests/snapshot_tests/test_snapshots.py | 4 + 3 files changed, 196 insertions(+) create mode 100644 tests/snapshot_tests/snapshot_apps/alignment_containers.py diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr index 4f4413e48..7130b1f5f 100644 --- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr +++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr @@ -1,3 +1,166 @@ +# name: test_alignment_containers + ''' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AlignContainersApp + + + + + + + + + + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ + center + ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ + + + + + + + + + + + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ + middle + ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ + + + + + + ▅▅ + + + + + + + ''' +# --- # name: test_auto_width_input ''' diff --git a/tests/snapshot_tests/snapshot_apps/alignment_containers.py b/tests/snapshot_tests/snapshot_apps/alignment_containers.py new file mode 100644 index 000000000..c419f29e9 --- /dev/null +++ b/tests/snapshot_tests/snapshot_apps/alignment_containers.py @@ -0,0 +1,29 @@ +""" +App to test alignment containers. +""" + +from textual.app import App, ComposeResult +from textual.containers import Center, Middle +from textual.widgets import Button + + +class AlignContainersApp(App[None]): + CSS = """ + Center { + tint: $primary 10%; + } + Middle { + tint: $secondary 10%; + } + """ + + def compose(self) -> ComposeResult: + with Center(): + yield Button.success("center") + with Middle(): + yield Button.error("middle") + + +app = AlignContainersApp() +if __name__ == "__main__": + app.run() diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index c8ecb7d12..47098eb91 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -52,6 +52,10 @@ def test_layout_containers(snap_compare): assert snap_compare(SNAPSHOT_APPS_DIR / "layout_containers.py") +def test_alignment_containers(snap_compare): + assert snap_compare(SNAPSHOT_APPS_DIR / "alignment_containers.py") + + # --- Widgets - rendering and basic interactions --- # Each widget should have a canonical example that is display in the docs. # When adding a new widget, ideally we should also create a snapshot test