blob: 58368afc31f2c6fe0d653c48f23a1a6a3c03ec1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import '@testing-library/jest-dom';
import React from 'react';
import { fireEvent } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import { describe, expect, it } from 'vitest';
import { createMemoryRouter, RouterProvider } from 'react-router-dom';
import { renderWithProviders } from '../renderWithProviders';
import routes from '../routes';
describe('Admin Login', async () => {
const memoryRouter = createMemoryRouter(routes, {
initialEntries: ['/admin/login'],
});
it('can log in', async () => {
const { getByLabelText, getByRole, findByText } = renderWithProviders(
<RouterProvider router={memoryRouter} />
);
const user = userEvent.setup();
await user.type(getByLabelText(/username/i), 'username');
await user.type(getByLabelText(/password/i), 'password');
fireEvent.click(getByRole('button', { name: 'Log in' }));
expect(await findByText(/first name/i)).toBeInTheDocument();
expect(await findByText(/last name/i)).toBeInTheDocument();
expect(await findByText(/attendance/i)).toBeInTheDocument();
expect(await findByText(/email/i)).toBeInTheDocument();
expect(await findByText(/message/i)).toBeInTheDocument();
expect(await findByText(/party size/i)).toBeInTheDocument();
});
});
|