@@ -1291,3 +1291,95 @@ describe('Salesforce Payments Integration', () => {
12911291 )
12921292 } )
12931293} )
1294+
1295+ describe ( 'Checkout error display and submitOrder' , ( ) => {
1296+ test ( 'place order calls create order and shows Place Order button (non-SF Payments)' , async ( ) => {
1297+ let currentBasket = JSON . parse ( JSON . stringify ( scapiBasketWithItem ) )
1298+ currentBasket . shipments [ 0 ] . shippingMethod = defaultShippingMethod
1299+ currentBasket . customerInfo . email = 'customer@test.com'
1300+ currentBasket . shipments [ 0 ] . shippingAddress = {
1301+ address1 : '123 Main St' ,
1302+ city : 'Tampa' ,
1303+ countryCode : 'US' ,
1304+ firstName : 'Test' ,
1305+ fullName : 'Test McTester' ,
1306+ id : 'addr1' ,
1307+ lastName : 'McTester' ,
1308+ phone : '(727) 555-1234' ,
1309+ postalCode : '33712' ,
1310+ stateCode : 'FL'
1311+ }
1312+ currentBasket . billingAddress = currentBasket . shipments [ 0 ] . shippingAddress
1313+ currentBasket . paymentInstruments = [
1314+ {
1315+ amount : 0 ,
1316+ paymentCard : { cardType : 'Visa' , numberLastDigits : '1111' } ,
1317+ paymentInstrumentId : 'pi1' ,
1318+ paymentMethodId : 'CREDIT_CARD'
1319+ }
1320+ ]
1321+
1322+ let orderPostCalled = false
1323+ global . server . use (
1324+ rest . post ( '*/orders' , ( req , res , ctx ) => {
1325+ orderPostCalled = true
1326+ return res (
1327+ ctx . json ( {
1328+ ...currentBasket ,
1329+ ...scapiOrderResponse ,
1330+ status : 'created'
1331+ } )
1332+ )
1333+ } ) ,
1334+ rest . get ( '*/baskets' , ( req , res , ctx ) => {
1335+ return res ( ctx . json ( { baskets : [ currentBasket ] , total : 1 } ) )
1336+ } )
1337+ )
1338+
1339+ window . history . pushState ( { } , 'Checkout' , createPathWithDefaults ( '/checkout' ) )
1340+ const { user} = renderWithProviders ( < WrappedCheckout /> , {
1341+ wrapperProps : {
1342+ bypassAuth : true ,
1343+ isGuest : false ,
1344+ siteAlias : 'uk' ,
1345+ locale : { id : 'en-GB' } ,
1346+ appConfig : mockConfig . app
1347+ }
1348+ } )
1349+
1350+ await waitFor ( ( ) => {
1351+ expect ( screen . getByTestId ( 'sf-checkout-container' ) ) . toBeInTheDocument ( )
1352+ } )
1353+
1354+ const placeOrderBtn = await screen . findByTestId ( 'sf-checkout-place-order-btn' )
1355+ await user . click ( placeOrderBtn )
1356+
1357+ await waitFor ( ( ) => {
1358+ expect ( orderPostCalled ) . toBe ( true )
1359+ } )
1360+ expect (
1361+ screen . queryByText ( / A n u n e x p e c t e d e r r o r o c c u r r e d d u r i n g c h e c k o u t / i)
1362+ ) . not . toBeInTheDocument ( )
1363+ } )
1364+ } )
1365+
1366+ describe ( 'CheckoutContainer with basket and modal' , ( ) => {
1367+ test ( 'renders checkout with Order Summary and basket productItems for modal' , async ( ) => {
1368+ window . history . pushState ( { } , 'Checkout' , createPathWithDefaults ( '/checkout' ) )
1369+ renderWithProviders ( < WrappedCheckout /> , {
1370+ wrapperProps : {
1371+ bypassAuth : true ,
1372+ isGuest : false ,
1373+ siteAlias : 'uk' ,
1374+ locale : { id : 'en-GB' } ,
1375+ appConfig : mockConfig . app
1376+ }
1377+ } )
1378+
1379+ await waitFor ( ( ) => {
1380+ expect ( screen . getByTestId ( 'sf-checkout-container' ) ) . toBeInTheDocument ( )
1381+ } )
1382+
1383+ expect ( screen . getByTestId ( 'sf-order-summary' ) ) . toBeInTheDocument ( )
1384+ } )
1385+ } )
0 commit comments