Commit Graph

51 Commits

Author SHA1 Message Date
Isaiah Odhner
70284d6f94 Tweak comment about event recording 2023-09-11 17:59:56 -04:00
Isaiah Odhner
792d5c8294 Ignore duplicate events in a much less hacky way
Immediately reduce tech debt.
2023-09-11 17:59:56 -04:00
Isaiah Odhner
ea07b54315 Ignore every other event
It's the simplest thing that could possibly work.
And it does, as a matter of fact.
2023-09-11 17:59:56 -04:00
Isaiah Odhner
a10b9eac11 Allow Ctrl+Z also while replaying in test recorder 2023-09-11 17:59:56 -04:00
Isaiah Odhner
c395f4e8f3 Exit from test recorder on Ctrl+C after test saved 2023-09-11 17:59:55 -04:00
Isaiah Odhner
a2e1b6cfd8 Record events before they're handled normally
This might fix a race condition that lead to a `query` raising `NoMatches`, but this is just theoretical.
Regardless, this seems like the way to go.
Generating the selectors to match the clicked widget needs a view of the DOM before the widget is removed from it (or reordered in the DOM etc.)
2023-09-11 17:59:55 -04:00
Isaiah Odhner
61c9b4e49e Fix undo seemingly not working
Stop recording mouse events that aren't even handled yet,
and which should be undone in batches when they are recorded.
2023-09-11 17:59:54 -04:00
Isaiah Odhner
941b2b52e6 Auto-save replay code for debugging purposes 2023-09-11 17:57:01 -04:00
Isaiah Odhner
43ae6f7365 Add assert for type checker 2023-09-11 17:56:03 -04:00
Isaiah Odhner
26f6bfe8ed Convert test recorder to OOP
Never have I ever been this `self`-conscious...
2023-09-11 17:56:03 -04:00
Isaiah Odhner
c37a123be4 Add module docstring 2023-09-11 17:56:03 -04:00
Isaiah Odhner
bef86c95bc Clean up 2023-09-11 17:56:03 -04:00
Isaiah Odhner
78e86f1bc1 Enable recording key events 2023-09-11 17:56:03 -04:00
Isaiah Odhner
3cebba06ec WIP: handle edge cases 2023-09-11 17:56:03 -04:00
Isaiah Odhner
2fb0dc2467 Good progress on stepwise undo (+gaurd against NoWidget) 2023-09-11 17:56:03 -04:00
Isaiah Odhner
8a2f4d6b72 WIP on stepwise undo app lifecycle
No error... until 30s passes.
WaitForScreenTimeout: Timed out while waiting for widgets to process pending messages.
2023-09-11 17:56:03 -04:00
Isaiah Odhner
74c3c49eb7 WIP on stepwise undo app lifecycle spaghetti code 2023-09-11 17:56:03 -04:00
Isaiah Odhner
961e9a1560 WIP trying to get stepwise undo working (and complicating things) 2023-09-11 17:56:03 -04:00
Isaiah Odhner
8838250e94 WIP on test recorder click offsets 2023-09-11 17:56:03 -04:00
Isaiah Odhner
24b9b9986c WIP on test recorder 2023-09-11 17:56:03 -04:00
Isaiah Odhner
0c43b7ff5a WIP: Make test recorder for Pilot tests 2023-09-11 17:56:03 -04:00
Isaiah Odhner
dedeedb129 Debug Polygon test by running interactively 2023-09-11 17:56:03 -04:00
Isaiah Odhner
86a403eb80 WIP: test polygon tool prematurely closing polygon 2023-09-11 17:56:03 -04:00
Isaiah Odhner
1ae3cbe37b WIP: test polygon tool 2023-09-11 17:56:02 -04:00
Isaiah Odhner
2e89e73f37 Fix About Paint dialog test failing due to version string changes
Make version info static when running in pytest.

I also tried adding in test_snapshots.py:

    import textual_paint
    textual_paint.__version__ = "snapshot test edition 1"

    import textual_paint.__init__ as init
    init.__version__ = "snapshot test edition 2"

which seemed to have no effect.

Since I already have special case logic for __version__ in __init__.py,
I'm reasonably happy with this solution.
2023-09-09 00:19:39 -04:00
Isaiah Odhner
9f12ba7833 Guard against future usage of unique class at runtime 2023-09-08 23:49:52 -04:00
Isaiah Odhner
cc6b0d65c0 Unify import style 2023-09-08 23:47:09 -04:00
Isaiah Odhner
d2300c96a3 Annotate tests with type hints 2023-09-08 23:38:37 -04:00
Isaiah Odhner
ad9ff303f1 Update fixture docstring 2023-09-08 22:53:58 -04:00
Isaiah Odhner
3cc70b6e4d Test About Paint dialog 2023-09-08 22:46:52 -04:00
Isaiah Odhner
ea5ca0c90f Fix flaky test due to pressed style of Show Details button 2023-09-08 22:40:49 -04:00
Isaiah Odhner
c5353f4e7b Test custom zoom dialog 2023-09-08 22:32:53 -04:00
Isaiah Odhner
628170d213 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".
2023-09-08 22:32:53 -04:00
Isaiah Odhner
faa9cefe85 Test expand canvas dialog 2023-09-08 21:40:29 -04:00
Isaiah Odhner
ed679ab721 Accept snapshots for new tests 2023-09-08 21:29:54 -04:00
Isaiah Odhner
1b9cfe51b3 Fix dark mode tests failing to open dialogs
This was kind of mind-boggling, narrowing it down to dark mode,
and then to dark mode *but not CSS*.
I kept narrowing it down, and looked into how dark mode was implemented,
and finally figured this out.
`app.call_later(app.refresh_css)` in `App.watch_dark` causes a timing issue.
2023-09-08 21:29:12 -04:00
Isaiah Odhner
90f52f0655 It's not flaky... it's really the dark mode tests that are failing 2023-09-08 21:21:58 -04:00
Isaiah Odhner
278490f7d5 WIP: Add more tests 2023-09-08 20:03:30 -04:00
Isaiah Odhner
b9822a8290 Fix flaky tests due to cursor blinking 2023-09-08 20:03:17 -04:00
Isaiah Odhner
57ae2e8d44 Clean up 2023-09-08 20:03:17 -04:00
Isaiah Odhner
5a66037592 Create script for extracting SVGs from ambr files 2023-09-08 14:44:56 -04:00
Isaiah Odhner
18c38fd3e0 Merge snapshot results for ASCII-only and Unicode UI tests
I'm basically doing TDD to snapshot testing!
I'm creating tests that don't pass yet, setting up an expectation
that the app match the given screenshots, which is funny in a nice
"improper hierarchy" sort of way, but it's possible because I do
actually have the app rendering how I want, just only in isolation.
If I run the ascii_only tests by themselves, I can get good results
from them, but running them interwoven with default Unicode-using UI
tests doesn't work yet, since the ASCII-only mode permanently changes
how certain widgets render, for the life of the process, so that's
what I'm applying TDD to: making it toggleable at runtime.

I commented out the Unicode tests, and uncommented the ASCII-only tests,
renamed test_snapshots.ambr to test_snapshots_ascii.ambr,
reverted the changes to test_snapshots.ambr to get the Unicode version,
ran my new merge_ambr.py script to join the sets of snapshots,
then replaced test_snapshots.ambr with test_snapshots_merged.ambr
Finally, I uncommented both sets of tests, and I'm ready to do TDD!
2023-09-08 14:44:56 -04:00
Isaiah Odhner
d49c144a96 Create script for merging ambr files 2023-09-08 11:28:14 -04:00
Isaiah Odhner
8a4ca8d380 Fix toggling light/dark mode not affecting file/folder icons in tree
I already fixed my first bug caught by the snapshot testing!
These variables were intended as constants, but were being mutated.
I recall writing it as `prefix = (...).stylize_before(...)` and then
moving it to a new line when I realized it was mutation-style method,
not so much the chaining-style factory that I wanted, but I conceived
of it too much as a stylistic distinction in the moment, looking back.
Mutation style means mutation!

Side note: tests also showed a spurious change of a cursor blinking.
I don't really know whether that's in this changeset or not, because
the workflow involves re-running the tests to update the baseline, and
the nice visual diffs provided in the snapshot report aren't available
when viewing the commit diff.
1. If the SVGs were separate files, I could see the diffs on GitHub
   or in GitHub Desktop, and maybe some other Git clients.
   It would also make it a lot easier to simply view the baselines,
   which is useful in general.
2. It would be nice if built-in components didn't cause spurious diffs,
   including the Input's cursor blinking and the Header's clock ticking.
   I already removed the clock from my gallery app, because it's a sort
   of trivial decision, but Inputs I'll have to reckon with.
2023-09-08 02:31:54 -04:00
Isaiah Odhner
f09f5fbf55 Test light and dark theme variations with a pytest fixture
First I tried setting PYTEST_TEXTUAL_PAINT_ARGS as an environment variable, to be interpreted by args.py, but it turns out args.py is only executed once, not once per test. It's not using subprocesses, only importing and reimporting the app code, and instantiating new App instances, so parts of the code that are at the top level of modules is only evaluated once.

So I found a new strategy, of importing the `args` object in the test fixture and modifying it directly.

I also realized the --ascii-only option permanently modifies Textual's widgets and borders, and my own widgets, for the life of the process, so I'm holding off on that one. I should be able to make --ascii-only mode more dynamic, and could even target it as a runtime toggle, as a goal, since that's basically what I'll need to achieve to get it working for the tests, but thinking of it as a feature is more fun.
2023-09-08 02:18:48 -04:00
Isaiah Odhner
11939b6603 Resize screenshots for some tests 2023-09-07 17:46:48 -04:00
Isaiah Odhner
7d88cbe44f Rename test to match 2023-09-07 17:23:35 -04:00
Isaiah Odhner
f8f2d5ea01 Add snapshot tests for more keyboard-accessible dialogs 2023-09-07 17:22:34 -04:00
Isaiah Odhner
ca23a7712c Remove clock from gallery app
I don't feel like trying to figure out how to spoof the time for snapshot testing.
2023-09-07 16:53:31 -04:00
Isaiah Odhner
bcfddbe2fa Add first baseline for visual regression testing
It works!
2023-09-07 16:41:59 -04:00