diff --git a/docs/examples/widgets/footer.py b/docs/examples/widgets/footer.py index 47d9c9aa6..85406b4e9 100644 --- a/docs/examples/widgets/footer.py +++ b/docs/examples/widgets/footer.py @@ -4,7 +4,16 @@ from textual.widgets import Footer class FooterApp(App): - BINDINGS = [Binding(key="q", action="quit", description="Quit the app")] + BINDINGS = [ + Binding(key="q", action="quit", description="Quit the app"), + Binding( + key="question_mark", + action="help", + description="Show help screen", + key_display="?", + ), + Binding(key="j", action="down", description="Scroll down", show=False), + ] def compose(self) -> ComposeResult: yield Footer() diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr index e4bc44f84..1c5ed27e0 100644 --- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr +++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr @@ -4464,133 +4464,134 @@ font-weight: 700; } - .terminal-2487729631-matrix { + .terminal-133545376-matrix { font-family: Fira Code, monospace; font-size: 20px; line-height: 24.4px; font-variant-east-asian: full-width; } - .terminal-2487729631-title { + .terminal-133545376-title { font-size: 18px; font-weight: bold; font-family: arial; } - .terminal-2487729631-r1 { fill: #dde6ed;font-weight: bold } - .terminal-2487729631-r2 { fill: #e1e1e1 } - .terminal-2487729631-r3 { fill: #c5c8c6 } - .terminal-2487729631-r4 { fill: #211505 } + .terminal-133545376-r1 { fill: #dde6ed;font-weight: bold } + .terminal-133545376-r2 { fill: #e1e1e1 } + .terminal-133545376-r3 { fill: #c5c8c6 } + .terminal-133545376-r4 { fill: #e7e5e2 } + .terminal-133545376-r5 { fill: #211505 } - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - TableApp + TableApp - - - -  lane  swimmer               country        time   -  4     Joseph Schooling      Singapore      50.39  -  2     Michael Phelps        United States  51.14  -  5     Chad le Clos          South Africa   51.14  -  6     László Cseh           Hungary        51.14  -  3     Li Zhuhao             China          51.26  -  8     Mehdy Metella         France         51.58  -  7     Tom Shields           United States  51.73  -  1     Aleksandr Sadovnikov  Russia         51.84  - - - - - - - - - - - - - - + + + +  lane  swimmer               country        time   +  4     Joseph Schooling      Singapore      50.39  +  2     Michael Phelps        United States  51.14  +  5     Chad le Clos          South Africa   51.14  +  6     László Cseh           Hungary        51.14  +  3     Li Zhuhao             China          51.26  +  8     Mehdy Metella         France         51.58  +  7     Tom Shields           United States  51.73  +  1     Aleksandr Sadovnikov  Russia         51.84  + + + + + + + + + + + + + + @@ -4755,6 +4756,163 @@ ''' # --- +# name: test_footer_render + ''' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + FooterApp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +  Q  Quit the app  ?  Show help screen  + + + + + ''' +# --- # name: test_grid_layout_basic ''' diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index c4af6167c..fb66234f1 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -34,6 +34,9 @@ def test_dock_layout_sidebar(snap_compare): # --- 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 +# from these examples which test rendering and simple interactions with it. # before snapshot test: # src/textual/widgets/_checkbox.py 47 47 0% 1-126 @@ -70,7 +73,12 @@ def test_buttons_render(snap_compare): # src/textual/widgets/_data_table.py 312 312 0% # src/textual/widgets/_data_table.py 312 85 73% def test_datatable_render(snap_compare): - assert snap_compare("docs/examples/widgets/data_table.py") + press = ["tab", "down", "down", "right", "up", "left"] + assert snap_compare("docs/examples/widgets/data_table.py", press=press) + + +def test_footer_render(snap_compare): + assert snap_compare("docs/examples/widgets/footer.py") # --- CSS properties ---