@@ -549,6 +549,128 @@ describe('Update this is a gift option', function () {
549549 } )
550550 } )
551551} )
552+ describe ( 'Update this is not a gift option' , function ( ) {
553+ beforeEach ( ( ) => {
554+ global . server . use (
555+ rest . patch ( '*/baskets/:basketId/items/:itemId' , ( req , res , ctx ) => {
556+ const basket = mockCustomerBaskets . baskets [ 0 ]
557+ const updatedBasket = {
558+ ...basket ,
559+ productItems : [
560+ {
561+ adjustedTax : 2.93 ,
562+ basePrice : 61.43 ,
563+ bonusProductLineItem : false ,
564+ gift : false ,
565+ itemId : '4a9af0a24fe46c3f6d8721b371' ,
566+ itemText : 'Belted Cardigan With Studs' ,
567+ price : 61.43 ,
568+ priceAfterItemDiscount : 61.43 ,
569+ priceAfterOrderDiscount : 61.43 ,
570+ productId : '701642889830M' ,
571+ productName : 'Belted Cardigan With Studs' ,
572+ quantity : 2 ,
573+ shipmentId : 'me' ,
574+ tax : 2.93 ,
575+ taxBasis : 61.43 ,
576+ taxClassId : 'standard' ,
577+ taxRate : 0.05
578+ }
579+ ]
580+ }
581+ return res ( ctx . json ( updatedBasket ) )
582+ } ) ,
583+ rest . get ( '*/customers/:customerId/baskets' , ( req , res , ctx ) => {
584+ return res (
585+ ctx . delay ( 0 ) ,
586+ ctx . json ( {
587+ baskets : [
588+ {
589+ ...mockCustomerBaskets . baskets [ 0 ] ,
590+ productItems : [
591+ {
592+ adjustedTax : 2.93 ,
593+ basePrice : 61.43 ,
594+ bonusProductLineItem : false ,
595+ gift : true ,
596+ itemId : '4a9af0a24fe46c3f6d8721b371' ,
597+ itemText : 'Belted Cardigan With Studs' ,
598+ price : 61.43 ,
599+ priceAfterItemDiscount : 61.43 ,
600+ priceAfterOrderDiscount : 61.43 ,
601+ productId : '701642889830M' ,
602+ productName : 'Belted Cardigan With Studs' ,
603+ quantity : 2 ,
604+ shipmentId : 'me' ,
605+ tax : 2.93 ,
606+ taxBasis : 61.43 ,
607+ taxClassId : 'standard' ,
608+ taxRate : 0.05
609+ }
610+ ]
611+ }
612+ ] ,
613+ total : 1
614+ } )
615+ )
616+ } )
617+ )
618+ } )
619+ test ( 'can update cart item when user unchecks the gift checkbox' , async ( ) => {
620+ const { user} = renderWithProviders ( < Cart /> )
621+ await waitFor ( ( ) => {
622+ expect ( screen . getByTestId ( 'sf-cart-container' ) ) . toBeInTheDocument ( )
623+ expect ( screen . getByText ( / B e l t e d C a r d i g a n W i t h S t u d s / i) ) . toBeInTheDocument ( )
624+
625+ const cartItem = screen . getByTestId ( 'sf-cart-item-701642889830M' )
626+ expect ( cartItem ) . toBeInTheDocument ( )
627+ } )
628+
629+ const giftCheckbox = screen . getByRole ( 'checkbox' )
630+ expect ( giftCheckbox ) . toBeChecked ( )
631+ await user . click ( giftCheckbox )
632+ global . server . use (
633+ rest . get ( '*/customers/:customerId/baskets' , ( req , res , ctx ) => {
634+ return res . once (
635+ ctx . delay ( 0 ) ,
636+ ctx . json ( {
637+ baskets : [
638+ {
639+ ...mockCustomerBaskets . baskets [ 0 ] ,
640+ productItems : [
641+ {
642+ adjustedTax : 2.93 ,
643+ basePrice : 61.43 ,
644+ bonusProductLineItem : false ,
645+ gift : false ,
646+ itemId : '4a9af0a24fe46c3f6d8721b371' ,
647+ itemText : 'Belted Cardigan With Studs' ,
648+ price : 61.43 ,
649+ priceAfterItemDiscount : 61.43 ,
650+ priceAfterOrderDiscount : 61.43 ,
651+ productId : '701642889830M' ,
652+ productName : 'Belted Cardigan With Studs' ,
653+ quantity : 2 ,
654+ shipmentId : 'me' ,
655+ tax : 2.93 ,
656+ taxBasis : 61.43 ,
657+ taxClassId : 'standard' ,
658+ taxRate : 0.05
659+ }
660+ ]
661+ }
662+ ] ,
663+ total : 1
664+ } )
665+ )
666+ } )
667+ )
668+
669+ await waitFor ( ( ) => {
670+ expect ( giftCheckbox ) . not . toBeChecked ( )
671+ } )
672+ } )
673+ } )
552674
553675describe ( 'Product bundles' , ( ) => {
554676 beforeEach ( ( ) => {
0 commit comments