Skip to content

Commit a6fefcb

Browse files
test: added cleanup code for fixing tests (#1718)
1 parent 72c9f26 commit a6fefcb

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

test/integration/tasks.test.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,29 @@ describe("Tasks", function () {
11871187
const res = await chai.request(app).post("/tasks/migration").set("cookie", `${cookieName}=${nonSuperUserJwt}`);
11881188
expect(res).to.have.status(401);
11891189
});
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+
});
11901213

11911214
// TASK createdAt and updatedAt migration script
11921215
it("Should update status createdAt and updatedAt", async function () {
@@ -1196,7 +1219,7 @@ describe("Tasks", function () {
11961219
});
11971220
expect(res).to.have.status(200);
11981221
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);
12001223
expect(res.body.failedTasksIds).to.deep.equal([]);
12011224
});
12021225

@@ -1213,9 +1236,9 @@ describe("Tasks", function () {
12131236
field: "CREATED_AT+UPDATED_AT",
12141237
});
12151238
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);
12191242
});
12201243
});
12211244
});

0 commit comments

Comments
 (0)