From f332eaf9b3e26c5f100be194fc208fe3fb0f3d9d Mon Sep 17 00:00:00 2001 From: gabu90 Date: Mon, 16 Sep 2024 21:01:00 +0300 Subject: [PATCH] Enable MultiSelect component test suite --- .../inputs/multi-select/multi-select.test.tsx | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/components/inputs/multi-select/multi-select.test.tsx b/src/components/inputs/multi-select/multi-select.test.tsx index 8cf3dc5aa..919cd98e7 100644 --- a/src/components/inputs/multi-select/multi-select.test.tsx +++ b/src/components/inputs/multi-select/multi-select.test.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { act, render, screen } from '@testing-library/react'; -import { userEvent } from '@testing-library/user-event'; +import userEvent from '@testing-library/user-event'; // Correct import for userEvent import { type FetchResponse, openmrsFetch, usePatient, useSession } from '@openmrs/esm-framework'; import { type FormSchema } from '../../../types'; import { mockPatient } from '__mocks__/patient.mock'; @@ -31,7 +31,7 @@ jest.mock('../../../api', () => { }); const renderForm = async () => { - await act(() => + await act(async () => { render( { formSessionIntent={undefined} visit={visit} />, - ), - ); + ); + }); }; -describe.skip('MultiSelect Component', () => { +describe('MultiSelect Component', () => { beforeEach(() => { mockOpenmrsFetch.mockResolvedValue({ data: { results: [{ ...multiSelectFormSchema }] }, @@ -69,22 +69,20 @@ describe.skip('MultiSelect Component', () => { it('should disable checkbox option if the field value depends on evaluates the expression to true', async () => { const user = userEvent.setup(); await renderForm(); - await user.click(screen.getByRole('combobox', { name: /Patient covered by NHIF/i })); await user.click(screen.getByRole('option', { name: /no/i })); - await user.click(screen.getByText('Was this visit scheduled?')); - expect(screen.getByRole('option', { name: /Unscheduled visit early/i })).toHaveAttribute('disabled'); + const unscheduledVisitOption = screen.getByRole('option', { name: /Unscheduled visit early/i }); + expect(unscheduledVisitOption).toHaveAttribute('disabled'); }); it('should enable checkbox option if the field value depends on evaluates the expression to false', async () => { const user = userEvent.setup(); await renderForm(); - await user.click(screen.getByRole('combobox', { name: /patient covered by nhif/i })); await user.click(screen.getByRole('option', { name: /yes/i })); - await user.click(screen.getByText('Was this visit scheduled?')); - expect(screen.getByRole('option', { name: /Unscheduled visit early/i })).not.toHaveAttribute('disabled'); + const unscheduledVisitOption = screen.getByRole('option', { name: /Unscheduled visit early/i }); + expect(unscheduledVisitOption).not.toBeDisabled(); }); });