fix(test): some etapi tests failing

This commit is contained in:
Elian Doran 2025-06-03 20:16:39 +03:00
parent cecbe5862c
commit 4a4c34e966
No known key found for this signature in database
3 changed files with 14 additions and 5 deletions

View File

@ -21,6 +21,6 @@ describe("etapi/backup", () => {
const response = await supertest(app) const response = await supertest(app)
.put("/etapi/backup/etapi_test") .put("/etapi/backup/etapi_test")
.auth(USER, token, { "type": "basic"}) .auth(USER, token, { "type": "basic"})
.expect(201); .expect(204);
}); });
}); });

View File

@ -3,6 +3,8 @@ import config from "../../src/services/config.js";
import { login } from "./utils.js"; import { login } from "./utils.js";
import { Application } from "express"; import { Application } from "express";
import supertest from "supertest"; import supertest from "supertest";
import date_notes from "../../src/services/date_notes.js";
import cls from "../../src/services/cls.js";
let app: Application; let app: Application;
let token: string; let token: string;
@ -42,9 +44,16 @@ describe("etapi/get-date-notes", () => {
}); });
describe("weeks", () => { describe("weeks", () => {
beforeAll(() => {
cls.init(() => {
const rootCalendarNote = date_notes.getRootCalendarNote();
rootCalendarNote.setLabel("enableWeekNote");
});
});
it("obtains week calendar", async () => { it("obtains week calendar", async () => {
await supertest(app) await supertest(app)
.get("/etapi/calendar/weeks/2022-01-01") .get("/etapi/calendar/weeks/2022-W01")
.auth(USER, token, { "type": "basic"}) .auth(USER, token, { "type": "basic"})
.expect(200); .expect(200);
}); });
@ -54,14 +63,14 @@ describe("etapi/get-date-notes", () => {
.get("/etapi/calendar/weeks/2022-1") .get("/etapi/calendar/weeks/2022-1")
.auth(USER, token, { "type": "basic"}) .auth(USER, token, { "type": "basic"})
.expect(400); .expect(400);
expect(response.body.code).toStrictEqual("DATE_INVALID"); expect(response.body.code).toStrictEqual("WEEK_INVALID");
}); });
}); });
describe("months", () => { describe("months", () => {
it("obtains month calendar", async () => { it("obtains month calendar", async () => {
await supertest(app) await supertest(app)
.get("/etapi/calendar/weeks/2022-01") .get("/etapi/calendar/months/2022-01")
.auth(USER, token, { "type": "basic"}) .auth(USER, token, { "type": "basic"})
.expect(200); .expect(200);
}); });

View File

@ -21,6 +21,6 @@ describe("etapi/refresh-note-ordering/root", () => {
await supertest(app) await supertest(app)
.post("/etapi/refresh-note-ordering/root") .post("/etapi/refresh-note-ordering/root")
.auth(USER, token, { "type": "basic"}) .auth(USER, token, { "type": "basic"})
.expect(200); .expect(204);
}); });
}); });