Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit af3a0cc

Browse files
committed
test(routes/login): add initial test via supertest for failed login
1 parent cb80d62 commit af3a0cc

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/routes/login.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { beforeAll, describe, it } from "vitest";
2+
import supertest from "supertest";
3+
import { initializeTranslations } from "../services/i18n.js";
4+
import type { Application, Request, Response, NextFunction } from "express";
5+
6+
let app: Application;
7+
8+
describe("Login Route test", () => {
9+
10+
beforeAll(async () => {
11+
initializeTranslations();
12+
app = (await import("../app.js")).default;
13+
});
14+
15+
it("return a 401 status, when login fails with wrong password", async () => {
16+
17+
await supertest(app)
18+
.post("/login")
19+
.send({ password: "fakePassword" })
20+
.expect(401)
21+
22+
});
23+
24+
// TriliumNextTODO: how to handle different configs here? e.g. TOTP, or different cookieMaxAge from config.ini
25+
26+
/*
27+
28+
it("sets correct Expires, when 'Remember Me' is ticked", async () => {
29+
await supertest(app)
30+
.post("/login")
31+
.expect(302)
32+
.expect("Set-Cookie", "trilium.sid=trilium.sid; Path=/; Expires=TODO");
33+
});
34+
35+
*/
36+
});

0 commit comments

Comments
 (0)