Skip to content

feat: add TUI integration tests#580

Open
aidandaly24 wants to merge 2 commits intoaws:mainfrom
aidandaly24:feat/tui-integ-tests
Open

feat: add TUI integration tests#580
aidandaly24 wants to merge 2 commits intoaws:mainfrom
aidandaly24:feat/tui-integ-tests

Conversation

@aidandaly24
Copy link
Contributor

Summary

  • Adds 27 integration tests across 5 suites verifying the TUI harness against the real AgentCore CLI
  • harness.test.ts (9 tests): core TuiSession functionality — launch, read, sendKeys, close, waitFor, error handling, concurrent sessions
  • navigation.test.ts (8 tests): TUI routing — HomeScreen/HelpScreen rendering, forward/back navigation, exit via Esc/Ctrl+C
  • create-flow.test.ts (3 tests): create wizard — full flow with agent, skip agent, back navigation
  • add-flow.test.ts (4 tests): add resource — navigate to screen, drill into agent wizard, escape back at each level
  • deploy-screen.test.ts (3 tests): deploy screen — navigation, AWS content rendering, escape back
  • All tests use describe.skipIf(!isAvailable) to gracefully skip when node-pty is not installed
  • Updated create wizard test to handle the new Protocol step in the agent creation flow

Test plan

  • npm run test:tui — all 27 tests pass (5 suites, 0 failures)
  • TypeScript typecheck passes
  • ESLint and Prettier pass

27 tests across 5 suites verifying the TUI harness against the real
AgentCore CLI: harness self-tests, navigation flows, create wizard,
add-resource flows, and deploy screen rendering.

Tests use describe.skipIf(!isAvailable) to gracefully skip when
node-pty is not installed. createMinimalProjectDir provides fast
(~10ms) project directory setup without npm install.
@github-actions github-actions bot added the size/l PR size: L label Mar 19, 2026
Hweinstock
Hweinstock previously approved these changes Mar 20, 2026
Copy link
Contributor

@Hweinstock Hweinstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Two small questions, but I don't think either are blocking.


// Type 'add' to filter the command list, then press Enter to select it.
await session.sendKeys('add');
await session.waitFor('add', 3000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 3 seconds feels like a long timeout to load the menu. Is it worth dropping this a bit to try to catch performance regressions, or do you think we risk making the tests flaky?

import { LaunchError, TuiSession, WaitForTimeoutError, isAvailable } from '../../src/tui-harness/index.js';
import { afterEach, describe, expect, it } from 'vitest';

describe.skipIf(!isAvailable)('TuiSession harness self-tests', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, I like the idea of separating these so we can know if a regression is in the framework or the source code itself.

try {
const { isAvailable, unavailableReason } = await import('../../src/tui-harness/lib/availability.js');
if (!isAvailable) {
console.warn(`TUI harness unavailable: ${unavailableReason}. Skipping all TUI tests.`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a risk that our CI could be "green" but actually silently skipping? Is it worth failing if we can't run the tests?

- Drop waitFor timeout for menu filter from 3s to 1.5s to catch
  performance regressions (filter echo should be near-instant)
- Fail hard in CI when TUI harness is unavailable instead of silently
  skipping, preventing false-green CI runs
- Bump create wizard completion timeout from 30s to 60s (CDK
  scaffolding regularly takes >30s under load)
@aidandaly24 aidandaly24 requested a review from a team March 20, 2026 20:36
@github-actions github-actions bot added size/l PR size: L and removed size/l PR size: L labels Mar 20, 2026
Copy link
Contributor

@notgitika notgitika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left 2 nits otherwise lgtm

// (a) HomeScreen renders when no project exists
// ---------------------------------------------------------------------------
it('renders HomeScreen when launched in a directory without a project', async () => {
const bareDir = await mkdtemp(join(tmpdir(), 'tui-nav-bare-'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do realpathSync throughout this file as well like you've done in create-flow.test.ts?

// ---------------------------------------------------------------------------
it('navigates from HomeScreen to CreateScreen on Enter', async () => {
const bareDir = await mkdtemp(join(tmpdir(), 'tui-nav-create-'));
cleanup = () => rm(bareDir, { recursive: true, force: true });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also add a .catch(() => {}) in this file as well? like you have with create-flow.test.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants