From 49d4fd44a3e542dc366e594038598d54f0e861b5 Mon Sep 17 00:00:00 2001 From: Jillian Date: Fri, 2 Feb 2024 17:00:04 +1030 Subject: [PATCH] fix: fixed typo in updateContentTaxonomyTags URL [FC-0036] (#815) * fix: fixed typo in updateContentTaxonomyTags URL * fix: use params instead of urlencoding --- src/content-tags-drawer/data/api.js | 6 +++--- src/content-tags-drawer/data/api.test.js | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/content-tags-drawer/data/api.js b/src/content-tags-drawer/data/api.js index d5a4f3de1..28bd7a36c 100644 --- a/src/content-tags-drawer/data/api.js +++ b/src/content-tags-drawer/data/api.js @@ -75,8 +75,8 @@ export async function getContentData(contentId) { * @returns {Promise} */ export async function updateContentTaxonomyTags(contentId, taxonomyId, tags) { - let url = getContentTaxonomyTagsApiUrl(contentId); - url = `${url}&taxonomy=${taxonomyId}`; - const { data } = await getAuthenticatedHttpClient().put(url, { tags }); + const url = getContentTaxonomyTagsApiUrl(contentId); + const params = { taxonomy: taxonomyId }; + const { data } = await getAuthenticatedHttpClient().put(url, { tags }, { params }); return camelCaseObject(data[contentId]); } diff --git a/src/content-tags-drawer/data/api.test.js b/src/content-tags-drawer/data/api.test.js index 229e6daee..1ac441c2f 100644 --- a/src/content-tags-drawer/data/api.test.js +++ b/src/content-tags-drawer/data/api.test.js @@ -110,10 +110,11 @@ describe('content tags drawer api calls', () => { const contentId = 'block-v1:SampleTaxonomyOrg1+STC1+2023_1+type@vertical+block@aaf8b8eb86b54281aeeab12499d2cb0b'; const taxonomyId = 3; const tags = ['flat taxonomy tag 100', 'flat taxonomy tag 3856']; - axiosMock.onPut(`${getContentTaxonomyTagsApiUrl(contentId)}&taxonomy=${taxonomyId}`).reply(200, updateContentTaxonomyTagsMock); + axiosMock.onPut(`${getContentTaxonomyTagsApiUrl(contentId)}`).reply(200, updateContentTaxonomyTagsMock); const result = await updateContentTaxonomyTags(contentId, taxonomyId, tags); - expect(axiosMock.history.put[0].url).toEqual(`${getContentTaxonomyTagsApiUrl(contentId)}&taxonomy=${taxonomyId}`); + expect(axiosMock.history.put[0].url).toEqual(`${getContentTaxonomyTagsApiUrl(contentId)}`); + expect(axiosMock.history.put[0].params).toEqual({ taxonomy: taxonomyId }); expect(result).toEqual(updateContentTaxonomyTagsMock[contentId]); }); });