@@ -834,6 +834,43 @@ test("POST /signup validates password length", async () => {
834834 expect ( res . status ) . toBe ( 400 ) ;
835835} ) ;
836836
837+ test ( "POST /signup without email verification creates session and redirects to chat" , async ( ) => {
838+ const { url, bindings } = await serve ( {
839+ bindings : {
840+ sendEmail : undefined , // Disable email verification
841+ } ,
842+ } ) ;
843+ const email = "noeverify@example.com" ;
844+ const password = "securepassword123" ;
845+
846+ const res = await fetch ( `${ url } /api/auth/signup` , {
847+ method : "POST" ,
848+ headers : {
849+ "Content-Type" : "application/json" ,
850+ } ,
851+ body : JSON . stringify ( { email, password } ) ,
852+ } ) ;
853+
854+ expect ( res . status ) . toBe ( 200 ) ;
855+ const data = await res . json ( ) ;
856+ expect ( data . ok ) . toBe ( true ) ;
857+ expect ( data . redirect_url ) . toBe ( "/chat" ) ;
858+
859+ // Verify user was created
860+ const db = await bindings . database ( ) ;
861+ const user = await db . selectUserByEmail ( email ) ;
862+ expect ( user ) . toBeDefined ( ) ;
863+ expect ( user ?. email ) . toBe ( email ) ;
864+
865+ // Verify session cookie was set (auto-login)
866+ const cookies = res . headers . getSetCookie ?.( ) || [
867+ res . headers . get ( "Set-Cookie" ) || "" ,
868+ ] ;
869+ const cookieString = cookies . join ( "; " ) ;
870+ expect ( cookieString ) . toContain ( "blink_session_token=" ) ;
871+ expect ( cookieString ) . toContain ( "last_login_provider=credentials" ) ;
872+ } ) ;
873+
837874test ( "POST /resend-email-verification regenerates token" , async ( ) => {
838875 const { url, helpers, bindings } = await serve ( ) ;
839876 const { user } = await helpers . createUser ( {
0 commit comments