@@ -15,6 +15,7 @@ const tasksData = require("../fixtures/tasks/tasks")();
15
15
const { DINERO , NEELAM } = require ( "../../constants/wallets" ) ;
16
16
const cleanDb = require ( "../utils/cleanDb" ) ;
17
17
const { TASK_STATUS } = require ( "../../constants/tasks" ) ;
18
+ const updateTaskStatus = require ( "../fixtures/tasks/tasks1" ) ( ) ;
18
19
chai . use ( chaiHttp ) ;
19
20
20
21
const appOwner = userData [ 3 ] ;
@@ -836,6 +837,30 @@ describe("Tasks", function () {
836
837
return done ( ) ;
837
838
} ) ;
838
839
} ) ;
840
+
841
+ it ( "Should update the task status for given self taskid under feature flag" , function ( done ) {
842
+ chai
843
+ . request ( app )
844
+ . patch ( `/tasks/self/${ taskId1 } ?userStatusFlag=true` )
845
+ . set ( "cookie" , `${ cookieName } =${ jwt } ` )
846
+ . send ( { status : "DONE" , percentCompleted : 100 } )
847
+ . end ( ( err , res ) => {
848
+ if ( err ) {
849
+ return done ( err ) ;
850
+ }
851
+ expect ( res ) . to . have . status ( 200 ) ;
852
+ expect ( res . body . taskLog ) . to . have . property ( "type" ) ;
853
+ expect ( res . body . taskLog ) . to . have . property ( "id" ) ;
854
+ expect ( res . body . taskLog . body ) . to . be . a ( "object" ) ;
855
+ expect ( res . body . taskLog . meta ) . to . be . a ( "object" ) ;
856
+ expect ( res . body . message ) . to . equal ( "Task updated successfully!" ) ;
857
+
858
+ expect ( res . body . taskLog . body . new . status ) . to . equal ( "DONE" ) ;
859
+ expect ( res . body . taskLog . body . new . percentCompleted ) . to . equal ( 100 ) ;
860
+ return done ( ) ;
861
+ } ) ;
862
+ } ) ;
863
+
839
864
it ( "Should return fail response if task data has non-acceptable status value to update the task status for given self taskid" , function ( done ) {
840
865
chai
841
866
. request ( app )
@@ -945,6 +970,18 @@ describe("Tasks", function () {
945
970
expect ( res . body . message ) . to . be . equal ( "Status cannot be updated. Task is not completed yet" ) ;
946
971
} ) ;
947
972
973
+ it ( "Should give 400 if percentCompleted is not 100 and new status is DONE under feature flag " , async function ( ) {
974
+ taskId = ( await tasks . updateTask ( { ...taskData , status : "REVIEW" , assignee : appOwner . username } ) ) . taskId ;
975
+ const res = await chai
976
+ . request ( app )
977
+ . patch ( `/tasks/self/${ taskId } ?userStatusFlag=true` )
978
+ . set ( "cookie" , `${ cookieName } =${ jwt } ` )
979
+ . send ( { ...taskStatusData , status : "DONE" } ) ;
980
+
981
+ expect ( res ) . to . have . status ( 400 ) ;
982
+ expect ( res . body . message ) . to . be . equal ( "Status cannot be updated. Task is not done yet" ) ;
983
+ } ) ;
984
+
948
985
it ( "Should give 400 if percentCompleted is not 100 and new status is VERIFIED " , async function ( ) {
949
986
taskId = ( await tasks . updateTask ( { ...taskData , status : "REVIEW" , assignee : appOwner . username } ) ) . taskId ;
950
987
const res = await chai
@@ -957,6 +994,18 @@ describe("Tasks", function () {
957
994
expect ( res . body . message ) . to . be . equal ( "Status cannot be updated. Task is not completed yet" ) ;
958
995
} ) ;
959
996
997
+ it ( "Should give 400 if percentCompleted is not 100 and new status is VERIFIED under feature flag" , async function ( ) {
998
+ taskId = ( await tasks . updateTask ( { ...taskData , status : "REVIEW" , assignee : appOwner . username } ) ) . taskId ;
999
+ const res = await chai
1000
+ . request ( app )
1001
+ . patch ( `/tasks/self/${ taskId } ?userStatusFlag=true` )
1002
+ . set ( "cookie" , `${ cookieName } =${ jwt } ` )
1003
+ . send ( { ...taskStatusData , status : "VERIFIED" } ) ;
1004
+
1005
+ expect ( res ) . to . have . status ( 400 ) ;
1006
+ expect ( res . body . message ) . to . be . equal ( "Status cannot be updated. Task is not done yet" ) ;
1007
+ } ) ;
1008
+
960
1009
it ( "Should give 400 if status is COMPLETED and newpercent is less than 100" , async function ( ) {
961
1010
const taskData = {
962
1011
title : "Test task" ,
@@ -981,6 +1030,18 @@ describe("Tasks", function () {
981
1030
expect ( res ) . to . have . status ( 400 ) ;
982
1031
expect ( res . body . message ) . to . be . equal ( "Task percentCompleted can't updated as status is COMPLETED" ) ;
983
1032
} ) ;
1033
+
1034
+ it ( "Should give 400 if status is DONE and newpercent is less than 100 under feature flag" , async function ( ) {
1035
+ taskId = ( await tasks . updateTask ( updateTaskStatus [ 0 ] ) ) . taskId ;
1036
+ const res = await chai
1037
+ . request ( app )
1038
+ . patch ( `/tasks/self/${ taskId } ?userStatusFlag=true` )
1039
+ . set ( "cookie" , `${ cookieName } =${ jwt } ` )
1040
+ . send ( { percentCompleted : 80 } ) ;
1041
+
1042
+ expect ( res ) . to . have . status ( 400 ) ;
1043
+ expect ( res . body . message ) . to . be . equal ( "Task percentCompleted can't updated as status is DONE" ) ;
1044
+ } ) ;
984
1045
} ) ;
985
1046
986
1047
describe ( "GET /tasks/overdue" , function ( ) {
0 commit comments