Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ describe('Checkout One Click', () => {
}

// Wait for continue button and click
const continueBtn = await screen.findByText(/continue to shipping address/i)
const continueBtn = await screen.findByText(/continue to payment/i)
await user.click(continueBtn)

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

// Wait for continue button and click
const continueBtn = await screen.findByText(/continue to shipping address/i)
const continueBtn = await screen.findByText(/continue to payment/i)
await user.click(continueBtn)

// Verify we continue to payment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {API_ERROR_MESSAGE} from '@salesforce/retail-react-app/app/constants'
import {isValidEmail} from '@salesforce/retail-react-app/app/utils/email-utils'
import {formatPhoneNumber} from '@salesforce/retail-react-app/app/utils/phone-utils'
import useMultiSite from '@salesforce/retail-react-app/app/hooks/use-multi-site'
import {isPickupShipment} from '@salesforce/retail-react-app/app/utils/shipment-utils'

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

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

// Determine if this order has delivery shipments
const shipments = basket?.shipments || []
const productItems = basket?.productItems || []
const shipmentsWithItems = shipments.filter((s) =>
productItems.some((i) => i.shipmentId === s.shipmentId)
)
const hasDeliveryShipments = shipmentsWithItems.some((s) => !isPickupShipment(s))

const form = useForm({
defaultValues: {
email: customer?.email || basket?.customerInfo?.email || '',
Expand Down Expand Up @@ -615,10 +624,17 @@ const ContactInfo = ({isSocialEnabled = false, idps = [], onRegisteredUserChoseG
isLoading={isSubmitting}
disabled={isSubmitting}
>
<FormattedMessage
defaultMessage="Continue to Shipping Address"
id="contact_info.button.continue_to_shipping_address"
/>
{hasDeliveryShipments ? (
<FormattedMessage
defaultMessage="Continue to Shipping Address"
id="contact_info.button.continue_to_shipping_address"
/>
) : (
<FormattedMessage
defaultMessage="Continue to Payment"
id="contact_info.button.continue_to_payment"
/>
)}
</Button>
)}
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ const mockUseCurrentBasket = jest.fn(() => ({
basketId: 'test-basket-id',
customerInfo: {
email: null
}
},
shipments: [{shipmentId: 'shipment-1', shipmentType: 'delivery'}],
productItems: [{productId: 'product-1', shipmentId: 'shipment-1'}]
},
derivedData: {
hasBasket: true,
Expand Down Expand Up @@ -126,6 +128,17 @@ beforeEach(() => {
jest.clearAllMocks()
// Default: allow OTP authorization so modal can open unless a test overrides it
mockAuthHelperFunctions[AuthHelpers.AuthorizePasswordless].mutateAsync.mockResolvedValue({})
// Reset basket mock to default (delivery shipment)
mockUseCurrentBasket.mockReturnValue({
data: {
basketId: 'test-basket-id',
customerInfo: {email: null},
shipments: [{shipmentId: 'shipment-1', shipmentType: 'delivery'}],
productItems: [{productId: 'product-1', shipmentId: 'shipment-1'}]
},
derivedData: {hasBasket: true, totalItems: 1},
refetch: jest.fn()
})
})

afterEach(() => {})
Expand Down Expand Up @@ -405,6 +418,43 @@ describe('ContactInfo Component', () => {
})
})

test('renders "Continue to Payment" button for BOPIS-only orders', async () => {
// Mock BOPIS-only basket
mockUseCurrentBasket.mockReturnValue({
data: {
basketId: 'test-basket-id',
customerInfo: {email: null},
shipments: [{shipmentId: 'pickup-1', c_fromStoreId: 'store-123'}],
productItems: [{productId: 'product-1', shipmentId: 'pickup-1'}]
},
derivedData: {hasBasket: true, totalItems: 1},
refetch: jest.fn()
})

// Mock the passwordless login to fail (guest checkout)
mockAuthHelperFunctions[AuthHelpers.AuthorizePasswordless].mutateAsync.mockRejectedValue(
new Error('Email not found')
)

const {user} = renderWithProviders(<ContactInfo />)

const emailInput = screen.getByLabelText('Email')
await user.type(emailInput, validEmail)
fireEvent.blur(emailInput)

await waitFor(() => {
const continueBtn = screen.getByRole('button', {
name: /continue to payment/i
})
expect(continueBtn).toBeEnabled()
})

// Verify "Continue to Shipping Address" is NOT shown
expect(
screen.queryByRole('button', {name: /continue to shipping address/i})
).not.toBeInTheDocument()
})

test('requires phone for guest shoppers on submit', async () => {
// Ensure guest path (no OTP modal)
mockAuthHelperFunctions[AuthHelpers.AuthorizePasswordless].mutateAsync.mockRejectedValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,12 @@
"value": "Checkout as Guest"
}
],
"contact_info.button.continue_to_payment": [
{
"type": 0,
"value": "Continue to Payment"
}
],
"contact_info.button.continue_to_shipping_address": [
{
"type": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,12 @@
"value": "Checkout as Guest"
}
],
"contact_info.button.continue_to_payment": [
{
"type": 0,
"value": "Continue to Payment"
}
],
"contact_info.button.continue_to_shipping_address": [
{
"type": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3147,6 +3147,20 @@
"value": "]"
}
],
"contact_info.button.continue_to_payment": [
{
"type": 0,
"value": "["
},
{
"type": 0,
"value": "Ƈǿǿƞŧīƞŭŭḗḗ ŧǿǿ Ƥȧȧẏḿḗḗƞŧ"
},
{
"type": 0,
"value": "]"
}
],
"contact_info.button.continue_to_shipping_address": [
{
"type": 0,
Expand Down
3 changes: 3 additions & 0 deletions packages/template-retail-react-app/translations/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,9 @@
"contact_info.button.checkout_as_guest": {
"defaultMessage": "Checkout as Guest"
},
"contact_info.button.continue_to_payment": {
"defaultMessage": "Continue to Payment"
},
"contact_info.button.continue_to_shipping_address": {
"defaultMessage": "Continue to Shipping Address"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/template-retail-react-app/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,9 @@
"contact_info.button.checkout_as_guest": {
"defaultMessage": "Checkout as Guest"
},
"contact_info.button.continue_to_payment": {
"defaultMessage": "Continue to Payment"
},
"contact_info.button.continue_to_shipping_address": {
"defaultMessage": "Continue to Shipping Address"
},
Expand Down
Loading