Skip to content

Commit

Permalink
get library mode working
Browse files Browse the repository at this point in the history
  • Loading branch information
LekoArts committed Dec 18, 2024
1 parent c10c094 commit 28d5959
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 7 deletions.
7 changes: 2 additions & 5 deletions integration/templates/react-router-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
60 changes: 59 additions & 1 deletion integration/tests/react-router/library-mode.test.ts
Original file line number Diff line number Diff line change
@@ -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]);
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 28d5959

Please sign in to comment.