|
1 | 1 | import React from 'react'; |
2 | 2 | import { QueryClient } from '@tanstack/react-query'; |
3 | 3 | import type { RenderResult } from '@testing-library/react'; |
4 | | -import { waitFor, render, screen } from '@testing-library/react'; |
| 4 | +import { waitFor, render, screen, act } from '@testing-library/react'; |
5 | 5 | import ProfileButton from './ProfileButton'; |
6 | 6 | import defaultUser from '../../../__tests__/fixture/loggedUser'; |
7 | 7 | import { TestBootProvider } from '../../../__tests__/helpers/boot'; |
@@ -32,21 +32,27 @@ const renderComponent = (): RenderResult => { |
32 | 32 | ); |
33 | 33 | }; |
34 | 34 |
|
35 | | -it('account details should link to account profile page', async () => { |
| 35 | +it('should show settings option that opens modal', async () => { |
36 | 36 | renderComponent(); |
37 | 37 |
|
38 | 38 | const profileBtn = await screen.findByLabelText('Profile settings'); |
39 | | - profileBtn.click(); |
40 | | - |
41 | | - const accountLink = await screen.findByRole('link', { name: 'Settings' }); |
42 | | - expect(accountLink).toHaveAttribute('href', '/account/profile'); |
| 39 | + await act(async () => { |
| 40 | + profileBtn.click(); |
| 41 | + }); |
| 42 | + |
| 43 | + const settingsButton = await screen.findByRole('button', { |
| 44 | + name: 'Settings', |
| 45 | + }); |
| 46 | + expect(settingsButton).toBeInTheDocument(); |
43 | 47 | }); |
44 | 48 |
|
45 | 49 | it('should click the logout button and logout', async () => { |
46 | 50 | renderComponent(); |
47 | 51 |
|
48 | 52 | const profileBtn = await screen.findByLabelText('Profile settings'); |
49 | | - profileBtn.click(); |
| 53 | + await act(async () => { |
| 54 | + profileBtn.click(); |
| 55 | + }); |
50 | 56 |
|
51 | 57 | const logoutBtn = await screen.findByText('Logout'); |
52 | 58 | logoutBtn.click(); |
|
0 commit comments