Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .changeset/enterprise-sso-isolate-runs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
17 changes: 13 additions & 4 deletions integration/tests/tanstack-start/enterprise-sso.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { randomBytes } from 'node:crypto';

import type { EnterpriseConnection } from '@clerk/backend';
import { expect, test } from '@playwright/test';

Expand Down Expand Up @@ -36,14 +38,17 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEnterpriseSso] })(
({ app }) => {
test.describe.configure({ mode: 'serial' });

const testDomain = 'e2e-enterprise-test.dev';
// Per-run suffix so a failed afterAll on a previous run can't brick the shared
// long-running instance with a duplicate-domain 422 on the next run.
const runId = randomBytes(4).toString('hex');
const testDomain = `e2e-enterprise-test-${runId}.dev`;
const fakeIdpHost = `fake-idp.${testDomain}`;
let enterpriseConnection: EnterpriseConnection;
let enterpriseConnection: EnterpriseConnection | undefined;

test.beforeAll(async () => {
const u = createTestUtils({ app });
enterpriseConnection = await createActiveEnterpriseConnection(u.services.clerk, {
name: 'E2E Test SAML Connection',
name: `E2E Test SAML Connection ${runId}`,
domain: testDomain,
idpEntityId: `https://${fakeIdpHost}`,
idpSsoUrl: `https://${fakeIdpHost}/sso`,
Expand All @@ -52,7 +57,11 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEnterpriseSso] })(

test.afterAll(async () => {
const u = createTestUtils({ app });
await u.services.clerk.enterpriseConnections.deleteEnterpriseConnection(enterpriseConnection.id);
// Guard against a failed beforeAll: without this, the TypeError here masks
// the real error from beforeAll in the Playwright report.
if (enterpriseConnection) {
await u.services.clerk.enterpriseConnections.deleteEnterpriseConnection(enterpriseConnection.id);
}
await app.teardown();
});

Expand Down
Loading