This commit is contained in:
Will McGugan
2024-11-18 15:54:12 +00:00
parent 3addcdbf03
commit 2a1f74e699

39
tests/test_compositor.py Normal file
View File

@@ -0,0 +1,39 @@
from textual.app import App, ComposeResult
from textual.containers import Container
from textual.widgets import Static
async def test_compositor_scroll_placements():
"""Regression test for https://github.com/Textualize/textual/issues/5249"""
class ScrollApp(App):
CSS = """
Screen {
overflow: scroll;
}
Container {
width: 200vw;
}
#hello {
width: 20;
height: 10;
offset: 50 10;
background: blue;
color: white;
}
"""
def compose(self) -> ComposeResult:
with Container():
yield Static("Hello", id="hello")
def on_mount(self) -> None:
self.query_one("Screen").scroll_to(20, 0, animate=False)
app = ScrollApp()
async with app.run_test() as pilot:
await pilot.pause()
static = app.query_one("#hello")
widgets = app.screen._compositor.visible_widgets
# The static wasn't scrolled out of view, and should be visible
assert static in widgets