Skip to content

Commit 7db9f45

Browse files
committed
W-20892497 Show Phone number in Contact Info summary
1 parent 5c8c6ce commit 7db9f45

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed

packages/template-retail-react-app/app/pages/checkout-one-click/partials/one-click-contact-info.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,14 @@ const ContactInfo = ({isSocialEnabled = false, idps = [], onRegisteredUserChoseG
639639

640640
{(customer?.email || form.getValues('email')) && (
641641
<ToggleCardSummary>
642-
<Text>{customer?.email || form.getValues('email')}</Text>
642+
<Stack spacing={1}>
643+
<Text>{customer?.email || form.getValues('email')}</Text>
644+
{(customer?.phoneHome || form.getValues('phone')) && (
645+
<Text fontSize="sm" color="gray.600">
646+
{customer?.phoneHome || form.getValues('phone')}
647+
</Text>
648+
)}
649+
</Stack>
643650
</ToggleCardSummary>
644651
)}
645652
</ToggleCard>

packages/template-retail-react-app/app/pages/checkout-one-click/partials/one-click-contact-info.test.js

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: BSD-3-Clause
55
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
7-
import React from 'react'
7+
import React, {useState, useEffect} from 'react'
88
import {screen, waitFor, fireEvent, act} from '@testing-library/react'
99
import ContactInfo from '@salesforce/retail-react-app/app/pages/checkout-one-click/partials/one-click-contact-info'
1010
import {renderWithProviders} from '@salesforce/retail-react-app/app/utils/test-utils'
@@ -213,6 +213,65 @@ describe('ContactInfo Component', () => {
213213
expect(phoneInput).toHaveAttribute('disabled')
214214
})
215215

216+
test('displays phone number in summary card for registered user', async () => {
217+
jest.resetModules()
218+
jest.doMock('@salesforce/commerce-sdk-react', () => {
219+
const originalModule = jest.requireActual('@salesforce/commerce-sdk-react')
220+
return {
221+
...originalModule,
222+
useCustomerType: jest.fn(() => ({isRegistered: true})),
223+
useAuthHelper: jest
224+
.fn()
225+
.mockImplementation(
226+
(helperType) =>
227+
mockAuthHelperFunctions[helperType] || {mutateAsync: jest.fn()}
228+
)
229+
}
230+
})
231+
jest.doMock('@salesforce/retail-react-app/app/hooks/use-current-customer', () => ({
232+
useCurrentCustomer: () => ({
233+
data: {
234+
email: 'reg@salesforce.com',
235+
isRegistered: true,
236+
phoneHome: '(111) 222-3333'
237+
}
238+
})
239+
}))
240+
jest.doMock(
241+
'@salesforce/retail-react-app/app/pages/checkout-one-click/util/checkout-context',
242+
() => {
243+
return {
244+
useCheckout: jest.fn().mockReturnValue({
245+
customer: null,
246+
basket: {basketId: 'test-basket-id'},
247+
isGuestCheckout: false,
248+
setIsGuestCheckout: jest.fn(),
249+
step: 1, // Not on CONTACT_INFO step, so summary shows
250+
login: null,
251+
STEPS: {CONTACT_INFO: 0},
252+
goToStep: jest.fn(),
253+
goToNextStep: jest.fn(),
254+
setContactPhone: jest.fn()
255+
})
256+
}
257+
}
258+
)
259+
const {renderWithProviders: localRenderWithProviders} = await import(
260+
'@salesforce/retail-react-app/app/utils/test-utils'
261+
)
262+
const module = await import(
263+
'@salesforce/retail-react-app/app/pages/checkout-one-click/partials/one-click-contact-info'
264+
)
265+
const Component = module.default
266+
267+
localRenderWithProviders(<Component />)
268+
269+
// Verify email and phone are displayed in summary
270+
expect(screen.getByText('reg@salesforce.com')).toBeInTheDocument()
271+
expect(screen.getByText('(111) 222-3333')).toBeInTheDocument()
272+
})
273+
274+
216275
test('shows social login when enabled', () => {
217276
renderWithProviders(<ContactInfo isSocialEnabled={true} idps={['google', 'apple']} />)
218277

0 commit comments

Comments
 (0)