|
5 | 5 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause |
6 | 6 | */ |
7 | 7 | import React from 'react' |
8 | | -import {screen, waitFor, within} from '@testing-library/react' |
| 8 | +import {act, screen, waitFor, within} from '@testing-library/react' |
9 | 9 | import {createPathWithDefaults, renderWithProviders} from '../../utils/test-utils' |
10 | 10 | import {rest} from 'msw' |
11 | 11 | import AccountDetail from '../../pages/account/profile' |
@@ -69,22 +69,26 @@ test('Allows customer to edit phone number', async () => { |
69 | 69 | }) |
70 | 70 |
|
71 | 71 | const profileCard = screen.getByTestId('sf-toggle-card-my-profile') |
72 | | - // Change phone number |
73 | | - await user.click(within(profileCard).getByText(/edit/i)) |
| 72 | + await act(async () => { |
| 73 | + // Change phone number |
| 74 | + await user.click(within(profileCard).getByText(/edit/i)) |
| 75 | + }) |
74 | 76 |
|
75 | 77 | // Profile Form must be present |
76 | 78 | expect(screen.getByLabelText('Profile Form')).toBeInTheDocument() |
77 | 79 |
|
78 | | - await user.type(screen.getByLabelText('Phone Number'), '7275551234') |
79 | | - |
| 80 | + await act(async () => { |
| 81 | + await user.type(screen.getByLabelText('Phone Number'), '7275551234') |
| 82 | + }) |
80 | 83 | global.server.use( |
81 | 84 | rest.get('*/customers/:customerId', (req, res, ctx) => |
82 | 85 | res(ctx.delay(0), ctx.status(200), ctx.json(mockedRegisteredCustomer)) |
83 | 86 | ) |
84 | 87 | ) |
85 | 88 |
|
86 | | - await user.click(screen.getByText(/^Save$/i)) |
87 | | - |
| 89 | + await act(async () => { |
| 90 | + await user.click(screen.getByText(/^Save$/i)) |
| 91 | + }) |
88 | 92 | await waitFor(() => { |
89 | 93 | // Toast messages are rendered in a portal, so we need to search within document.body |
90 | 94 | expect(within(document.body).getByText(/Profile updated/i)).toBeInTheDocument() |
|
0 commit comments