Skip to content

Add automation testing for full binary#54

Merged
CSRessel merged 10 commits intofork/acp-with-geminifrom
fork/playwright-for-tui
Nov 22, 2025
Merged

Add automation testing for full binary#54
CSRessel merged 10 commits intofork/acp-with-geminifrom
fork/playwright-for-tui

Conversation

@CSRessel
Copy link
Copy Markdown
Collaborator

Summary

  • Adds PTY-based integration test framework for full binary TUI testing
  • Implements visual regression testing using insta snapshots
  • Provides test coverage for startup, input handling, prompt flow, and cancellation flows
  • Includes comprehensive documentation and Claude skills for PTY testing patterns

Key Features

  • PTY Test Harness: Custom test framework that spawns the actual binary in a pseudo-terminal for realistic testing
  • Visual Regression Tests: Insta snapshot tests capture terminal output for detecting UI regressions
  • Test Coverage: Startup flows, input handling, prompt interactions, and cancellation scenarios
  • Developer Tools: PTY testing skill documentation to guide future test development

Technical Details

  • Intercepts cursor position queries to prevent test hangs
  • Non-blocking PTY reader implementation for reliable test execution
  • Normalizes screen snapshots to handle variable content
  • Supports multiple terminal dimensions for responsive UI testing

Test Plan

  • All existing tests pass
  • New PTY integration tests pass with snapshots
  • Tests run reliably without timeouts or hangs
  • Documentation accurately describes the test framework

CSRessel and others added 10 commits November 20, 2025 15:02
Add comprehensive TUI integration testing infrastructure:
- New tui-integration-tests crate with PTY session management
- Test coverage for startup, prompt flow, input handling, and cancellation
- Enhanced mock-acp-agent with configurable responses and delays
- Support for simulating realistic streaming behavior via env vars

The testing framework uses portable-pty and vt100 parser to drive
the TUI programmatically and verify screen contents, enabling
reliable end-to-end testing of terminal interactions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Crossterm queries cursor position during initialization via ESC[6n control
sequence, but the PTY emulator doesn't automatically respond. This caused
tests to timeout waiting for the response.

Added intercept_control_sequences() to detect cursor position queries in
the PTY output stream and write back ESC[1;1R responses, enabling the TUI
to initialize properly in the test environment.

Updated test expectations to match the initial welcome screen that now
appears, and added snapshot for regression detection.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…imeout hangs

Previously, tests using wait_for_text() would hang indefinitely when the
expected text never appeared, because the PTY reader was in blocking mode.
This caused read() to block forever waiting for data, preventing the timeout
mechanism from executing.

Changes:
- Set PTY master to non-blocking mode using fcntl(O_NONBLOCK) on Unix
- Add helper function set_nonblocking() using libc for low-level fcntl ops
- read() now returns WouldBlock immediately when no data is available
- Timeout checks in wait_for() can now execute, failing tests cleanly after 5s
- Add test_poll_does_not_block_when_no_data to verify non-blocking behavior
- Convert debug logging to conditional (DEBUG_TUI_PTY env var)
- Uncomment and fix previously disabled tests in startup.rs
- Update documentation with PTY non-blocking details and debugging info

Dependencies added (Unix only):
- nix = "0.27" (features: fs)
- libc = "0.2"

The fix ensures test timeouts work correctly, with tests failing cleanly
rather than hanging indefinitely when conditions are not met.
🤖 Generated with [Nori](https://nori.ai)

Co-Authored-By: Nori <noreply@tilework.tech>
…ession testing

Adds snapshot assertions to 4 startup tests to capture final screen states:
- startup_shows_welcome: Welcome screen with logo and /tmp/ path
- startup_welcome_dimensions_40x120: Welcome screen at 40x120 dimensions
- runs_in_temp_directory: Verification of /tmp/ directory usage
- trust_screen_skipped: Main prompt without trust screen

Excludes test_poll_does_not_block_when_no_data as it tests timing behavior, not UI.
🤖 Generated with [Nori](https://nori.ai)

Co-Authored-By: Nori <noreply@tilework.tech>
…overage

Move normalize_for_snapshot() and TIMEOUT constant from test modules to library exports
for consistent reuse across all tests. Consolidate streaming/cancellation tests into a
unified streaming.rs module.

Add Drop trait implementation to TuiSession that prints screen state on panic, improving
debugging of PTY timing issues. Expand snapshot testing coverage to input handling
scenarios (ctrl-c, typing, arrow navigation).

Add 100ms sleep delays after PTY input operations in tests to prevent race conditions
between sending input and TUI processing. Update documentation to reflect new exported
utilities, debugging aids, and PTY timing patterns.
@CSRessel
Copy link
Copy Markdown
Collaborator Author

1st in stack

@CSRessel CSRessel merged commit e665335 into fork/acp-with-gemini Nov 22, 2025
5 of 9 checks passed
@CSRessel CSRessel deleted the fork/playwright-for-tui branch November 22, 2025 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant