Skip to content

Commit 0089186

Browse files
dannyphan2000syadupathi-sf
authored andcommitted
@W-21006290: [BOPIS] Continue to Shipping Address label fix for BOPIS-only orders (#3604)
* @W-21006290: [BOPIS] Continue to Shipping Address label fix for BOPIS-only orders Signed-off-by: d.phan <d.phan@salesforce.com> * add translations Signed-off-by: d.phan <d.phan@salesforce.com> * fix lint Signed-off-by: d.phan <d.phan@salesforce.com> * fix utest Signed-off-by: d.phan <d.phan@salesforce.com> --------- Signed-off-by: d.phan <d.phan@salesforce.com>
1 parent 9a042b8 commit 0089186

File tree

8 files changed

+105
-7
lines changed

8 files changed

+105
-7
lines changed

packages/template-retail-react-app/app/pages/checkout-one-click/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ describe('Checkout One Click', () => {
430430
}
431431

432432
// Wait for continue button and click
433-
const continueBtn = await screen.findByText(/continue to shipping address/i)
433+
const continueBtn = await screen.findByText(/continue to payment/i)
434434
await user.click(continueBtn)
435435

436436
// Verify we skip directly to payment
@@ -524,7 +524,7 @@ describe('Checkout One Click', () => {
524524
}
525525

526526
// Wait for continue button and click
527-
const continueBtn = await screen.findByText(/continue to shipping address/i)
527+
const continueBtn = await screen.findByText(/continue to payment/i)
528528
await user.click(continueBtn)
529529

530530
// Verify we continue to payment

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import {API_ERROR_MESSAGE} from '@salesforce/retail-react-app/app/constants'
5050
import {isValidEmail} from '@salesforce/retail-react-app/app/utils/email-utils'
5151
import {formatPhoneNumber} from '@salesforce/retail-react-app/app/utils/phone-utils'
5252
import useMultiSite from '@salesforce/retail-react-app/app/hooks/use-multi-site'
53+
import {isPickupShipment} from '@salesforce/retail-react-app/app/utils/shipment-utils'
5354

5455
const ContactInfo = ({isSocialEnabled = false, idps = [], onRegisteredUserChoseGuest}) => {
5556
const {formatMessage} = useIntl()
@@ -70,6 +71,14 @@ const ContactInfo = ({isSocialEnabled = false, idps = [], onRegisteredUserChoseG
7071

7172
const {step, STEPS, goToStep, goToNextStep, setContactPhone} = useCheckout()
7273

74+
// Determine if this order has delivery shipments
75+
const shipments = basket?.shipments || []
76+
const productItems = basket?.productItems || []
77+
const shipmentsWithItems = shipments.filter((s) =>
78+
productItems.some((i) => i.shipmentId === s.shipmentId)
79+
)
80+
const hasDeliveryShipments = shipmentsWithItems.some((s) => !isPickupShipment(s))
81+
7382
const form = useForm({
7483
defaultValues: {
7584
email: customer?.email || basket?.customerInfo?.email || '',
@@ -615,10 +624,17 @@ const ContactInfo = ({isSocialEnabled = false, idps = [], onRegisteredUserChoseG
615624
isLoading={isSubmitting}
616625
disabled={isSubmitting}
617626
>
618-
<FormattedMessage
619-
defaultMessage="Continue to Shipping Address"
620-
id="contact_info.button.continue_to_shipping_address"
621-
/>
627+
{hasDeliveryShipments ? (
628+
<FormattedMessage
629+
defaultMessage="Continue to Shipping Address"
630+
id="contact_info.button.continue_to_shipping_address"
631+
/>
632+
) : (
633+
<FormattedMessage
634+
defaultMessage="Continue to Payment"
635+
id="contact_info.button.continue_to_payment"
636+
/>
637+
)}
622638
</Button>
623639
)}
624640
</Stack>

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

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ const mockUseCurrentBasket = jest.fn(() => ({
4848
basketId: 'test-basket-id',
4949
customerInfo: {
5050
email: null
51-
}
51+
},
52+
shipments: [{shipmentId: 'shipment-1', shipmentType: 'delivery'}],
53+
productItems: [{productId: 'product-1', shipmentId: 'shipment-1'}]
5254
},
5355
derivedData: {
5456
hasBasket: true,
@@ -126,6 +128,17 @@ beforeEach(() => {
126128
jest.clearAllMocks()
127129
// Default: allow OTP authorization so modal can open unless a test overrides it
128130
mockAuthHelperFunctions[AuthHelpers.AuthorizePasswordless].mutateAsync.mockResolvedValue({})
131+
// Reset basket mock to default (delivery shipment)
132+
mockUseCurrentBasket.mockReturnValue({
133+
data: {
134+
basketId: 'test-basket-id',
135+
customerInfo: {email: null},
136+
shipments: [{shipmentId: 'shipment-1', shipmentType: 'delivery'}],
137+
productItems: [{productId: 'product-1', shipmentId: 'shipment-1'}]
138+
},
139+
derivedData: {hasBasket: true, totalItems: 1},
140+
refetch: jest.fn()
141+
})
129142
})
130143

131144
afterEach(() => {})
@@ -405,6 +418,43 @@ describe('ContactInfo Component', () => {
405418
})
406419
})
407420

421+
test('renders "Continue to Payment" button for BOPIS-only orders', async () => {
422+
// Mock BOPIS-only basket
423+
mockUseCurrentBasket.mockReturnValue({
424+
data: {
425+
basketId: 'test-basket-id',
426+
customerInfo: {email: null},
427+
shipments: [{shipmentId: 'pickup-1', c_fromStoreId: 'store-123'}],
428+
productItems: [{productId: 'product-1', shipmentId: 'pickup-1'}]
429+
},
430+
derivedData: {hasBasket: true, totalItems: 1},
431+
refetch: jest.fn()
432+
})
433+
434+
// Mock the passwordless login to fail (guest checkout)
435+
mockAuthHelperFunctions[AuthHelpers.AuthorizePasswordless].mutateAsync.mockRejectedValue(
436+
new Error('Email not found')
437+
)
438+
439+
const {user} = renderWithProviders(<ContactInfo />)
440+
441+
const emailInput = screen.getByLabelText('Email')
442+
await user.type(emailInput, validEmail)
443+
fireEvent.blur(emailInput)
444+
445+
await waitFor(() => {
446+
const continueBtn = screen.getByRole('button', {
447+
name: /continue to payment/i
448+
})
449+
expect(continueBtn).toBeEnabled()
450+
})
451+
452+
// Verify "Continue to Shipping Address" is NOT shown
453+
expect(
454+
screen.queryByRole('button', {name: /continue to shipping address/i})
455+
).not.toBeInTheDocument()
456+
})
457+
408458
test('requires phone for guest shoppers on submit', async () => {
409459
// Ensure guest path (no OTP modal)
410460
mockAuthHelperFunctions[AuthHelpers.AuthorizePasswordless].mutateAsync.mockRejectedValue(

packages/template-retail-react-app/app/static/translations/compiled/en-GB.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,12 @@
15471547
"value": "Checkout as Guest"
15481548
}
15491549
],
1550+
"contact_info.button.continue_to_payment": [
1551+
{
1552+
"type": 0,
1553+
"value": "Continue to Payment"
1554+
}
1555+
],
15501556
"contact_info.button.continue_to_shipping_address": [
15511557
{
15521558
"type": 0,

packages/template-retail-react-app/app/static/translations/compiled/en-US.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,12 @@
15471547
"value": "Checkout as Guest"
15481548
}
15491549
],
1550+
"contact_info.button.continue_to_payment": [
1551+
{
1552+
"type": 0,
1553+
"value": "Continue to Payment"
1554+
}
1555+
],
15501556
"contact_info.button.continue_to_shipping_address": [
15511557
{
15521558
"type": 0,

packages/template-retail-react-app/app/static/translations/compiled/en-XA.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,6 +3147,20 @@
31473147
"value": "]"
31483148
}
31493149
],
3150+
"contact_info.button.continue_to_payment": [
3151+
{
3152+
"type": 0,
3153+
"value": "["
3154+
},
3155+
{
3156+
"type": 0,
3157+
"value": "Ƈǿǿƞŧīƞŭŭḗḗ ŧǿǿ Ƥȧȧẏḿḗḗƞŧ"
3158+
},
3159+
{
3160+
"type": 0,
3161+
"value": "]"
3162+
}
3163+
],
31503164
"contact_info.button.continue_to_shipping_address": [
31513165
{
31523166
"type": 0,

packages/template-retail-react-app/translations/en-GB.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,9 @@
601601
"contact_info.button.checkout_as_guest": {
602602
"defaultMessage": "Checkout as Guest"
603603
},
604+
"contact_info.button.continue_to_payment": {
605+
"defaultMessage": "Continue to Payment"
606+
},
604607
"contact_info.button.continue_to_shipping_address": {
605608
"defaultMessage": "Continue to Shipping Address"
606609
},

packages/template-retail-react-app/translations/en-US.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,9 @@
601601
"contact_info.button.checkout_as_guest": {
602602
"defaultMessage": "Checkout as Guest"
603603
},
604+
"contact_info.button.continue_to_payment": {
605+
"defaultMessage": "Continue to Payment"
606+
},
604607
"contact_info.button.continue_to_shipping_address": {
605608
"defaultMessage": "Continue to Shipping Address"
606609
},

0 commit comments

Comments
 (0)