flamingo.me/flamingo-commerce/v3@v3.11.0/test/integrationtest/projecttest/tests/graphql/product_get_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_CommerceProductGet(t *testing.T) {
    15  	baseURL := "http://" + FlamingoURL
    16  	e := integrationtest.NewHTTPExpect(t, baseURL)
    17  	response := helper.GraphQlRequest(t, e, loadGraphQL(t, "product_get", nil)).Expect().Status(http.StatusOK)
    18  
    19  	expectedState := map[string]interface{}{
    20  		"simple": map[string]interface{}{
    21  			"title":           "TypeSimple product",
    22  			"marketPlaceCode": "fake_simple",
    23  			"meta":            map[string]interface{}{"keywords": []interface{}{"keywords"}},
    24  			"price":           map[string]interface{}{"activeBase": map[string]interface{}{"amount": 1.0, "currency": "EUR"}},
    25  		},
    26  		"configurable": map[string]interface{}{
    27  			"title":           "TypeConfigurable product",
    28  			"marketPlaceCode": "fake_configurable",
    29  			"meta":            map[string]interface{}{"keywords": []interface{}{"keywords"}},
    30  			"variantSelection": map[string]interface{}{
    31  				"variants": []interface{}{
    32  					map[string]interface{}{
    33  						"attributes": []interface{}{
    34  							map[string]interface{}{
    35  								"key":   "color",
    36  								"value": "White",
    37  							},
    38  							map[string]interface{}{
    39  								"key":   "size",
    40  								"value": "M",
    41  							},
    42  						},
    43  						"variant": map[string]interface{}{
    44  							"marketplaceCode": "shirt-white-m",
    45  						},
    46  					},
    47  					map[string]interface{}{
    48  						"attributes": []interface{}{
    49  							map[string]interface{}{
    50  								"key":   "color",
    51  								"value": "Black",
    52  							},
    53  							map[string]interface{}{
    54  								"key":   "size",
    55  								"value": "L",
    56  							},
    57  						},
    58  						"variant": map[string]interface{}{
    59  							"marketplaceCode": "shirt-black-l",
    60  						},
    61  					},
    62  					map[string]interface{}{
    63  						"attributes": []interface{}{
    64  							map[string]interface{}{
    65  								"key":   "color",
    66  								"value": "Red",
    67  							},
    68  							map[string]interface{}{
    69  								"key":   "size",
    70  								"value": "L",
    71  							},
    72  						},
    73  						"variant": map[string]interface{}{
    74  							"marketplaceCode": "shirt-red-l",
    75  						},
    76  					},
    77  					map[string]interface{}{
    78  						"attributes": []interface{}{
    79  							map[string]interface{}{
    80  								"key":   "color",
    81  								"value": "Red",
    82  							},
    83  							map[string]interface{}{
    84  								"key":   "size",
    85  								"value": "M",
    86  							},
    87  						},
    88  						"variant": map[string]interface{}{
    89  							"marketplaceCode": "shirt-red-m",
    90  						},
    91  					},
    92  				},
    93  				"attributes": []interface{}{
    94  					map[string]interface{}{
    95  						"label": "Color",
    96  						"code":  "color",
    97  						"options": []interface{}{
    98  							map[string]interface{}{
    99  								"label":    "White",
   100  								"unitCode": "",
   101  								"otherAttributesRestrictions": []interface{}{
   102  									map[string]interface{}{
   103  										"code":             "size",
   104  										"availableOptions": []interface{}{"M"},
   105  									},
   106  								},
   107  							},
   108  							map[string]interface{}{
   109  								"label":    "Black",
   110  								"unitCode": "",
   111  								"otherAttributesRestrictions": []interface{}{
   112  									map[string]interface{}{
   113  										"code":             "size",
   114  										"availableOptions": []interface{}{"L"},
   115  									},
   116  								},
   117  							},
   118  							map[string]interface{}{
   119  								"label":    "Red",
   120  								"unitCode": "",
   121  								"otherAttributesRestrictions": []interface{}{
   122  									map[string]interface{}{
   123  										"code":             "size",
   124  										"availableOptions": []interface{}{"L", "M"},
   125  									},
   126  								},
   127  							},
   128  						},
   129  					},
   130  					map[string]interface{}{
   131  						"label": "Size",
   132  						"code":  "size",
   133  						"options": []interface{}{
   134  							map[string]interface{}{
   135  								"label":    "M",
   136  								"unitCode": "",
   137  								"otherAttributesRestrictions": []interface{}{
   138  									map[string]interface{}{
   139  										"code":             "color",
   140  										"availableOptions": []interface{}{"White", "Red"},
   141  									},
   142  								},
   143  							},
   144  							map[string]interface{}{
   145  								"label":    "L",
   146  								"unitCode": "",
   147  								"otherAttributesRestrictions": []interface{}{
   148  									map[string]interface{}{
   149  										"code":             "color",
   150  										"availableOptions": []interface{}{"Black", "Red"},
   151  									},
   152  								},
   153  							},
   154  						},
   155  					},
   156  				},
   157  			},
   158  		},
   159  		"active_variant": map[string]interface{}{
   160  			"type":  "configurable_with_activevariant",
   161  			"title": "Shirt Black L",
   162  			"meta":  map[string]interface{}{"keywords": []interface{}{"keywords"}},
   163  			"variationSelections": []interface{}{
   164  				map[string]interface{}{"code": "color", "label": "Color"},
   165  				map[string]interface{}{"code": "size", "label": "Size"},
   166  			},
   167  			"activeVariationSelections": []interface{}{
   168  				map[string]interface{}{"code": "color", "label": "Color", "value": "Black"},
   169  				map[string]interface{}{"code": "size", "label": "Size", "value": "L"},
   170  			},
   171  		},
   172  	}
   173  
   174  	assertResponseForExpectedState(t, response, expectedState)
   175  }