From 2afacfe1aa3a00ed3087b01d830fa54348b52402 Mon Sep 17 00:00:00 2001 From: Dylan Staley <88163+dstaley@users.noreply.github.com> Date: Thu, 1 May 2025 10:26:35 -0700 Subject: [PATCH 1/4] experiment(e2e): Use Turbopack in Next.js app router e2e --- integration/templates/next-app-router/next.config.js | 1 + integration/templates/next-app-router/package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/integration/templates/next-app-router/next.config.js b/integration/templates/next-app-router/next.config.js index 35b183b6064..4b01655c99d 100644 --- a/integration/templates/next-app-router/next.config.js +++ b/integration/templates/next-app-router/next.config.js @@ -6,6 +6,7 @@ const nextConfig = { experimental: { serverActions: true, }, + outputFileTracingRoot: '/', }; module.exports = nextConfig; diff --git a/integration/templates/next-app-router/package.json b/integration/templates/next-app-router/package.json index c574d569ce3..a333650f839 100644 --- a/integration/templates/next-app-router/package.json +++ b/integration/templates/next-app-router/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "build": "next build", - "dev": "next dev", + "dev": "next dev --turbo", "lint": "next lint", "start": "next start" }, From 2ff4ffb27bac6452c576718f138cd0bd4e8e6b01 Mon Sep 17 00:00:00 2001 From: Dylan Staley <88163+dstaley@users.noreply.github.com> Date: Thu, 1 May 2025 11:55:28 -0700 Subject: [PATCH 2/4] fix(testing): Update signInWithEmailAndInstantPassword to wait for session --- .changeset/funny-hotels-stand.md | 5 +++++ .../playwright/unstable/page-objects/common.ts | 5 +++++ .../playwright/unstable/page-objects/signIn.ts | 18 +++++++++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 .changeset/funny-hotels-stand.md diff --git a/.changeset/funny-hotels-stand.md b/.changeset/funny-hotels-stand.md new file mode 100644 index 00000000000..6e1e292b14a --- /dev/null +++ b/.changeset/funny-hotels-stand.md @@ -0,0 +1,5 @@ +--- +'@clerk/testing': patch +--- + +Update `signInWithEmailAndInstantPassword` to wait for session by default. diff --git a/packages/testing/src/playwright/unstable/page-objects/common.ts b/packages/testing/src/playwright/unstable/page-objects/common.ts index 618a0957db4..af562c94b8b 100644 --- a/packages/testing/src/playwright/unstable/page-objects/common.ts +++ b/packages/testing/src/playwright/unstable/page-objects/common.ts @@ -51,6 +51,11 @@ export const common = ({ page }: { page: EnhancedPage }) => { getLastNameInput: () => { return page.locator('input[name=lastName]'); }, + waitForSession: async () => { + return page.waitForFunction(() => { + return !!window.Clerk?.session; + }); + }, }; return self; diff --git a/packages/testing/src/playwright/unstable/page-objects/signIn.ts b/packages/testing/src/playwright/unstable/page-objects/signIn.ts index 3196aab6785..38b05df6282 100644 --- a/packages/testing/src/playwright/unstable/page-objects/signIn.ts +++ b/packages/testing/src/playwright/unstable/page-objects/signIn.ts @@ -63,13 +63,25 @@ export const createSignInComponentPageObject = (testArgs: { page: EnhancedPage } signInWithOauth: (provider: string) => { return page.getByRole('button', { name: new RegExp(`continue with ${provider}`, 'gi') }); }, - signInWithEmailAndInstantPassword: async (opts: { email: string; password: string }) => { + signInWithEmailAndInstantPassword: async ({ + email, + password, + waitForSession = true, + }: { + email: string; + password: string; + waitForSession?: boolean; + }) => { const identifierField = self.getIdentifierInput(); await expect(identifierField).toBeVisible(); - await identifierField.fill(opts.email); - await self.setInstantPassword(opts.password); + await identifierField.fill(email); + await self.setInstantPassword(password); await self.continue(); + + if (waitForSession) { + await self.waitForSession(); + } }, }; return self; From 6656cad2795ded7b81d75f55506ca8f4f2bde314 Mon Sep 17 00:00:00 2001 From: Dylan Staley <88163+dstaley@users.noreply.github.com> Date: Thu, 1 May 2025 12:07:14 -0700 Subject: [PATCH 3/4] fix(e2e): Use webpack with next v13 --- integration/presets/next.ts | 2 +- integration/templates/next-app-router/package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/integration/presets/next.ts b/integration/presets/next.ts index a44dc9c6e1e..e2397d2a236 100644 --- a/integration/presets/next.ts +++ b/integration/presets/next.ts @@ -8,7 +8,7 @@ const appRouter = applicationConfig() .useTemplate(templates['next-app-router']) .setEnvFormatter('public', key => `NEXT_PUBLIC_${key}`) .addScript('setup', constants.E2E_NPM_FORCE ? 'pnpm install --force' : 'pnpm install') - .addScript('dev', 'pnpm dev') + .addScript('dev', constants.E2E_NEXTJS_VERSION === '13' ? 'pnpm dev:webpack' : 'pnpm dev') .addScript('build', 'pnpm build') .addScript('serve', 'pnpm start') .addDependency('next', constants.E2E_NEXTJS_VERSION) diff --git a/integration/templates/next-app-router/package.json b/integration/templates/next-app-router/package.json index a333650f839..285fb5d7d0d 100644 --- a/integration/templates/next-app-router/package.json +++ b/integration/templates/next-app-router/package.json @@ -5,6 +5,7 @@ "scripts": { "build": "next build", "dev": "next dev --turbo", + "dev:webpack": "next dev", "lint": "next lint", "start": "next start" }, From c36090104765335cbcc161608c897fd24708cc98 Mon Sep 17 00:00:00 2001 From: Dylan Staley <88163+dstaley@users.noreply.github.com> Date: Thu, 1 May 2025 12:35:18 -0700 Subject: [PATCH 4/4] fix(e2e): Don't wait for session --- integration/tests/next-account-portal/common.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/integration/tests/next-account-portal/common.ts b/integration/tests/next-account-portal/common.ts index 9ce7dad1589..2cdf16a397d 100644 --- a/integration/tests/next-account-portal/common.ts +++ b/integration/tests/next-account-portal/common.ts @@ -159,8 +159,12 @@ export const testSSR = async ({ app, page, context, fakeUser }: TestParams) => { await u.page.getByRole('button', { name: /Sign in/i }).click(); await u.po.signIn.waitForMounted(); - // Sign in with email and password - await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password }); + // Sign in with email and password. If we wait for the session, we will miss the initial redirect back to localhost. + await u.po.signIn.signInWithEmailAndInstantPassword({ + email: fakeUser.email, + password: fakeUser.password, + waitForSession: false, + }); // Navigate back to localhost const response = await page.waitForResponse(