File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 - cli
1414 - stripe
1515 - polar
16- schedule :
17- - cron : " 0 6 * * *"
1816
1917permissions : {}
2018
Original file line number Diff line number Diff line change @@ -22,9 +22,10 @@ describe.skipIf(harness.id !== "stripe")(
2222 let t : TestPayKit ;
2323 let customerId : string ;
2424 let providerSubscriptionId : string ;
25- const stripeClient = new Stripe ( env . E2E_STRIPE_SK ! , { maxNetworkRetries : 3 } ) ;
25+ let stripeClient : Stripe ;
2626
2727 beforeAll ( async ( ) => {
28+ stripeClient = new Stripe ( env . E2E_STRIPE_SK ! , { maxNetworkRetries : 3 } ) ;
2829 t = await createTestPayKit ( ) ;
2930 const customer = await createTestCustomerWithPM ( {
3031 t,
Original file line number Diff line number Diff line change @@ -57,6 +57,17 @@ export interface CapturedWebhookRequest {
5757const activeSubscriptionStatuses = [ "active" , "trialing" , "past_due" ] as const ;
5858const presentSubscriptionStatuses = [ ...activeSubscriptionStatuses , "scheduled" ] as const ;
5959
60+ function buildUniqueTestEmail ( input : { email : string ; suffix : string } ) : string {
61+ const [ localPart , domain = "" ] = input . email . split ( "@" ) ;
62+ if ( ! localPart || ! domain ) {
63+ throw new Error ( `Invalid test email: ${ input . email } ` ) ;
64+ }
65+
66+ const uniqueLocalPart = `${ localPart } +${ input . suffix } ` ;
67+
68+ return `${ uniqueLocalPart } @e2e.paykit.sh` ;
69+ }
70+
6071export async function createTestPayKit ( ) : Promise < TestPayKit > {
6172 harness . validateEnv ( ) ;
6273
@@ -143,7 +154,10 @@ export async function createTestCustomer(input: {
143154} ) : Promise < { customerId : string ; providerCustomerId : string } > {
144155 const suffix = `${ Date . now ( ) } _${ Math . random ( ) . toString ( 36 ) . slice ( 2 , 8 ) } ` ;
145156 const uniqueId = `${ input . customer . id } _${ suffix } ` ;
146- const uniqueEmail = input . customer . email . replace ( "@" , `+${ suffix } @` ) ;
157+ const uniqueEmail = buildUniqueTestEmail ( {
158+ email : input . customer . email ,
159+ suffix,
160+ } ) ;
147161
148162 await input . t . paykit . upsertCustomer ( {
149163 ...input . customer ,
Original file line number Diff line number Diff line change 11import { defineConfig } from "vitest/config" ;
22
3+ const provider = process . env . PROVIDER ;
4+ const isPolar = provider === "polar" ;
5+
36export default defineConfig ( {
47 test : {
58 // Cap parallel workers — Stripe test mode rate-limits at 25 ops/sec; too many
69 // workers starting syncProducts simultaneously trips it. Paired with Stripe
710 // SDK maxNetworkRetries for headroom.
8- maxWorkers : 6 ,
11+ maxWorkers : isPolar ? 1 : 6 ,
912 projects : [
1013 {
1114 test : {
@@ -14,6 +17,7 @@ export default defineConfig({
1417 globalSetup : [ "./test-utils/hub.ts" ] ,
1518 hookTimeout : 180_000 ,
1619 include : [ "core/**/*.test.ts" ] ,
20+ sequence : isPolar ? { concurrent : false } : undefined ,
1721 testTimeout : 600_000 ,
1822 } ,
1923 } ,
You can’t perform that action at this time.
0 commit comments