mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
test(etapi): port app-info
This commit is contained in:
parent
d9249e3760
commit
053ff0568d
@ -1,7 +0,0 @@
|
|||||||
GET {{triliumHost}}/etapi/app-info
|
|
||||||
Authorization: {{authToken}}
|
|
||||||
|
|
||||||
> {%
|
|
||||||
client.assert(response.status === 200);
|
|
||||||
client.assert(response.body.clipperProtocolVersion === "1.0");
|
|
||||||
%}
|
|
20
apps/server/spec/etapi/app-info.spec.ts
Normal file
20
apps/server/spec/etapi/app-info.spec.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { Application } from "express";
|
||||||
|
import { beforeAll, describe, expect, it } from "vitest";
|
||||||
|
import buildApp from "../../src/app.js";
|
||||||
|
import supertest from "supertest";
|
||||||
|
|
||||||
|
let app: Application;
|
||||||
|
let token: string;
|
||||||
|
|
||||||
|
describe("etapi/app-info", () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
app = await buildApp();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("retrieves correct app info", async () => {
|
||||||
|
const response = await supertest(app)
|
||||||
|
.get("/etapi/app-info")
|
||||||
|
.expect(200);
|
||||||
|
expect(response.body.clipperProtocolVersion).toBe("1.0");
|
||||||
|
});
|
||||||
|
});
|
15
apps/server/spec/etapi/utils.ts
Normal file
15
apps/server/spec/etapi/utils.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import type { Application } from "express";
|
||||||
|
import supertest from "supertest";
|
||||||
|
import { expect } from "vitest";
|
||||||
|
|
||||||
|
export async function login(app: Application) {
|
||||||
|
// Obtain auth token.
|
||||||
|
const response = await supertest(app)
|
||||||
|
.post("/etapi/auth/login")
|
||||||
|
.send({
|
||||||
|
"password": "demo1234"
|
||||||
|
})
|
||||||
|
.expect(201);
|
||||||
|
const token = response.body.authToken;
|
||||||
|
expect(token).toBeTruthy();
|
||||||
|
}
|
@ -7,6 +7,8 @@ import dayjs from "dayjs";
|
|||||||
process.env.TRILIUM_DATA_DIR = join(__dirname, "db");
|
process.env.TRILIUM_DATA_DIR = join(__dirname, "db");
|
||||||
process.env.TRILIUM_RESOURCE_DIR = join(__dirname, "../src");
|
process.env.TRILIUM_RESOURCE_DIR = join(__dirname, "../src");
|
||||||
process.env.TRILIUM_INTEGRATION_TEST = "memory";
|
process.env.TRILIUM_INTEGRATION_TEST = "memory";
|
||||||
|
process.env.TRILIUM_ENV = "dev";
|
||||||
|
process.env.TRILIUM_PUBLIC_SERVER = "http://localhost:4200";
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// Initialize the translations manually to avoid any side effects.
|
// Initialize the translations manually to avoid any side effects.
|
||||||
|
@ -10,7 +10,7 @@ export default defineConfig(() => ({
|
|||||||
globals: true,
|
globals: true,
|
||||||
setupFiles: ["./spec/setup.ts"],
|
setupFiles: ["./spec/setup.ts"],
|
||||||
environment: "node",
|
environment: "node",
|
||||||
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
include: ['{src,spec}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
||||||
reporters: ['default'],
|
reporters: ['default'],
|
||||||
coverage: {
|
coverage: {
|
||||||
reportsDirectory: './test-output/vitest/coverage',
|
reportsDirectory: './test-output/vitest/coverage',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user