fix: add missing tests for webhook dead-letter queue, e2e cleanup, governance lifecycle, and FxRateCache outage#755
Merged
Conversation
…on and dead-letter queue Adds three tests covering the previously untested scenario where all retry attempts are exhausted: verifies the delivery is moved to dead-letter status (attempt_count >= max_attempts), that dead-letter deliveries can be replayed when reset to pending, and that a successful replay does not re-queue the delivery via enqueueWebhookDelivery. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…and mocks are cleared first Reorders the resetDb table clears to respect foreign-key dependency order (fx_rates → transactions → user_kyc_status → anchor_kyc_configs) so the function is safe to call against a real database. Also swaps the beforeEach order to call vi.clearAllMocks() before resetDb(), ensuring stale mock queues from a previous test cannot influence the subsequent DB reset. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lifecycle through REST API Adds a full-lifecycle integration test covering the propose → vote → execute (admin confirmation) flow through the /api/admin/actions REST endpoints, including multi-admin voting (self-confirm blocked), timelock enforcement (expired proposals rejected, absent from pending list), and authentication guards on every route. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…r outage on first request Adds the missing test case where both the live cache and the stale fallback cache are empty (no prior successful fetch) and the provider returns a non-429 error. Verifies the error is propagated as 'Failed to fetch FX rate' rather than being silently swallowed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@Fidelis900 is attempting to deploy a commit to the Harold's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Fidelis900 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! 🚀 |
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.
Summary
This PR resolves four open issues by adding the missing test coverage across the backend and API test suites:
#704 — WebhookDispatcher retry exhaustion and dead-letter queue
File:
backend/src/__tests__/webhook-dispatcher.test.tsAdded a
retry exhaustion and dead-letter queuedescribe block with three tests:attempt_count = max_attempts - 1),markWebhookDeliveryFailureis called withnextAttempt >= maxAttempts— the condition the database uses to setstatus = 'failed'(dead-letter).pendingis successfully replayed viaretryPendingDeliveries, callingmarkWebhookDeliverySuccess.enqueueWebhookDelivery, preventing duplicate re-queuing.#701 — e2e.test.ts uses real database without cleanup between tests
File:
backend/src/__tests__/e2e.test.tsresetDbtable clears to respect foreign-key dependency order:fx_rates → transactions → user_kyc_status → anchor_kyc_configs. This makes the function safe to run against a real PostgreSQL database without FK-constraint violations.beforeEachcall order tovi.clearAllMocks()beforeresetDb(), ensuring any unconsumedmockResolvedValueOncequeues from a failing test are flushed before the DB state is reset.#702 — No integration tests for the governance proposal lifecycle end-to-end
File:
api/src/__tests__/governance-lifecycle.test.ts(new file)Added a full-lifecycle integration test suite for the governance proposal flow (
propose → vote → confirm) exercised through the/api/admin/actionsREST endpoints:409); pending list reflects all unconfirmed proposals.409) and are excluded fromGET /api/admin/actions; unknown IDs return404.Uses a
vi.hoisted+vi.mockin-memoryAdminConfirmationServicethat mirrors the real service's business rules, so the test exercises the full HTTP → router → service path without a database.#703 — No test for FxRateCache stale fallback when both caches are empty
File:
backend/src/__tests__/fx-rate-cache.test.tsAdded the previously missing test case:
When no prior successful fetch exists (stale cache is empty) and the provider returns a non-429 error on the very first call, the cache must propagate the error as
'Failed to fetch FX rate'rather than silently swallowing it.Test plan
vitest run backend/src/__tests__/webhook-dispatcher.test.ts— all existing + 3 new tests passvitest run backend/src/__tests__/e2e.test.ts— all tests pass with no cross-test pollutionvitest run api/src/__tests__/governance-lifecycle.test.ts— all 11 new lifecycle tests passvitest run backend/src/__tests__/fx-rate-cache.test.ts— all existing + 1 new test passCloses #704
Closes #701
Closes #702
Closes #703
🤖 Generated with Claude Code