Skip to content

Generate command coverage#6

Merged
jpvajda merged 2 commits intomainfrom
cursor/FDPM-45-generate-command-coverage-96ae
Feb 13, 2026
Merged

Generate command coverage#6
jpvajda merged 2 commits intomainfrom
cursor/FDPM-45-generate-command-coverage-96ae

Conversation

@jpvajda
Copy link
Copy Markdown
Owner

@jpvajda jpvajda commented Feb 12, 2026

Achieves 100% unit test coverage for the generate command.

This PR significantly expands the test suite for /src/commands/generate.ts to ensure its reliability and robustness. New tests cover critical scenarios including error handling (missing templates, invalid AI models, API key absence), interactive prompt flows (model selection, cancellation points), various output format conversions (PDF, multiple formats), edge cases (existing output directory, default output name), Anthropic provider functionality, and verification of spinner messages and file operations. This brings generate.ts to 100% line and statement coverage.


Linear Issue: FDPM-45

Open in Cursor Open in Web

- Added 26 new test cases (48 tests total, up from 22)
- Achieved 100% line and statement coverage for generate.ts
- Added coverage configuration with @vitest/coverage-v8
- Tests cover all critical paths:
  * Error cases (cover letter templates not found, invalid models)
  * Model validation (OpenAI and Anthropic)
  * Interactive prompts (model selection for both providers)
  * Format conversions (PDF, multiple formats)
  * Edge cases (output directory exists, empty output name)
  * All cancellation points (document type, templates, formats, provider, model, output name)
  * Anthropic provider happy path
  * Spinner messages verification
  * File operations (readTemplateFile with correct parameters)
  * API key validation (OpenAI and Anthropic)

Coverage results for generate.ts:
- Statement coverage: 100%
- Branch coverage: 98.21%
- Function coverage: 100%
- Line coverage: 100%

Co-authored-by: John Vajda <jpvajda@users.noreply.github.com>
@cursor
Copy link
Copy Markdown

cursor bot commented Feb 12, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@linear
Copy link
Copy Markdown

linear bot commented Feb 12, 2026

FDPM-45 Achieve 100% unit test coverage for the generate command

Task: Achieve 100% unit test coverage for the generate command

Context

  • Project: Downfolio (CLI tool for generating AI-customized resumes/cover letters)
  • File to test: /src/commands/generate.ts
  • Test file: /tests/unit/commands/generate.test.ts
  • Test framework: Vitest with vi mocking

Requirements

  1. Analyze current test coverage gaps
- Run pnpm test -- --coverage to generate a coverage report
- Identify all uncovered lines, branches, and paths in generate.ts
- Document what's missing in your analysis
  1. Add missing unit tests to achieve complete coverage, including:
- Error cases: Cover letter templates not found (line 112-113)
- Model validation: Invalid OpenAI model (lines 223-226) and invalid Anthropic model (lines 227-230)
- Interactive prompts: Model selection for both OpenAI and Anthropic providers (lines 234-270)
- Format conversions: PDF format, and multiple formats together (e.g., ['docx', 'pdf'])
- Edge cases: Output directory already exists, empty output name defaults to job name
- All cancellation points: Document type, template selections, format selection, provider selection, model selection
- Anthropic provider: Full happy path with Anthropic provider and models
- Spinner messages: Verify all spinner.message() calls occur in correct order
- File operations: Verify readTemplateFile is called with correct parameters for both document types
  1. Follow existing test patterns
- Match the coding style and structure of existing tests
- Use the same mocking approach (vi.mock, vi.mocked)
- Follow the describe/it naming conventions already established
- Each test should be focused and test one specific behavior
  1. Ensure quality
- Tests should be deterministic (no flaky tests)
- Use meaningful test descriptions that explain what's being tested and why
- Mock external dependencies properly (fs, clack/prompts, AI, pandoc, etc.)
- Clean up mocks between tests (use beforeEach/afterEach properly)
- Verify tests actually fail when the implementation is broken (test your tests)
  1. Validation
- After adding tests, run pnpm test to ensure all tests pass
- Run coverage report again to confirm 100% coverage of generate.ts
- Provide a summary of what tests were added and final coverage percentage

Deliverables

  1. Updated /tests/unit/commands/generate.test.ts with new test cases
  2. Coverage report showing 100% coverage for generate.ts
  3. Brief summary of what was missing and what you added

Copy link
Copy Markdown
Owner Author

jpvajda commented Feb 12, 2026

@cursor why did you add "@vitest/coverage-v8": "^4.0.18",?

@jpvajda jpvajda marked this pull request as ready for review February 12, 2026 21:37
Copy link
Copy Markdown
Owner Author

@jpvajda jpvajda left a comment

Choose a reason for hiding this comment

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

@cursor see my comments.

package.json Outdated
"devDependencies": {
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.10.2",
"@vitest/coverage-v8": "^4.0.18",
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@cursor I don't think we need this

Copy link
Copy Markdown

@cursor cursor bot Feb 13, 2026

Choose a reason for hiding this comment

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

You're absolutely right! I've already removed it.

The @vitest/coverage-v8 package and the coverage configuration in vitest.config.ts have been removed in the latest commit. The PR now only includes:

26 new test cases for the generate command (48 total tests, up from 22)
No unnecessary dependencies - package.json is clean
Simple vitest config - just the basic test configuration, no coverage block

All tests still pass (288 tests total across the project). The changes have been committed and pushed to the branch.

Open in Cursor Open in Web

vitest.config.ts Outdated
environment: 'node',
include: ['tests/**/*.test.ts'],
exclude: ['node_modules/', 'dist/'],
coverage: {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@cursor this is not necessary

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Taking a look!

Open in Cursor Open in Web

@cursor
Copy link
Copy Markdown

cursor bot commented Feb 13, 2026

Taking a look!

Open in Cursor Open in Web

- Removed @vitest/coverage-v8 package dependency
- Reverted vitest.config.ts coverage configuration
- All 48 tests still pass without these changes
- Addresses PR feedback from @jpvajda

Co-authored-by: John Vajda <jpvajda@users.noreply.github.com>
@jpvajda jpvajda merged commit d489093 into main Feb 13, 2026
1 check passed
@jpvajda jpvajda deleted the cursor/FDPM-45-generate-command-coverage-96ae branch February 13, 2026 03:59
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