mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
test(etapi): port post revision
This commit is contained in:
parent
bef121239c
commit
842c8a5028
@ -1,23 +0,0 @@
|
|||||||
POST {{triliumHost}}/etapi/create-note
|
|
||||||
Authorization: {{authToken}}
|
|
||||||
Content-Type: application/json
|
|
||||||
|
|
||||||
{
|
|
||||||
"parentNoteId": "root",
|
|
||||||
"title": "Hello",
|
|
||||||
"type": "code",
|
|
||||||
"mime": "text/plain",
|
|
||||||
"content": "Hi there!"
|
|
||||||
}
|
|
||||||
|
|
||||||
> {% client.global.set("createdNoteId", response.body.note.noteId); %}
|
|
||||||
|
|
||||||
###
|
|
||||||
|
|
||||||
POST {{triliumHost}}/etapi/notes/{{createdNoteId}}/revision
|
|
||||||
Authorization: {{authToken}}
|
|
||||||
Content-Type: text/plain
|
|
||||||
|
|
||||||
Changed content
|
|
||||||
|
|
||||||
> {% client.assert(response.status === 204); %}
|
|
29
apps/server/spec/etapi/post-revision.spec.ts
Normal file
29
apps/server/spec/etapi/post-revision.spec.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
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";
|
||||||
|
|
||||||
|
let app: Application;
|
||||||
|
let token: string;
|
||||||
|
|
||||||
|
const USER = "etapi";
|
||||||
|
let createdNoteId: string;
|
||||||
|
|
||||||
|
describe("etapi/post-revision", () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
config.General.noAuthentication = false;
|
||||||
|
const buildApp = (await (import("../../src/app.js"))).default;
|
||||||
|
app = await buildApp();
|
||||||
|
token = await login(app);
|
||||||
|
createdNoteId = await createNote(app, token);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("posts note revision", async () => {
|
||||||
|
await supertest(app)
|
||||||
|
.post(`/etapi/notes/${createdNoteId}/revision`)
|
||||||
|
.auth(USER, token, { "type": "basic"})
|
||||||
|
.send("Changed content")
|
||||||
|
.expect(204);
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user