From e3c7f22352d6f7e3d24c7fa762df788c905f25e4 Mon Sep 17 00:00:00 2001 From: Kanad Gupta <8854718+kanadgupta@users.noreply.github.com> Date: Tue, 31 Jan 2023 15:20:32 -0600 Subject: [PATCH] fix(docs): don't merge payloads for PUT requests (#740) --- __tests__/cmds/changelogs/index.test.ts | 2 -- __tests__/cmds/changelogs/single.test.ts | 1 - __tests__/cmds/custompages/index.test.ts | 2 -- __tests__/cmds/custompages/single.test.ts | 1 - __tests__/cmds/docs/index.test.ts | 4 ---- __tests__/cmds/docs/single.test.ts | 2 -- src/lib/syncDocsPath.ts | 6 +----- 7 files changed, 1 insertion(+), 17 deletions(-) diff --git a/__tests__/cmds/changelogs/index.test.ts b/__tests__/cmds/changelogs/index.test.ts index ae6bb0cde..134950c31 100644 --- a/__tests__/cmds/changelogs/index.test.ts +++ b/__tests__/cmds/changelogs/index.test.ts @@ -90,7 +90,6 @@ describe('rdme changelogs', () => { const updateMocks = getAPIMock() .put('/api/v1/changelogs/simple-doc', { - slug: simpleDoc.slug, body: simpleDoc.doc.content, lastUpdatedHash: simpleDoc.hash, ...simpleDoc.doc.data, @@ -101,7 +100,6 @@ describe('rdme changelogs', () => { body: simpleDoc.doc.content, }) .put('/api/v1/changelogs/another-doc', { - slug: anotherDoc.slug, body: anotherDoc.doc.content, lastUpdatedHash: anotherDoc.hash, ...anotherDoc.doc.data, diff --git a/__tests__/cmds/changelogs/single.test.ts b/__tests__/cmds/changelogs/single.test.ts index d68b10ea4..b3e628515 100644 --- a/__tests__/cmds/changelogs/single.test.ts +++ b/__tests__/cmds/changelogs/single.test.ts @@ -198,7 +198,6 @@ describe('rdme changelogs (single)', () => { const updateMock = getAPIMock() .put('/api/v1/changelogs/simple-doc', { - slug: simpleDoc.slug, body: simpleDoc.doc.content, lastUpdatedHash: simpleDoc.hash, ...simpleDoc.doc.data, diff --git a/__tests__/cmds/custompages/index.test.ts b/__tests__/cmds/custompages/index.test.ts index b7611d6b0..4d0330472 100644 --- a/__tests__/cmds/custompages/index.test.ts +++ b/__tests__/cmds/custompages/index.test.ts @@ -90,7 +90,6 @@ describe('rdme custompages', () => { const updateMocks = getAPIMock() .put('/api/v1/custompages/simple-doc', { - slug: simpleDoc.slug, body: simpleDoc.doc.content, htmlmode: false, lastUpdatedHash: simpleDoc.hash, @@ -103,7 +102,6 @@ describe('rdme custompages', () => { body: simpleDoc.doc.content, }) .put('/api/v1/custompages/another-doc', { - slug: anotherDoc.slug, body: anotherDoc.doc.content, htmlmode: false, lastUpdatedHash: anotherDoc.hash, diff --git a/__tests__/cmds/custompages/single.test.ts b/__tests__/cmds/custompages/single.test.ts index 3462cf0bf..29d590e33 100644 --- a/__tests__/cmds/custompages/single.test.ts +++ b/__tests__/cmds/custompages/single.test.ts @@ -229,7 +229,6 @@ describe('rdme custompages (single)', () => { const updateMock = getAPIMock() .put('/api/v1/custompages/simple-doc', { - slug: simpleDoc.slug, body: simpleDoc.doc.content, htmlmode: false, lastUpdatedHash: simpleDoc.hash, diff --git a/__tests__/cmds/docs/index.test.ts b/__tests__/cmds/docs/index.test.ts index c28692d2e..94a6b348e 100644 --- a/__tests__/cmds/docs/index.test.ts +++ b/__tests__/cmds/docs/index.test.ts @@ -139,8 +139,6 @@ describe('rdme docs', () => { const updateMocks = getAPIMockWithVersionHeader(version) .put('/api/v1/docs/simple-doc', { - category, - slug: simpleDoc.slug, body: simpleDoc.doc.content, lastUpdatedHash: simpleDoc.hash, ...simpleDoc.doc.data, @@ -152,8 +150,6 @@ describe('rdme docs', () => { body: simpleDoc.doc.content, }) .put('/api/v1/docs/another-doc', { - category, - slug: anotherDoc.slug, body: anotherDoc.doc.content, lastUpdatedHash: anotherDoc.hash, ...anotherDoc.doc.data, diff --git a/__tests__/cmds/docs/single.test.ts b/__tests__/cmds/docs/single.test.ts index cf81ee648..b973315e1 100644 --- a/__tests__/cmds/docs/single.test.ts +++ b/__tests__/cmds/docs/single.test.ts @@ -243,8 +243,6 @@ describe('rdme docs (single)', () => { const updateMock = getAPIMockWithVersionHeader(version) .put('/api/v1/docs/simple-doc', { - category, - slug: simpleDoc.slug, body: simpleDoc.doc.content, lastUpdatedHash: simpleDoc.hash, ...simpleDoc.doc.data, diff --git a/src/lib/syncDocsPath.ts b/src/lib/syncDocsPath.ts index 1517ce05c..9bd4d288c 100644 --- a/src/lib/syncDocsPath.ts +++ b/src/lib/syncDocsPath.ts @@ -104,11 +104,7 @@ async function pushDoc( 'Content-Type': 'application/json', }) ), - body: JSON.stringify( - Object.assign(existingDoc, { - ...payload, - }) - ), + body: JSON.stringify(payload), }) .then(handleRes) .then(res => `✏️ successfully updated '${res.slug}' with contents from ${filepath}`);