From c2dce85be9698b012a78cfe9005e68b578c63fe9 Mon Sep 17 00:00:00 2001 From: Laura Beatris <48022589+LauraBeatris@users.noreply.github.com> Date: Fri, 25 Jul 2025 20:33:53 -0300 Subject: [PATCH 1/3] Add E2E tests for flow with `TaskSelectOrganization` --- .../tests/session-tasks-eject-flow.test.ts | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 integration/tests/session-tasks-eject-flow.test.ts diff --git a/integration/tests/session-tasks-eject-flow.test.ts b/integration/tests/session-tasks-eject-flow.test.ts new file mode 100644 index 00000000000..ad5e8241973 --- /dev/null +++ b/integration/tests/session-tasks-eject-flow.test.ts @@ -0,0 +1,108 @@ +import { test } from '@playwright/test'; + +import type { Application } from '../models/application'; +import { appConfigs } from '../presets'; +import type { FakeUser } from '../testUtils'; +import { createTestUtils } from '../testUtils'; + +test.describe('session tasks eject flow @nextjs', () => { + test.describe.configure({ mode: 'serial' }); + let app: Application; + let user: FakeUser; + + test.beforeAll(async () => { + app = await appConfigs.next.appRouter + .clone() + .addFile( + 'src/app/provider.tsx', + () => `'use client' +import { ClerkProvider } from "@clerk/nextjs"; + +export function Provider({ children }: { children: any }) { +return ( + + {children} + +) +}`, + ) + .addFile( + 'src/app/layout.tsx', + () => `import './globals.css'; +import { Inter } from 'next/font/google'; +import { Provider } from './provider'; + +const inter = Inter({ subsets: ['latin'] }); + +export const metadata = { +title: 'Create Next App', +description: 'Generated by create next app', +}; + +export default function RootLayout({ children }: { children: React.ReactNode }) { +return ( + + + {children} + + +); +}`, + ) + .addFile( + 'src/app/onboarding/select-organization/page.tsx', + () => ` +import { TaskSelectOrganization } from '@clerk/nextjs'; + +export default function Page() { +return ( + +); +}`, + ) + .commit(); + + await app.setup(); + await app.withEnv(appConfigs.envs.withSessionTasks); + await app.dev(); + + const u = createTestUtils({ app }); + user = u.services.users.createFakeUser(); + await u.services.users.createBapiUser(user); + }); + + test.afterAll(async () => { + const u = createTestUtils({ app }); + await user.deleteIfExists(); + await u.services.organizations.deleteAll(); + await app.teardown(); + }); + + test.afterEach(async ({ page, context }) => { + const u = createTestUtils({ app, page, context }); + await u.page.signOut(); + await u.page.context().clearCookies(); + }); + + test('redirects to completion page after resolving task', async ({ page, context }) => { + const u = createTestUtils({ app, page, context }); + + // Performs sign-in + await u.po.signIn.goTo(); + await u.po.signIn.setIdentifier(user.email); + await u.po.signIn.continue(); + await u.po.signIn.setPassword(user.password); + await u.po.signIn.continue(); + await u.po.expect.toBeSignedIn(); + + // Complete the organization selection task + const fakeOrganization = Object.assign(u.services.organizations.createFakeOrganization(), { + slug: u.services.organizations.createFakeOrganization().slug + '-eject-flow', + }); + await u.po.sessionTask.resolveForceOrganizationSelectionTask(fakeOrganization); + await u.po.expect.toHaveResolvedTask(); + + // Verify redirect to completion page + await u.page.waitForAppUrl('/'); + }); +}); From 7926a1e739593df59c7fbd0988f1a351c0395fc1 Mon Sep 17 00:00:00 2001 From: Laura Beatris <48022589+LauraBeatris@users.noreply.github.com> Date: Sat, 26 Jul 2025 16:12:41 -0300 Subject: [PATCH 2/3] Add empty changeset --- .changeset/lovely-buttons-say.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changeset/lovely-buttons-say.md diff --git a/.changeset/lovely-buttons-say.md b/.changeset/lovely-buttons-say.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/lovely-buttons-say.md @@ -0,0 +1,2 @@ +--- +--- From 7eabde0b6d8b5b3003d7884dfec440c2d909959f Mon Sep 17 00:00:00 2001 From: Laura Beatris <48022589+LauraBeatris@users.noreply.github.com> Date: Sat, 26 Jul 2025 16:39:36 -0300 Subject: [PATCH 3/3] Add assertion for `taskUrls` --- integration/tests/session-tasks-eject-flow.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/integration/tests/session-tasks-eject-flow.test.ts b/integration/tests/session-tasks-eject-flow.test.ts index ad5e8241973..964a75b0eb2 100644 --- a/integration/tests/session-tasks-eject-flow.test.ts +++ b/integration/tests/session-tasks-eject-flow.test.ts @@ -96,6 +96,7 @@ return ( await u.po.expect.toBeSignedIn(); // Complete the organization selection task + await u.page.waitForAppUrl('/onboarding/select-organization'); const fakeOrganization = Object.assign(u.services.organizations.createFakeOrganization(), { slug: u.services.organizations.createFakeOrganization().slug + '-eject-flow', });