Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,10 +769,8 @@ async def scenario() -> None:
run(scenario())


def test_every_theme_paints_every_screen(book: Book, tmp_path, monkeypatch) -> None:
"""The stylesheet is all theme variables; a missing one fails at load.

Also: the choice is saved, and the transparent theme turns on the ANSI
def test_theme_choice_persists_and_transparency(book: Book, tmp_path, monkeypatch) -> None:
"""The choice is saved, and the transparent theme turns on the ANSI
colour that keeps the terminal's background showing through.
"""
monkeypatch.setenv("XDG_STATE_HOME", str(tmp_path))
Expand All @@ -785,18 +783,35 @@ async def scenario() -> None:
await pilot.pause()
assert app.theme == themes.DEFAULT_THEME
assert app.ansi_color is True
for key in ("i", "w", "n", "e", "m", "P"):
await pilot.press(key)
await pilot.pause(0.2)
for name in app.available_themes:
app.theme = name
await pilot.pause()
await pilot.press("escape")
await pilot.press("escape")
await pilot.pause(0.2)
app.theme = "dracula-neutral"
await pilot.pause()
assert app.ansi_color is None

run(scenario())
assert themes.load_theme() == "dracula-neutral"


@pytest.mark.parametrize(
"key",
["", "i", "w", "n", "e", "m", "P"],
ids=["recipes", "inventory", "storage", "nanites", "effects", "multitools", "portals"],
)
def test_every_theme_paints_every_screen(
book: Book, tmp_path, monkeypatch, key: str
) -> None:
"""The stylesheet is all theme variables; a missing one fails at load."""
monkeypatch.setenv("XDG_STATE_HOME", str(tmp_path))

async def scenario() -> None:
app = RecipeApp(book)
app.inv = Inventory(tmp_path / "inv.json")
async with app.run_test(size=(140, 40)) as pilot:
await pilot.pause()
if key:
await pilot.press(key)
await pilot.pause(0.2)
for name in app.available_themes:
app.theme = name
await pilot.pause()

run(scenario())