mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	test(etapi): port delete-note-with-all-branches
This commit is contained in:
		
							parent
							
								
									9d1717ca9f
								
							
						
					
					
						commit
						594e264eea
					
				| @ -1,126 +0,0 @@ | |||||||
| 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); |  | ||||||
|     client.global.set("createdBranchId", response.body.branch.branchId); |  | ||||||
| %} |  | ||||||
| 
 |  | ||||||
| ### |  | ||||||
| 
 |  | ||||||
| POST {{triliumHost}}/etapi/attributes |  | ||||||
| Authorization: {{authToken}} |  | ||||||
| Content-Type: application/json |  | ||||||
| 
 |  | ||||||
| { |  | ||||||
|   "noteId": "{{createdNoteId}}", |  | ||||||
|   "type": "label", |  | ||||||
|   "name": "mylabel", |  | ||||||
|   "value": "val", |  | ||||||
|   "isInheritable": true |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| > {% client.global.set("createdAttributeId", response.body.attributeId); %} |  | ||||||
| 
 |  | ||||||
| ### Clone to another location |  | ||||||
| 
 |  | ||||||
| POST {{triliumHost}}/etapi/branches |  | ||||||
| Authorization: {{authToken}} |  | ||||||
| Content-Type: application/json |  | ||||||
| 
 |  | ||||||
| { |  | ||||||
|   "noteId": "{{createdNoteId}}", |  | ||||||
|   "parentNoteId": "_hidden" |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| > {% client.global.set("clonedBranchId", response.body.branchId); %} |  | ||||||
| 
 |  | ||||||
| ### |  | ||||||
| 
 |  | ||||||
| GET {{triliumHost}}/etapi/notes/{{createdNoteId}} |  | ||||||
| Authorization: {{authToken}} |  | ||||||
| 
 |  | ||||||
| > {% client.assert(response.status === 200); %} |  | ||||||
| 
 |  | ||||||
| ### |  | ||||||
| 
 |  | ||||||
| GET {{triliumHost}}/etapi/branches/{{createdBranchId}} |  | ||||||
| Authorization: {{authToken}} |  | ||||||
| 
 |  | ||||||
| > {% client.assert(response.status === 200); %} |  | ||||||
| 
 |  | ||||||
| ### |  | ||||||
| 
 |  | ||||||
| GET {{triliumHost}}/etapi/branches/{{clonedBranchId}} |  | ||||||
| Authorization: {{authToken}} |  | ||||||
| 
 |  | ||||||
| > {% client.assert(response.status === 200); %} |  | ||||||
| 
 |  | ||||||
| ### |  | ||||||
| 
 |  | ||||||
| GET {{triliumHost}}/etapi/attributes/{{createdAttributeId}} |  | ||||||
| Authorization: {{authToken}} |  | ||||||
| 
 |  | ||||||
| > {% client.assert(response.status === 200); %} |  | ||||||
| 
 |  | ||||||
| ### |  | ||||||
| 
 |  | ||||||
| DELETE {{triliumHost}}/etapi/notes/{{createdNoteId}} |  | ||||||
| Authorization: {{authToken}} |  | ||||||
| 
 |  | ||||||
| > {% client.assert(response.status === 204, "Response status is not 204"); %} |  | ||||||
| 
 |  | ||||||
| ### repeat the DELETE request to test the idempotency |  | ||||||
| 
 |  | ||||||
| DELETE {{triliumHost}}/etapi/notes/{{createdNoteId}} |  | ||||||
| Authorization: {{authToken}} |  | ||||||
| 
 |  | ||||||
| > {% client.assert(response.status === 204, "Response status is not 204"); %} |  | ||||||
| 
 |  | ||||||
| ### |  | ||||||
| 
 |  | ||||||
| GET {{triliumHost}}/etapi/branches/{{createdBranchId}} |  | ||||||
| Authorization: {{authToken}} |  | ||||||
| 
 |  | ||||||
| > {% |  | ||||||
|     client.assert(response.status === 404, "Response status is not 404"); |  | ||||||
|     client.assert(response.body.code === "BRANCH_NOT_FOUND"); |  | ||||||
| %} |  | ||||||
| 
 |  | ||||||
| ### |  | ||||||
| 
 |  | ||||||
| GET {{triliumHost}}/etapi/branches/{{clonedBranchId}} |  | ||||||
| Authorization: {{authToken}} |  | ||||||
| 
 |  | ||||||
| > {% |  | ||||||
|     client.assert(response.status === 404, "Response status is not 404"); |  | ||||||
|     client.assert(response.body.code == "BRANCH_NOT_FOUND"); |  | ||||||
| %} |  | ||||||
| 
 |  | ||||||
| ### |  | ||||||
| 
 |  | ||||||
| GET {{triliumHost}}/etapi/notes/{{createdNoteId}} |  | ||||||
| Authorization: {{authToken}} |  | ||||||
| 
 |  | ||||||
| > {% |  | ||||||
|     client.assert(response.status === 404, "Response status is not 404"); |  | ||||||
|     client.assert(response.body.code === "NOTE_NOT_FOUND"); |  | ||||||
| %} |  | ||||||
| 
 |  | ||||||
| ### |  | ||||||
| 
 |  | ||||||
| GET {{triliumHost}}/etapi/attributes/{{createdAttributeId}} |  | ||||||
| Authorization: {{authToken}} |  | ||||||
| 
 |  | ||||||
| > {% |  | ||||||
|     client.assert(response.status === 404, "Response status is not 404"); |  | ||||||
|     client.assert(response.body.code === "ATTRIBUTE_NOT_FOUND"); |  | ||||||
| %} |  | ||||||
| @ -56,6 +56,30 @@ describe("etapi/delete-entities", () => { | |||||||
|         expectFound("branches", clonedBranchId); |         expectFound("branches", clonedBranchId); | ||||||
|         expectFound("notes", createdNoteId); |         expectFound("notes", createdNoteId); | ||||||
|     }); |     }); | ||||||
|  | 
 | ||||||
|  |     it("deletes note with all branches", async () => { | ||||||
|  |         const attributeId = await createAttribute(); | ||||||
|  | 
 | ||||||
|  |         const response = await supertest(app) | ||||||
|  |             .post("/etapi/branches") | ||||||
|  |             .auth(USER, token, { "type": "basic"}) | ||||||
|  |             .send({ | ||||||
|  |                 noteId: createdNoteId, | ||||||
|  |                 parentNoteId: "_hidden" | ||||||
|  |             }); | ||||||
|  |         const clonedBranchId = response.body.branchId; | ||||||
|  | 
 | ||||||
|  |         expectFound("notes", createdNoteId); | ||||||
|  |         expectFound("branches", createdBranchId); | ||||||
|  |         expectFound("branches", clonedBranchId); | ||||||
|  |         expectFound("attributes", attributeId); | ||||||
|  |         deleteEntity("notes", createdNoteId); | ||||||
|  | 
 | ||||||
|  |         expectNotFound("branches", createdBranchId); | ||||||
|  |         expectNotFound("branches", clonedBranchId); | ||||||
|  |         expectNotFound("notes", createdNoteId); | ||||||
|  |         expectNotFound("attributes", attributeId); | ||||||
|  |     }); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| async function createNote() { | async function createNote() { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran