diora-web/tui/tests/test_app_smoke.py

31 lines
1 KiB
Python
Raw Normal View History

"""The Textual app starts, lists a library, opens a book and leaves it again."""
import asyncio
from diora_tui.app import DioraTuiApp
from diora_tui.reader_screen import ReaderScreen
def test_open_read_and_leave(epub, tmp_path):
lib = tmp_path / "lib"
lib.mkdir()
path = epub(["<h1>Anfang</h1>" + "".join(f"<p>Absatz {i} " + "wort " * 40 + "</p>" for i in range(60))])
path.rename(lib / path.name)
async def run():
app = DioraTuiApp(lib)
async with app.run_test(size=(100, 30)) as pilot:
await pilot.pause()
await pilot.press("enter")
for _ in range(50):
await pilot.pause(0.1)
if isinstance(app.screen, ReaderScreen):
break
assert isinstance(app.screen, ReaderScreen)
await pilot.pause(0.5)
await pilot.press("j", "j", "j", "n")
await pilot.press("escape")
await pilot.pause()
assert not isinstance(app.screen, ReaderScreen)
asyncio.run(run())