From 4a4c34e9669e88287ceb91d1957e155e97a1e994 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 3 Jun 2025 20:16:39 +0300 Subject: [PATCH] fix(test): some etapi tests failing --- apps/server/spec/etapi/create-backup.spec.ts | 2 +- apps/server/spec/etapi/get-date-notes.spec.ts | 15 ++++++++++++--- apps/server/spec/etapi/other.spec.ts | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/server/spec/etapi/create-backup.spec.ts b/apps/server/spec/etapi/create-backup.spec.ts index efab80218..00c8751aa 100644 --- a/apps/server/spec/etapi/create-backup.spec.ts +++ b/apps/server/spec/etapi/create-backup.spec.ts @@ -21,6 +21,6 @@ describe("etapi/backup", () => { const response = await supertest(app) .put("/etapi/backup/etapi_test") .auth(USER, token, { "type": "basic"}) - .expect(201); + .expect(204); }); }); diff --git a/apps/server/spec/etapi/get-date-notes.spec.ts b/apps/server/spec/etapi/get-date-notes.spec.ts index b472fde06..e1f67fec6 100644 --- a/apps/server/spec/etapi/get-date-notes.spec.ts +++ b/apps/server/spec/etapi/get-date-notes.spec.ts @@ -3,6 +3,8 @@ import config from "../../src/services/config.js"; import { login } from "./utils.js"; import { Application } from "express"; import supertest from "supertest"; +import date_notes from "../../src/services/date_notes.js"; +import cls from "../../src/services/cls.js"; let app: Application; let token: string; @@ -42,9 +44,16 @@ describe("etapi/get-date-notes", () => { }); describe("weeks", () => { + beforeAll(() => { + cls.init(() => { + const rootCalendarNote = date_notes.getRootCalendarNote(); + rootCalendarNote.setLabel("enableWeekNote"); + }); + }); + it("obtains week calendar", async () => { await supertest(app) - .get("/etapi/calendar/weeks/2022-01-01") + .get("/etapi/calendar/weeks/2022-W01") .auth(USER, token, { "type": "basic"}) .expect(200); }); @@ -54,14 +63,14 @@ describe("etapi/get-date-notes", () => { .get("/etapi/calendar/weeks/2022-1") .auth(USER, token, { "type": "basic"}) .expect(400); - expect(response.body.code).toStrictEqual("DATE_INVALID"); + expect(response.body.code).toStrictEqual("WEEK_INVALID"); }); }); describe("months", () => { it("obtains month calendar", async () => { await supertest(app) - .get("/etapi/calendar/weeks/2022-01") + .get("/etapi/calendar/months/2022-01") .auth(USER, token, { "type": "basic"}) .expect(200); }); diff --git a/apps/server/spec/etapi/other.spec.ts b/apps/server/spec/etapi/other.spec.ts index 733ab12a6..d7c1d38b3 100644 --- a/apps/server/spec/etapi/other.spec.ts +++ b/apps/server/spec/etapi/other.spec.ts @@ -21,6 +21,6 @@ describe("etapi/refresh-note-ordering/root", () => { await supertest(app) .post("/etapi/refresh-note-ordering/root") .auth(USER, token, { "type": "basic"}) - .expect(200); + .expect(204); }); });