@@ -104,9 +104,9 @@ describe("SignUpPage", () => {
104104 } ) ;
105105 } ) ;
106106
107- it ( "calls supabase.auth.signUp with correct parameters" , async ( ) => {
107+ it ( "calls supabase.auth.signUp with correct parameters including emailRedirectTo " , async ( ) => {
108108 mockSignUp . mockResolvedValue ( {
109- data : { user : { id : "user-1" } } ,
109+ data : { user : { id : "user-1" , identities : [ { id : "id-1" } ] } } ,
110110 error : null ,
111111 } ) ;
112112
@@ -137,14 +137,43 @@ describe("SignUpPage", () => {
137137 data : {
138138 display_name : "Jane Doe" ,
139139 } ,
140+ emailRedirectTo : "http://localhost:3000/auth/callback" ,
140141 } ,
141142 } ) ;
142143 } ) ;
143144 } ) ;
144145
145- it ( "redirects to workspace after successful sign-up " , async ( ) => {
146+ it ( "shows confirmation screen when email confirmation is required " , async ( ) => {
146147 mockSignUp . mockResolvedValue ( {
147- data : { user : { id : "user-1" } } ,
148+ data : { user : { id : "user-1" , identities : [ ] } } ,
149+ error : null ,
150+ } ) ;
151+
152+ const user = userEvent . setup ( ) ;
153+ render ( < SignUpPage /> ) ;
154+
155+ await user . type ( screen . getByLabelText ( "Display name" ) , "Jane Doe" ) ;
156+ await user . type ( screen . getByLabelText ( "Email" ) , "jane@example.com" ) ;
157+ await user . type ( screen . getByLabelText ( "Password" ) , "password123" ) ;
158+
159+ const form = screen . getByRole ( "button" , { name : / s i g n u p / i } )
160+ . closest ( "form" ) ! ;
161+ form . requestSubmit ( ) ;
162+
163+ await waitFor ( ( ) => {
164+ expect ( screen . getByText ( "Check your inbox" ) ) . toBeInTheDocument ( ) ;
165+ expect ( screen . getByText ( "jane@example.com" ) ) . toBeInTheDocument ( ) ;
166+ } ) ;
167+
168+ // Form should no longer be visible
169+ expect ( screen . queryByLabelText ( "Email" ) ) . not . toBeInTheDocument ( ) ;
170+ // Should not have attempted a redirect
171+ expect ( mockPush ) . not . toHaveBeenCalled ( ) ;
172+ } ) ;
173+
174+ it ( "redirects to workspace after successful sign-up without email confirmation" , async ( ) => {
175+ mockSignUp . mockResolvedValue ( {
176+ data : { user : { id : "user-1" , identities : [ { id : "id-1" } ] } } ,
148177 error : null ,
149178 } ) ;
150179
@@ -174,7 +203,7 @@ describe("SignUpPage", () => {
174203
175204 it ( "redirects to root when no workspace found after sign-up" , async ( ) => {
176205 mockSignUp . mockResolvedValue ( {
177- data : { user : { id : "user-1" } } ,
206+ data : { user : { id : "user-1" , identities : [ { id : "id-1" } ] } } ,
178207 error : null ,
179208 } ) ;
180209
0 commit comments