Skip to content

test(integration): un-skip revenue-tracking via fuller stripe-client mock#3327

Merged
bokelley merged 2 commits into
mainfrom
claude/issue-3318-stripe-webhook-mock
Apr 27, 2026
Merged

test(integration): un-skip revenue-tracking via fuller stripe-client mock#3327
bokelley merged 2 commits into
mainfrom
claude/issue-3318-stripe-webhook-mock

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Refs #3318. Part of #3289 integration-test restoration.

server/tests/integration/revenue-tracking.test.ts was describe.skip'd because there was no vi.mock for the stripe-client module — stripe was null in the test environment, so every call to POST /api/webhooks/stripe returned 400 Stripe not configured before reaching any test logic. This PR adds the missing vi.hoisted + vi.mock for stripe-client (following the identical pattern from admin-sync-revenue-backfill.test.ts, merged in #3313), exports a truthy STRIPE_WEBHOOK_SECRET, and removes the stale dead-code block in beforeAll that attempted to patch the live stripe object at runtime (it was a no-op while stripe was null, and became a mock-overwrite bug once the vi.mock was added).

Non-breaking justification: test-only change; no production code, no schemas, no exported types touched.

Pre-PR review:

  • code-reviewer: approved — stale dead code fully removed, STRIPE_WEBHOOK_SECRET correctly truthy, mockConstructEvent Buffer path correct, no blockers remaining
  • internal-tools-strategist: approved — Option A (fuller mock) is right-tool; route-layer coverage is exactly what these tests should exercise; ops risk of bypassing signature verification in tests is nil (module scoped to Vitest registry, never ships to runtime)

Triage-managed PR. This bot does not currently iterate on
review comments or PR conversation threads (only on the source
issue). To unblock:

  • Push fixup commits directly: gh pr checkout <num>
    fix → push.
  • Or re-trigger: comment /triage execute on the source
    issue.

See #3121
for context.

Session: https://claude.ai/code/session_01DZZ43na714gw4EYgJ5dJUQ


Generated by Claude Code

…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
@bokelley bokelley added the claude-triaged Issue has been triaged by the Claude Code triage routine. Remove to re-triage. label Apr 26, 2026
…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>
@bokelley bokelley marked this pull request as ready for review April 27, 2026 11:25
@bokelley bokelley merged commit 7097a13 into main Apr 27, 2026
12 checks passed
@bokelley bokelley deleted the claude/issue-3318-stripe-webhook-mock branch April 27, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-triaged Issue has been triaged by the Claude Code triage routine. Remove to re-triage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants