Просмотр исходного кода

Merge pull request #18424 from overleaf/ii-delete-with-body-fe

[web] Replace delete with post requests when having body (FE)

GitOrigin-RevId: df727f35ea77eaa8273687f75aafd9bd983b7f25
ilkin-overleaf 2 лет назад
Родитель
Сommit
d56f5a3030

+ 1 - 1
services/web/frontend/js/features/project-list/util/api.ts

@@ -42,7 +42,7 @@ export function removeProjectFromTag(tagId: string, projectId: string) {
 }
 }
 
 
 export function removeProjectsFromTag(tagId: string, projectIds: string[]) {
 export function removeProjectsFromTag(tagId: string, projectIds: string[]) {
-  return deleteJSON(`/tag/${tagId}/projects`, {
+  return postJSON(`/tag/${tagId}/projects/remove`, {
     body: {
     body: {
       projectIds,
       projectIds,
     },
     },

+ 10 - 7
services/web/test/frontend/features/project-list/components/project-list-root.test.tsx

@@ -682,8 +682,8 @@ describe('<ProjectListRoot />', function () {
         })
         })
 
 
         it('opens the tags dropdown and remove a tag from selected projects', async function () {
         it('opens the tags dropdown and remove a tag from selected projects', async function () {
-          const deleteProjectsFromTagMock = fetchMock.delete(
-            `express:/tag/:id/projects`,
+          const deleteProjectsFromTagMock = fetchMock.post(
+            `express:/tag/:id/projects/remove`,
             {
             {
               status: 204,
               status: 204,
             }
             }
@@ -702,11 +702,14 @@ describe('<ProjectListRoot />', function () {
           await fetchMock.flush(true)
           await fetchMock.flush(true)
 
 
           expect(
           expect(
-            deleteProjectsFromTagMock.called(`/tag/${this.tagId}/projects`, {
-              body: {
-                projectIds: [projectsData[0].id, projectsData[1].id],
-              },
-            })
+            deleteProjectsFromTagMock.called(
+              `/tag/${this.tagId}/projects/remove`,
+              {
+                body: {
+                  projectIds: [projectsData[0].id, projectsData[1].id],
+                },
+              }
+            )
           ).to.be.true
           ).to.be.true
           screen.getByRole('button', { name: `${this.tagName} (0)` })
           screen.getByRole('button', { name: `${this.tagName} (0)` })
         })
         })