@@ -595,6 +595,7 @@ describe("discordactions", function () {
595
595
let activeUserWithProgressUpdates ;
596
596
let idleUser ;
597
597
let userNotInDiscord ;
598
+ let activeUserId ;
598
599
beforeEach ( async function ( ) {
599
600
idleUser = { ...userData [ 9 ] , discordId : getDiscordMembers [ 0 ] . user . id } ;
600
601
activeUserWithProgressUpdates = { ...userData [ 10 ] , discordId : getDiscordMembers [ 1 ] . user . id } ;
@@ -611,6 +612,7 @@ describe("discordactions", function () {
611
612
await addUser ( activeUserWithNoUpdates ) , // active user with no task progress updates
612
613
await addUser ( userNotInDiscord ) , // OOO user with
613
614
] ) ;
615
+ activeUserId = userIdList [ 2 ] ;
614
616
await Promise . all ( [
615
617
await userStatusModel . updateUserStatus ( userIdList [ 0 ] , idleUserStatus ) ,
616
618
await userStatusModel . updateUserStatus ( userIdList [ 1 ] , activeUserStatus ) ,
@@ -625,12 +627,12 @@ describe("discordactions", function () {
625
627
const validTask = {
626
628
...task ,
627
629
assignee : userIdList [ index ] ,
628
- startedOn : ( new Date ( ) . getTime ( ) - convertDaysToMilliseconds ( 5 ) ) / 1000 ,
630
+ startedOn : ( new Date ( ) . getTime ( ) - convertDaysToMilliseconds ( 7 ) ) / 1000 ,
629
631
endsOn : ( new Date ( ) . getTime ( ) + convertDaysToMilliseconds ( 4 ) ) / 1000 ,
630
632
status : TASK_STATUS . IN_PROGRESS ,
631
633
} ;
632
634
633
- tasksPromise . push ( await tasksModel . add ( validTask ) ) ;
635
+ tasksPromise . push ( tasksModel . add ( validTask ) ) ;
634
636
}
635
637
const taskIdList = ( await Promise . all ( tasksPromise ) ) . map ( ( tasksDoc ) => tasksDoc . id ) ;
636
638
const progressDataList = [ ] ;
@@ -676,7 +678,6 @@ describe("discordactions", function () {
676
678
date3 . setDate ( date3 . getDate ( ) - 3 ) ;
677
679
const date4 = new Date ( ) ;
678
680
date4 . setDate ( date4 . getDate ( ) - 4 ) ;
679
- // this should now only get users who have not provided any update in last 7 days instead of 3;
680
681
const result = await getMissedProgressUpdatesUsers ( {
681
682
excludedDates : [ date . valueOf ( ) , date2 . valueOf ( ) , date3 . valueOf ( ) , date4 . valueOf ( ) ] ,
682
683
} ) ;
@@ -688,6 +689,40 @@ describe("discordactions", function () {
688
689
} ) ;
689
690
} ) ;
690
691
692
+ it ( "should not list of users when all days of week are excluded" , async function ( ) {
693
+ const result = await getMissedProgressUpdatesUsers ( {
694
+ excludedDays : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 ] ,
695
+ } ) ;
696
+ expect ( result ) . to . be . an ( "object" ) ;
697
+ expect ( result ) . to . be . deep . equal ( {
698
+ tasks : 0 ,
699
+ missedUpdatesTasks : 0 ,
700
+ usersToAddRole : [ ] ,
701
+ } ) ;
702
+ } ) ;
703
+ it ( "should not list any users since 5 days of weeks are excluded" , async function ( ) {
704
+ const oneMonthOldTask = { ...tasksData [ 0 ] } ;
705
+ oneMonthOldTask . assignee = activeUserId ;
706
+ oneMonthOldTask . startedOn = ( new Date ( ) . getTime ( ) - convertDaysToMilliseconds ( 30 ) ) / 1000 ;
707
+ oneMonthOldTask . endsOn = ( new Date ( ) . getTime ( ) + convertDaysToMilliseconds ( 4 ) ) / 1000 ;
708
+ const taskId = ( await tasksModel . add ( oneMonthOldTask ) ) . id ;
709
+ const date = new Date ( ) ;
710
+ date . setDate ( date . getDate ( ) - 29 ) ;
711
+ const progressData = stubbedModelTaskProgressData ( null , taskId , date . getTime ( ) , date . valueOf ( ) ) ;
712
+ await createProgressDocument ( progressData ) ;
713
+
714
+ const result = await getMissedProgressUpdatesUsers ( {
715
+ excludedDays : [ 0 , 1 , 2 , 3 , 4 , 5 ] ,
716
+ dateGap : 3 ,
717
+ } ) ;
718
+ expect ( result ) . to . be . an ( "object" ) ;
719
+ expect ( result ) . to . be . deep . equal ( {
720
+ tasks : 1 ,
721
+ missedUpdatesTasks : 0 ,
722
+ usersToAddRole : [ ] ,
723
+ } ) ;
724
+ } ) ;
725
+
691
726
it ( "should process only 1 task when size is passed as 1" , async function ( ) {
692
727
const result = await getMissedProgressUpdatesUsers ( { size : 1 } ) ;
693
728
0 commit comments