diff --git a/integration/templates/react-router-library/package.json b/integration/templates/react-router-library/package.json index 68fa32f107..28970a47e3 100644 --- a/integration/templates/react-router-library/package.json +++ b/integration/templates/react-router-library/package.json @@ -5,9 +5,8 @@ "type": "module", "scripts": { "build": "tsc -b && vite build", - "dev": "vite", - "lint": "eslint .", - "preview": "vite preview" + "dev": "vite --port $PORT", + "preview": "vite preview --port $PORT" }, "dependencies": { "@clerk/react-router": "^0.1.2", @@ -16,13 +15,11 @@ "react-router": "^7.0.2" }, "devDependencies": { - "@eslint/js": "^9.15.0", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "@vitejs/plugin-react": "^4.3.4", "globals": "^15.12.0", "typescript": "~5.6.2", - "typescript-eslint": "^8.15.0", "vite": "^6.0.1" } } diff --git a/integration/tests/react-router/library-mode.test.ts b/integration/tests/react-router/library-mode.test.ts index 70b786d12e..6f5af6f63b 100644 --- a/integration/tests/react-router/library-mode.test.ts +++ b/integration/tests/react-router/library-mode.test.ts @@ -1 +1,59 @@ -// TODO +import { test } from '@playwright/test'; + +import type { Application } from '../../models/application'; +import { appConfigs } from '../../presets'; +import type { FakeOrganization, FakeUser } from '../../testUtils'; +import { createTestUtils } from '../../testUtils'; + +test.describe('Library Mode basic tests for @react-router', () => { + test.describe.configure({ mode: 'parallel' }); + let app: Application; + let fakeUser: FakeUser; + let fakeOrganization: FakeOrganization; + + test.beforeAll(async () => { + app = await appConfigs.reactRouter.reactRouterLibrary.commit(); + + await app.setup(); + await app.withEnv(appConfigs.envs.withEmailCodes); + await app.dev(); + + const u = createTestUtils({ app }); + fakeUser = u.services.users.createFakeUser(); + const user = await u.services.users.createBapiUser(fakeUser); + fakeOrganization = await u.services.users.createFakeOrganization(user.id); + }); + + test.afterAll(async () => { + await fakeOrganization.delete(); + await fakeUser.deleteIfExists(); + + await app.teardown(); + }); + + test.afterEach(async ({ page, context }) => { + const u = createTestUtils({ app, page, context }); + await u.page.signOut(); + await u.page.context().clearCookies(); + }); + + test('should log in successfully', async ({ page, context }) => { + const u = createTestUtils({ app, page, context }); + + await u.page.goToAppHome(); + await u.po.expect.toBeSignedOut(); + await u.page.waitForClerkJsLoaded(); + + await u.page.getByRole('button', { name: /Sign in/i }).click(); + await u.po.signIn.waitForMounted(); + await u.po.signIn.signInWithEmailAndInstantPassword({ email: fakeUser.email, password: fakeUser.password }); + + await u.page.waitForAppUrl('/'); + await u.po.expect.toBeSignedIn(); + await u.po.userButton.waitForMounted(); + await u.po.userButton.toggleTrigger(); + await u.po.userButton.waitForPopover(); + + await u.po.userButton.toHaveVisibleMenuItems([/Manage account/i, /Sign out$/i]); + }); +}); diff --git a/package.json b/package.json index bf422c2522..3bfbe08b6d 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "test:integration:nextjs": "E2E_APP_ID=next.appRouter.* pnpm test:integration:base --grep @nextjs", "test:integration:nuxt": "E2E_APP_ID=nuxt.node npm run test:integration:base -- --grep @nuxt", "test:integration:quickstart": "E2E_APP_ID=quickstart.* pnpm test:integration:base --grep @quickstart", - "test:integration:react-router": "E2E_APP_ID=react-router.node npm run test:integration:base -- --grep @react-router", + "test:integration:react-router": "E2E_APP_ID=react-router.* npm run test:integration:base -- --grep @react-router", "test:integration:sessions": "pnpm test:integration:base --grep @sessions", "test:integration:tanstack-router": "E2E_APP_ID=tanstack.router pnpm test:integration:base --grep @tanstack-router", "test:integration:tanstack-start": "E2E_APP_ID=tanstack.start pnpm test:integration:base --grep @tanstack-start",