Skip to content

test: add unit tests for TUI#320

Merged
jesseturner21 merged 11 commits intomainfrom
gitikavj/tui-unit-tests
Feb 18, 2026
Merged

test: add unit tests for TUI#320
jesseturner21 merged 11 commits intomainfrom
gitikavj/tui-unit-tests

Conversation

@notgitika
Copy link
Contributor

@notgitika notgitika commented Feb 16, 2026

Description

Adds comprehensive unit test coverage for TUI components and hooks using ink-testing-library. This brings the test count from ~874 to 1623 and roughly doubles overall statement coverage (~20% → ~42%).

Components tested (25 files): AwsTargetConfigUI, ConfirmReview, CredentialSourcePrompt, Cursor, DeployStatus, FatalError, FullScreenLogView, Header, HelpText, LogLink, LogPanel, MultiSelectList, NextSteps, Panel, PathInput, PromptScreen, ResourceGraph, Screen, ScreenHeader, ScreenLayout, ScrollableList, ScrollableText, SecretInput, SelectList, SelectScreen, StepIndicator, StepProgress, TextInput, TwoColumn, WizardSelect

Hooks tested (8 files): useExitHandler, useListNavigation, useMultiSelectNavigation, useProject, useRemove, useResponsive, useSchemaDocument, useTextInput

Also includes: guards (project guard), context (LayoutContext), exit-message, and additional lib coverage for ConfigIO, errors, packaging helpers, and platform utils.

All tests use keyboard simulation (stdin.write) to verify interactive behavior (navigation, selection, input masking, scrolling, exit handling).

Type of Change

  • Other (please describe): unit test coverage expansion

Testing

  • I ran npm run test:all
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

@notgitika notgitika requested a review from a team February 16, 2026 17:19
@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 41.29% 2656 / 6432
🔵 Statements 40.74% 2785 / 6835
🔵 Functions 43.55% 571 / 1311
🔵 Branches 46.81% 1765 / 3770
Generated in workflow #408 for commit b415def by the Vitest Coverage Report Action

@notgitika notgitika force-pushed the gitikavj/tui-unit-tests branch from 8d5062a to efc3475 Compare February 16, 2026 22:35
…tiSelectNavigation, useProject, useSchemaDocument, useResponsive; fix tsc and formatting after merge
@notgitika
Copy link
Contributor Author

/strands review (no actions, only review this PR). be concise and clear

@github-actions
Copy link
Contributor

Code Review Summary

Overall Assessment: Strong test coverage expansion with consistent patterns. Tests pass and achieve the stated coverage goals (20% → 42%). A few minor improvements recommended but nothing blocking.


✅ Strengths

  1. Comprehensive Coverage: 50 new test files covering 25 components, 8 hooks, guards, context, and lib utilities
  2. Consistent Patterns: All tests use ink-testing-library, vi.fn() for mocks, and standard vitest assertions
  3. Interactive Testing: Excellent use of stdin.write() to simulate keyboard input (arrows, enter, escape, tab, etc.)
  4. Clean Structure: Tests are well-organized, readable, and focused on single responsibilities
  5. Proper Cleanup: Consistent use of afterEach(() => vi.restoreAllMocks())
  6. Edge Cases: Good coverage of boundary conditions (empty lists, disabled items, wrapping, etc.)

🔍 Suggestions

suggestion: Consider reducing reliance on timing-based delays

  • Many tests use delay(50) or delay(100) which can cause flakiness on slow CI runners
  • Where possible, use event-driven waiting or consider if delays are truly necessary
  • Example: src/cli/tui/components/__tests__/TextInput.test.tsx:57-62

suggestion: Some async operations missing await

  • A few stdin.write() calls aren't followed by await delay() which could cause race conditions
  • Example: src/cli/tui/components/__tests__/PromptScreen.test.tsx:34 - immediate assertion after write
  • Consider adding delays before assertions that depend on input processing

suggestion: Mock organization could be more consistent

  • Some tests use vi.hoisted() (PathInput.test.tsx:6-8)
  • Others define mocks inline (useRemove.test.tsx:14-18)
  • Consider standardizing on one approach for better maintainability

nit: File extension changes

  • useListNavigation.test.ts.tsx and useTextInput.test.ts.tsx
  • While valid (they now render components), worth noting this changes import resolution slightly

nit: Test consolidation

  • config-extended.test.ts and config-io-extended.test.ts were removed
  • Changes consolidated into main test files - verify no test cases were lost

✅ Verified

  • All tests pass (npm run test:unit)
  • Coverage increased as stated (40.74% statements)
  • No new linting errors
  • Follows TESTING.md guidelines (co-located tests, vitest imports, assertions)
  • Tests use recommended patterns from existing codebase

Summary

Excellent work on comprehensive TUI test coverage! The tests are well-written, consistent, and achieve the coverage goals. The timing-dependent delays are the main concern but not blocking. Consider addressing the suggestions in a follow-up if needed.

Copy link
Contributor

@jesseturner21 jesseturner21 left a comment

Choose a reason for hiding this comment

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

LGTM

@jesseturner21 jesseturner21 merged commit aae1a9d into main Feb 18, 2026
15 checks passed
@jesseturner21 jesseturner21 deleted the gitikavj/tui-unit-tests branch February 18, 2026 20:10
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.

2 participants

Comments