diff --git a/knip.json b/knip.json index d1163be75..d3f560166 100644 --- a/knip.json +++ b/knip.json @@ -11,6 +11,7 @@ "enumMembers", "duplicates" ], + "ignore": ["ai/**"], "ignoreWorkspaces": [ "packages/atmn", "packages/autumn-js", diff --git a/package.json b/package.json index bba7cf07f..737dcd053 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,7 @@ "setup": "node scripts/setup/setup.js", "setup:s3-admin": "bun scripts/setup/setupS3Admin.ts", "setup:test": "infisical run --env=dev --recursive -- bun scripts/setup/setup-test.ts", + "stripe:link-test": "ENV_FILE=.env infisical run --env=dev --recursive -- bun scripts/setup/link-test-stripe-account.ts", "agent:bootstrap": "bash scripts/setup/agent-bootstrap.sh", "dev:agent": "bash scripts/setup/devAgent.sh", "migrate-functions": "infisical run --env=dev --recursive -- bun scripts/migrations/migrate-functions.ts", diff --git a/scripts/setup/STRIPE_TEST_OAUTH.md b/scripts/setup/STRIPE_TEST_OAUTH.md new file mode 100644 index 000000000..5d90110f9 --- /dev/null +++ b/scripts/setup/STRIPE_TEST_OAUTH.md @@ -0,0 +1,47 @@ +# Stripe Test OAuth Linking + +Use this when local tests say the test org has no linked Stripe account, or when Stripe Connect webhooks are visible in Stripe but Autumn cannot map events back to `unit-test-org`. + +The Connect webhook destination should be: + +```txt +https://c.autumn.ngrok.app/webhooks/connect/sandbox +``` + +OAuth still needs the Autumn org row to store the connected account ID: + +```json +{ "test_stripe_connect": { "account_id": "acct_..." } } +``` + +## Commands + +List recent connected accounts for the test org email: + +```sh +bun stripe:link-test -- --list --email=unit-test-org@test.com +``` + +Link an explicit account: + +```sh +bun stripe:link-test -- --account-id=acct_... +``` + +Link the newest account matching the test org email: + +```sh +bun stripe:link-test -- --latest --email=unit-test-org@test.com +``` + +If the org has a direct Stripe secret key, `createStripeCli` will prefer that over OAuth Connect. To force the OAuth account for sandbox tests: + +```sh +bun stripe:link-test -- --account-id=acct_... --clear-secret-key +``` + +After linking, rerun a focused checkout test before the full suite: + +```sh +ENV_FILE=.env infisical run --env=dev --recursive -- bun test --timeout 0 server/tests/integration/billing/attach/checkout/stripe-checkout/prepaid/stripe-checkout-prepaid-basic.test.ts +``` diff --git a/server/tests/unit/webhooks/stripe-webhook-early-ack.test.ts b/server/tests/unit/webhooks/stripe-webhook-early-ack.test.ts index 929d56f59..22c4955c8 100644 --- a/server/tests/unit/webhooks/stripe-webhook-early-ack.test.ts +++ b/server/tests/unit/webhooks/stripe-webhook-early-ack.test.ts @@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test"; import { Hono } from "hono"; import { stripeWebhookEarlyAckMiddleware } from "@/external/stripe/webhookMiddlewares/stripeWebhookEarlyAckMiddleware"; -const wait = (ms = 0) => new Promise((resolve) => setTimeout(resolve, ms)); +const waitForImmediate = () => new Promise((resolve) => setImmediate(resolve)); const createApp = () => { const app = new Hono(); @@ -72,7 +72,7 @@ describe("stripeWebhookEarlyAckMiddleware", () => { expect(processed).toBe(false); resolveProcessing(); - await wait(5); + await waitForImmediate(); expect(processed).toBe(true); }); @@ -91,7 +91,7 @@ describe("stripeWebhookEarlyAckMiddleware", () => { expect(await response.json()).toEqual({ received: true }); expect(started).toBe(false); - await wait(5); + await waitForImmediate(); expect(started).toBe(true); }); });