@@ -320,6 +320,11 @@ describe('POST /users/current/carts', () => {
320
320
supplements : [ ] ,
321
321
} )
322
322
. expect ( 403 , { error : Error . NotPlayerOrCoachOrSpectator } ) ;
323
+
324
+ // Delete the user to not make the results wrong for the success test
325
+ await database . cartItem . deleteMany ( { where : { forUserId : attendantUser . id } } ) ;
326
+ await database . cart . deleteMany ( { where : { userId : attendantUser . id } } ) ;
327
+ await database . user . delete ( { where : { id : attendantUser . id } } ) ;
323
328
} ) ;
324
329
325
330
it ( 'should fail as the user is already paid' , async ( ) => {
@@ -341,17 +346,23 @@ describe('POST /users/current/carts', () => {
341
346
} ) ;
342
347
343
348
it ( 'should fail as the user is not in the same team' , async ( ) => {
344
- const userInOtherTeam = await createFakeUser ( { type : UserType . player } ) ;
345
- const tokenInOtherTeam = generateToken ( userInOtherTeam ) ;
349
+ const otherTeam = await createFakeTeam ( { members : 1 , tournament : tournament . id , name : 'reallydontcare' } ) ;
350
+ const userInOtherTeam = getCaptain ( otherTeam ) ;
351
+
346
352
347
353
await request ( app )
348
354
. post ( `/users/current/carts` )
349
- . set ( 'Authorization' , `Bearer ${ tokenInOtherTeam } ` )
355
+ . set ( 'Authorization' , `Bearer ${ token } ` )
350
356
. send ( {
351
- tickets : { userIds : [ ] } ,
357
+ tickets : { userIds : [ userInOtherTeam . id ] } ,
352
358
supplements : [ ] ,
353
359
} )
354
360
. expect ( 403 , { error : Error . NotInSameTeam } ) ;
361
+
362
+ // Delete the user to not make the results wrong for the success test
363
+ await database . cartItem . deleteMany ( { where : { forUserId : userInOtherTeam . id } } ) ;
364
+ await database . cart . deleteMany ( { where : { userId : userInOtherTeam . id } } ) ;
365
+ await database . user . delete ( { where : { id : userInOtherTeam . id } } ) ;
355
366
} ) ;
356
367
357
368
it ( 'should fail with an internal server error (inner try/catch)' , ( ) => {
0 commit comments