Skip to content

feat: systematically achieve 90% test coverage per file - #930

Open
avoidwork wants to merge 15 commits into
mainfrom
feat/achieve-90-percent-test-coverage
Open

feat: systematically achieve 90% test coverage per file#930
avoidwork wants to merge 15 commits into
mainfrom
feat/achieve-90-percent-test-coverage

Conversation

@avoidwork

Copy link
Copy Markdown
Owner

What

Systematically achieve ≥90% line coverage per file across the madz codebase. This PR establishes the OpenSpec change framework and task plan.

Scope

In Scope

  • All priority files from issue feat: systematically achieve 90% test coverage per file #929 audit (spreadsheet, calendar, email providers, compactContext, scheduler, session, logger, skills, yaml, webhook)
  • New test files for modules without existing tests
  • Extended test files for modules with <90% coverage
  • Mocking of external APIs (Gmail, Microsoft Graph, IMAP)
  • c8 ignore next annotations for genuinely untestable paths

Out of Scope

  • Refactoring source code to improve testability (separate concern)
  • Achieving 90% on all 118+ files without test files (incremental effort)
  • Integration or end-to-end tests

Technical Approach

  • Test framework: node --test (built-in, no dependencies)
  • Coverage tool: c8 via --experimental-test-coverage
  • Mocking strategy:
    • External APIs (Gmail, Graph, IMAP) → stubbed with sinon-style manual mocks or node:test mock module
    • File system → stubbed with fs mocks
    • LLM providers → stubbed with mock responses
    • Pino logger → stubbed with pino test helpers
  • c8 ignore: // c8 ignore next for platform-specific code, unresolvable error paths, and live-credential dependencies

Tasks

See openspec/changes/achieve-90-percent-test-coverage/tasks.md for the full task breakdown (27 tasks across 7 groups).

Priority Files (by coverage)

File Current Target
src/tools/spreadsheet/formulaParser.js 16.99% 90%
src/tools/calendar/index.js 18.18% 90%
src/tools/email/providers/graph.js 18.52% 90%
src/tools/email/providers/gmail.js 21.89% 90%
src/tools/compactContext/index.js 23.40% 90%
src/tools/email/providers/imap.js 24.43% 90%
src/tools/spreadsheet/pivot.js 25.00% 90%
src/tools/calendar/providers/msgraph.js 28.75% 90%
src/tools/calendar/providers/google.js 29.51% 90%
src/tools/spreadsheet/stats.js 34.31% 90%
src/tools/spreadsheet/spreadsheet.js 33.27% 90%

Verification

  • All existing tests pass
  • Coverage ≥90% on all priority files
  • Lint passes (oxlint + oxfmt)
  • Application starts without crash

Closes #929

Closes #929

- proposal.md: motivation and scope for achieving 90% line coverage
- design.md: technical approach, mocking strategy, c8 ignore decisions
- tasks.md: 27 tasks across 7 groups (spreadsheet, calendar, email, core)
- specs/test-coverage/spec.md: requirements and scenarios for test coverage
@avoidwork avoidwork self-assigned this Aug 30, 2026
better-sqlite3's fromConnString with file: URIs doesn't reliably
resolve paths or create parent directories. Create the Database
instance directly with an absolute path, ensure parent dirs exist,
and set WAL mode manually.
Switch from sync fs (mkdirSync, existsSync) to async fs/promises
(mkdir). mkdir with recursive: true is idempotent, so the exists
check is no longer needed. Update the call site in index.js and
all tests to handle the async function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: systematically achieve 90% test coverage per file

1 participant