From fdf5cfa4c104e3e17fcd2dd82c2e9f0d82186410 Mon Sep 17 00:00:00 2001 From: Katrin Khilko Date: Tue, 22 Oct 2024 16:35:28 +0300 Subject: [PATCH 1/2] FIO-9244: fixed an issue where Radio component with Allow only available values checked does not submit --- .../rules/__tests__/validateAvailableItems.test.ts | 12 ++++++++++-- .../validation/rules/validateAvailableItems.ts | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/process/validation/rules/__tests__/validateAvailableItems.test.ts b/src/process/validation/rules/__tests__/validateAvailableItems.test.ts index 4b530d88..63b6a904 100644 --- a/src/process/validation/rules/__tests__/validateAvailableItems.test.ts +++ b/src/process/validation/rules/__tests__/validateAvailableItems.test.ts @@ -476,7 +476,11 @@ describe('validateAvailableItems', function () { context.fetch = () => { return Promise.resolve({ ok: true, - json: () => Promise.resolve(['1', '2', '3']), + json: () => Promise.resolve([ + { label: '1', value: '1' }, + { label: '2', value: '2' }, + { label: '3', value: '3' }, + ]), }); }; const result = await validateAvailableItems(context); @@ -501,7 +505,11 @@ describe('validateAvailableItems', function () { context.fetch = () => { return Promise.resolve({ ok: true, - json: () => Promise.resolve(['1', '2', '3']), + json: () => Promise.resolve([ + { label: '1', value: '1' }, + { label: '2', value: '2' }, + { label: '3', value: '3' }, + ]), }); }; const result = await validateAvailableItems(context); diff --git a/src/process/validation/rules/validateAvailableItems.ts b/src/process/validation/rules/validateAvailableItems.ts index e0db8496..ea605aca 100644 --- a/src/process/validation/rules/validateAvailableItems.ts +++ b/src/process/validation/rules/validateAvailableItems.ts @@ -249,7 +249,7 @@ export const validateAvailableItems: RuleFn = async (context: ValidationContext) ? null : error; } - return values.find((optionValue) => optionValue === value) !== undefined ? null : error; + return values.find(({ value: optionValue }) => optionValue === value) !== undefined ? null : error; } return null; From dc79aaad31deaaf5eb6b4a777080202a803134ef Mon Sep 17 00:00:00 2001 From: Katrin Khilko Date: Wed, 23 Oct 2024 14:57:30 +0300 Subject: [PATCH 2/2] FIO-9244: fixed an issue where Radio component with Allow only available values checked --- src/process/validation/rules/validateAvailableItems.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/process/validation/rules/validateAvailableItems.ts b/src/process/validation/rules/validateAvailableItems.ts index ea605aca..7e37ffed 100644 --- a/src/process/validation/rules/validateAvailableItems.ts +++ b/src/process/validation/rules/validateAvailableItems.ts @@ -249,7 +249,10 @@ export const validateAvailableItems: RuleFn = async (context: ValidationContext) ? null : error; } - return values.find(({ value: optionValue }) => optionValue === value) !== undefined ? null : error; + return values.find((optionValue) => optionValue.value === value || optionValue === value) !== + undefined + ? null + : error; } return null;