Skip to content

Commit b10ec6c

Browse files
committed
Expand component test suite
1 parent f77669d commit b10ec6c

File tree

13 files changed

+138
-7
lines changed

13 files changed

+138
-7
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { CreateOrganization } from '@clerk/nextjs';
2+
3+
export default function Page() {
4+
return (
5+
<div>
6+
<CreateOrganization fallback={<>Loading create organization</>} />
7+
</div>
8+
);
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { OrganizationList } from '@clerk/nextjs';
2+
3+
export default function Page() {
4+
return (
5+
<div>
6+
<OrganizationList fallback={<>Loading organization list</>} />
7+
</div>
8+
);
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { OrganizationProfile } from '@clerk/nextjs';
2+
3+
export default function Page() {
4+
return (
5+
<div>
6+
<OrganizationProfile
7+
routing='hash'
8+
fallback={<>Loading organization profile</>}
9+
/>
10+
</div>
11+
);
12+
}

integration/templates/next-app-router/src/app/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { SignedIn, SignedOut, SignIn, UserButton, Protect } from '@clerk/nextjs';
1+
import { SignedIn, SignedOut, SignIn, UserButton, Protect, OrganizationSwitcher } from '@clerk/nextjs';
22
import Link from 'next/link';
33
import { ClientId } from './client-id';
44

55
export default function Home() {
66
return (
77
<main>
88
<UserButton fallback={<>Loading user button</>} />
9+
<OrganizationSwitcher fallback={<>Loading organization switcher</>} />
910
<ClientId />
1011
<SignedIn>SignedIn</SignedIn>
1112
<SignedOut>SignedOut</SignedOut>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Waitlist } from '@clerk/nextjs';
2+
3+
export default function Page() {
4+
return (
5+
<div>
6+
<Waitlist fallback={<>Loading waitlist</>} />
7+
</div>
8+
);
9+
}

integration/templates/react-vite/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function App() {
66
return (
77
<main>
88
<UserButton afterSignOutUrl={'/'} />
9-
<OrganizationSwitcher />
9+
<OrganizationSwitcher fallback={<>Loading organization switcher</>} />
1010
<ClientId />
1111
<SignedOut>SignedOut</SignedOut>
1212
<SignedIn>SignedIn</SignedIn>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { CreateOrganization } from '@clerk/clerk-react';
2+
3+
export default function Page() {
4+
return (
5+
<div>
6+
<CreateOrganization fallback={<>Loading create organization</>} />
7+
</div>
8+
);
9+
}

integration/templates/react-vite/src/main.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import UserProfileCustom from './custom-user-profile';
1212
import UserButtonCustom from './custom-user-button';
1313
import UserButtonCustomTrigger from './custom-user-button-trigger';
1414
import UserButton from './user-button';
15+
import Waitlist from './waitlist';
16+
import OrganizationProfile from './organization-profile';
17+
import OrganizationList from './organization-list';
18+
import CreateOrganization from './create-organization';
1519

1620
const Root = () => {
1721
const navigate = useNavigate();
@@ -74,6 +78,22 @@ const router = createBrowserRouter([
7478
path: '/custom-user-button-trigger',
7579
element: <UserButtonCustomTrigger />,
7680
},
81+
{
82+
path: '/waitlist',
83+
element: <Waitlist />,
84+
},
85+
{
86+
path: '/organization-profile',
87+
element: <OrganizationProfile />,
88+
},
89+
{
90+
path: '/organization-list',
91+
element: <OrganizationList />,
92+
},
93+
{
94+
path: '/create-organization',
95+
element: <CreateOrganization />,
96+
},
7797
],
7898
},
7999
]);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { OrganizationList } from '@clerk/clerk-react';
2+
3+
export default function Page() {
4+
return (
5+
<div>
6+
<OrganizationList fallback={<>Loading organization list</>} />
7+
</div>
8+
);
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { OrganizationProfile } from '@clerk/clerk-react';
2+
3+
export default function Page() {
4+
return (
5+
<div>
6+
<OrganizationProfile
7+
routing='hash'
8+
fallback={<>Loading organization profile</>}
9+
/>
10+
</div>
11+
);
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Waitlist } from '@clerk/clerk-react';
2+
3+
export default function Page() {
4+
return (
5+
<div>
6+
<Waitlist fallback={<>Loading waitlist</>} />
7+
</div>
8+
);
9+
}

integration/testUtils/appPageObject.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const createAppPageObject = (testArgs: { page: Page }, app: Application)
1313
// do not fail the test if interstitial is returned (401)
1414
}
1515
},
16-
goToRelative: (path: string, opts: { searchParams?: URLSearchParams; timeout?: number } = {}) => {
16+
goToRelative: (path: string, opts: { waitUntil?: any; searchParams?: URLSearchParams; timeout?: number } = {}) => {
1717
let url: URL;
1818

1919
try {
@@ -35,7 +35,7 @@ export const createAppPageObject = (testArgs: { page: Page }, app: Application)
3535
if (opts.searchParams) {
3636
url.search = opts.searchParams.toString();
3737
}
38-
return page.goto(url.toString(), { timeout: opts.timeout ?? 20000 });
38+
return page.goto(url.toString(), { timeout: opts.timeout ?? 20000, waitUntil: opts.waitUntil });
3939
},
4040
waitForClerkJsLoaded: async () => {
4141
return page.waitForFunction(() => {

integration/tests/components.test.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
import { expect, test } from '@playwright/test';
22

33
import { appConfigs } from '../presets';
4-
import type { FakeUser } from '../testUtils';
4+
import type { FakeOrganization, FakeUser } from '../testUtils';
55
import { createTestUtils, testAgainstRunningApps } from '../testUtils';
66

77
testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })('component smoke tests @generic', ({ app }) => {
88
let fakeUser: FakeUser;
9+
let fakeOrganization: FakeOrganization;
910

1011
test.beforeAll(async () => {
1112
const u = createTestUtils({ app });
1213
fakeUser = u.services.users.createFakeUser({
1314
withPhoneNumber: true,
1415
withUsername: true,
1516
});
16-
await u.services.users.createBapiUser(fakeUser);
17+
const user = await u.services.users.createBapiUser(fakeUser);
18+
fakeOrganization = await u.services.users.createFakeOrganization(user.id);
1719
});
1820

1921
test.afterAll(async () => {
2022
await app.teardown();
2123
await fakeUser.deleteIfExists();
24+
await fakeOrganization.delete();
2225
});
2326

2427
const components = [
@@ -44,6 +47,35 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })('component
4447
protected: true,
4548
fallback: 'Loading user button',
4649
},
50+
{
51+
name: 'Waitlist',
52+
path: '/waitlist',
53+
fallback: 'Loading waitlist',
54+
},
55+
{
56+
name: 'OrganizationSwitcher',
57+
path: '/',
58+
fallback: 'Loading organization switcher',
59+
protected: true,
60+
},
61+
{
62+
name: 'OrganizationProfile',
63+
path: '/organization-profile',
64+
fallback: 'Loading organization profile',
65+
protected: true,
66+
},
67+
{
68+
name: 'OrganizationList',
69+
path: '/organization-list',
70+
fallback: 'Loading organization list',
71+
protected: true,
72+
},
73+
{
74+
name: 'CreateOrganization',
75+
path: '/create-organization',
76+
fallback: 'Loading create organization',
77+
protected: true,
78+
},
4779
];
4880

4981
const signIn = async ({ app, page, context }) => {
@@ -68,7 +100,7 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })('component
68100
}
69101

70102
const u = createTestUtils({ app, page, context });
71-
await u.page.goToRelative(component.path);
103+
await u.page.goToRelative(component.path, { waitUntil: 'commit' });
72104
await expect(u.page.getByText(component.fallback)).toBeVisible();
73105

74106
await signOut({ app, page, context });

0 commit comments

Comments
 (0)