Skip to main content
Glama
SearchFieldEditor.test.tsx2.19 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import type { SearchRequest } from '@medplum/core'; import { MockClient } from '@medplum/mock'; import { act, fireEvent, render, screen } from '../test-utils/render'; import { SearchFieldEditor } from './SearchFieldEditor'; describe('SearchFieldEditor', () => { beforeAll(async () => { await new MockClient().requestSchema('Patient'); }); test('Render not visible', () => { const currSearch: SearchRequest = { resourceType: 'Patient', fields: ['name'], }; render(<SearchFieldEditor search={currSearch} visible={false} onOk={jest.fn()} onCancel={jest.fn()} />); expect(screen.queryByText('OK')).toBeNull(); }); test('Modal onClose not called when overlay clicked while dropdown open', async () => { let currSearch: SearchRequest = { resourceType: 'Patient', fields: [], }; const onCancel = jest.fn(); render(<SearchFieldEditor search={currSearch} visible={true} onOk={(e) => (currSearch = e)} onCancel={onCancel} />); // opens the dropdown await act(async () => { fireEvent.focus(screen.getByPlaceholderText('Select fields to display')); }); // click the overlay await act(async () => { fireEvent.mouseDown(screen.getByTestId('overlay-child')); fireEvent.mouseUp(screen.getByTestId('overlay-child')); fireEvent.click(screen.getByTestId('overlay-child')); }); expect(onCancel).not.toHaveBeenCalled(); }); test('Modal onClose called when overlay clicked while dropdown NOT open', async () => { let currSearch: SearchRequest = { resourceType: 'Patient', fields: [], }; const onCancel = jest.fn(); render(<SearchFieldEditor search={currSearch} visible={true} onOk={(e) => (currSearch = e)} onCancel={onCancel} />); // click the overlay await act(async () => { fireEvent.mouseDown(screen.getByTestId('overlay-child')); fireEvent.mouseUp(screen.getByTestId('overlay-child')); fireEvent.click(screen.getByTestId('overlay-child')); }); expect(onCancel).toHaveBeenCalled(); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/medplum/medplum'

If you have feedback or need assistance with the MCP directory API, please join our Discord server