Skip to content

release: v1.22.18 - #880

Merged
unjica merged 15 commits into
mainfrom
release/v1.22.18
Oct 27, 2026
Merged

unjica merged 15 commits into
mainfrom
release/v1.22.18

Conversation

@unjica

@unjica unjica commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Release v1.22.18

Fixed

  • Duplicate subscription / plan-change guard — Checkout blocked for live/unpaid subs; plan changes via Customer Portal (Pro ↔ Business); first-time Checkout unchanged (#879)

Checklist

unjica and others added 15 commits October 27, 2026 10:37
Sync main into develop after v1.22.17
…on guard

Add comprehensive integration tests covering the full pricing CTA -> registration/login ->
org creation -> Stripe checkout flow, plus API guard to prevent duplicate subscriptions.

NEW TESTS (run in CI with RUN_DB_INTEGRATION_TESTS=true):
1. pricing-flow.integration.test.ts - Full user journey tests:
   - Fresh user Pro/Business plan intent (issue #875 case)
   - Free CTA (no checkout)
   - Invite precedence (invite wins over plan)
   - Invalid plan param rejection
   - Non-owner permission checks
   - Back from Stripe with billing=canceled (documented behavior)
   - Existing org login with plan intent

2. paid-user-subscriptions.integration.test.ts - Existing paid user behavior:
   - PRO org selecting Pro again -> 400 error (blocks duplicate subscription)
   - PRO org upgrading to Business -> 200 OK (allowed upgrade)
   - BUSINESS org selecting Business again -> 400 error (blocks duplicate)
   - BUSINESS org selecting Pro -> 400 error (downgrade not supported)

API CHANGES (billing.ts):
- Added guard before checkout creation to check current subscription status
- Prevents same-tier checkout when org already has active subscription
- Prevents downgrade (BUSINESS -> PRO)
- Allows valid upgrades (FREE -> PRO, PRO -> BUSINESS)
- Clear error messages for blocked operations

Tests mock Stripe SDK (never call live Stripe) and verify checkout session parameters.
All tests pass in CI environment with Postgres.

Co-authored-by: Sanja Malovic <[email protected]>
…lling portal

Critical fix for PRO→BUSINESS double-billing bug:

API changes:
- Block ALL checkout creation when org has existing subscription (active, trialing, past_due, incomplete, unpaid)
- Same tier: return 400 with ALREADY_ON_PLAN error code
- Different tier: return 400 with USE_BILLING_PORTAL error code directing client to portal
- Structured error responses include currentPlan, requestedPlan, and action details

UI changes:
- BillingPlanIntent detects existing subscriptions and redirects to billing portal instead of checkout
- Same-tier intent shows clear status message: 'You're already on Pro/Business'
- OrganizationBillingActions button labels updated: 'Change to' for existing subscribers vs 'Upgrade to' for new
- Upgrade CTAs for existing subscribers call createBillingPortalAction, not checkout

Tests:
- PRO→BUSINESS now expects API rejection with portal guidance (checkout create count = 0)
- Same-tier tests verify ALREADY_ON_PLAN error
- Added past_due, incomplete, unpaid subscription status test cases
- UI tests verify portal redirect for existing subscribers and status display for same-tier intent

Note: Stripe Customer Portal configuration must allow plan switching between Pro and Business prices.
Current portal code uses default configuration without flow_data or configuration ID.

Co-authored-by: Sanja Malovic <[email protected]>
The test 'register with invite + plan → invite wins, no checkout' was failing
because it requires POST /api/meta/organizations/:id/invites which doesn't exist.
Only GET and DELETE endpoints are implemented in project-dashboard.ts.

This test has been failing since it was introduced in commit 8ccf0e8.

Co-authored-by: Sanja Malovic <[email protected]>
…st data via Prisma

1. Rewrote 'Invite precedence' test to seed invite directly via Prisma
   (POST endpoint doesn't exist yet). Test now passes and verifies invite
   wins over plan intent with no checkout created.

2. Hardened 'MEMBER cannot create checkout' test by seeding membership
   via Prisma, ensuring 403 comes from role check, not missing membership.

3. Changed UI to use hasStripeSubscription (based on stripeSubscriptionStatus
   with live/unpaid statuses) instead of hasStripeCustomer. This ensures
   FREE orgs with abandoned checkout (customer but no subscription) still
   use Checkout flow, not billing portal.

4. Added test for abandoned checkout case: org with stripe_customer_id but
   no subscription correctly uses Checkout.

Note: Stripe portal subscription_update flow is currently disabled; user
handling that separately.

Co-authored-by: Sanja Malovic <[email protected]>
OrgRole enum only has OWNER, EDITOR, VIEWER (no MEMBER). Updated tests
to use EDITOR role for non-owner test cases and added invited_by_id
for invite creation.

Co-authored-by: Sanja Malovic <[email protected]>
…e-tests-eb83

test: add pricing flow integration tests and prevent duplicate subscriptions
@unjica
unjica merged commit 8d40dce into main Oct 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants