flamingo.me/flamingo-commerce/v3@v3.11.0/test/integrationtest/projecttest/tests/graphql/product_search_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_CommerceProductSearchFacets(t *testing.T) {
    15  	baseURL := "http://" + FlamingoURL
    16  	e := integrationtest.NewHTTPExpect(t, baseURL)
    17  	resp := helper.GraphQlRequest(t, e, loadGraphQL(t, "product_search", nil)).Expect()
    18  	resp.Status(http.StatusOK)
    19  
    20  	facets := getValue(resp, "Commerce_Product_Search", "facets").Array()
    21  	facets.Length().IsEqual(3)
    22  
    23  	for _, facet := range facets.Iter() {
    24  		facetName := facet.Object().Value("name").String()
    25  
    26  		switch facetName.Raw() {
    27  		case "brandCode":
    28  			facet.Object().Value("items").Array().Value(0).Object().Value("value").String().IsEqual("apple")
    29  		case "retailerCode":
    30  			facet.Object().Value("items").Array().Value(0).Object().Value("value").String().IsEqual("retailer")
    31  		case "categoryCodes":
    32  			facet.Object().Value("items").Array().Value(0).Object().Value("value").String().IsEqual("electronics")
    33  		default:
    34  			// Do nothing here
    35  		}
    36  	}
    37  }