Skip to content

test: close coverage gaps — 623 → 907 tests, 94.6% → 97.0% coverage#18

Merged
dbejarano820 merged 3 commits into
mainfrom
test/coverage-gaps
Feb 22, 2026
Merged

test: close coverage gaps — 623 → 907 tests, 94.6% → 97.0% coverage#18
dbejarano820 merged 3 commits into
mainfrom
test/coverage-gaps

Conversation

@dbejarano820
Copy link
Copy Markdown
Contributor

Coverage Gap Fixes

Adds 284 new tests across all packages to close the gaps identified in the code review.

Changes by area

Area Before After New Tests
shared-xml-helpers.ts 77% stmts 100% +73
tax/calculator.ts 95% stmts 95% (branches 91→95%) +14
api/http-client.ts 93% stmts 96% +4
signing/p12-loader.ts 89% stmts 93% +3
MCP create_invoice 0 functional tests 5 full tests +5
SDK Overall 94.6% / 85.7% 97.0% / 90.7%
Documents module 83% 100%

What's tested now

XML Helpers (73 tests): All optional paths — receptor fax/foreign ID, emisor fax/location details, ResumenFactura currency/exoneration/IVA-devuelto/otros-cargos fields, OtrosCargos, InformacionReferencia, Otros, StandardDocumentBody with every combination.

Tax Edge Cases (14 tests): IEEE 754 boundaries for round5(), micro quantities (0.001), free items, large amounts (999M), multiple taxes per line, 100% exoneration, all-zero summaries, services-only and merchandise-only invoices.

HTTP Client Parsing (4 tests): XML content-type responses, 204 No Content, plain text fallback, JSON-in-text fallback.

P12 Signing Errors (3 tests): Corrupt .p12 buffer, wrong PIN, empty buffer — all throw SigningError.

MCP create_invoice (5 tests): Exempt items, IVA 13% with correct totals, missing required fields → error, multiple line items, discounts reflected in XML.

Verification

907 tests passed | 4 skipped
Build: 4/4 packages ✅

Add 284 new tests (623 → 907 total), targeting all identified coverage gaps:

- shared-xml-helpers: 77% → 100% (+73 tests)
  All optional XML paths: receptor fax/identificacionExtranjero, emisor fax/ubicacion,
  ResumenFactura optional totals, OtrosCargos, InformacionReferencia, Otros,
  StandardDocumentBody with all optional fields

- tax/calculator: +14 tests for IEEE 754 edge cases and boundary conditions
  round5 precision boundaries, micro quantities, free items, large amounts,
  multiple taxes, 100% exoneration, all-zero summary, services-only, merchandise-only

- api/http-client: +4 tests for response parsing paths
  XML content-type, 204 empty, plain text fallback, JSON text fallback

- signing/p12-loader: +3 tests for error paths
  Invalid buffer, wrong PIN, empty buffer → SigningError

- MCP create_invoice: +5 functional tests
  Exempt items, IVA 13%, missing fields, multiple items, discounts

SDK coverage: 94.6% → 97.0% statements, 85.7% → 90.7% branches
Documents module: 83% → 100%
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Feb 22, 2026

Greptile Summary

This PR adds 284 new tests across SDK, MCP, and CLI packages to close coverage gaps identified in prior code review. Coverage increases from 94.6% to 97.0% statements and 85.7% to 90.7% branches.

Key improvements:

  • shared-xml-helpers.ts: 77% → 100% coverage with 73 tests for all optional XML fields (Emisor/Receptor fax, ubicacion details, ResumenFactura currency/exoneration, OtrosCargos, InformacionReferencia)
  • tax/calculator.ts: Branch coverage 91% → 95% with 14 edge case tests (IEEE 754 boundaries, micro quantities, free items, 999M amounts, multiple taxes, 100% exoneration, all-zero summaries)
  • http-client.ts: 93% → 96% with 4 response parsing tests (XML content-type, 204 No Content, plain text, JSON-in-text fallback)
  • p12-loader.ts: 89% → 93% with 3 error tests (corrupt buffer, wrong PIN, empty buffer)
  • MCP create_invoice: 0 → 5 functional tests (exempt items, IVA 13%, missing fields, multiple items, discounts)

All tests are well-structured with clear describe blocks, minimal fixtures, and focused assertions. No production code changes — pure test additions.

Confidence Score: 4/5

  • This PR is very safe to merge — adds only well-written test code with no production changes
  • Score reflects excellent test quality and zero production code risk, but lacking explicit verification that all 907 tests actually pass and coverage numbers match PR claims
  • No files require special attention — all test additions are clean and well-structured

Important Files Changed

Filename Overview
packages/mcp/src/server.spec.ts Adds comprehensive MCP server tests (162 lines) covering tool registration, resource listing, and 6 new create_invoice functional tests with edge cases like exempt items, IVA 13%, missing fields, multiple items, and discounts
packages/sdk/src/api/http-client.spec.ts Adds 4 response parsing tests for XML content-type, 204 No Content, plain text fallback, and JSON-in-text fallback — closes coverage gaps in response handling
packages/sdk/src/documents/shared-xml-helpers.spec.ts Adds 73 exhaustive tests for XML mapping helpers covering all optional fields (Emisor fax/ubicacion, Receptor foreign ID, ResumenFactura currency/exoneration fields, OtrosCargos, InformacionReferencia, Otros) — achieves 100% coverage
packages/sdk/src/signing/p12-loader.spec.ts Adds 3 error path tests for P12 loader (corrupt buffer, wrong PIN, empty buffer) — all correctly throw SigningError
packages/sdk/src/tax/calculator.spec.ts Adds 14 edge case tests for tax calculations including IEEE 754 boundaries, micro quantities (0.001), free items, large amounts (999M), multiple taxes per line, 100% exoneration, all-zero summaries, services-only and merchandise-only invoices

Last reviewed commit: 31807c2

@dbejarano820 dbejarano820 merged commit c65ab41 into main Feb 22, 2026
1 check passed
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