diff --git a/apps/server/src/becca/entities/brevision.spec.ts b/apps/server/src/becca/entities/brevision.spec.ts index 176ee66c0..1181c956c 100644 --- a/apps/server/src/becca/entities/brevision.spec.ts +++ b/apps/server/src/becca/entities/brevision.spec.ts @@ -1,3 +1,5 @@ +import { describe, expect, it } from "vitest"; + import BRevision from "./brevision.js"; describe("Revision", () => { diff --git a/apps/server/src/becca/similarity.spec.ts b/apps/server/src/becca/similarity.spec.ts index 4809e1f13..f7f9df909 100644 --- a/apps/server/src/becca/similarity.spec.ts +++ b/apps/server/src/becca/similarity.spec.ts @@ -1,4 +1,6 @@ import { trimIndentation } from "@triliumnext/commons"; +import { describe, expect, it } from "vitest"; + import { buildNote } from "../test/becca_easy_mocking"; import { buildRewardMap } from "./similarity"; diff --git a/apps/server/src/routes/api/clipper.spec.ts b/apps/server/src/routes/api/clipper.spec.ts index 4bfac679e..693b831a6 100644 --- a/apps/server/src/routes/api/clipper.spec.ts +++ b/apps/server/src/routes/api/clipper.spec.ts @@ -1,3 +1,5 @@ +import { beforeAll, describe, expect, it, vi } from "vitest"; + import BNote from '../../becca/entities/bnote.js'; import cls from "../../services/cls"; import { buildNote } from "../../test/becca_easy_mocking"; @@ -17,7 +19,7 @@ describe("processContent", () => { return { attachmentId: "foo", title: "encodedTitle", - } + }; } } })); @@ -25,12 +27,12 @@ describe("processContent", () => { it("processes basic note", () => { const processed = cls.init(() => processContent([], note, "
Hello world.
")); - expect(processed).toStrictEqual("Hello world.
") + expect(processed).toStrictEqual("Hello world.
"); }); it("processes plain text", () => { const processed = cls.init(() => processContent([], note, "Hello world.")); - expect(processed).toStrictEqual("Hello world.
") + expect(processed).toStrictEqual("Hello world.
"); }); it("replaces images", () => { diff --git a/apps/server/src/routes/api/llm.spec.ts b/apps/server/src/routes/api/llm.spec.ts index 846b9ecc9..bbc3aaf7a 100644 --- a/apps/server/src/routes/api/llm.spec.ts +++ b/apps/server/src/routes/api/llm.spec.ts @@ -1,9 +1,10 @@ -import { Application } from "express"; -import { beforeAll, describe, expect, it, vi, beforeEach, afterEach } from "vitest"; -import supertest from "supertest"; -import config from "../../services/config.js"; -import { refreshAuth } from "../../services/auth.js"; import { sleepFor } from "@triliumnext/commons"; +import { Application } from "express"; +import supertest from "supertest"; +import { afterAll,afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; + +import { refreshAuth } from "../../services/auth.js"; +import config from "../../services/config.js"; // Mock the CSRF protection middleware to allow tests to pass vi.mock("../csrf_protection.js", () => ({ @@ -841,7 +842,7 @@ describe("LLM API Tests", () => { try { await supertest(app) .delete(`/api/llm/chat/${createdChatId}`) - ; + ; } catch (error) { // Ignore cleanup errors } diff --git a/apps/server/src/routes/api/note_map.spec.ts b/apps/server/src/routes/api/note_map.spec.ts index 0ab5d1d2d..6d37ce269 100644 --- a/apps/server/src/routes/api/note_map.spec.ts +++ b/apps/server/src/routes/api/note_map.spec.ts @@ -1,4 +1,6 @@ import { trimIndentation } from "@triliumnext/commons"; +import { describe, expect, it } from "vitest"; + import { buildNote, buildNotes } from "../../test/becca_easy_mocking"; import note_map from "./note_map"; diff --git a/apps/server/src/routes/login.spec.ts b/apps/server/src/routes/login.spec.ts index 07451ec43..0f210bfdc 100644 --- a/apps/server/src/routes/login.spec.ts +++ b/apps/server/src/routes/login.spec.ts @@ -1,10 +1,11 @@ -import { beforeAll, describe, expect, it } from "vitest"; -import supertest, { type Response } from "supertest"; -import type { Application } from "express"; import { dayjs } from "@triliumnext/commons"; -import { type SQLiteSessionStore } from "./session_parser.js"; +import type { Application } from "express"; import { SessionData } from "express-session"; +import supertest, { type Response } from "supertest"; +import { beforeAll, describe, expect, it, vi } from "vitest"; + import cls from "../services/cls.js"; +import { type SQLiteSessionStore } from "./session_parser.js"; let app: Application; let sessionStore: SQLiteSessionStore; @@ -24,7 +25,7 @@ describe("Login Route test", () => { // RegExp for login page specific string in HTML const res = await supertest(app) .get("/login") - .expect(200) + .expect(200); expect(res.text).toMatch(/assets\/v[0-9.a-z]+\/src\/login\.js/); @@ -35,7 +36,7 @@ describe("Login Route test", () => { await supertest(app) .post("/login") .send({ password: "fakePassword" }) - .expect(401) + .expect(401); }); @@ -69,7 +70,7 @@ describe("Login Route test", () => { // ignore the seconds in the comparison, just to avoid flakiness in tests, // if for some reason execution is slow between calculation of expected and actual - expect(actualExpiresDate.slice(0,23)).toBe(expectedExpiresDate.slice(0,23)) + expect(actualExpiresDate.slice(0,23)).toBe(expectedExpiresDate.slice(0,23)); }); it("sets the correct sesssion data", async () => { @@ -121,14 +122,14 @@ describe("Login Route test", () => { res = await supertest(app) .post("/login") .send({ password: "demo1234" }) - .expect(302) + .expect(302); setCookieHeader = res.headers["set-cookie"][0]; }); it("does not set Expires", async () => { // match for e.g. "Expires=Wed, 07 May 2025 07:02:59 GMT;" - expect(setCookieHeader).not.toMatch(/Expires=(?