@@ -714,10 +714,6 @@ describe('Reward Config API', () => {
714714
715715 beforeAll ( async ( ) => {
716716 await setupTestDatabase ( ) ;
717- adminUser = await createTestUser ( { role : 'ADMIN' , email : 'admin@example.com' } ) ;
718- regularUser = await createTestUser ( { role : 'PLAYER' , email : 'user@example.com' } ) ;
719- adminToken = createTestToken ( adminUser . id , adminUser . email , adminUser . role ) ;
720- userToken = createTestToken ( regularUser . id , regularUser . email , regularUser . role ) ;
721717 } ) ;
722718
723719 afterAll ( async ( ) => {
@@ -727,6 +723,10 @@ describe('Reward Config API', () => {
727723 beforeEach ( async ( ) => {
728724 await clearTestData ( ) ;
729725 resetUserCounter ( ) ;
726+ adminUser = await createTestUser ( { role : 'ADMIN' , email : 'admin@example.com' } ) ;
727+ regularUser = await createTestUser ( { role : 'PLAYER' , email : 'user@example.com' } ) ;
728+ adminToken = createTestToken ( adminUser . id , adminUser . email , adminUser . role ) ;
729+ userToken = createTestToken ( regularUser . id , regularUser . email , regularUser . role ) ;
730730 } ) ;
731731
732732 it ( 'should allow admin to get and update reward config' , async ( ) => {
@@ -735,10 +735,11 @@ describe('Reward Config API', () => {
735735 . get ( '/rewards/config' )
736736 . set ( 'Authorization' , `Bearer ${ adminToken } ` )
737737 . expect ( 200 ) ;
738- expect ( res . body ) . toHaveProperty ( 'monthlyBountyReward' ) ;
739- expect ( res . body ) . toHaveProperty ( 'monthlyQuestReward' ) ;
740- expect ( res . body ) . toHaveProperty ( 'quarterlyCollectiveGoal' ) ;
741- expect ( res . body ) . toHaveProperty ( 'quarterlyCollectiveReward' ) ;
738+ expect ( res . body . success ) . toBe ( true ) ;
739+ expect ( res . body . data ) . toHaveProperty ( 'monthlyBountyReward' ) ;
740+ expect ( res . body . data ) . toHaveProperty ( 'monthlyQuestReward' ) ;
741+ expect ( res . body . data ) . toHaveProperty ( 'quarterlyCollectiveGoal' ) ;
742+ expect ( res . body . data ) . toHaveProperty ( 'quarterlyCollectiveReward' ) ;
742743
743744 // Admin can update config
744745 const newConfig = {
@@ -759,10 +760,11 @@ describe('Reward Config API', () => {
759760 . get ( '/rewards/config' )
760761 . set ( 'Authorization' , `Bearer ${ adminToken } ` )
761762 . expect ( 200 ) ;
762- expect ( res . body . monthlyBountyReward ) . toBe ( 100 ) ;
763- expect ( res . body . monthlyQuestReward ) . toBe ( 50 ) ;
764- expect ( res . body . quarterlyCollectiveGoal ) . toBe ( 1000 ) ;
765- expect ( res . body . quarterlyCollectiveReward ) . toBe ( 'Pizza Party!' ) ;
763+ expect ( res . body . success ) . toBe ( true ) ;
764+ expect ( res . body . data . monthlyBountyReward ) . toBe ( 100 ) ;
765+ expect ( res . body . data . monthlyQuestReward ) . toBe ( 50 ) ;
766+ expect ( res . body . data . quarterlyCollectiveGoal ) . toBe ( 1000 ) ;
767+ expect ( res . body . data . quarterlyCollectiveReward ) . toBe ( 'Pizza Party!' ) ;
766768 } ) ;
767769
768770 it ( 'should not allow non-admins to update reward config' , async ( ) => {
@@ -860,12 +862,14 @@ describe('Collective Reward Progress API', () => {
860862 . set ( 'Authorization' , `Bearer ${ token } ` )
861863 . expect ( 200 ) ;
862864
863- expect ( res . body ) . toHaveProperty ( 'goal' , 1000 ) ;
864- expect ( res . body ) . toHaveProperty ( 'reward' , 'Team Pizza Party!' ) ;
865- expect ( res . body ) . toHaveProperty ( 'progress' , totalBounty ) ;
866- expect ( res . body ) . toHaveProperty ( 'percent' ) ;
867- expect ( typeof res . body . percent ) . toBe ( 'number' ) ;
868- expect ( res . body . percent ) . toBeCloseTo ( ( totalBounty / 1000 ) * 100 , 1 ) ;
865+ expect ( res . body ) . toHaveProperty ( 'success' , true ) ;
866+ expect ( res . body ) . toHaveProperty ( 'data' ) ;
867+ expect ( res . body . data ) . toHaveProperty ( 'goal' , 1000 ) ;
868+ expect ( res . body . data ) . toHaveProperty ( 'reward' , 'Team Pizza Party!' ) ;
869+ expect ( res . body . data ) . toHaveProperty ( 'progress' , totalBounty ) ;
870+ expect ( res . body . data ) . toHaveProperty ( 'percent' ) ;
871+ expect ( typeof res . body . data . percent ) . toBe ( 'number' ) ;
872+ expect ( res . body . data . percent ) . toBeCloseTo ( ( totalBounty / 1000 ) * 100 , 1 ) ;
869873 } ) ;
870874
871875 it ( 'should require authentication' , async ( ) => {
0 commit comments