Skip to content

Commit 44146bc

Browse files
mikepitreclaude
andcommitted
test(expo): add fixture screens for the AuthView logo, an inline profile, and the native modules
The older device tests in integration/tests/expo-native check three things on the fixture's first home that the verify home has no place for: a React Native logo in AuthView, an inline UserProfileView with onHostBack and a custom page, and the Google and biometrics hooks. Each gets a launch screen, so the verify specs can cover them and the home stays the same as on iOS and Android. - authLogo is the home, with a React Native view as the logo of its AuthView. - embeddedProfile is UserProfileView inline with one custom page. The Back button on its root calls onHostBack, which shows the home. - nativeModules holds the two existing buttons for useSignInWithGoogle and useBiometricCredentials. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent d7bc0ac commit 44146bc

6 files changed

Lines changed: 124 additions & 6 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { type AuthViewMode } from '@clerk/expo/native';
2+
import { type ReactElement } from 'react';
3+
import { StyleSheet, Text, View } from 'react-native';
4+
5+
import { Home } from './Home';
6+
7+
export function AuthLogo({ authMode }: { authMode: AuthViewMode }): ReactElement {
8+
return (
9+
<Home
10+
authMode={authMode}
11+
authLogo={
12+
<View
13+
testID='verify.authLogo.logo'
14+
style={styles.logo}
15+
>
16+
<Text style={styles.logoText}>E2E Custom Logo</Text>
17+
</View>
18+
}
19+
/>
20+
);
21+
}
22+
23+
const styles = StyleSheet.create({
24+
logo: {
25+
backgroundColor: '#6C47FF',
26+
borderRadius: 8,
27+
paddingHorizontal: 16,
28+
paddingVertical: 10,
29+
},
30+
logoText: {
31+
color: '#FFFFFF',
32+
fontSize: 16,
33+
fontWeight: '600',
34+
},
35+
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { UserProfileView } from '@clerk/expo/native';
2+
import { type ReactElement } from 'react';
3+
import { StyleSheet, Text, View } from 'react-native';
4+
5+
export function EmbeddedProfile({ onHostBack }: { onHostBack: () => void }): ReactElement {
6+
return (
7+
<UserProfileView
8+
customPages={[
9+
{
10+
path: 'e2e-custom-page',
11+
label: 'E2E Custom Page',
12+
icon: 'key',
13+
placement: { type: 'after', row: 'security' },
14+
content: (
15+
<View
16+
testID='verify.embeddedProfile.customPage'
17+
style={styles.customPage}
18+
>
19+
<Text style={styles.customPageText}>Rehosted RN body</Text>
20+
</View>
21+
),
22+
},
23+
]}
24+
isDismissible={false}
25+
onHostBack={onHostBack}
26+
/>
27+
);
28+
}
29+
30+
const styles = StyleSheet.create({
31+
customPage: {
32+
alignItems: 'center',
33+
flex: 1,
34+
justifyContent: 'center',
35+
padding: 24,
36+
},
37+
customPageText: {
38+
fontSize: 16,
39+
fontWeight: '600',
40+
},
41+
});

‎integration/templates/expo-native/screens/Home.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { useAuth, useSession, useUser } from '@clerk/expo';
22
import { AuthView, type AuthViewMode, UserButton } from '@clerk/expo/native';
3-
import { type ReactElement, useState } from 'react';
3+
import { type ComponentProps, type ReactElement, useState } from 'react';
44
import { Button, Modal, StyleSheet, Text, View } from 'react-native';
55

6-
export function Home({ authMode }: { authMode: AuthViewMode }): ReactElement {
6+
type HomeProps = { authMode: AuthViewMode; authLogo?: ComponentProps<typeof AuthView>['logo'] };
7+
8+
export function Home({ authMode, authLogo }: HomeProps): ReactElement {
79
const { isSignedIn, signOut } = useAuth();
810
const { user } = useUser();
911
const { session } = useSession();
@@ -82,6 +84,7 @@ export function Home({ authMode }: { authMode: AuthViewMode }): ReactElement {
8284
>
8385
<AuthView
8486
mode={authMode}
87+
logo={authLogo}
8588
onDismiss={closeAuth}
8689
/>
8790
</Modal>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { type ReactElement } from 'react';
2+
import { Text, View } from 'react-native';
3+
4+
import { BiometricAvailabilityButton } from '../components/BiometricAvailabilityButton';
5+
import { GoogleSignInButton } from '../components/GoogleSignInButton';
6+
import { styles } from './styles';
7+
8+
export function NativeModules(): ReactElement {
9+
return (
10+
<View style={styles.form}>
11+
<Text style={styles.title}>Native modules</Text>
12+
<GoogleSignInButton />
13+
<BiometricAvailabilityButton />
14+
</View>
15+
);
16+
}

‎integration/templates/expo-native/verify/VerifyHost.tsx‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ import { tokenCache } from '@clerk/expo/token-cache';
1313
import { type ReactElement, useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react';
1414
import { ActivityIndicator, StyleSheet, Text, View } from 'react-native';
1515

16+
import { AuthLogo } from '../screens/AuthLogo';
1617
import { CustomSignIn } from '../screens/CustomSignIn';
1718
import { CustomSignUp } from '../screens/CustomSignUp';
19+
import { EmbeddedProfile } from '../screens/EmbeddedProfile';
1820
import { Home } from '../screens/Home';
21+
import { NativeModules } from '../screens/NativeModules';
1922
import { TokenCache } from '../screens/TokenCache';
2023
import { publishableKeyFailure, type VerifyFailure, type VerifyLaunch, type VerifyScreen } from './launch';
2124
import { type VerifyState, verifyStateJson, type VerifyTicket } from './state';
@@ -96,7 +99,7 @@ function RoutedHost({ launch }: HostProps): ReactElement {
9699
const { signIn } = useSignIn();
97100
const { signUp } = useSignUp();
98101
const authView = useAuthViewState();
99-
const [authDismissed, setAuthDismissed] = useState(false);
102+
const [screenClosed, setScreenClosed] = useState(false);
100103
const [ticket, setTicket] = useState<VerifyTicket>(launch.signInTicket ? 'pending' : 'none');
101104
const [failure, setFailure] = useState<VerifyFailure | null>(null);
102105
const ticketStarted = useRef(false);
@@ -146,14 +149,18 @@ function RoutedHost({ launch }: HostProps): ReactElement {
146149
switch (launch.screen) {
147150
case 'auth':
148151
case 'nativeAuth':
149-
if (authView.isAuthFlowComplete || authDismissed) {
152+
if (authView.isAuthFlowComplete || screenClosed) {
150153
return 'home';
151154
}
152155
return authView.isLoaded ? launch.screen : 'loading';
153156
case 'customSignIn':
154157
case 'customSignUp':
155158
return isSignedIn ? 'home' : launch.screen;
159+
case 'embeddedProfile':
160+
return isSignedIn && !screenClosed ? launch.screen : 'home';
156161
case 'home':
162+
case 'authLogo':
163+
case 'nativeModules':
157164
return launch.screen;
158165
}
159166
})();
@@ -197,7 +204,7 @@ function RoutedHost({ launch }: HostProps): ReactElement {
197204
return (
198205
<AuthView
199206
mode={launch.authMode}
200-
onDismiss={() => setAuthDismissed(true)}
207+
onDismiss={() => setScreenClosed(true)}
201208
/>
202209
);
203210
case 'customSignIn':
@@ -206,6 +213,12 @@ function RoutedHost({ launch }: HostProps): ReactElement {
206213
return <CustomSignUp />;
207214
case 'tokenCache':
208215
return <TokenCache />;
216+
case 'authLogo':
217+
return <AuthLogo authMode={launch.authMode} />;
218+
case 'embeddedProfile':
219+
return <EmbeddedProfile onHostBack={() => setScreenClosed(true)} />;
220+
case 'nativeModules':
221+
return <NativeModules />;
209222
}
210223
}
211224

‎integration/templates/expo-native/verify/launch.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import { VerifyLaunchConfig } from '../modules/verify-launch-config';
22

3-
const verifyScreens = ['home', 'auth', 'nativeAuth', 'customSignIn', 'customSignUp', 'tokenCache'] as const;
3+
const verifyScreens = [
4+
'home',
5+
'auth',
6+
'nativeAuth',
7+
'authLogo',
8+
'customSignIn',
9+
'customSignUp',
10+
'tokenCache',
11+
'embeddedProfile',
12+
'nativeModules',
13+
] as const;
414

515
const authModes = ['signIn', 'signUp', 'signInOrUp'] as const;
616

0 commit comments

Comments
 (0)