File tree Expand file tree Collapse file tree
templates/next-app-router/src/app Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ export default function Home() {
1717 < ul >
1818 < li >
1919 < Link href = '/page-protected' > Page Protected</ Link >
20+ < Link href = '/protected' > Protected</ Link >
2021 </ li >
2122 </ ul >
2223 </ main >
Original file line number Diff line number Diff line change 1+ import Link from 'next/link' ;
2+
13export default function Page ( ) {
2- return < div > Protected</ div > ;
4+ return (
5+ < >
6+ < div data-testid = 'protected' > Protected</ div >
7+ < Link href = '/' > Home</ Link >
8+ </ >
9+ ) ;
310}
Original file line number Diff line number Diff line change @@ -68,6 +68,24 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })('sign out
6868 const client_id_after_sign_out = await u . page . locator ( 'p[data-clerk-id]' ) . innerHTML ( ) ;
6969 expect ( client_id ) . toEqual ( client_id_after_sign_out ) ;
7070 } ) ;
71+
72+ test ( 'Protected routes do not persist after sign out' , async ( { page, context } ) => {
73+ const u = createTestUtils ( { app, page, context } ) ;
74+
75+ await u . po . signIn . goTo ( ) ;
76+ await u . po . signIn . waitForMounted ( ) ;
77+ await u . po . signIn . signInWithEmailAndInstantPassword ( { email : fakeUser . email , password : fakeUser . password } ) ;
78+ await u . po . expect . toBeSignedIn ( ) ;
79+
80+ await u . page . getByRole ( 'link' , { name : 'Protected' , exact : true } ) . click ( ) ;
81+ await u . page . getByTestId ( 'protected' ) . waitFor ( ) ;
82+ await u . page . getByRole ( 'link' , { name : 'Home' } ) . click ( ) ;
83+ await u . page . getByRole ( 'button' , { name : 'Open user button' } ) . click ( ) ;
84+
85+ await u . page . getByRole ( 'menuitem' , { name : 'Sign out' } ) . click ( ) ;
86+ await u . page . getByRole ( 'link' , { name : 'Protected' , exact : true } ) . click ( ) ;
87+ await u . page . waitForURL ( / s i g n - i n \? r e d i r e c t _ u r l / ) ;
88+ } ) ;
7189} ) ;
7290
7391testAgainstRunningApps ( { withEnv : [ appConfigs . envs . withEmailCodes_destroy_client ] } ) (
You can’t perform that action at this time.
0 commit comments