tui-td 0.2.11 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +47 -1
- data/README.md +31 -9
- data/lib/tui_td/ansi_parser.rb +3 -727
- data/lib/tui_td/ansi_utils.rb +3 -73
- data/lib/tui_td/cli.rb +51 -0
- data/lib/tui_td/driver.rb +74 -17
- data/lib/tui_td/matchers.rb +131 -25
- data/lib/tui_td/mcp/server.rb +71 -6
- data/lib/tui_td/selector.rb +31 -0
- data/lib/tui_td/state.rb +2 -123
- data/lib/tui_td/test_runner.rb +101 -19
- data/lib/tui_td/version.rb +1 -1
- data/lib/tui_td.rb +1 -0
- metadata +16 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 88f553e060b5f2836421a48eadf8aa6b0341974e7081f7e9dd98e024b0665a59
|
|
4
|
+
data.tar.gz: ddd0b1fd0f0666382b8f8d1fb9cb8b170cef2829299685da4a56d51d4cfc7945
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5d478553f03b514f380d46c6aff519d3f6aec2f44dcd790ab51a162eca9cba8e73b136f79ebdf72cecaa7f66c9939fcb028edf80c1d904c00efb026ec0b92fa2
|
|
7
|
+
data.tar.gz: d16aef5de09e4be72370113d5ec06ecebc6a3ec2ceda55837bf61ade4953906ec500513f24d3eef0127a8aa6a2919339660b922615f26c4b01848c496c6ff359
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 0.2.13
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Auto-wait mechanisms: `Driver#wait_for(predicate)` with adaptive polling (10ms → 100ms),
|
|
8
|
+
auto-wait on RSpec matchers (3s timeout when given a Driver), auto-wait on JSON test
|
|
9
|
+
assertions (2s per-check timeout)
|
|
10
|
+
- Semantic selectors: `Element` struct and `Selector` class with heuristic role detection
|
|
11
|
+
for buttons, checkboxes, dialogs, statusbars, and progress bars
|
|
12
|
+
- RSpec matchers: `have_button`, `have_dialog`, `have_checkbox`, `have_role`
|
|
13
|
+
- JSON test steps: `assert_button`, `assert_dialog`, `assert_checkbox`, `assert_role`
|
|
14
|
+
- `within` scoping for filtering elements by bounding box
|
|
15
|
+
- `poll_interval` parameter on Driver for configurable polling speed
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- `wait_for_stable` uses buffer-size tracking instead of full grid parse for performance
|
|
20
|
+
- Output buffer capped at 10 MB (ring buffer) to prevent unbounded memory growth
|
|
21
|
+
- Delegate `Selector` and `Element` to tans-parser 0.1.1
|
|
22
|
+
|
|
23
|
+
### Documentation
|
|
24
|
+
|
|
25
|
+
- Add CONTRIBUTING.md with development setup, code quality, and PR workflow
|
|
26
|
+
- Add docs/quick_start.md with 2-minute getting-started tutorial
|
|
27
|
+
- Add docs/faq.md covering 8 common troubleshooting topics
|
|
28
|
+
- Add whiptail dialog example (`examples/whiptail_dialog.json`)
|
|
29
|
+
- Update CLI help (`tui-td help test`, `tui-td help rspec`) with new steps and matchers
|
|
30
|
+
|
|
31
|
+
## 0.2.12
|
|
32
|
+
|
|
33
|
+
### Security
|
|
34
|
+
|
|
35
|
+
- Command injection prevention: use Shellwords.shellsplit + array form of PTY.spawn
|
|
36
|
+
- Environment variable sanitization: block dangerous vars (PATH, LD_PRELOAD, etc.)
|
|
37
|
+
- Path traversal prevention: validate output paths for screenshot/HTML
|
|
38
|
+
- ReDoS prevention: add regex timeout in find_text
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
- ANSI erase operations (ED/EL) now reset all cell attributes (fg, bg, bold, italic,
|
|
43
|
+
underline), not just the character — colors and styles no longer leak across lines
|
|
44
|
+
|
|
45
|
+
### Architecture
|
|
46
|
+
|
|
47
|
+
- Extract ANSIParser, ANSIUtils, and State into standalone tans-parser gem (v0.1.0)
|
|
48
|
+
- Add tans-parser as a runtime dependency (~>0.1)
|
|
49
|
+
- Replace extracted unit tests with forwarder integration smoke tests
|
|
4
50
|
|
|
5
51
|
## 0.2.11
|
|
6
52
|
|
data/README.md
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
# TUI Test Drive
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://rubygems.org/gems/tui-td)
|
|
4
|
+
[](LICENSE.txt)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
Testing framework for Terminal User Interfaces (TUIs). Start a TUI in a PTY, send input, analyze output — as structured JSON, plain text, PNG screenshots, or HTML renders. Includes an MCP server for AI-driven testing, auto-wait RSpec matchers, and semantic selectors.
|
|
7
|
+
|
|
8
|
+
> New to tui-td? Jump to [Quick Start](docs/quick_start.md).
|
|
9
|
+
|
|
10
|
+
**What tui-td gives you:**
|
|
11
|
+
|
|
12
|
+
1. **Start any TUI** in a virtual terminal (PTY) with `Driver` or JSON test plans
|
|
13
|
+
2. **Auto-wait assertions** — matchers automatically retry until the condition is met or timeout
|
|
14
|
+
3. **Semantic selectors** — `get_by_role(:button)`, `get_by_role(:dialog)`, `within { }` scoping
|
|
15
|
+
4. **Multiple output formats** — structured JSON, plain text, PNG screenshots, HTML renders
|
|
16
|
+
5. **JSON test runner** — language-agnostic, 15+ step types, CI-friendly
|
|
17
|
+
6. **RSpec matchers** — `have_text`, `have_fg`, `have_button`, `have_dialog`, and more
|
|
18
|
+
7. **MCP server** — AI agents can drive TUIs via JSON-RPC over stdio
|
|
19
|
+
8. **Pure Ruby rendering** — embedded Spleen font + 2766 Unifont glyphs, no native deps required
|
|
11
20
|
|
|
12
21
|
## Installation
|
|
13
22
|
|
|
@@ -83,6 +92,7 @@ Examples:
|
|
|
83
92
|
Interactive commands (drive mode):
|
|
84
93
|
state Show terminal state as pretty JSON
|
|
85
94
|
raw Show raw ANSI output
|
|
95
|
+
elements Show detected UI elements (buttons, dialogs, etc.)
|
|
86
96
|
key <name> Send keystroke (enter, tab, escape, up, down, left, right,
|
|
87
97
|
backspace, ctrl_c, ctrl_d)
|
|
88
98
|
<text> Send text to the TUI
|
|
@@ -273,6 +283,10 @@ tui-td test examples/echo_test.json
|
|
|
273
283
|
| `assert_exit` | `N` | Assert the process exit code equals N |
|
|
274
284
|
| `screenshot` | `"path"` | Save PNG screenshot |
|
|
275
285
|
| `html` | `"path"` | Save HTML render for browser viewing |
|
|
286
|
+
| `assert_button` | `"text"` | Assert a button with given text is visible (`[ OK ]`, `(Cancel)`, `<Submit>`) |
|
|
287
|
+
| `assert_dialog` | — | Assert a dialog (box-drawing region) is visible |
|
|
288
|
+
| `assert_checkbox` | `"label", "checked": true` | Assert a checkbox with given label (and optionally checked state) |
|
|
289
|
+
| `assert_role` | `":button", "text": "OK"` | Generic role assertion (`:button`, `:checkbox`, `:dialog`, `:statusbar`, `:progress`) |
|
|
276
290
|
| `close` | — | Close the TUI |
|
|
277
291
|
|
|
278
292
|
Example with `html` step for before/after snapshots:
|
|
@@ -347,6 +361,10 @@ end
|
|
|
347
361
|
| `have_fg("color").at(row, col)` | Assert foreground color at position |
|
|
348
362
|
| `have_bg("color").at(row, col)` | Assert background color at position |
|
|
349
363
|
| `have_style.at(row, col).with(bold: true, ...)` | Assert cell style |
|
|
364
|
+
| `have_button("OK")` | Assert a button with given text is visible |
|
|
365
|
+
| `have_dialog` | Assert a dialog (box-drawing region) is visible |
|
|
366
|
+
| `have_checkbox("Label").checked` | Assert a checkbox with given label (chain `.checked`) |
|
|
367
|
+
| `have_role(:button, text: "OK")` | Generic role assertion with optional text filter |
|
|
350
368
|
| `have_exit_status(N)` | Assert the driver process exit status equals N |
|
|
351
369
|
|
|
352
370
|
## MCP Server — AI Integration
|
|
@@ -373,6 +391,7 @@ tui-td serve
|
|
|
373
391
|
| `tui_wait_for_exit` | Wait until the TUI process exits. Returns exit status. |
|
|
374
392
|
| `tui_exit_status` | Get the exit status code (nil if still running). |
|
|
375
393
|
| `tui_find_text` | Search for text or regex in terminal state. Returns positions of all matches. |
|
|
394
|
+
| `tui_find_elements` | Detect UI elements (buttons, checkboxes, dialogs, etc.) with optional role/text filters. |
|
|
376
395
|
| `tui_close` | Close the TUI and clean up. |
|
|
377
396
|
|
|
378
397
|
### MCP configuration
|
|
@@ -419,10 +438,13 @@ Add to your MCP client configuration:
|
|
|
419
438
|
// 8. Search for text in the terminal
|
|
420
439
|
{"method": "tools/call", "params": {"name": "tui_find_text", "arguments": {"pattern": "error|fail"}}}
|
|
421
440
|
|
|
422
|
-
// 9.
|
|
441
|
+
// 9. Find UI elements by role
|
|
442
|
+
{"method": "tools/call", "params": {"name": "tui_find_elements", "arguments": {"role": "button"}}}
|
|
443
|
+
|
|
444
|
+
// 10. Check exit status (or wait for exit)
|
|
423
445
|
{"method": "tools/call", "params": {"name": "tui_exit_status", "arguments": {}}}
|
|
424
446
|
|
|
425
|
-
//
|
|
447
|
+
// 11. Clean up
|
|
426
448
|
{"method": "tools/call", "params": {"name": "tui_close", "arguments": {}}}
|
|
427
449
|
```
|
|
428
450
|
|