Description
The test suite (src/test/suite/extension.test.ts) currently contains only two basic tests:
- Extension loads and activates
- Commands are registered
There are no tests for the core diagnostic functionality, code actions, or report panel. This makes refactoring risky.
Required Test Coverage
Unit Tests for diagnostics.ts
- Mock the Soroban Guard CLI and verify:
- JSON output is parsed correctly into
GuardResults
- Findings are mapped to VS Code
Diagnostic objects with correct severity
- Severity mapping works for all levels (critical, high, medium, low, info)
- CLI errors are handled gracefully
shouldScan() correctly filters files based on exclude patterns
Unit Tests for codeActions.ts
- Mock diagnostics with various rule IDs
- Verify correct code action is returned for each rule ID (A-01, A-04, O-01, R-01)
- Verify workspace edits are constructed correctly
Unit Tests for statusBar.ts
- Verify state transitions produce correct text and colors
- Verify score display formatting
Integration Tests
- Full end-to-end flow: activate extension → scan file → receive diagnostics → apply fix
- Use a small Soroban contract fixture with known vulnerabilities
Implementation Notes
- Use VS Code's mock APIs from
@vscode/test-electron
- Create test fixtures in
src/test/fixtures/ directory
- Use
ts-mocha or ts-node for running TypeScript tests directly
- Add a
test:coverage script if possible
Acceptance Criteria
Complexity
Medium — requires mocking VS Code APIs and CLI processes.
Points
150
Description
The test suite (
src/test/suite/extension.test.ts) currently contains only two basic tests:There are no tests for the core diagnostic functionality, code actions, or report panel. This makes refactoring risky.
Required Test Coverage
Unit Tests for diagnostics.ts
GuardResultsDiagnosticobjects with correct severityshouldScan()correctly filters files based on exclude patternsUnit Tests for codeActions.ts
Unit Tests for statusBar.ts
Integration Tests
Implementation Notes
@vscode/test-electronsrc/test/fixtures/directoryts-mochaorts-nodefor running TypeScript tests directlytest:coveragescript if possibleAcceptance Criteria
Complexity
Medium — requires mocking VS Code APIs and CLI processes.
Points
150