Skip to content

Commit

Permalink
Add regression tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigogiraoserrao committed Jan 15, 2024
1 parent 044fbdb commit 052f81b
Show file tree
Hide file tree
Showing 8 changed files with 1,399 additions and 0 deletions.
978 changes: 978 additions & 0 deletions tests/snapshot_tests/__snapshots__/test_snapshots.ambr

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions tests/snapshot_tests/snapshot_apps/dimensions_height.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"""
Regression test for https://github.com/Textualize/textual/issues/3721
and follow-up issues that were discovered.
"""

from textual.app import App, ComposeResult
from textual.containers import Horizontal, Vertical
from textual.widgets import Input, TextArea, Label, Button, DataTable


class DimensionsApp(App[None]):
CSS = """
Vertical {
width: auto;
}
.ruler {
text-style: reverse;
height: 24;
width: 1;
}
.target {
width: 3;
height: 50%;
border: solid red;
box-sizing: border-box;
}
Input.target, Button.target, TextArea.target, DataTable.target {
width: 12;
min-width: 0; # "Unset" Button's min-width.
}
.padding {
padding: 1 0;
}
.margin {
margin: 2 0;
}
"""

def compose(self) -> ComposeResult:
with Horizontal():
yield Label("1234567890" * 3, classes="ruler")
with Vertical():
yield Label("123456789012", classes="target")
yield Label("123456789012", classes="target")
with Vertical():
yield Label("123456789012", classes="target padding")
yield Label("123456789012", classes="target padding")
yield Label("1234567890" * 3, classes="ruler")
with Vertical():
yield Label("123456789012", classes="target margin")
yield Label("123456789012", classes="target")
with Vertical():
yield Label("123456789012", classes="target padding margin")
yield Label("123456789012", classes="target padding")
yield Label("1234567890" * 3, classes="ruler")
with Vertical():
yield Input(classes="target")
yield Button(classes="target")
with Vertical():
yield TextArea(classes="target")
yield DataTable(classes="target")


if __name__ == "__main__":
DimensionsApp().run()
71 changes: 71 additions & 0 deletions tests/snapshot_tests/snapshot_apps/dimensions_max_height.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""
Regression test for https://github.com/Textualize/textual/issues/3721
and follow-up issues that were discovered.
"""

from textual.app import App, ComposeResult
from textual.containers import Horizontal, Vertical
from textual.widgets import Input, TextArea, Label, Button, DataTable


class DimensionsApp(App[None]):
CSS = """
Vertical {
width: auto;
}
.ruler {
text-style: reverse;
height: 24;
width: 1;
}
.target {
width: 3;
height: 24;
max-height: 50%;
border: solid red;
box-sizing: border-box;
}
Input.target, Button.target, TextArea.target, DataTable.target {
width: 12;
min-width: 0; # "Unset" Button's min-width.
}
.padding {
padding: 1 0;
}
.margin {
margin: 2 0;
}
"""

def compose(self) -> ComposeResult:
with Horizontal():
yield Label("1234567890" * 3, classes="ruler")
with Vertical():
yield Label("123456789012", classes="target")
yield Label("123456789012", classes="target")
with Vertical():
yield Label("123456789012", classes="target padding")
yield Label("123456789012", classes="target padding")
yield Label("1234567890" * 3, classes="ruler")
with Vertical():
yield Label("123456789012", classes="target margin")
yield Label("123456789012", classes="target")
with Vertical():
yield Label("123456789012", classes="target padding margin")
yield Label("123456789012", classes="target padding")
yield Label("1234567890" * 3, classes="ruler")
with Vertical():
yield Input(classes="target")
yield Button(classes="target")
with Vertical():
yield TextArea(classes="target")
yield DataTable(classes="target")


if __name__ == "__main__":
DimensionsApp().run()
62 changes: 62 additions & 0 deletions tests/snapshot_tests/snapshot_apps/dimensions_max_width.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""
Regression test for https://github.com/Textualize/textual/issues/3721
and follow-up issues that were discovered.
"""

from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Input, TextArea, Label, Button, DataTable


class DimensionsApp(App[None]):
CSS = """
Horizontal {
height: auto;
}
.ruler {
text-style: reverse;
}
.target {
width: 80;
max-width: 50%;
height: 3;
border: solid red;
box-sizing: border-box;
}
.padding {
padding: 0 6;
}
.margin {
margin: 0 10;
}
"""

def compose(self) -> ComposeResult:
yield Label("1234567890" * 8, classes="ruler")
with Horizontal():
yield Label("1234567890" * 4, classes="target")
yield Label("1234567890" * 4, classes="target")
with Horizontal():
yield Label("1234567890" * 4, classes="target padding")
yield Label("1234567890" * 4, classes="target padding")
yield Label("1234567890" * 8, classes="ruler")
with Horizontal():
yield Label("1234567890" * 4, classes="target margin")
yield Label("1234567890" * 4, classes="target")
with Horizontal():
yield Label("1234567890" * 4, classes="target padding margin")
yield Label("1234567890" * 4, classes="target padding")
with Horizontal():
yield Input(classes="target")
yield Button(classes="target")
with Horizontal():
yield TextArea(classes="target")
yield DataTable(classes="target")


if __name__ == "__main__":
DimensionsApp().run()
71 changes: 71 additions & 0 deletions tests/snapshot_tests/snapshot_apps/dimensions_min_height.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""
Regression test for https://github.com/Textualize/textual/issues/3721
and follow-up issues that were discovered.
"""

from textual.app import App, ComposeResult
from textual.containers import Horizontal, Vertical
from textual.widgets import Input, TextArea, Label, Button, DataTable


class DimensionsApp(App[None]):
CSS = """
Vertical {
width: auto;
}
.ruler {
text-style: reverse;
height: 24;
width: 1;
}
.target {
width: 3;
height: 0;
min-height: 50%;
border: solid red;
box-sizing: border-box;
}
Input.target, Button.target, TextArea.target, DataTable.target {
width: 12;
min-width: 0; # "Unset" Button's min-width.
}
.padding {
padding: 1 0;
}
.margin {
margin: 2 0;
}
"""

def compose(self) -> ComposeResult:
with Horizontal():
yield Label("1234567890" * 3, classes="ruler")
with Vertical():
yield Label("123456789012", classes="target")
yield Label("123456789012", classes="target")
with Vertical():
yield Label("123456789012", classes="target padding")
yield Label("123456789012", classes="target padding")
yield Label("1234567890" * 3, classes="ruler")
with Vertical():
yield Label("123456789012", classes="target margin")
yield Label("123456789012", classes="target")
with Vertical():
yield Label("123456789012", classes="target padding margin")
yield Label("123456789012", classes="target padding")
yield Label("1234567890" * 3, classes="ruler")
with Vertical():
yield Input(classes="target")
yield Button(classes="target")
with Vertical():
yield TextArea(classes="target")
yield DataTable(classes="target")


if __name__ == "__main__":
DimensionsApp().run()
62 changes: 62 additions & 0 deletions tests/snapshot_tests/snapshot_apps/dimensions_min_width.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""
Regression test for https://github.com/Textualize/textual/issues/3721
and follow-up issues that were discovered.
"""

from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Input, TextArea, Label, Button, DataTable


class DimensionsApp(App[None]):
CSS = """
Horizontal {
height: auto;
}
.ruler {
text-style: reverse;
}
.target {
width: 0;
min-width: 50%;
height: 3;
border: solid red;
box-sizing: border-box;
}
.padding {
padding: 0 6;
}
.margin {
margin: 0 10;
}
"""

def compose(self) -> ComposeResult:
yield Label("1234567890" * 8, classes="ruler")
with Horizontal():
yield Label("1234567890" * 4, classes="target")
yield Label("1234567890" * 4, classes="target")
with Horizontal():
yield Label("1234567890" * 4, classes="target padding")
yield Label("1234567890" * 4, classes="target padding")
yield Label("1234567890" * 8, classes="ruler")
with Horizontal():
yield Label("1234567890" * 4, classes="target margin")
yield Label("1234567890" * 4, classes="target")
with Horizontal():
yield Label("1234567890" * 4, classes="target padding margin")
yield Label("1234567890" * 4, classes="target padding")
with Horizontal():
yield Input(classes="target")
yield Button(classes="target")
with Horizontal():
yield TextArea(classes="target")
yield DataTable(classes="target")


if __name__ == "__main__":
DimensionsApp().run()
Loading

0 comments on commit 052f81b

Please sign in to comment.