@@ -10,7 +10,7 @@ import { type User } from '~/schema'
1010
1111const BOX_TEST_USER = generateTestUserCredentials ( )
1212const BOX_TEST_USER_BOX = {
13- name : `${ BOX_TEST_USER } s Box` ,
13+ name : `${ BOX_TEST_USER . name } s Box` , // Fixed: was using BOX_TEST_USER instead of BOX_TEST_USER.name
1414 exposure : 'outdoor' ,
1515 expiresAt : null ,
1616 tags : [ ] ,
@@ -20,14 +20,13 @@ const BOX_TEST_USER_BOX = {
2020 mqttEnabled : false ,
2121 ttnEnabled : false ,
2222}
23-
24- const OTHER_TEST_USER = generateTestUserCredentials ( )
25-
2623// TODO Give the users some boxes to test with
24+ const OTHER_TEST_USER = generateTestUserCredentials ( )
2725
2826describe ( 'openSenseMap API Routes: /users' , ( ) => {
2927 describe ( '/me/boxes/:deviceId' , ( ) => {
30- describe ( 'GET' , async ( ) => {
28+ describe ( 'GET' , ( ) => {
29+ // Removed async here - not needed on describe
3130 let jwt : string = ''
3231 let otherJwt : string = ''
3332 let deviceId : string = ''
@@ -53,7 +52,7 @@ describe('openSenseMap API Routes: /users', () => {
5352
5453 const device = await createDevice ( BOX_TEST_USER_BOX , ( user as User ) . id )
5554 deviceId = device . id
56- } )
55+ } , 30000 ) // Increase timeout to 30 seconds
5756
5857 it ( 'should let users retrieve one of their boxes with all fields' , async ( ) => {
5958 // Act: Get single box
@@ -70,6 +69,7 @@ describe('openSenseMap API Routes: /users', () => {
7069 // Assert: Response for single box
7170 expect ( singleBoxResponse . status ) . toBe ( 200 )
7271 } )
72+
7373 it ( 'should deny to retrieve a box of other user' , async ( ) => {
7474 // Arrange
7575 const forbiddenRequest = new Request (
@@ -96,7 +96,7 @@ describe('openSenseMap API Routes: /users', () => {
9696 // delete the valid test user
9797 await deleteUserByEmail ( BOX_TEST_USER . email )
9898 await deleteUserByEmail ( OTHER_TEST_USER . email )
99- } )
99+ } , 30000 ) // Increase timeout for cleanup too
100100 } )
101101 } )
102102} )
0 commit comments