@@ -85,6 +85,7 @@ describe("Integration - Auth Routes", () => {
8585
8686 beforeEach ( ( ) => {
8787 vi . clearAllMocks ( ) ;
88+ vi . stubEnv ( "APP_URL" , "http://localhost:3001/api" ) ;
8889
8990 // Sessão padrão para rotas OAuth (AuthController)
9091 vi . mocked ( getIronSession ) . mockResolvedValue ( {
@@ -229,7 +230,9 @@ describe("Integration - Auth Routes", () => {
229230 . get ( `${ BASE } /github/callback?code=abc123&state=valid-state-abc123` )
230231 . expect ( 302 ) ;
231232
232- expect ( res . headers . location ) . toContain ( "/login?error=oauth_state_missing" ) ;
233+ expect ( res . headers . location ) . toContain (
234+ "/login?error=oauth_state_missing" ,
235+ ) ;
233236 } ) ;
234237
235238 it ( "redireciona ao login quando state do query nao confere com o da sessao" , async ( ) => {
@@ -242,7 +245,9 @@ describe("Integration - Auth Routes", () => {
242245 . get ( `${ BASE } /github/callback?code=abc123&state=state-errado` )
243246 . expect ( 302 ) ;
244247
245- expect ( res . headers . location ) . toContain ( "/login?error=oauth_state_invalid" ) ;
248+ expect ( res . headers . location ) . toContain (
249+ "/login?error=oauth_state_invalid" ,
250+ ) ;
246251 } ) ;
247252
248253 it ( "redireciona ao login para provider invalido nos params" , async ( ) => {
@@ -285,7 +290,9 @@ describe("Integration - Auth Routes", () => {
285290
286291 it ( "redireciona ao frontend em callback valido para linkedin" , async ( ) => {
287292 const res = await request ( app )
288- . get ( `${ BASE } /linkedin/callback?code=li-code-123&state=valid-state-abc123` )
293+ . get (
294+ `${ BASE } /linkedin/callback?code=li-code-123&state=valid-state-abc123` ,
295+ )
289296 . expect ( 302 ) ;
290297
291298 expect ( res . headers . location ) . toContain ( "/auth/callback" ) ;
@@ -315,7 +322,9 @@ describe("Integration - Auth Routes", () => {
315322
316323 describe ( "POST /register" , ( ) => {
317324 it ( "cria usuario e retorna 201" , async ( ) => {
318- vi . mocked ( getIronSession ) . mockResolvedValue ( fixtureCredentialsSession as any ) ;
325+ vi . mocked ( getIronSession ) . mockResolvedValue (
326+ fixtureCredentialsSession as any ,
327+ ) ;
319328
320329 const res = await request ( app )
321330 . post ( `${ BASE } /register` )
@@ -327,7 +336,9 @@ describe("Integration - Auth Routes", () => {
327336 } ) ;
328337
329338 it ( "chama register com email, password e name" , async ( ) => {
330- vi . mocked ( getIronSession ) . mockResolvedValue ( fixtureCredentialsSession as any ) ;
339+ vi . mocked ( getIronSession ) . mockResolvedValue (
340+ fixtureCredentialsSession as any ,
341+ ) ;
331342
332343 await request ( app ) . post ( `${ BASE } /register` ) . send ( registerPayload ) ;
333344
@@ -341,7 +352,9 @@ describe("Integration - Auth Routes", () => {
341352 } ) ;
342353
343354 it ( "retorna 400 para email invalido (ZodError)" , async ( ) => {
344- vi . mocked ( getIronSession ) . mockResolvedValue ( fixtureCredentialsSession as any ) ;
355+ vi . mocked ( getIronSession ) . mockResolvedValue (
356+ fixtureCredentialsSession as any ,
357+ ) ;
345358
346359 const res = await request ( app )
347360 . post ( `${ BASE } /register` )
@@ -352,7 +365,9 @@ describe("Integration - Auth Routes", () => {
352365 } ) ;
353366
354367 it ( "retorna 400 para senha curta (ZodError)" , async ( ) => {
355- vi . mocked ( getIronSession ) . mockResolvedValue ( fixtureCredentialsSession as any ) ;
368+ vi . mocked ( getIronSession ) . mockResolvedValue (
369+ fixtureCredentialsSession as any ,
370+ ) ;
356371
357372 await request ( app )
358373 . post ( `${ BASE } /register` )
@@ -361,7 +376,9 @@ describe("Integration - Auth Routes", () => {
361376 } ) ;
362377
363378 it ( "retorna 409 quando email ja esta cadastrado" , async ( ) => {
364- vi . mocked ( getIronSession ) . mockResolvedValue ( fixtureCredentialsSession as any ) ;
379+ vi . mocked ( getIronSession ) . mockResolvedValue (
380+ fixtureCredentialsSession as any ,
381+ ) ;
365382 mockCredentialsService . register . mockRejectedValueOnce (
366383 new Error ( "Email já cadastrado" ) ,
367384 ) ;
@@ -375,7 +392,9 @@ describe("Integration - Auth Routes", () => {
375392 } ) ;
376393
377394 it ( "retorna 500 para erro inesperado no register" , async ( ) => {
378- vi . mocked ( getIronSession ) . mockResolvedValue ( fixtureCredentialsSession as any ) ;
395+ vi . mocked ( getIronSession ) . mockResolvedValue (
396+ fixtureCredentialsSession as any ,
397+ ) ;
379398 mockCredentialsService . register . mockRejectedValueOnce (
380399 new Error ( "db connection failed" ) ,
381400 ) ;
@@ -391,7 +410,9 @@ describe("Integration - Auth Routes", () => {
391410
392411 describe ( "POST /login" , ( ) => {
393412 it ( "autentica e retorna 200 com user e session" , async ( ) => {
394- vi . mocked ( getIronSession ) . mockResolvedValue ( fixtureCredentialsSession as any ) ;
413+ vi . mocked ( getIronSession ) . mockResolvedValue (
414+ fixtureCredentialsSession as any ,
415+ ) ;
395416
396417 const res = await request ( app )
397418 . post ( `${ BASE } /login` )
@@ -403,7 +424,9 @@ describe("Integration - Auth Routes", () => {
403424 } ) ;
404425
405426 it ( "chama login com email e password corretos" , async ( ) => {
406- vi . mocked ( getIronSession ) . mockResolvedValue ( fixtureCredentialsSession as any ) ;
427+ vi . mocked ( getIronSession ) . mockResolvedValue (
428+ fixtureCredentialsSession as any ,
429+ ) ;
407430
408431 await request ( app ) . post ( `${ BASE } /login` ) . send ( loginPayload ) ;
409432
@@ -413,7 +436,9 @@ describe("Integration - Auth Routes", () => {
413436 } ) ;
414437
415438 it ( "retorna 400 para email invalido (ZodError)" , async ( ) => {
416- vi . mocked ( getIronSession ) . mockResolvedValue ( fixtureCredentialsSession as any ) ;
439+ vi . mocked ( getIronSession ) . mockResolvedValue (
440+ fixtureCredentialsSession as any ,
441+ ) ;
417442
418443 await request ( app )
419444 . post ( `${ BASE } /login` )
@@ -422,7 +447,9 @@ describe("Integration - Auth Routes", () => {
422447 } ) ;
423448
424449 it ( "retorna 400 para senha ausente (ZodError)" , async ( ) => {
425- vi . mocked ( getIronSession ) . mockResolvedValue ( fixtureCredentialsSession as any ) ;
450+ vi . mocked ( getIronSession ) . mockResolvedValue (
451+ fixtureCredentialsSession as any ,
452+ ) ;
426453
427454 await request ( app )
428455 . post ( `${ BASE } /login` )
@@ -431,7 +458,9 @@ describe("Integration - Auth Routes", () => {
431458 } ) ;
432459
433460 it ( "retorna 401 para credenciais invalidas" , async ( ) => {
434- vi . mocked ( getIronSession ) . mockResolvedValue ( fixtureCredentialsSession as any ) ;
461+ vi . mocked ( getIronSession ) . mockResolvedValue (
462+ fixtureCredentialsSession as any ,
463+ ) ;
435464 mockCredentialsService . login . mockRejectedValueOnce (
436465 new Error ( "Credenciais inválidas" ) ,
437466 ) ;
@@ -445,7 +474,9 @@ describe("Integration - Auth Routes", () => {
445474 } ) ;
446475
447476 it ( "retorna 500 para erro inesperado no login" , async ( ) => {
448- vi . mocked ( getIronSession ) . mockResolvedValue ( fixtureCredentialsSession as any ) ;
477+ vi . mocked ( getIronSession ) . mockResolvedValue (
478+ fixtureCredentialsSession as any ,
479+ ) ;
449480 mockCredentialsService . login . mockRejectedValueOnce (
450481 new Error ( "db timeout" ) ,
451482 ) ;
0 commit comments