Skip to content

Conversation

@fegge
Copy link

@fegge fegge commented Nov 25, 2025

Summary

This PR introduces comprehensive test coverage for the weAudit VS Code extension.

Testing Plan

See TESTING.md for the full testing strategy covering:

  • Framework: mocha, chai, sinon, @vscode/test-electron, jsdom, nyc
  • Coverage targets: 80% for types.ts, 60% overall
  • 248 planned tests across 5 phases

Related Issues

This work is tracked in the Test Coverage v1.0 milestone:

Progress

Current status: 487 unit tests passing, CI workflow active

Test plan

  • Review TESTING.md for completeness
  • Verify issue breakdown covers all planned tests
  • CI runs on every PR

🤖 Generated with Claude Code

fegge and others added 17 commits December 23, 2025 10:40
Document the comprehensive test strategy for the weAudit extension including:
- Test framework and tools (mocha, chai, sinon, nyc)
- Four-phase testing approach (P0-P2 priority)
- 173 planned tests across data integrity, entry lifecycle,
  workspace management, and UI components
- VS Code API mocking strategies
- CI requirements and conventions

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

Co-Authored-By: Claude <noreply@anthropic.com>
Set up foundational test infrastructure for weAudit extension:

- Add devDependencies: jsdom, nyc, @vscode/test-electron, proxyquire
- Create test directory structure (unit/, mocks/, fixtures/)
- Add VS Code API mock factories (12 factories for Uri, WorkspaceFolder,
  TextEditor, ExtensionContext, Range, Selection, TextDocument, etc.)
- Add fixture .weaudit files for testing (valid, minimal, legacy,
  corrupt, empty, invalid-entry-type, missing-fields)
- Configure nyc for coverage reporting (60% threshold)
- Add npm scripts: test, test:unit, test:ext, coverage
- Add tests for mock factories and fixture validation

52 tests passing

Closes #95

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix prettier formatting in .nycrc.json
- Add husky pre-commit hook to run ESLint and Prettier checks
- Ensures code style consistency before commits

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

Co-Authored-By: Claude <noreply@anthropic.com>
Phase 1 - Data Integrity (#96):
- validators.test.ts: 54 tests for validateSerializedData
- persistence.test.ts: 22 tests for file load/save operations
- types.test.ts: Extended with comprehensive type guards, equality,
  merging, and factory function tests

Phase 2 - Entry Lifecycle (#97):
- entryCrud.test.ts: 32 tests for entry creation, deletion, resolution
- locations.test.ts: 42 tests for location management and selection
- auditing.test.ts: 42 tests for file auditing and partial audits

Total: 311 tests passing

Closes #96, Closes #97

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

Co-Authored-By: Claude <noreply@anthropic.com>
Phase 3 - Workspace & Navigation (#98):
- multiRoot.test.ts: 35 tests for workspace root management,
  unique label generation, and path resolution
- permalinks.test.ts: 44 tests for GitHub/GitLab/Bitbucket
  permalink generation, SSH URL handling, and line formatting
- navigation.test.ts: 32 tests for partially audited region
  navigation, wrapping, and multi-root traversal

Total: 398 tests passing

Closes #98

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

Co-Authored-By: Claude <noreply@anthropic.com>
Phase 4 - UI Components (#99):
- treeProviders.test.ts: 65 tests for main tree provider,
  MultipleSavedFindingsTree, and ResolvedEntriesTree
- messageHandlers.test.ts: 27 tests for webview message handling
  including update-entry, update-repository-config, choose-workspace-root
- decorations.test.ts: 36 tests for DecorationManager including
  color configuration, hoverOnLabel, and labelAfterFirstLineTextDecoration

Total: 487 tests passing

Closes #99

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add test.yml workflow with unit tests, extension tests, and build jobs
- Configure VS Code version matrix (stable + insiders on Ubuntu)
- Configure OS matrix (ubuntu, macos, windows)
- Add Codecov integration for coverage reporting
- Add .vscode-test.mjs configuration for extension host tests
- Add Tests and Codecov badges to README

Closes #100

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

Co-Authored-By: Claude <noreply@anthropic.com>
Document 75 planned extension integration tests covering:
- Extension activation and command registration
- Command execution (addFinding, toggleAudited, copyPermalink, etc.)
- Tree view integration and drag-and-drop
- Editor decorations and gutter icons
- Webview panels (finding details, git config)
- Workspace operations (single/multi-root, file watchers)
- File decorations in explorer
- Error handling and performance requirements

Also includes test runner configuration examples and sample test file.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Replace TreeViewMode.PerFile with TreeViewMode.GroupByFile to match
the actual enum definition in src/types.ts.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Refactor extension tests to remove invalid/always-passing tests
- Remove ~33 tests that used `|| true` patterns or try/catch blocks
  that always passed regardless of outcome
- Fix misleading test names in performance tests
- Update CI workflow to test against both stable and insiders VS Code
- Add unit tests to pre-commit hook (eslint + prettier + unit tests)

Test matrix now covers:
- 3 platforms (ubuntu, macos, windows)
- 2 VS Code versions (stable required, insiders allowed to fail)

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix unsafe non-null assertions by properly handling undefined
  activeTextEditor in getActiveSelectionLocation and related methods
- Add eslint-disable comments with justifications for necessary
  non-null assertions
- Refactor extension tests to verify actual behavior (persisted data)
  instead of only checking command execution success
- Remove redundant unit tests superseded by integration tests
- Update pre-commit hook to fail on ESLint warnings
- Add pretest:ext script to ensure compilation before extension tests

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix configuration property tests to handle package.json configuration
  as an array of sections instead of a single object
- Fix toggleTreeViewMode test to get fresh config object after toggle
- Fix performance test to create .vscode directory if it doesn't exist
- Fix addPartiallyAudited test to use non-zero end character to prevent
  line decrement behavior

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

Co-Authored-By: Claude <noreply@anthropic.com>
Pin codecov/codecov-action to commit hash instead of version tag
to address CodeQL warning about unpinned 3rd party actions.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix state sharing between tests by adding suiteTeardown cleanup
- Restore original weaudit file content after tests complete
- Fix addPartiallyAudited test to handle file already being fully audited
- Replace showInputBox mocking (doesn't work across extension host) with
  VS Code commands (acceptSelectedQuickOpenItem, closeQuickOpen)
- Improve showMarkedFilesDayLog test to verify actual document content
- All tests now have meaningful assertions that can fail

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

Co-Authored-By: Claude <noreply@anthropic.com>
Replace fixed setTimeout delays with a polling mechanism that waits for
expected state changes. This resolves intermittent test failures in CI
where 500ms delays were insufficient for VS Code operations to complete.

- Add waitForCondition helper to poll for state changes with timeout
- Update toggleAudited test to poll until audit state changes
- Update addPartiallyAudited test to poll for state changes
- Update showMarkedFilesDayLog test to poll for editor visibility

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

Co-Authored-By: Claude <noreply@anthropic.com>
The extension uses path.relative() which returns OS-native separators.
On Windows this produces backslashes (src\sample.ts) while the tests
were hardcoding forward slashes (src/sample.ts), causing path comparison
failures in CI.

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

Co-Authored-By: Claude <noreply@anthropic.com>
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.

3 participants