Snapshot testing data table, checkbox interactions

This commit is contained in:
Darren Burns
2022-10-24 12:14:52 +01:00
parent 8a92cc470b
commit c6418e5e20
4 changed files with 243 additions and 65 deletions

View File

@@ -11,13 +11,13 @@ The example below populates a table with CSV data.
=== "Output" === "Output"
```{.textual path="docs/examples/widgets/table.py"} ```{.textual path="docs/examples/widgets/data_table.py"}
``` ```
=== "table.py" === "data_table.py"
```python ```python
--8<-- "docs/examples/widgets/table.py" --8<-- "docs/examples/widgets/data_table.py"
``` ```

File diff suppressed because one or more lines are too long

View File

@@ -33,12 +33,27 @@ def test_dock_layout_sidebar(snap_compare):
assert snap_compare("docs/examples/guide/layout/dock_layout2_sidebar.py") 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): def test_checkboxes(snap_compare):
"""Tests checkboxes but also acts a regression test for using """Tests checkboxes but also acts a regression test for using
width: auto in a Horizontal layout context.""" 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): 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"]) 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 --- # --- CSS properties ---
# We have a canonical example for each CSS property that is shown in their docs. # 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. # If any of these change, something has likely broken, so snapshot each of them.