Test error dialog

It's pretty ridiculous in the expanded state, but better to show it.
Also, the button text isn't switching to "Hide Details".
This commit is contained in:
Isaiah Odhner 2023-09-08 22:12:29 -04:00
parent faa9cefe85
commit 628170d213
2 changed files with 723 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING
import pytest import pytest
from textual.pilot import Pilot from textual.pilot import Pilot
@ -18,7 +19,7 @@ LARGEST = (107, 42)
# Prevent flaky tests due to timing issues. # Prevent flaky tests due to timing issues.
Input.cursor_blink = False # type: ignore Input.cursor_blink = False # type: ignore
paint.DOUBLE_CLICK_TIME = 20.0 # seconds; ridiculously high # paint.DOUBLE_CLICK_TIME = 20.0 # seconds; ridiculously high; probably ineffective since paint.py is re-evaluated for each test
@pytest.fixture(params=[ @pytest.fixture(params=[
{"theme": "light", "ascii_only": False}, {"theme": "light", "ascii_only": False},
@ -98,10 +99,27 @@ def test_paint_edit_colors_dialog(snap_compare, each_theme):
def test_paint_expand_canvas_dialog(snap_compare, each_theme): def test_paint_expand_canvas_dialog(snap_compare, each_theme):
async def paste_large_content(pilot: Pilot[None]): async def paste_large_content(pilot: Pilot[None]):
if TYPE_CHECKING:
# Will be a different class at runtime, per test, due to re-evaluating the module.
assert isinstance(pilot.app, paint.PaintApp)
pilot.app.paste("a" * 1000) pilot.app.paste("a" * 1000)
assert snap_compare(PAINT, run_before=paste_large_content, terminal_size=LARGER) assert snap_compare(PAINT, run_before=paste_large_content, terminal_size=LARGER)
def test_paint_error_dialog(snap_compare, each_theme):
async def show_error(pilot: Pilot[None]):
if TYPE_CHECKING:
# Will be a different class at runtime, per test, due to re-evaluating the module.
assert isinstance(pilot.app, paint.PaintApp)
pilot.app.message_box("EMIT", "Error Message Itself Test", "ok", error=Exception("Error Message Itself Test"))
assert pilot.app.query_one("MessageBox")
await pilot.pause(1.0)
assert pilot.app.query_one("MessageBox .details_button")
# pilot.app.query_one("MessageBox .details_button", Button).press()
await pilot.click("MessageBox .details_button")
assert snap_compare(PAINT, run_before=show_error)
def test_gallery_app(snap_compare): def test_gallery_app(snap_compare):
assert snap_compare(GALLERY) assert snap_compare(GALLERY)