From 268c616221543160a4d826a73667465d9f2137c5 Mon Sep 17 00:00:00 2001 From: phlipsterit <131464883+phlipsterit@users.noreply.github.com> Date: Fri, 23 Oct 2026 12:53:13 +0200 Subject: [PATCH] fix: required Checkboxes/MultipleSelect no longer fail when using a label binding (#4394) --- .../saveToGroup/useValidateGroupIsEmpty.ts | 7 ++++++- .../CheckboxesContainerComponent.test.tsx | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/features/saveToGroup/useValidateGroupIsEmpty.ts b/src/features/saveToGroup/useValidateGroupIsEmpty.ts index 2fd34803fc..a6eb8b66d1 100644 --- a/src/features/saveToGroup/useValidateGroupIsEmpty.ts +++ b/src/features/saveToGroup/useValidateGroupIsEmpty.ts @@ -37,7 +37,12 @@ export function useValidateGroupIsEmpty { expect(screen.getByRole('listitem')).toHaveTextContent('Du må fylle ut land'); }); + it('required validation should not show when values are selected and labels are stored in an array', async () => { + await render({ + component: { + showValidations: ['Required'], + required: true, + dataModelBindings: { + simpleBinding: { dataType: defaultDataTypeMock, field: 'value' }, + label: { dataType: defaultDataTypeMock, field: 'label' }, + }, + }, + options: twoOptions, + queries: { + fetchFormData: () => Promise.resolve({ value: 'norway,sweden', label: ['Norway', 'Sweden'] }), + }, + }); + + expect(getCheckbox({ name: 'Norway', isChecked: true })).toBeInTheDocument(); + expect(getCheckbox({ name: 'Sweden', isChecked: true })).toBeInTheDocument(); + expect(screen.queryByText('Du må fylle ut land')).not.toBeInTheDocument(); + }); + it('required validation should show for group', async () => { await render({ component: {