Skip to main content
Glama
ServiceRequestTimeline.test.tsx2.89 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { createReference } from '@medplum/core'; import { HomerServiceRequest, MockClient } from '@medplum/mock'; import { MedplumProvider } from '@medplum/react-hooks'; import { MemoryRouter } from 'react-router'; import { act, fireEvent, render, screen, waitFor } from '../test-utils/render'; import type { ServiceRequestTimelineProps } from './ServiceRequestTimeline'; import { ServiceRequestTimeline } from './ServiceRequestTimeline'; const medplum = new MockClient(); describe('ServiceRequestTimeline', () => { async function setup(args: ServiceRequestTimelineProps): Promise<void> { await act(async () => { render( <MemoryRouter> <MedplumProvider medplum={medplum} navigate={jest.fn()}> <ServiceRequestTimeline {...args} /> </MedplumProvider> </MemoryRouter> ); }); } test('Renders reference', async () => { await setup({ serviceRequest: createReference(HomerServiceRequest) }); await waitFor(() => screen.getAllByTestId('timeline-item')); const items = screen.getAllByTestId('timeline-item'); expect(items).toBeDefined(); }); test('Renders resource', async () => { await setup({ serviceRequest: HomerServiceRequest }); await waitFor(() => screen.getAllByTestId('timeline-item')); const items = screen.getAllByTestId('timeline-item'); expect(items).toBeDefined(); }); test('Create comment', async () => { await setup({ serviceRequest: HomerServiceRequest }); // Wait for initial load await waitFor(() => screen.getAllByTestId('timeline-item')); // Enter the comment text await act(async () => { fireEvent.change(screen.getByPlaceholderText('Add comment'), { target: { value: 'Test comment' }, }); }); // Submit the form await act(async () => { fireEvent.submit(screen.getByTestId('timeline-form'), { target: { text: 'Test comment' }, }); }); // Wait for new comment await waitFor(() => screen.getAllByTestId('timeline-item')); const items = screen.getAllByTestId('timeline-item'); expect(items).toBeDefined(); }); test('Upload media', async () => { await setup({ serviceRequest: HomerServiceRequest }); // Wait for initial load await waitFor(() => screen.getAllByTestId('timeline-item')); // Upload the file await act(async () => { const files = [new File(['hello'], 'hello.txt', { type: 'text/plain' })]; fireEvent.change(screen.getByTestId('upload-file-input'), { target: { files }, }); }); // Wait for new comment await waitFor(() => screen.getAllByTestId('timeline-item')); const items = screen.getAllByTestId('timeline-item'); expect(items).toBeDefined(); }); });

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