@@ -420,40 +420,6 @@ describe('query getOpportunityMatch', () => {
420420 } ) ;
421421 } ) ;
422422
423- it ( 'should clear alert when alert matches opportunityId' , async ( ) => {
424- loggedUser = '1' ;
425-
426- await saveFixtures ( con , Alerts , [
427- {
428- userId : '1' ,
429- opportunityId : '550e8400-e29b-41d4-a716-446655440001' ,
430- } ,
431- ] ) ;
432-
433- const res = await client . query ( GET_OPPORTUNITY_MATCH_QUERY , {
434- variables : { id : '550e8400-e29b-41d4-a716-446655440001' } ,
435- } ) ;
436-
437- expect ( res . errors ) . toBeFalsy ( ) ;
438- expect ( res . data . getOpportunityMatch ) . toEqual ( {
439- status : 'pending' ,
440- description : {
441- reasoning : 'Interested candidate' ,
442- } ,
443- } ) ;
444- expect (
445- await con . getRepository ( Alerts ) . countBy ( {
446- userId : '1' ,
447- opportunityId : '550e8400-e29b-41d4-a716-446655440001' ,
448- } ) ,
449- ) . toEqual ( 0 ) ;
450- expect (
451- await con
452- . getRepository ( Alerts )
453- . countBy ( { userId : '1' , opportunityId : IsNull ( ) } ) ,
454- ) . toEqual ( 1 ) ;
455- } ) ;
456-
457423 it ( 'should not clear alert when alert does not match opportunityId' , async ( ) => {
458424 loggedUser = '1' ;
459425
@@ -1147,6 +1113,38 @@ describe('mutation acceptOpportunityMatch', () => {
11471113 ) . toEqual ( 1 ) ;
11481114 } ) ;
11491115
1116+ it ( 'should clear alert when accepting opportunity match' , async ( ) => {
1117+ loggedUser = '1' ;
1118+
1119+ await saveFixtures ( con , Alerts , [
1120+ {
1121+ userId : '1' ,
1122+ opportunityId : '550e8400-e29b-41d4-a716-446655440001' ,
1123+ } ,
1124+ ] ) ;
1125+
1126+ const res = await client . mutate ( MUTATION , {
1127+ variables : {
1128+ id : '550e8400-e29b-41d4-a716-446655440001' ,
1129+ } ,
1130+ } ) ;
1131+
1132+ expect ( res . errors ) . toBeFalsy ( ) ;
1133+ expect ( res . data . acceptOpportunityMatch ) . toEqual ( { _ : true } ) ;
1134+
1135+ expect (
1136+ await con . getRepository ( Alerts ) . countBy ( {
1137+ userId : '1' ,
1138+ opportunityId : '550e8400-e29b-41d4-a716-446655440001' ,
1139+ } ) ,
1140+ ) . toEqual ( 0 ) ;
1141+ expect (
1142+ await con
1143+ . getRepository ( Alerts )
1144+ . countBy ( { userId : '1' , opportunityId : IsNull ( ) } ) ,
1145+ ) . toEqual ( 1 ) ;
1146+ } ) ;
1147+
11501148 it ( 'should return error when the match is not pending' , async ( ) => {
11511149 loggedUser = '2' ;
11521150
@@ -1231,6 +1229,38 @@ describe('mutation rejectOpportunityMatch', () => {
12311229 ) . toEqual ( 1 ) ;
12321230 } ) ;
12331231
1232+ it ( 'should clear alert when rejecting opportunity match' , async ( ) => {
1233+ loggedUser = '1' ;
1234+
1235+ await saveFixtures ( con , Alerts , [
1236+ {
1237+ userId : '1' ,
1238+ opportunityId : '550e8400-e29b-41d4-a716-446655440001' ,
1239+ } ,
1240+ ] ) ;
1241+
1242+ const res = await client . mutate ( MUTATION , {
1243+ variables : {
1244+ id : '550e8400-e29b-41d4-a716-446655440001' ,
1245+ } ,
1246+ } ) ;
1247+
1248+ expect ( res . errors ) . toBeFalsy ( ) ;
1249+ expect ( res . data . rejectOpportunityMatch ) . toEqual ( { _ : true } ) ;
1250+
1251+ expect (
1252+ await con . getRepository ( Alerts ) . countBy ( {
1253+ userId : '1' ,
1254+ opportunityId : '550e8400-e29b-41d4-a716-446655440001' ,
1255+ } ) ,
1256+ ) . toEqual ( 0 ) ;
1257+ expect (
1258+ await con
1259+ . getRepository ( Alerts )
1260+ . countBy ( { userId : '1' , opportunityId : IsNull ( ) } ) ,
1261+ ) . toEqual ( 1 ) ;
1262+ } ) ;
1263+
12341264 it ( 'should return error when the match is not pending' , async ( ) => {
12351265 loggedUser = '2' ;
12361266
0 commit comments