Skip to content

Commit

Permalink
Adds fallback to integration test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
BRKalow committed Dec 17, 2024
1 parent 044001a commit 2853620
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion integration/templates/next-app-router/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ClientId } from './client-id';
export default function Home() {
return (
<main>
<UserButton />
<UserButton fallback={<>Loading user button</>} />
<ClientId />
<SignedIn>SignedIn</SignedIn>
<SignedOut>SignedOut</SignedOut>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default function Page() {
routing={'path'}
path={'/sign-up'}
signInUrl={'/sign-in'}
fallback={<>Loading sign up</>}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { OrganizationSwitcher } from '@clerk/nextjs';

export default function Page() {
return <OrganizationSwitcher hidePersonal={true} />;
return (
<OrganizationSwitcher
hidePersonal={true}
fallback={<>Loading organization switcher</>}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UserProfile } from '@clerk/nextjs';
export default function Page() {
return (
<div>
<UserProfile />
<UserProfile fallback={<>Loading user profile</>} />
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Page1() {
export default function Page() {
return (
<PageContextProvider>
<UserButton>
<UserButton fallback={<>Loading user button</>}>
<UserButton.UserProfilePage
label={'Page 1'}
labelIcon={<p data-label-icon={'page-1'}>🙃</p>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ function Page1() {
export default function Page() {
return (
<PageContextProvider>
<UserProfile path={'/custom-user-profile'}>
<UserProfile
fallback={<>Loading user profile</>}
path={'/custom-user-profile'}
>
<UserProfile.Page
label={'Page 1'}
labelIcon={<p data-label-icon={'page-1'}>🙃</p>}
Expand Down
1 change: 1 addition & 0 deletions integration/templates/react-vite/src/sign-up/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default function Page() {
<SignUp
path={'/sign-up'}
signInUrl={'/sign-in'}
fallback={<>Loading sign up</>}
/>
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion integration/templates/react-vite/src/user/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { UserProfile } from '@clerk/clerk-react';
export default function Page() {
return (
<div>
<UserProfile path={'/user'} />
<UserProfile
path={'/user'}
fallback={<>Loading user profile</>}
/>
</div>
);
}
6 changes: 6 additions & 0 deletions integration/tests/sign-up-flow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })('sign up f
await app.teardown();
});

test('sign up supports fallback', async ({ page, context }) => {
const u = createTestUtils({ app, page, context });
await u.page.goToRelative('/sign-up');
await expect(u.page.getByText('Loading sign up')).toBeVisible();
});

test('sign up with email and password', async ({ page, context }) => {
const u = createTestUtils({ app, page, context });
const fakeUser = u.services.users.createFakeUser({
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/uiComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
WaitlistProps,
Without,
} from '@clerk/types';
import type { PropsWithChildren, ReactElement } from 'react';
import type { PropsWithChildren, ReactNode } from 'react';
import React, { createContext, createElement, useContext } from 'react';

import {
Expand Down Expand Up @@ -49,7 +49,7 @@ type FallbackProp = {
/**
* An optional element to render while the component is mounting.
*/
fallback?: ReactElement;
fallback?: ReactNode;
};

type UserProfileExportType = typeof _UserProfile & {
Expand Down

0 comments on commit 2853620

Please sign in to comment.