test(integration): un-skip revenue-tracking via fuller stripe-client mock#3327
Merged
Conversation
…mock Adds vi.hoisted + vi.mock for stripe-client following the pattern from admin-sync-revenue-backfill.test.ts (#3313). The webhook route guard requires both stripe and STRIPE_WEBHOOK_SECRET to be non-null; the mock satisfies both. products.retrieve rejects so the handler exercises its description-fallback path. Removes the stale dead-code block in beforeAll that attempted to patch the live stripe object at runtime — this was a no-op since stripe was null, and became a mock-overwrite bug after the vi.mock was added. Refs #3318. Part of #3289 integration-test restoration. https://claude.ai/code/session_01DZZ43na714gw4EYgJ5dJUQ
1 task
…nt behavior
formatCurrency in server/src/routes/admin/stats.ts rounds to whole dollars
for dashboard display (10998¢ → \$110, 5998¢ → \$60). Test was asserting
cent-precision strings ('\$109.98', '\$59.98') which no longer match.
Update expectations.
MRR test: live MRR query reads from revenue_events (DISTINCT ON
stripe_subscription_id, period_end > NOW(), revenue_type IN
subscription_initial/recurring), not from columns on the organizations
table. Replace the UPDATE with a properly-shaped revenue_event INSERT.
Refunds + product-breakdown tests also pick up the formatter rounding.
Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Refs #3318. Part of #3289 integration-test restoration.
server/tests/integration/revenue-tracking.test.tswasdescribe.skip'd because there was novi.mockfor the stripe-client module —stripewasnullin the test environment, so every call toPOST /api/webhooks/stripereturned400 Stripe not configuredbefore reaching any test logic. This PR adds the missingvi.hoisted+vi.mockforstripe-client(following the identical pattern fromadmin-sync-revenue-backfill.test.ts, merged in #3313), exports a truthySTRIPE_WEBHOOK_SECRET, and removes the stale dead-code block inbeforeAllthat attempted to patch the live stripe object at runtime (it was a no-op whilestripewasnull, and became a mock-overwrite bug once thevi.mockwas added).Non-breaking justification: test-only change; no production code, no schemas, no exported types touched.
Pre-PR review:
STRIPE_WEBHOOK_SECRETcorrectly truthy,mockConstructEventBuffer path correct, no blockers remainingSession: https://claude.ai/code/session_01DZZ43na714gw4EYgJ5dJUQ
Generated by Claude Code