• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

acossta / captan / 17160716822

22 Aug 2025 04:32PM UTC coverage: 82.954% (+2.3%) from 80.673%
17160716822

push

github

web-flow
feat: Complete CLI redesign with comprehensive testing (#24)

* feat: Complete CLI redesign to resource-oriented architecture

Implements GitHub issue #23 - transforms CLI from inconsistent command
patterns to clean resource-oriented architecture following RESTful principles.

## Architecture Changes
- Resource-first commands: `captan [resource] [action]`
- Consistent CRUD verbs: add, list, show, update, delete
- Email-based stakeholder identification support
- Clean handler separation by resource type

## New Command Structure
- stakeholder: add/list/show/update/delete
- security: add/list/show/update/delete
- issuance: add/list/show/update/delete
- grant: add/list/show/update/delete
- safe: add/list/show/update/delete/convert
- report: summary/ownership/stakeholder/security
- export: csv/json/pdf
- system: init/validate/schema/log

## Implementation
- Extracted 2,593 lines of handlers into clean modular files
- Fixed property name mismatches (pps vs pricePerShare)
- Implemented missing CRUD operations (many were stubs)
- Added comprehensive identifier resolution system
- Updated all 28 integration tests to new syntax

## Documentation
- Added comprehensive Usage section with all commands
- Updated all examples to use new resource-oriented syntax
- Fixed parameter notation (<required> vs [optional])
- Removed outdated command references

## Testing
- All 521 tests passing
- Complete end-to-end verification of new commands
- Integration tests updated for new CLI structure

Breaking changes for v0.4.0 - new architecture is production ready.

* test: add comprehensive handler tests and fix test isolation issues

- Add complete test suites for all handler modules (10 new test files)
- Add identifier-resolver and helpers test suites
- Fix test isolation issues by using factory functions and deep cloning
- Fix mock return structures to match implementation expectations
- Improve coverage from 39.23% to 83.93% overall
- Handler coverage increased to 94.79% ... (continued)

1206 of 1401 branches covered (86.08%)

Branch coverage included in aggregate %.

2469 of 3102 new or added lines in 16 files covered. (79.59%)

4 existing lines in 1 file now uncovered.

4595 of 5592 relevant lines covered (82.17%)

1626.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

44.0
/src/utils/test-utils.ts
1
/**
2
 * Test utility functions for consistent test setup
3
 */
4

5
import { vi, beforeEach, afterEach } from 'vitest';
2✔
6
import * as dateUtils from './date-utils.js';
2✔
7

8
/**
9
 * Set up fake timers and mock the current date
10
 * @param date - The date to freeze time at (defaults to 2024-01-01)
11
 */
12
export function setupFakeTimers(date: string = '2024-01-01') {
2✔
NEW
13
  beforeEach(() => {
×
14
    // Mock the date utility functions
NEW
15
    vi.spyOn(dateUtils, 'getCurrentDate').mockReturnValue(date);
×
NEW
16
    vi.spyOn(dateUtils, 'getCurrentTimestamp').mockReturnValue(`${date}T00:00:00.000Z`);
×
17

18
    // Also set system time for any direct Date usage
NEW
19
    vi.useFakeTimers();
×
NEW
20
    vi.setSystemTime(new Date(`${date}T00:00:00.000Z`));
×
NEW
21
  });
×
22

NEW
23
  afterEach(() => {
×
NEW
24
    vi.restoreAllMocks();
×
NEW
25
    vi.useRealTimers();
×
NEW
26
  });
×
NEW
27
}
×
28

29
/**
30
 * Standard mock cleanup for consistent test isolation
31
 */
32
export function setupMockCleanup() {
2✔
33
  afterEach(() => {
2✔
34
    vi.clearAllMocks();
78✔
35
  });
2✔
36
}
2✔
37

38
/**
39
 * Create a deterministic ID generator for tests
40
 * @param prefix - The prefix for generated IDs
41
 * @returns A function that generates sequential IDs
42
 */
43
export function createIdGenerator(prefix: string) {
2✔
NEW
44
  let counter = 0;
×
NEW
45
  return () => `${prefix}_test_${++counter}`;
×
NEW
46
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc