From af8c11d237dfad53beb0530b71e11b0d9975f444 Mon Sep 17 00:00:00 2001 From: Pieter Doms Date: Thu, 24 Aug 2023 19:19:34 +0200 Subject: [PATCH 1/4] fix(admin-ui): nullability of custom fields in admin UI --- .../common/utilities/create-updated-translatable.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.ts b/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.ts index 69009754ec..340133e100 100644 --- a/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.ts +++ b/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.ts @@ -39,7 +39,9 @@ export function createUpdatedTranslatable Date: Thu, 24 Aug 2023 19:31:00 +0200 Subject: [PATCH 2/4] fix: tests --- .../utilities/create-updated-translatable.spec.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.spec.ts b/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.spec.ts index 973106b774..741f235266 100644 --- a/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.spec.ts +++ b/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.spec.ts @@ -184,11 +184,11 @@ describe('createUpdatedTranslatable()', () => { it('coerces empty customFields to correct type', () => { const customFieldConfig: CustomFieldConfig[] = [ - { name: 'a', type: 'boolean', list: false }, - { name: 'b', type: 'int', list: false }, - { name: 'c', type: 'float', list: false }, - { name: 'd', type: 'datetime', list: false }, - { name: 'e', type: 'string', list: false }, + { name: 'a', type: 'boolean', list: false, nullable: false }, + { name: 'b', type: 'int', list: false, nullable: false }, + { name: 'c', type: 'float', list: false, nullable: false }, + { name: 'd', type: 'datetime', list: false, nullable: false }, + { name: 'e', type: 'string', list: false, nullable: false }, ]; const formValue = { From d01768ab12c1d9b216b3bf10c6a5e494771f8ec8 Mon Sep 17 00:00:00 2001 From: Pieter Doms Date: Thu, 24 Aug 2023 19:49:10 +0200 Subject: [PATCH 3/4] fix: add some tests for nullable types --- .../common/utilities/create-updated-translatable.spec.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.spec.ts b/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.spec.ts index 741f235266..c167dba7bc 100644 --- a/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.spec.ts +++ b/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.spec.ts @@ -189,6 +189,8 @@ describe('createUpdatedTranslatable()', () => { { name: 'c', type: 'float', list: false, nullable: false }, { name: 'd', type: 'datetime', list: false, nullable: false }, { name: 'e', type: 'string', list: false, nullable: false }, + { name: 'f', type: 'int', list: false, nullable: true }, + { name: 'g', type: 'datetime', list: false, nullable: true }, ]; const formValue = { @@ -198,6 +200,8 @@ describe('createUpdatedTranslatable()', () => { c: '', d: '', e: '', + f: '', + g: '', }, }; @@ -213,5 +217,7 @@ describe('createUpdatedTranslatable()', () => { expect(result.customFields.c).toBe(0); expect(result.customFields.d instanceof Date).toBe(true); expect(result.customFields.e).toBe(''); + expect(result.customFields.e).toBe(null); + expect(result.customFields.g).toBe(null); }); }); From c2ee0994e216ad338d86974f6872754c5cc3aab6 Mon Sep 17 00:00:00 2001 From: Pieter Doms Date: Thu, 24 Aug 2023 20:04:13 +0200 Subject: [PATCH 4/4] fix: typo --- .../src/common/utilities/create-updated-translatable.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.spec.ts b/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.spec.ts index c167dba7bc..905e6a92e7 100644 --- a/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.spec.ts +++ b/packages/admin-ui/src/lib/core/src/common/utilities/create-updated-translatable.spec.ts @@ -217,7 +217,7 @@ describe('createUpdatedTranslatable()', () => { expect(result.customFields.c).toBe(0); expect(result.customFields.d instanceof Date).toBe(true); expect(result.customFields.e).toBe(''); - expect(result.customFields.e).toBe(null); + expect(result.customFields.f).toBe(null); expect(result.customFields.g).toBe(null); }); });