refactor(api/private/media): return MediaUpload object instead of url

This ensures the private POST /media API behaves in the same way as /me/media

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-01-29 18:57:44 +01:00
parent 4f10e17d40
commit 8e31f3a393
10 changed files with 50 additions and 43 deletions

View file

@ -64,7 +64,7 @@ describe('Media', () => {
.set('HedgeDoc-Note', 'test_upload_media')
.expect('Content-Type', /json/)
.expect(201);
const path: string = uploadResponse.body.link;
const path: string = uploadResponse.body.url;
const testImage = await fs.readFile('test/private-api/fixtures/test.png');
const downloadResponse = await agent.get(path);
expect(downloadResponse.body).toEqual(testImage);
@ -117,12 +117,12 @@ describe('Media', () => {
'test_delete_media',
);
const testImage = await fs.readFile('test/private-api/fixtures/test.png');
const url = await testSetup.mediaService.saveFile(
const upload = await testSetup.mediaService.saveFile(
testImage,
user,
testNote,
);
const filename = url.split('/').pop() || '';
const filename = upload.fileUrl.split('/').pop() || '';
await agent.delete('/api/private/media/' + filename).expect(204);
});
});