Skip to content

test: add infrastructure adapters test coverage#11

Merged
shepherdwind merged 1 commit into
mainfrom
test/009-infra-adapters-test-coverage
Apr 5, 2026
Merged

test: add infrastructure adapters test coverage#11
shepherdwind merged 1 commit into
mainfrom
test/009-infra-adapters-test-coverage

Conversation

@shepherdwind

Copy link
Copy Markdown
Owner

Background

Part of Phase 2 (Task 009) to achieve 90%+ test coverage. This is the final task, completing the coverage goal.

Approach

Added unit tests for all infrastructure adapters (Gmail, OpenAI, Telegram) with comprehensive mocking of external APIs and services.

Changes

Gmail adapters:

  • token-manager.test.ts — 16 tests: OAuth flow, token refresh, init, invalidation, save
  • email-processor.test.ts — 5 tests: fetch, mark as read, error handling
  • email.utils.test.ts — 8 tests: headers, body decoding, HTML conversion
  • gmail.adapter.test.ts — 3 tests: initialize, fetch, markAsRead

OpenAI adapter:

  • openai.adapter.test.ts — 5 tests: model defaults, processMessage, error handling

Telegram adapters:

  • telegram.adapter.test.ts — 9 tests: constructor, init, sendNotification with retry, pending merchants
  • query-command-handler.test.ts — 10 tests: handle, all time ranges, callback handling
  • custom-query-command-handler.test.ts — 6 tests: query parsing, NLP integration, error handling
  • categorization-constants.test.ts — 4 tests: all constant exports

Conversations:

  • add-bill.test.ts — 10 tests: full flow including cancel, confirm, NLP error, unauthorized user
  • categorization.test.ts — 6 tests: merchant lookup, NLP categorization, category selection, error

Testing

  • All 273 tests pass
  • Overall coverage: 46.92% → 91.5% (target: 90%)

Code Review

  • Review tool: codex
  • Rounds: 1
  • Issues fixed: none (passed on first round)

Add comprehensive tests for Gmail, OpenAI, and Telegram adapters:
- token-manager: OAuth flow, token refresh, init, save, invalidation
- email-processor: fetch emails, mark as read, error handling
- email.utils: header extraction, body decoding, HTML conversion
- gmail.adapter: initialize, fetch, mark as read
- openai.adapter: processMessage, model defaults, error handling
- telegram.adapter: constructor, init, sendNotification with retry
- query-command-handler: all time ranges, callback handling
- custom-query-command-handler: query parsing, NLP integration
- categorization-constants: all exports verified
- add-bill conversation: full flow including cancel, confirm, errors
- categorization conversation: flow with merchant lookup, NLP, selection

Overall coverage: 46.92% → 91.5%

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@shepherdwind shepherdwind merged commit bd86523 into main Apr 5, 2026
3 checks passed
@shepherdwind shepherdwind deleted the test/009-infra-adapters-test-coverage branch April 5, 2026 13:55
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.

1 participant