diff --git a/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts b/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts index 875bb87c..ce40eba2 100644 --- a/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts +++ b/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts @@ -146,20 +146,11 @@ export class ApiPlugin implements WorkboxPlugin { await RequestSerializer.fromRequest(this.initialRequest) ).toObject(); - if (!requestData.body) { - return new Response('Body found', { status: 404 }); - } - - const jsonObject = RequestSerializer.arrayBufferToJson>( - requestData.body, - ); - // Add a new doc id to the create request const uuid = self.crypto.randomUUID(); const newRequestData = { ...requestData, body: RequestSerializer.objectToArrayBuffer({ - ...jsonObject, id: uuid, }), }; @@ -175,16 +166,8 @@ export class ApiPlugin implements WorkboxPlugin { 'doc-mutation', ); - /** - * Create new item in the cache - */ - const bodyMutate = (await this.initialRequest - .clone() - .json()) as Partial; - const newResponse: Doc = { title: '', - ...bodyMutate, id: uuid, content: '', created_at: new Date().toISOString(), diff --git a/src/frontend/apps/impress/src/features/service-worker/__tests__/ApiPlugin.test.tsx b/src/frontend/apps/impress/src/features/service-worker/__tests__/ApiPlugin.test.tsx index 4285e00e..f9fdfae0 100644 --- a/src/frontend/apps/impress/src/features/service-worker/__tests__/ApiPlugin.test.tsx +++ b/src/frontend/apps/impress/src/features/service-worker/__tests__/ApiPlugin.test.tsx @@ -346,13 +346,8 @@ describe('ApiPlugin', () => { headers: new Headers({ 'Content-Type': 'application/json', }), - arrayBuffer: () => - RequestSerializer.objectToArrayBuffer({ - title: 'my new doc', - }), - json: () => ({ - title: 'my new doc', - }), + arrayBuffer: () => RequestSerializer.objectToArrayBuffer({}), + json: () => ({}), } as unknown as Request, } as any; @@ -389,9 +384,7 @@ describe('ApiPlugin', () => { ); expect(mockedPut).toHaveBeenCalledWith( 'doc-item', - expect.objectContaining({ - title: 'my new doc', - }), + expect.objectContaining({}), 'http://test.jest/documents/444555/', ); expect(mockedPut).toHaveBeenCalledWith( @@ -400,7 +393,6 @@ describe('ApiPlugin', () => { results: expect.arrayContaining([ expect.objectContaining({ id: '444555', - title: 'my new doc', }), ]), }),