Skip to main content
Glama
PatientTimeline.test.tsx2.9 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { createReference } from '@medplum/core'; import { HomerSimpson, 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 { PatientTimelineProps } from './PatientTimeline'; import { PatientTimeline } from './PatientTimeline'; const medplum = new MockClient(); describe('PatientTimeline', () => { async function setup(args: PatientTimelineProps): Promise<void> { await act(async () => { render( <MemoryRouter> <MedplumProvider medplum={medplum}> <PatientTimeline {...args} /> </MedplumProvider> </MemoryRouter> ); }); } test('Renders reference', async () => { await setup({ patient: createReference(HomerSimpson) }); await waitFor(() => screen.getAllByTestId('timeline-item')); const items = screen.getAllByTestId('timeline-item'); expect(items).toBeDefined(); expect(screen.getByText('SERVICE_REQUEST_CODE')).toBeInTheDocument(); }); test('Renders resource', async () => { await setup({ patient: HomerSimpson }); await waitFor(() => screen.getAllByTestId('timeline-item')); const items = screen.getAllByTestId('timeline-item'); expect(items).toBeDefined(); expect(screen.getByText('SERVICE_REQUEST_CODE')).toBeInTheDocument(); }); test('Create comment', async () => { await setup({ patient: HomerSimpson }); // 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({ patient: HomerSimpson }); // 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 media 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