Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
attachment ETAPI tests WIP
zadam00453fc1519b
diff --git a/test-etapi/delete-attachment.http b/test-etapi/delete-attachment.httpnew file mode 100644index 0000000000..3ed0dc4ec2--- /dev/null+++ b/test-etapi/delete-attachment.http@@ -0,0 +1,52 @@+POST {{triliumHost}}/etapi/create-note+Authorization: {{authToken}}+Content-Type: application/json++{+ "parentNoteId": "root",+ "title": "Hello",+ "type": "text",+ "content": "Hi there!"+}++> {% client.global.set("createdNoteId", response.body.note.noteId); %}++###++POST {{triliumHost}}/etapi/attachments+Authorization: {{authToken}}+Content-Type: application/json++{+ "parentId": "{{createdNoteId}}",+ "role": "file",+ "mime": "text/plain",+ "title": "my attachment",+ "content": "text"+}++> {% client.global.set("createdAttachmentId", response.body.attachmentId); %}++###++DELETE {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}+Authorization: {{authToken}}++> {% client.assert(response.status === 204, "Response status is not 204"); %}++### repeat the DELETE request to test the idempotency++DELETE {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}+Authorization: {{authToken}}++> {% client.assert(response.status === 204, "Response status is not 204"); %}++###++GET {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}+Authorization: {{authToken}}++> {%+ client.assert(response.status === 404, "Response status is not 404");+ client.assert(response.body.code === "ATTACHMENT_NOT_FOUND");+%}diff --git a/test-etapi/delete-attribute.http b/test-etapi/delete-attribute.httpindex 7433715e8c..d61b75ba2b 100644--- a/test-etapi/delete-attribute.http+++ b/test-etapi/delete-attribute.http@@ -9,10 +9,7 @@ Content-Type: application/json"content": "Hi there!"}-> {%- client.global.set("createdNoteId", response.body.note.noteId);- client.global.set("createdBranchId", response.body.branch.branchId);-%}+> {% client.global.set("createdNoteId", response.body.note.noteId); %}###@@ -32,20 +29,6 @@ Content-Type: application/json###-GET {{triliumHost}}/etapi/notes/{{createdNoteId}}-Authorization: {{authToken}}--> {% client.assert(response.status === 200); %}--###--GET {{triliumHost}}/etapi/branches/{{createdBranchId}}-Authorization: {{authToken}}--> {% client.assert(response.status === 200); %}--###-DELETE {{triliumHost}}/etapi/attributes/{{createdAttributeId}}Authorization: {{authToken}}diff --git a/test-etapi/patch-attachment.http b/test-etapi/patch-attachment.httpnew file mode 100644index 0000000000..8fd0fea1b7--- /dev/null+++ b/test-etapi/patch-attachment.http@@ -0,0 +1,79 @@+POST {{triliumHost}}/etapi/create-note+Authorization: {{authToken}}+Content-Type: application/json++{+ "parentNoteId": "root",+ "title": "Hello",+ "type": "text",+ "content": "Hi there!"+}++> {% client.global.set("createdNoteId", response.body.note.noteId); %}++###++POST {{triliumHost}}/etapi/attachments+Authorization: {{authToken}}+Content-Type: application/json++{+ "parentId": "{{createdNoteId}}",+ "role": "file",+ "mime": "text/plain",+ "title": "my attachment",+ "content": "text"+}++> {% client.global.set("createdAttachmentId", response.body.attachmentId); %}++###++PATCH {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}+Authorization: {{authToken}}+Content-Type: application/json++{+ "title": "CHANGED",+ "position": 999+}++###++GET {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}+Authorization: {{authToken}}++> {%+ client.assert(response.body.title === "CHANGED");+ client.assert(response.body.position === 999);+%}++###++PATCH {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}+Authorization: {{authToken}}+Content-Type: application/json++{+ "parentId": "root"+}++> {%+ client.assert(response.status === 400);+ client.assert(response.body.code == "PROPERTY_NOT_ALLOWED");+%}++###++PATCH {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}+Authorization: {{authToken}}+Content-Type: application/json++{+ "title": null+}++> {%+ client.assert(response.status === 400);+ client.assert(response.body.code == "PROPERTY_VALIDATION_ERROR");+%}\ No newline at end of filediff --git a/test-etapi/put-attachment-content-binary.http b/test-etapi/put-attachment-content-binary.httpnew file mode 100644index 0000000000..232667e567--- /dev/null+++ b/test-etapi/put-attachment-content-binary.http@@ -0,0 +1,39 @@+POST {{triliumHost}}/etapi/create-note+Authorization: {{authToken}}+Content-Type: application/json++{+ "parentNoteId": "root",+ "title": "Hello",+ "type": "text",+ "content": "Hi there!"+}++> {% client.global.set("createdNoteId", response.body.note.noteId); %}++###++POST {{triliumHost}}/etapi/attachments+Authorization: {{authToken}}+Content-Type: application/json++{+ "parentId": "{{createdNoteId}}",+ "role": "file",+ "mime": "text/plain",+ "title": "my attachment",+ "content": "text"+}++> {% client.global.set("createdAttachmentId", response.body.attachmentId); %}++###++PUT {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}/content+Authorization: {{authToken}}+Content-Type: application/octet-stream+Content-Transfer-Encoding: binary++< ../images/icon-color.png++> {% client.assert(response.status === 204); %}\ No newline at end of filediff --git a/test-etapi/put-attachment-content.http b/test-etapi/put-attachment-content.httpnew file mode 100644index 0000000000..2d0d809492--- /dev/null+++ b/test-etapi/put-attachment-content.http@@ -0,0 +1,45 @@+POST {{triliumHost}}/etapi/create-note+Authorization: {{authToken}}+Content-Type: application/json++{+ "parentNoteId": "root",+ "title": "Hello",+ "type": "text",+ "content": "Hi there!"+}++> {% client.global.set("createdNoteId", response.body.note.noteId); %}++###++POST {{triliumHost}}/etapi/attachments+Authorization: {{authToken}}+Content-Type: application/json++{+ "parentId": "{{createdNoteId}}",+ "role": "file",+ "mime": "text/plain",+ "title": "my attachment",+ "content": "text"+}++> {% client.global.set("createdAttachmentId", response.body.attachmentId); %}++###++PUT {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}/content+Authorization: {{authToken}}+Content-Type: text/plain++Changed content++> {% client.assert(response.status === 204); %}++###++GET {{triliumHost}}/etapi/attachments/{{createdAttachmentId}}/content+Authorization: {{authToken}}++> {% client.assert(response.body === "Changed content"); %}