// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
// SPDX-License-Identifier: Apache-2.0
import { MantineProvider } from '@mantine/core';
import { Notifications, notifications } from '@mantine/notifications';
import { MockClient } from '@medplum/mock';
import { ErrorBoundary, Loading, MedplumProvider } from '@medplum/react';
import { act, render, screen } from '@testing-library/react';
import { Suspense } from 'react';
import { MemoryRouter } from 'react-router';
import { AppRoutes } from '../AppRoutes';
describe('ExportPage', () => {
async function setup(url: string, medplum = new MockClient()): Promise<void> {
await act(async () => {
render(
<MedplumProvider medplum={medplum}>
<MemoryRouter initialEntries={[url]} initialIndex={0}>
<MantineProvider>
<Notifications />
<ErrorBoundary>
<Suspense fallback={<Loading />}>
<AppRoutes />
</Suspense>
</ErrorBoundary>
</MantineProvider>
</MemoryRouter>
</MedplumProvider>
);
});
}
afterEach(async () => {
await act(async () => notifications.clean());
});
test('Patient', async () => {
await setup('/Patient/123/export');
expect(await screen.findByText('Request Export')).toBeInTheDocument();
});
test('Unsupported', async () => {
await setup('/Practitioner/123/export');
expect(await screen.findByText('Unsupported export type')).toBeInTheDocument();
});
});