Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions browser_tests/fixtures/helpers/LiveCloudBilling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ export class LiveCloudCheckout {
return subscription.billing_op_id
}

async completeCheckout(session: LiveCloudBillingSession, testInfo: TestInfo) {
async completeCheckout(
session: LiveCloudBillingSession,
testInfo: TestInfo,
expectedPaymentMethodCount = 1
) {
const balanceBefore = await session.read(
'/api/billing/balance',
zBillingBalanceResponse
Expand All @@ -236,7 +240,8 @@ export class LiveCloudCheckout {
balanceBefore.amount_micros,
preview,
subscription.billing_op_id,
'checkout-completed.png'
'checkout-completed.png',
expectedPaymentMethodCount
)
}

Expand Down Expand Up @@ -318,7 +323,8 @@ export class LiveCloudCheckout {
'/api/billing/status',
zBillingStatusResponse
)
expect(status.subscription_tier).toBe('FREE')
expect(status.is_active).toBe(false)
expect([undefined, 'FREE']).toContain(status.subscription_tier)
const balanceAfter = await session.read(
'/api/billing/balance',
zBillingBalanceResponse
Expand Down Expand Up @@ -619,7 +625,8 @@ export class LiveCloudCheckout {
balanceBeforeCents: number,
preview: ReturnType<typeof zPreviewSubscribeResponse.parse>,
operationId: string,
screenshotName: string
screenshotName: string,
expectedPaymentMethodCount = 1
) {
await expect
.poll(
Expand Down Expand Up @@ -657,7 +664,7 @@ export class LiveCloudCheckout {
'/api/billing/payment-methods',
zListSavedPaymentMethodsResponse
)
expect(methods).toHaveLength(1)
expect(methods).toHaveLength(expectedPaymentMethodCount)
await testInfo.attach('checkout-completion.json', {
body: JSON.stringify({
operationId,
Expand Down
2 changes: 1 addition & 1 deletion browser_tests/playwrightSelection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Live billing opt-in', () => {
{ enabled: '0', project: 'cloud-live', count: 0 },
{ enabled: '1', project: 'cloud-live', count: 3 },
{ enabled: '1', project: 'cloud-live-paid', count: 2 },
{ enabled: '1', project: 'cloud-live-disposable', count: 6 }
{ enabled: '1', project: 'cloud-live-disposable', count: 7 }
])(
'collects $project only when explicitly enabled ($enabled)',
{ timeout: 90_000 },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
expect,
liveCloudDisposableBillingFixture as test
} from '@e2e/fixtures/liveCloudDisposableBillingFixture'

test.describe('Real Cloud checkout recovery', { tag: ['@cloud-live'] }, () => {
test.setTimeout(240_000)

test('completes checkout after a card decline', async ({
disposableCheckout
}, testInfo) => {
await disposableCheckout.checkout.declineCheckout(
disposableCheckout.billingSession,
testInfo
)
const completion = await disposableCheckout.checkout.completeCheckout(
disposableCheckout.billingSession,
testInfo,
2
)
expect(completion).toMatchObject({
planSlug: 'creator-monthly',
paymentMethodCount: 2
})
})
})
Loading