mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
test(etapi): port search
This commit is contained in:
40
apps/server/spec/etapi/search.spec.ts
Normal file
40
apps/server/spec/etapi/search.spec.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Application } from "express";
|
||||
import { beforeAll, describe, expect, it } from "vitest";
|
||||
import supertest from "supertest";
|
||||
import { createNote, login } from "./utils.js";
|
||||
import config from "../../src/services/config.js";
|
||||
import { randomUUID } from "crypto";
|
||||
|
||||
let app: Application;
|
||||
let token: string;
|
||||
|
||||
const USER = "etapi";
|
||||
let content: string;
|
||||
|
||||
describe("etapi/search", () => {
|
||||
beforeAll(async () => {
|
||||
config.General.noAuthentication = false;
|
||||
const buildApp = (await (import("../../src/app.js"))).default;
|
||||
app = await buildApp();
|
||||
token = await login(app);
|
||||
|
||||
content = randomUUID();
|
||||
await createNote(app, token, content);
|
||||
});
|
||||
|
||||
it("finds by content", async () => {
|
||||
const response = await supertest(app)
|
||||
.get(`/etapi/notes?search=${content}&debug=true`)
|
||||
.auth(USER, token, { "type": "basic"})
|
||||
.expect(200);
|
||||
expect(response.body.results).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("does not find by content when fast search is on", async () => {
|
||||
const response = await supertest(app)
|
||||
.get(`/etapi/notes?search=${content}&debug=true&fastSearch=true`)
|
||||
.auth(USER, token, { "type": "basic"})
|
||||
.expect(200);
|
||||
expect(response.body.results).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user