Repository navigation
test(linq): fixture every documented KYC failure code, and stop guess… - #259
Merged
Miracle656 merged 2 commits intoOct 20, 2026
Merged
Conversation
…ing a cause (W087) The provider documented its KYC failure codes on 2026-10-14 and both clients branch on them, but nothing tested a single one against the shape it arrives in. The route tests hand-built LinqErrors and skipped the parser. - fixtures/linq/kyc-errors.json: one case per documented code, plus undocumented-code and no-code cases. Each pairs the provider's response with wraith's answer, so the clients test against the same contract. - kycErrorFixtures.test.ts drives every case through stubbed fetch, the real parser and the real route. No provider path is reachable. - A reasonless 5xx no longer reads "Linq rejected the request", which blamed the request for a cause nobody sent. 4xx wording is unchanged. - The route's own 11-digit check now carries code: invalid_nin_format, so the clients' branch for it is reachable for the commonest case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LvL6Yz2Zfg7spM1F9DXXtz
|
@JemimahEkong Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Owner
|
Rebase needed — #261 landed, consolidating the two Linq HTTP clients into a single What changed, so the rebase is predictable:
Also worth knowing: Push and I will pick it up. |
Brings the branch onto Miracle656#261's single Linq client (src/linq/http.ts). Conflict in src/linq/onramp.ts: this branch changed the reasonless-error fallback inside onramp's private call(), which Miracle656#261 removed. The change now lives where every Linq error is built: unexplainedFailure() is in http.ts and used for both the non-JSON and the JSON fallback; onramp.ts re-exports it so the branch's public surface is unchanged. Because there is now one client, the wording applies to every Linq rail, not only KYC: a reasonless 5xx reads "Linq returned an error without giving a reason (HTTP 5xx)"; a reasonless 4xx is still "Linq rejected the request". Two httpClient.test.ts expectations (502 HTML page, 500 oversized body) are updated accordingly — flagging for review, since they pinned the old wording on all rails. Verified: typecheck, tsc --noEmit, build; jest 63 suites / 958 tests. Reverting the fallback to the old wording fails 12 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LvL6Yz2Zfg7spM1F9DXXtz
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.
W087 · Fixtures for the provider's documented KYC failure codes
Closes #244
What changed
fixtures/linq/kyc-errors.json, at the repo root: one case per documented code (invalid_nin_format400,nin_already_used409,nin_verification_failed422,kyc_provider_error502,kyc_internal_error500), plus two undocumented-code cases and five no-code cases. Each pairs the provider response with the veil answer fromPOST /ngn/customers/kyc. Clients test againstveil;fixtures/README.mdsays how to vendor it pinned to a commit.src/__tests__/linq/kycErrorFixtures.test.ts(50 tests) drives every case through stubbedglobal.fetch→ the realsubmitCustomerKycparser → the real route. The existing route tests hand-builtLinqErrors and never touched the parser. No path reaches the provider.Linq returned an error without giving a reason (HTTP 500), with the code appended if there was one. 4xx wording is unchanged.code: "invalid_nin_format". That check catches almost every malformed NIN before the provider sees it, and it answered with no code. The clients' branch for this code was therefore unreachable for the commonest case. It is the same condition with the same code, so this is not a mapping.docs/ngn-rails.mdgains a failure-code table.Acceptance criteria
nin_name_mismatch(with prose) andkyc_queue_unavailable(without).{}, unrelated fields, blankmessageandcode, an empty body, and an HTML gateway page. In each casecodeis absent, no cause words appear, and a 5xx never says "rejected".src/is read by the backend tests and published for the clients.Things to know
{ message, code }envelope is what the parser already reads.customerRefonnin_already_usedmatches whatclient.tsalready documents. Please replace the prose with a real capture when one exists.kyc_internal_errorarrives from the provider as 500 and reaches clients as 502. That is existingsendLinqErrorbehaviour, and the fixture and docs now state it explicitly. Clients should branch oncode.onramp.test.tschanged. Both pinned the old 5xx wording, so they had to change, and I added a 4xx counterpart.ninfield. Tests use00000000000.Tests
npm testbefore: 710/711 passing. After: 760/761 passing. The one failure both times is the pre-existingopenapiCoverage.test.ts(W082).npm run typecheckis clean.