"""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(["

Anfang

" + "".join(f"

Absatz {i} " + "wort " * 40 + "

" 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())