@@ -1187,6 +1187,29 @@ describe("Tasks", function () {
1187
1187
const res = await chai . request ( app ) . post ( "/tasks/migration" ) . set ( "cookie" , `${ cookieName } =${ nonSuperUserJwt } ` ) ;
1188
1188
expect ( res ) . to . have . status ( 401 ) ;
1189
1189
} ) ;
1190
+ } ) ;
1191
+
1192
+ describe ( "POST /tasks/migration for adding createdAt+updatedAt" , function ( ) {
1193
+ beforeEach ( async function ( ) {
1194
+ const userId = await addUser ( appOwner ) ;
1195
+ const superUserId = await addUser ( superUser ) ;
1196
+ jwt = authService . generateAuthToken ( { userId } ) ;
1197
+ superUserJwt = authService . generateAuthToken ( { userId : superUserId } ) ;
1198
+ // Add the active task
1199
+ taskId = ( await tasks . updateTask ( tasksData [ 0 ] ) ) . taskId ;
1200
+ taskId = ( await tasks . updateTask ( tasksData [ 1 ] ) ) . taskId ;
1201
+ taskId = ( await tasks . updateTask ( tasksData [ 3 ] ) ) . taskId ;
1202
+ taskId = ( await tasks . updateTask ( tasksData [ 4 ] ) ) . taskId ;
1203
+ taskId = ( await tasks . updateTask ( tasksData [ 5 ] ) ) . taskId ;
1204
+ taskId = ( await tasks . updateTask ( tasksData [ 6 ] ) ) . taskId ;
1205
+ } ) ;
1206
+ afterEach ( async function ( ) {
1207
+ await cleanDb ( ) ;
1208
+ } ) ;
1209
+ it ( "Should return 401 if not super_user" , async function ( ) {
1210
+ const res = await chai . request ( app ) . post ( "/tasks/migration" ) . set ( "cookie" , `${ cookieName } =${ jwt } ` ) ;
1211
+ expect ( res ) . to . have . status ( 401 ) ;
1212
+ } ) ;
1190
1213
1191
1214
// TASK createdAt and updatedAt migration script
1192
1215
it ( "Should update status createdAt and updatedAt" , async function ( ) {
@@ -1196,7 +1219,7 @@ describe("Tasks", function () {
1196
1219
} ) ;
1197
1220
expect ( res ) . to . have . status ( 200 ) ;
1198
1221
expect ( res . body . totalFailedTasks ) . to . be . equal ( 0 ) ;
1199
- expect ( res . body . totalTasks ) . to . be . equal ( 23 ) ;
1222
+ expect ( res . body . totalTasks ) . to . be . equal ( 6 ) ;
1200
1223
expect ( res . body . failedTasksIds ) . to . deep . equal ( [ ] ) ;
1201
1224
} ) ;
1202
1225
@@ -1213,9 +1236,9 @@ describe("Tasks", function () {
1213
1236
field : "CREATED_AT+UPDATED_AT" ,
1214
1237
} ) ;
1215
1238
expect ( res ) . to . have . status ( 200 ) ;
1216
- expect ( res . body . totalFailedTasks ) . to . be . equal ( 23 ) ;
1217
- expect ( res . body . totalTasks ) . to . be . equal ( 23 ) ;
1218
- expect ( res . body . failedTasksIds . length ) . to . equal ( 23 ) ;
1239
+ expect ( res . body . totalFailedTasks ) . to . be . equal ( 6 ) ;
1240
+ expect ( res . body . totalTasks ) . to . be . equal ( 6 ) ;
1241
+ expect ( res . body . failedTasksIds . length ) . to . equal ( 6 ) ;
1219
1242
} ) ;
1220
1243
} ) ;
1221
1244
} ) ;
0 commit comments