From 264ac40bcba574583c313ccc31c32e55941cb7ed Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 06:29:34 -0800 Subject: [PATCH] fix(billing): e2e keeps each org's Stripe email (customer lookup), trial check uses it --- cloud/apps/billing/scripts/e2e-test-mode.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloud/apps/billing/scripts/e2e-test-mode.ts b/cloud/apps/billing/scripts/e2e-test-mode.ts index e39e8379868..e4745be6469 100644 --- a/cloud/apps/billing/scripts/e2e-test-mode.ts +++ b/cloud/apps/billing/scripts/e2e-test-mode.ts @@ -70,7 +70,7 @@ const ids: Record = {} async function token(org: string, user = `user_${org}`): Promise { const now = Math.floor(Date.now() / 1000) - return new SignJWT({ sub: user, org, orgRole: 'owner', email: `e2e+${user}@example.com`, purpose: 'billing' }) + return new SignJWT({ sub: user, org, orgRole: 'owner', email: `e2e+${user === `user_${org}` ? org : user}@example.com`, purpose: 'billing' }) .setProtectedHeader({ alg: 'ES256', kid: jwk.kid }) .setIssuer(issuer) .setAudience('orca-billing') @@ -487,7 +487,7 @@ const grantedT = await billing('POST', '/v1/billing/trial', orgT) check('trial granted with no card: status trial, can start, 1 sandbox at a time, no overage', grantedT.status === 200 && grantedT.body.status === 'trial' && grantedT.body.canStartSandbox === true && grantedT.body.limits?.maxConcurrentSandboxes === 1 && grantedT.body.trial?.includedSeconds === 2 * HOUR && grantedT.body.overage?.active === false, grantedT) -const trialCustomers = await stripe<{ data: Array<{ metadata: Record }> }>('GET', '/v1/customers', { email: `e2e+user_${orgT}@example.com`, limit: 10 }) +const trialCustomers = await stripe<{ data: Array<{ metadata: Record }> }>('GET', '/v1/customers', { email: `e2e+${orgT}@example.com`, limit: 10 }) check('trial created nothing in Stripe (no customer)', trialCustomers.data.length === 0, trialCustomers.data.length) const secondRunning = await billing('POST', '/v1/internal/entitlements/check', null, { accountId: accountT, machineSize: 'standard', runningSandboxes: 1 }).then((r) => r.body) check('trial runs 1 sandbox at a time (concurrency_limit)', secondRunning.allow === false && secondRunning.reason === 'concurrency_limit', secondRunning)