flamingo.me/flamingo-commerce/v3@v3.11.0/test/integrationtest/projecttest/tests/graphql/cart_summary_test.go (about)

     1  //go:build integration
     2  // +build integration
     3  
     4  package graphql_test
     5  
     6  import (
     7  	"net/http"
     8  	"testing"
     9  
    10  	"flamingo.me/flamingo-commerce/v3/test/integrationtest"
    11  	"flamingo.me/flamingo-commerce/v3/test/integrationtest/projecttest/helper"
    12  )
    13  
    14  func Test_CartSummary(t *testing.T) {
    15  	t.Parallel()
    16  	baseURL := "http://" + FlamingoURL
    17  	tests := []struct {
    18  		name                 string
    19  		gatewayMethod        string
    20  		marketPlaceCode      string
    21  		expectedState        map[string]interface{}
    22  		expectedGraphQLState string
    23  	}{
    24  		{
    25  			name:            "sumPaymentSelectionCartSplitValueAmountByMethods",
    26  			gatewayMethod:   "creditcard",
    27  			marketPlaceCode: "fake_simple_with_fixed_price",
    28  			expectedState: map[string]interface{}{
    29  				"Commerce_Cart_DecoratedCart": map[string]interface{}{
    30  					"cartSummary": map[string]interface{}{
    31  						"total": map[string]interface{}{
    32  							"amount":   10.49,
    33  							"currency": "EUR",
    34  						},
    35  					},
    36  				},
    37  			},
    38  		},
    39  	}
    40  
    41  	for _, tt := range tests {
    42  		t.Run(tt.name, func(t *testing.T) {
    43  
    44  			e := integrationtest.NewHTTPExpect(t, baseURL)
    45  			prepareCartWithPaymentSelection(t, e, tt.gatewayMethod, &tt.marketPlaceCode)
    46  
    47  			response := helper.GraphQlRequest(t, e, loadGraphQL(t, "cart_summary", map[string]string{"METHOD": tt.gatewayMethod})).Expect().Status(http.StatusOK)
    48  			response.Status(http.StatusOK)
    49  
    50  			assertResponseForExpectedState(t, response, tt.expectedState)
    51  		})
    52  	}
    53  }