mirror of
https://github.com/zadam/trilium.git
synced 2025-10-29 17:26:38 +01:00
etapi improvements and more tests
This commit is contained in:
@@ -3,18 +3,20 @@ Authorization: {{authToken}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"noteId": "forcedId{{$randomInt}}",
|
||||
"branchId": "forcedId{{$randomInt}}",
|
||||
"parentNoteId": "root",
|
||||
"title": "Hello",
|
||||
"type": "text",
|
||||
"content": "Hi there!"
|
||||
}
|
||||
|
||||
> {%
|
||||
client.test("Request executed successfully", function() {
|
||||
client.assert(response.status === 200, "Response status is not 200");
|
||||
client.assert(response.body.note.title == "Hello");
|
||||
client.assert(response.body.branch.parentNoteId == "root");
|
||||
});
|
||||
> {%
|
||||
client.assert(response.status === 200);
|
||||
client.assert(response.body.note.noteId.startsWith("forcedId"));
|
||||
client.assert(response.body.note.title == "Hello");
|
||||
client.assert(response.body.branch.branchId.startsWith("forcedId"));
|
||||
client.assert(response.body.branch.parentNoteId == "root");
|
||||
|
||||
client.log(`Created note ` + response.body.note.noteId + ` and branch ` + response.body.branch.branchId);
|
||||
|
||||
@@ -29,15 +31,14 @@ Authorization: {{authToken}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"branchId": "forcedClonedId",
|
||||
"noteId": "{{createdNoteId}}",
|
||||
"parentNoteId": "hidden"
|
||||
}
|
||||
|
||||
> {%
|
||||
client.test("Request executed successfully", function() {
|
||||
client.assert(response.status === 200, "Response status is not 200");
|
||||
client.assert(response.body.parentNoteId == "hidden");
|
||||
});
|
||||
client.assert(response.status === 200);
|
||||
client.assert(response.body.parentNoteId == "hidden");
|
||||
|
||||
client.global.set("clonedBranchId", response.body.branchId);
|
||||
|
||||
@@ -50,14 +51,12 @@ GET {{triliumHost}}/etapi/notes/{{createdNoteId}}
|
||||
Authorization: {{authToken}}
|
||||
|
||||
> {%
|
||||
client.test("Request executed successfully", function() {
|
||||
client.assert(response.status === 200, "Response status is not 200");
|
||||
client.assert(response.body.noteId == client.global.get("createdNoteId"));
|
||||
client.assert(response.body.title == "Hello");
|
||||
// order is not defined and may fail in the future
|
||||
client.assert(response.body.parentBranchIds[0] == client.global.get("clonedBranchId"))
|
||||
client.assert(response.body.parentBranchIds[1] == client.global.get("createdBranchId"));
|
||||
});
|
||||
client.assert(response.status === 200);
|
||||
client.assert(response.body.noteId == client.global.get("createdNoteId"));
|
||||
client.assert(response.body.title == "Hello");
|
||||
// order is not defined and may fail in the future
|
||||
client.assert(response.body.parentBranchIds[0] == client.global.get("clonedBranchId"))
|
||||
client.assert(response.body.parentBranchIds[1] == client.global.get("createdBranchId"));
|
||||
%}
|
||||
|
||||
###
|
||||
@@ -66,10 +65,8 @@ GET {{triliumHost}}/etapi/notes/{{createdNoteId}}/content
|
||||
Authorization: {{authToken}}
|
||||
|
||||
> {%
|
||||
client.test("Request executed successfully", function() {
|
||||
client.assert(response.status === 200, "Response status is not 200");
|
||||
client.assert(response.body == "Hi there!");
|
||||
});
|
||||
client.assert(response.status === 200);
|
||||
client.assert(response.body == "Hi there!");
|
||||
%}
|
||||
|
||||
###
|
||||
@@ -78,11 +75,9 @@ GET {{triliumHost}}/etapi/branches/{{createdBranchId}}
|
||||
Authorization: {{authToken}}
|
||||
|
||||
> {%
|
||||
client.test("Request executed successfully", function() {
|
||||
client.assert(response.status === 200, "Response status is not 200");
|
||||
client.assert(response.body.branchId == client.global.get("createdBranchId"));
|
||||
client.assert(response.body.parentNoteId == "root");
|
||||
});
|
||||
client.assert(response.status === 200);
|
||||
client.assert(response.body.branchId == client.global.get("createdBranchId"));
|
||||
client.assert(response.body.parentNoteId == "root");
|
||||
%}
|
||||
|
||||
###
|
||||
@@ -91,11 +86,9 @@ GET {{triliumHost}}/etapi/branches/{{clonedBranchId}}
|
||||
Authorization: {{authToken}}
|
||||
|
||||
> {%
|
||||
client.test("Request executed successfully", function() {
|
||||
client.assert(response.status === 200, "Response status is not 200");
|
||||
client.assert(response.body.branchId == client.global.get("clonedBranchId"));
|
||||
client.assert(response.body.parentNoteId == "hidden");
|
||||
});
|
||||
client.assert(response.status === 200);
|
||||
client.assert(response.body.branchId == client.global.get("clonedBranchId"));
|
||||
client.assert(response.body.parentNoteId == "hidden");
|
||||
%}
|
||||
|
||||
###
|
||||
@@ -105,19 +98,17 @@ Content-Type: application/json
|
||||
Authorization: {{authToken}}
|
||||
|
||||
{
|
||||
"attributeId": "forcedAttributeId{{$randomInt}}",
|
||||
"noteId": "{{createdNoteId}}",
|
||||
"type": "label",
|
||||
"name": "mylabel",
|
||||
"value": "val",
|
||||
"isInheritable": "true"
|
||||
"isInheritable": true
|
||||
}
|
||||
|
||||
> {%
|
||||
client.test("Request executed successfully", function() {
|
||||
client.assert(response.status === 200, "Response status is not 200");
|
||||
});
|
||||
|
||||
client.log(`Created attribute ` + response.body.attributeId);
|
||||
client.assert(response.status === 200);
|
||||
client.assert(response.body.attributeId.startsWith("forcedAttributeId"));
|
||||
|
||||
client.global.set("createdAttributeId", response.body.attributeId);
|
||||
%}
|
||||
@@ -128,8 +119,6 @@ GET {{triliumHost}}/etapi/attributes/{{createdAttributeId}}
|
||||
Authorization: {{authToken}}
|
||||
|
||||
> {%
|
||||
client.test("Request executed successfully", function() {
|
||||
client.assert(response.status === 200, "Response status is not 200");
|
||||
client.assert(response.body.attributeId == client.global.get("createdAttributeId"));
|
||||
});
|
||||
client.assert(response.status === 200);
|
||||
client.assert(response.body.attributeId == client.global.get("createdAttributeId"));
|
||||
%}
|
||||
Reference in New Issue
Block a user