From 7d274e5a8443d164f1a69a1a453d6c2f7ace5b3f Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 28 Jun 2024 10:42:58 +0100 Subject: [PATCH] Remove unnecessary row mappings. Updated input processing tests to accommodate clearing BB_REFERENCE types by defaulting to an empty array --- packages/server/src/utilities/rowProcessor/map.ts | 10 ---------- .../rowProcessor/tests/inputProcessing.spec.ts | 14 +++++++++++++- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/server/src/utilities/rowProcessor/map.ts b/packages/server/src/utilities/rowProcessor/map.ts index 6c750630a9..6d70102233 100644 --- a/packages/server/src/utilities/rowProcessor/map.ts +++ b/packages/server/src/utilities/rowProcessor/map.ts @@ -57,13 +57,6 @@ export const TYPE_TRANSFORM_MAP: any = { [undefined]: undefined, parse: parseArrayString, }, - [FieldType.BB_REFERENCE_SINGLE]: { - "": null, - //@ts-ignore - [null]: null, - //@ts-ignore - [undefined]: undefined, - }, [FieldType.STRING]: { "": null, //@ts-ignore @@ -127,9 +120,6 @@ export const TYPE_TRANSFORM_MAP: any = { [undefined]: undefined, parse: parseArrayString, }, - [FieldType.ATTACHMENT_SINGLE]: { - "": null, - }, [FieldType.BOOLEAN]: { "": null, //@ts-ignore diff --git a/packages/server/src/utilities/rowProcessor/tests/inputProcessing.spec.ts b/packages/server/src/utilities/rowProcessor/tests/inputProcessing.spec.ts index 81094583e2..244ea3794c 100644 --- a/packages/server/src/utilities/rowProcessor/tests/inputProcessing.spec.ts +++ b/packages/server/src/utilities/rowProcessor/tests/inputProcessing.spec.ts @@ -209,10 +209,22 @@ describe("rowProcessor - inputProcessing", () => { const { row } = await inputProcessing(userId, table, newRow) + if (userValue === undefined) { + // The 'user' field is omitted + expect(row).toEqual({ + name: "Jack", + }) + } else { + // The update is processed if null or "". 'user' is changed to an empty array. + expect(row).toEqual({ + name: "Jack", + user: [], + }) + } + expect( bbReferenceProcessor.processInputBBReferences ).not.toHaveBeenCalled() - expect(row).toEqual(newRow) } )