mirror of
https://github.com/zadam/trilium.git
synced 2024-12-26 01:01:26 +08:00
attachment ETAPI tests WIP
This commit is contained in:
parent
5c393f959d
commit
00453fc151
5 changed files with 216 additions and 18 deletions
52
test-etapi/delete-attachment.http
Normal file
52
test-etapi/delete-attachment.http
Normal file
|
@ -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");
|
||||
%}
|
|
@ -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}}
|
||||
|
||||
|
|
79
test-etapi/patch-attachment.http
Normal file
79
test-etapi/patch-attachment.http
Normal file
|
@ -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");
|
||||
%}
|
39
test-etapi/put-attachment-content-binary.http
Normal file
39
test-etapi/put-attachment-content-binary.http
Normal file
|
@ -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); %}
|
45
test-etapi/put-attachment-content.http
Normal file
45
test-etapi/put-attachment-content.http
Normal file
|
@ -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"); %}
|
Loading…
Reference in a new issue