Skip to content

Commit 14e17e8

Browse files
authored
clean up test warnings (#2812)
1 parent eb90845 commit 14e17e8

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

packages/extension-chakra-storefront/src/pages/account/profile.test.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77
import React from 'react'
8-
import {screen, waitFor, within} from '@testing-library/react'
8+
import {act, screen, waitFor, within} from '@testing-library/react'
99
import {createPathWithDefaults, renderWithProviders} from '../../utils/test-utils'
1010
import {rest} from 'msw'
1111
import AccountDetail from '../../pages/account/profile'
@@ -69,22 +69,26 @@ test('Allows customer to edit phone number', async () => {
6969
})
7070

7171
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+
})
7476

7577
// Profile Form must be present
7678
expect(screen.getByLabelText('Profile Form')).toBeInTheDocument()
7779

78-
await user.type(screen.getByLabelText('Phone Number'), '7275551234')
79-
80+
await act(async () => {
81+
await user.type(screen.getByLabelText('Phone Number'), '7275551234')
82+
})
8083
global.server.use(
8184
rest.get('*/customers/:customerId', (req, res, ctx) =>
8285
res(ctx.delay(0), ctx.status(200), ctx.json(mockedRegisteredCustomer))
8386
)
8487
)
8588

86-
await user.click(screen.getByText(/^Save$/i))
87-
89+
await act(async () => {
90+
await user.click(screen.getByText(/^Save$/i))
91+
})
8892
await waitFor(() => {
8993
// Toast messages are rendered in a portal, so we need to search within document.body
9094
expect(within(document.body).getByText(/Profile updated/i)).toBeInTheDocument()

packages/extension-chakra-storefront/src/pages/checkout/confirmation.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ test('Create Account form - renders error message', async () => {
7979

8080
const createAccountButton = await screen.findByRole('button', {name: /create account/i})
8181
const passwordEl = await screen.findByLabelText('Password')
82-
await user.type(passwordEl, 'P4ssword!')
83-
await user.click(createAccountButton)
82+
await act(async () => {
83+
await user.type(passwordEl, 'P4ssword!')
84+
await user.click(createAccountButton)
85+
})
8486
const alert = await screen.findByRole('alert')
8587
expect(alert).toBeInTheDocument()
8688
})

0 commit comments

Comments
 (0)