From 628170d213c7f8dded9d48b166bacc3537375e63 Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Fri, 8 Sep 2023 22:12:29 -0400 Subject: [PATCH] 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". --- tests/__snapshots__/test_snapshots.ambr | 704 ++++++++++++++++++++++++ tests/test_snapshots.py | 20 +- 2 files changed, 723 insertions(+), 1 deletion(-) diff --git a/tests/__snapshots__/test_snapshots.ambr b/tests/__snapshots__/test_snapshots.ambr index 79deb43..5b84c89 100644 --- a/tests/__snapshots__/test_snapshots.ambr +++ b/tests/__snapshots__/test_snapshots.ambr @@ -2998,6 +2998,710 @@ ''' # --- +# name: test_paint_error_dialog[dark_ascii] + ''' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Paint + + + + + + + + + + \|// \ + /   \ + FileEditV/  !  \Show Details + (_______)______________ + Exception: Error Message Itself  + '::.::Test + ____________ + + /7H? + ____________ + +  P,O + ____________ + + c==-E)= + + [] + []_______________ + [] + [_______]_______________ + + + For Help, cli + + + + + + ''' +# --- +# name: test_paint_error_dialog[dark_unicode] + ''' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Paint + + + + + + + + + + \|/◢█◣ +  ⬮ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔ + FileEditV  •  Show Details + 🮃🮃🮃🮃🮃🮃🮃🮃🮃▁▁▁▁▁▁▁▁▁▁▁▁▁▁ + ▔▔▔▔▔▔▔▔▔▔▔▔Exception: Error Message Itself  + Test + ▁▁▁▁▁▁▁▁▁▁▁▁ + ▔▔▔▔▔▔▔▔▔▔▔▔▁▁ + 🧼🌊 + ▁▁▁▁▁▁▁▁▁▁▁▁ + ▔▔▔▔▔▔▔▔▔▔▔▔ + 💉🔍 + ▁▁▁▁▁▁▁▁▁▁▁▁ + ▔▔▔▔▔▔▔▔▔▔▔▔ + 🖍️🖌️ + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ + ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ + ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ + + ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ + For Help, cli + ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ + + + + + ''' +# --- +# name: test_paint_error_dialog[light_ascii] + ''' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Paint + + + + + + + + + + \|// \ + /   \ + FileEditV/  !  \Show Details + (_______)______________ + Exception: Error Message Itself  + '::.::Test + ____________ + + /7H? + ____________ + +  P,O + ____________ + + c==-E)= + + [] + []_______________ + [] + [_______]_______________ + + + For Help, cli + + + + + + ''' +# --- +# name: test_paint_error_dialog[light_unicode] + ''' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Paint + + + + + + + + + + \|/◢█◣ +  ⬮ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔ + FileEditV  •  Show Details + 🮃🮃🮃🮃🮃🮃🮃🮃🮃▁▁▁▁▁▁▁▁▁▁▁▁▁▁ + ▔▔▔▔▔▔▔▔▔▔▔▔Exception: Error Message Itself  + Test + ▁▁▁▁▁▁▁▁▁▁▁▁ + ▔▔▔▔▔▔▔▔▔▔▔▔▁▁ + 🧼🌊 + ▁▁▁▁▁▁▁▁▁▁▁▁ + ▔▔▔▔▔▔▔▔▔▔▔▔ + 💉🔍 + ▁▁▁▁▁▁▁▁▁▁▁▁ + ▔▔▔▔▔▔▔▔▔▔▔▔ + 🖍️🖌️ + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ + ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ + ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ + + ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ + For Help, cli + ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ + + + + + ''' +# --- # name: test_paint_expand_canvas_dialog[dark_ascii] ''' diff --git a/tests/test_snapshots.py b/tests/test_snapshots.py index bdbc453..f8bc92d 100644 --- a/tests/test_snapshots.py +++ b/tests/test_snapshots.py @@ -1,4 +1,5 @@ from pathlib import Path +from typing import TYPE_CHECKING import pytest from textual.pilot import Pilot @@ -18,7 +19,7 @@ LARGEST = (107, 42) # Prevent flaky tests due to timing issues. 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=[ {"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): 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) 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): assert snap_compare(GALLERY)