@@ -432,7 +432,7 @@ describe('ShippingOptions Component', () => {
432432 } )
433433
434434 describe ( 'in summary view (PAYMENT step)' , ( ) => {
435- test ( 'renders SingleShipmentSummary with price adjustments and strikethrough price' , async ( ) => {
435+ test ( 'renders SingleShipmentSummary without price adjustments and strikethrough price' , async ( ) => {
436436 jest . resetModules ( )
437437
438438 jest . doMock (
@@ -500,7 +500,81 @@ describe('ShippingOptions Component', () => {
500500
501501 expect ( screen . getAllByText ( 'Standard Shipping' ) . length ) . toBeGreaterThan ( 0 )
502502 expect ( screen . getAllByText ( '5-7 business days' ) . length ) . toBeGreaterThan ( 0 )
503- expect ( screen . getByText ( '50% off shipping!' ) ) . toBeInTheDocument ( )
503+ // Verify promotion text is NOT shown in summary view
504+ expect ( screen . queryByText ( '50% off shipping!' ) ) . not . toBeInTheDocument ( )
505+ // Verify only the final price is shown (no strikethrough)
506+ // Price is formatted with currency code (US$4.99)
507+ expect ( screen . getByText ( / 4 \. 9 9 / ) ) . toBeInTheDocument ( )
508+ // Verify original price with strikethrough is NOT shown
509+ expect ( screen . queryByText ( / 9 \. 9 9 / ) ) . not . toBeInTheDocument ( )
510+ } )
511+
512+ test ( 'renders only final price in summary view when price differs from original' , async ( ) => {
513+ jest . resetModules ( )
514+
515+ jest . doMock (
516+ '@salesforce/retail-react-app/app/pages/checkout-one-click/util/checkout-context' ,
517+ ( ) => ( {
518+ useCheckout : jest . fn ( ) . mockReturnValue ( {
519+ step : 4 ,
520+ STEPS : {
521+ CONTACT_INFO : 0 ,
522+ PICKUP_ADDRESS : 1 ,
523+ SHIPPING_ADDRESS : 2 ,
524+ SHIPPING_OPTIONS : 3 ,
525+ PAYMENT : 4
526+ } ,
527+ goToStep : mockGoToStep ,
528+ goToNextStep : mockGoToNextStep
529+ } )
530+ } )
531+ )
532+ jest . doMock ( '@salesforce/retail-react-app/app/hooks/use-current-customer' , ( ) => ( {
533+ useCurrentCustomer : ( ) => ( {
534+ data : { customerId : 'test-customer-id' , isRegistered : true }
535+ } )
536+ } ) )
537+ jest . doMock ( '@salesforce/retail-react-app/app/hooks/use-current-basket' , ( ) => ( {
538+ useCurrentBasket : ( ) => ( {
539+ data : {
540+ basketId : 'test-basket-id' ,
541+ shipments : [
542+ {
543+ shipmentId : 'me' ,
544+ shippingAddress : { address1 : '123 Main St' , city : 'Test City' } ,
545+ shippingMethod : {
546+ id : 'standard-shipping' ,
547+ name : 'Standard Shipping' ,
548+ description : '5-7 business days'
549+ }
550+ }
551+ ] ,
552+ shippingItems : [
553+ {
554+ price : 9.99 ,
555+ priceAfterItemDiscount : 0 ,
556+ priceAdjustments : [ ]
557+ }
558+ ]
559+ } ,
560+ derivedData : { hasBasket : true , totalItems : 1 , totalShippingCost : 0 }
561+ } )
562+ } ) )
563+
564+ const { renderWithProviders : localRenderWithProviders } = await import (
565+ '@salesforce/retail-react-app/app/utils/test-utils'
566+ )
567+ const module = await import (
568+ '@salesforce/retail-react-app/app/pages/checkout-one-click/partials/one-click-shipping-options'
569+ )
570+
571+ localRenderWithProviders ( < module . default /> )
572+
573+ // Verify "Free" is shown (final price is 0)
574+ // There may be multiple instances (edit view and summary view), so use getAllByText
575+ expect ( screen . getAllByText ( 'Free' ) . length ) . toBeGreaterThan ( 0 )
576+ // Verify original price is NOT shown
577+ expect ( screen . queryByText ( / 9 \. 9 9 / ) ) . not . toBeInTheDocument ( )
504578 } )
505579
506580 test ( 'renders "Free" label when shipping cost is zero' , async ( ) => {
@@ -580,7 +654,8 @@ describe('ShippingOptions Component', () => {
580654
581655 localRenderWithProviders ( < module . default /> )
582656
583- expect ( screen . getByText ( 'Free' ) ) . toBeInTheDocument ( )
657+ // There may be multiple instances (edit view and summary view), so use getAllByText
658+ expect ( screen . getAllByText ( 'Free' ) . length ) . toBeGreaterThan ( 0 )
584659 } )
585660 } )
586661
@@ -1014,6 +1089,96 @@ describe('ShippingOptions Component', () => {
10141089 screen . getByText ( 'Jane Doe, 456 Oak Avenue, Seattle, WA, 98101' )
10151090 ) . toBeInTheDocument ( )
10161091 } )
1092+
1093+ test ( 'displays shipping promotions in edit view for multi-shipment' , async ( ) => {
1094+ jest . resetModules ( )
1095+
1096+ const methodsWithPromos = {
1097+ defaultShippingMethodId : 'std' ,
1098+ applicableShippingMethods : [
1099+ {
1100+ id : 'std' ,
1101+ name : 'Standard Shipping' ,
1102+ description : '4-5 days' ,
1103+ price : 5.99 ,
1104+ shippingPromotions : [
1105+ {
1106+ promotionId : 'promo1' ,
1107+ calloutMsg : 'Free Shipping Amount Above 50'
1108+ }
1109+ ]
1110+ } ,
1111+ {
1112+ id : 'exp' ,
1113+ name : 'Express Shipping' ,
1114+ description : 'Overnight' ,
1115+ price : 10 ,
1116+ shippingPromotions : [ ]
1117+ }
1118+ ]
1119+ }
1120+
1121+ jest . doMock (
1122+ '@salesforce/retail-react-app/app/pages/checkout-one-click/util/checkout-context' ,
1123+ ( ) => ( {
1124+ useCheckout : jest . fn ( ) . mockReturnValue ( {
1125+ step : 3 ,
1126+ STEPS : {
1127+ CONTACT_INFO : 0 ,
1128+ PICKUP_ADDRESS : 1 ,
1129+ SHIPPING_ADDRESS : 2 ,
1130+ SHIPPING_OPTIONS : 3 ,
1131+ PAYMENT : 4
1132+ } ,
1133+ goToStep : mockGoToStep ,
1134+ goToNextStep : mockGoToNextStep
1135+ } )
1136+ } )
1137+ )
1138+ jest . doMock ( '@salesforce/retail-react-app/app/hooks/use-current-customer' , ( ) => ( {
1139+ useCurrentCustomer : ( ) => ( {
1140+ data : { customerId : null , isRegistered : false }
1141+ } )
1142+ } ) )
1143+ jest . doMock ( '@salesforce/retail-react-app/app/hooks/use-current-basket' , ( ) => ( {
1144+ useCurrentBasket : ( ) => ( {
1145+ data : {
1146+ basketId : 'test-basket-id' ,
1147+ shipments : [
1148+ {
1149+ shipmentId : 'ship1' ,
1150+ shippingAddress : {
1151+ firstName : 'John' ,
1152+ lastName : 'Smith' ,
1153+ address1 : '789 Elm Street' ,
1154+ city : 'Portland' ,
1155+ stateCode : 'OR' ,
1156+ postalCode : '97201'
1157+ } ,
1158+ shippingMethod : null
1159+ }
1160+ ] ,
1161+ shippingItems : [ { shipmentId : 'ship1' , price : 0 } ]
1162+ } ,
1163+ derivedData : { hasBasket : true , totalItems : 1 }
1164+ } )
1165+ } ) )
1166+
1167+ const sdk = await import ( '@salesforce/commerce-sdk-react' )
1168+ sdk . useShippingMethodsForShipment . mockReturnValue ( { data : methodsWithPromos } )
1169+
1170+ const { renderWithProviders : localRenderWithProviders } = await import (
1171+ '@salesforce/retail-react-app/app/utils/test-utils'
1172+ )
1173+ const module = await import (
1174+ '@salesforce/retail-react-app/app/pages/checkout-one-click/partials/one-click-shipping-options'
1175+ )
1176+
1177+ localRenderWithProviders ( < module . default /> )
1178+
1179+ // Verify promotion text is shown in edit view
1180+ expect ( screen . getByText ( 'Free Shipping Amount Above 50' ) ) . toBeInTheDocument ( )
1181+ } )
10171182 } )
10181183
10191184 describe ( 'multi-shipment summary view' , ( ) => {
0 commit comments