test: close coverage gaps — 623 → 907 tests, 94.6% → 97.0% coverage#18
Merged
Conversation
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 SummaryThis 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:
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
|
| 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
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Coverage Gap Fixes
Adds 284 new tests across all packages to close the gaps identified in the code review.
Changes by area
shared-xml-helpers.tstax/calculator.tsapi/http-client.tssigning/p12-loader.tscreate_invoiceWhat'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