Skip to content

Commit b04e0ad

Browse files
authored
Merge pull request #157 from getpaykit/feat/ci-tests
test(e2e): expand CI workflows and provider coverage
2 parents babe221 + daa984a commit b04e0ad

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

.github/workflows/e2e.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ on:
1313
- cli
1414
- stripe
1515
- polar
16-
schedule:
17-
- cron: "0 6 * * *"
1816

1917
permissions: {}
2018

e2e/core/webhook/subscription-deleted.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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,

e2e/test-utils/setup.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ export interface CapturedWebhookRequest {
5757
const activeSubscriptionStatuses = ["active", "trialing", "past_due"] as const;
5858
const 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+
6071
export 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,

e2e/vitest.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { defineConfig } from "vitest/config";
22

3+
const provider = process.env.PROVIDER;
4+
const isPolar = provider === "polar";
5+
36
export 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
},

0 commit comments

Comments
 (0)