Skip to main content
Glama
PreviewPage.test.tsx2.5 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import type { Questionnaire, ValueSet } from '@medplum/fhirtypes'; import { MockClient } from '@medplum/mock'; import { act, renderAppRoutes, screen } from '../test-utils/render'; const medplum = new MockClient(); describe('PreviewPage', () => { async function setup(url: string): Promise<void> { renderAppRoutes(medplum, url); } beforeEach(() => { jest.useFakeTimers(); }); afterEach(async () => { await act(async () => { jest.runOnlyPendingTimers(); }); jest.useRealTimers(); }); test('ValueSet preview tab appears in ResourcePage', async () => { const valueSet = await medplum.createResource<ValueSet>({ resourceType: 'ValueSet', status: 'active', url: 'http://example.com/valueset/test', }); await setup(`/ValueSet/${valueSet.id}`); // Wait for the page to load and check for Preview tab expect(await screen.findByText('Preview')).toBeInTheDocument(); }); test('Questionnaire preview tab appears in ResourcePage', async () => { const questionnaire = await medplum.createResource<Questionnaire>({ resourceType: 'Questionnaire', status: 'active', title: 'Test Questionnaire', }); await setup(`/Questionnaire/${questionnaire.id}`); // Wait for the page to load and check for Preview tab expect(await screen.findByText('Preview')).toBeInTheDocument(); }); test('Navigates to preview tab', async () => { const valueSet = await medplum.createResource<ValueSet>({ resourceType: 'ValueSet', status: 'active', url: 'http://example.com/valueset/test', expansion: { timestamp: '2023-01-01T00:00:00.000Z', contains: [ { system: 'http://example.com/codesystem', code: 'code1', display: 'Display 1', }, ], }, }); // Mock valueSetExpand medplum.valueSetExpand = jest.fn().mockResolvedValue(valueSet); await setup(`/ValueSet/${valueSet.id}`); const previewTab = await screen.findByText('Preview'); expect(previewTab).toBeInTheDocument(); await act(async () => { previewTab.click(); jest.advanceTimersByTime(100); }); // After clicking preview tab, should show the preview content expect(await screen.findByPlaceholderText('Select a value from the ValueSet')).toBeInTheDocument(); }); });

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