diff --git a/docs/examples/widgets/table.py b/docs/examples/widgets/data_table.py similarity index 100% rename from docs/examples/widgets/table.py rename to docs/examples/widgets/data_table.py diff --git a/docs/widgets/data_table.md b/docs/widgets/data_table.md index ce7f25bf5..7d5558a95 100644 --- a/docs/widgets/data_table.md +++ b/docs/widgets/data_table.md @@ -11,13 +11,13 @@ The example below populates a table with CSV data. === "Output" - ```{.textual path="docs/examples/widgets/table.py"} + ```{.textual path="docs/examples/widgets/data_table.py"} ``` -=== "table.py" +=== "data_table.py" ```python - --8<-- "docs/examples/widgets/table.py" + --8<-- "docs/examples/widgets/data_table.py" ``` diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr index e43445bf5..e4bc44f84 100644 --- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr +++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr @@ -207,136 +207,136 @@ font-weight: 700; } - .terminal-900458690-matrix { + .terminal-1548740802-matrix { font-family: Fira Code, monospace; font-size: 20px; line-height: 24.4px; font-variant-east-asian: full-width; } - .terminal-900458690-title { + .terminal-1548740802-title { font-size: 18px; font-weight: bold; font-family: arial; } - .terminal-900458690-r1 { fill: #e1e1e1 } - .terminal-900458690-r2 { fill: #c5c8c6 } - .terminal-900458690-r3 { fill: #e1e1e1;font-weight: bold } - .terminal-900458690-r4 { fill: #1e1e1e } - .terminal-900458690-r5 { fill: #e2e3e3 } - .terminal-900458690-r6 { fill: #0178d4 } - .terminal-900458690-r7 { fill: #e3e8e8 } + .terminal-1548740802-r1 { fill: #e1e1e1 } + .terminal-1548740802-r2 { fill: #c5c8c6 } + .terminal-1548740802-r3 { fill: #e1e1e1;font-weight: bold } + .terminal-1548740802-r4 { fill: #1e1e1e } + .terminal-1548740802-r5 { fill: #0178d4 } + .terminal-1548740802-r6 { fill: #e2e3e3 } + .terminal-1548740802-r7 { fill: #e3e8e8 } - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - CheckboxApp + CheckboxApp - - - - - - - - Example checkboxes - - - ▔▔▔▔▔▔▔▔ - off:      - ▁▁▁▁▁▁▁▁ - ▔▔▔▔▔▔▔▔ - on:       - ▁▁▁▁▁▁▁▁ - ▔▔▔▔▔▔▔▔ - focused:  - ▁▁▁▁▁▁▁▁ - ▔▔▔▔▔▔▔▔ - custom:   - ▁▁▁▁▁▁▁▁ - - - - + + + + + + + + Example checkboxes + + + ▔▔▔▔▔▔▔▔ + off:      + ▁▁▁▁▁▁▁▁ + ▔▔▔▔▔▔▔▔ + on:       + ▁▁▁▁▁▁▁▁ + ▔▔▔▔▔▔▔▔ + focused:  + ▁▁▁▁▁▁▁▁ + ▔▔▔▔▔▔▔▔ + custom:   + ▁▁▁▁▁▁▁▁ + + + + @@ -4441,6 +4441,163 @@ ''' # --- +# name: test_datatable_render + ''' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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  + + + + + + + + + + + + + + + + + + + + ''' +# --- # name: test_dock_layout_sidebar ''' diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index adb8743d3..c4af6167c 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -33,12 +33,27 @@ def test_dock_layout_sidebar(snap_compare): assert snap_compare("docs/examples/guide/layout/dock_layout2_sidebar.py") -# --- Interacting with widgets --- +# --- Widgets - rendering and basic interactions --- + +# before snapshot test: +# src/textual/widgets/_checkbox.py 47 47 0% 1-126 +# before testing presses in snapshot test: +# src/textual/widgets/_checkbox.py 47 11 77% 83-88, 110, 113, 118, 124-126 +# after testing presses in snapshot test: +# src/textual/widgets/_checkbox.py 47 2 96% 87, 110 def test_checkboxes(snap_compare): """Tests checkboxes but also acts a regression test for using width: auto in a Horizontal layout context.""" - assert snap_compare("docs/examples/widgets/checkbox.py") + press = [ + "shift+tab", + "enter", # toggle off + "shift+tab", + "wait:20", + "enter", # toggle on + "wait:20", + ] + assert snap_compare("docs/examples/widgets/checkbox.py", press=press) def test_input_and_focus(snap_compare): @@ -52,6 +67,12 @@ def test_buttons_render(snap_compare): assert snap_compare("docs/examples/widgets/button.py", press=["tab"]) +# 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") + + # --- CSS properties --- # We have a canonical example for each CSS property that is shown in their docs. # If any of these change, something has likely broken, so snapshot each of them.