From dc6bbbf684aa26ef2957387ea4992cebb7e4f6df Mon Sep 17 00:00:00 2001 From: Vincent Moittie Date: Fri, 11 Oct 2024 14:52:52 +0200 Subject: [PATCH] Fix bug on synchronize library --- src/services/LibraryService.js | 6 +++++- tests/e2e/support/step_definitions/api.js | 2 +- tests/unit/services/LibraryService.test.js | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/services/LibraryService.js b/src/services/LibraryService.js index 85ac750f..6af39f27 100644 --- a/src/services/LibraryService.js +++ b/src/services/LibraryService.js @@ -72,5 +72,9 @@ export async function create(url, role) { export async function synchronize(id, url) { const api = await prepareRequest(); - return api.put(`/libraries/${id}`, { url }).then(({ data }) => data); + return api.put(`/libraries/${id}`, url, { + headers: { + 'Content-Type': 'text/plain', + }, + }).then(({ data }) => data); } diff --git a/tests/e2e/support/step_definitions/api.js b/tests/e2e/support/step_definitions/api.js index 10672dd6..91ba909b 100644 --- a/tests/e2e/support/step_definitions/api.js +++ b/tests/e2e/support/step_definitions/api.js @@ -875,7 +875,7 @@ function setLibraryIntercepts() { }); cy.intercept('PUT', '/api/libraries/1', (request) => { - const { url } = request.body; + const url = request.body; if (url === 'notFound') { request.reply({ diff --git a/tests/unit/services/LibraryService.test.js b/tests/unit/services/LibraryService.test.js index 9ba02fa6..869fa26b 100644 --- a/tests/unit/services/LibraryService.test.js +++ b/tests/unit/services/LibraryService.test.js @@ -114,7 +114,11 @@ describe('Test: LibraryService', () => { const result = await LibraryService.synchronize('id', 'url'); - expect(mockPutRequest).toBeCalledWith('/libraries/id', { url: 'url' }); + expect(mockPutRequest).toBeCalledWith('/libraries/id', 'url', { + headers: { + 'Content-Type': 'text/plain', + }, + }); expect(result).toEqual({ id: 1 }); }); });