Skip to content

Commit

Permalink
OP-225: Behat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GracjanJozefczyk committed May 27, 2024
1 parent 9425502 commit 7b68ee2
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
21 changes: 10 additions & 11 deletions features/shop/site_wide_searching_products.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ Feature: Site-wide products search
And the store has a select product attribute "Car Type" with values "Cabrio" and "SUV"
And the store has a select product attribute "Motorbike Type" with values "Enduro" and "Naked"
And there is a product named "BMW Z4" in the store
And this product's price is "$42670"
And this product's price is "$42,670.00"
And this product has select attribute "Car Type" with value "Cabrio"
And this product has a text attribute "Color" with value "Red"
And this product has option "Supply" with values "Gasoline" and "Diesel"
And this product is available in "Gasoline" supply priced at "$42670"
And this product is available in "Diesel" supply priced at "$45670"
And this product is available in "Gasoline" supply priced at "$42,670.00"
And this product is available in "Diesel" supply priced at "$45,670.00"
And this product belongs to "Cars"
And there is a product named "Volvo XC90" in the store
And this product's price is "$64505.80"
And this product's price is "$64,505.80"
And this product has select attribute "Car Type" with value "SUV"
And this product has a text attribute "Color" with value "Black"
And this product belongs to "Cars"
And there is a product named "BMW 5 Series" in the store
And this product's price is "$52070"
And this product's price is "$52,070.00"
And this product has select attribute "Car Type" with value "Cabrio"
And this product has a text attribute "Color" with value "Red"
And this product belongs to "Cars"
And there is a product named "Lamborghini Aventador" in the store
And this product's price is "$450000"
And this product's price is "$450,000.00"
And this product has a text attribute "Color" with value "Yellow"
And this product belongs to "Cars"
And there is a product named "BMW GS" in the store
And this product's price is "$18070"
And this product's price is "$18,070.00"
And this product has select attribute "Motorbike Type" with value "Enduro"
And this product has a text attribute "Color" with value "Grey"
And this product belongs to "Motorbikes"
And there is a product named "Ducati Monster" in the store
And this product's price is "$14995"
And this product's price is "$14,995.00"
And this product has select attribute "Motorbike Type" with value "Naked"
And this product has a text attribute "Color" with value "Black"
And this product's short description is:
Expand All @@ -49,7 +49,7 @@ Feature: Site-wide products search
And there is a product named "Honda Africa Twin" in the store
And this product has select attribute "Motorbike Type" with value "Enduro"
And this product has a text attribute "Color" with value "Green & White"
And this product's price is "$13490"
And this product's price is "$13,490.00"
And this product's description is:
"""
This is the Honda Africa Twin which is like the BMW GS but from Honda.
Expand Down Expand Up @@ -101,8 +101,7 @@ Feature: Site-wide products search
When I browse the search page
And I search the products by "BMW" phrase in the site-wide search box
And I filter by price interval "$10,000.00 - $20,000.00"
And I filter by price interval "$50,000.00 - $60,000.00"
Then I should see 4 products in search results
Then I should see 3 products in search results

@ui
Scenario: Searching products and filtering by taxon
Expand Down
3 changes: 1 addition & 2 deletions features/shop/site_wide_searching_products_113.feature
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ Feature: Site-wide products search
When I browse the search page
And I search the products by "BMW" phrase in the site-wide search box
And I filter by price interval "$10,000.00 - $20,000.00"
And I filter by price interval "$50,000.00 - $60,000.00"
Then I should see 4 products in search results
Then I should see 3 products in search results

@ui
Scenario: Searching products and filtering by taxon
Expand Down
14 changes: 8 additions & 6 deletions src/Resources/views/Shop/search.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
<div style="display: none;">
{{ form_row(searchForm.box) }}
</div>
{% for facet in searchForm.facets %}
<div class="item">
{{ form_label(facet) }}
{{ form_widget(facet) }}
</div>
{% endfor %}
{% if searchForm.facets is defined %}
{% for facet in searchForm.facets %}
<div class="item">
{{ form_label(facet) }}
{{ form_widget(facet, sylius_test_form_attribute(facet.vars.id)) }}
</div>
{% endfor %}
{% endif %}
<div class="item">
<button type="submit" class="ui primary icon labeled button fluid">
<i class="search icon"></i>
Expand Down
13 changes: 13 additions & 0 deletions tests/Application/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@
parameters:
locale: en_US
bitbag_es_shop_price_facet_interval: 1000000

services:
bitbag_sylius_elasticsearch_plugin.facet.registry:
class: BitBag\SyliusElasticsearchPlugin\Facet\Registry
calls:
- method: addFacet
arguments:
- price
- '@bitbag_sylius_elasticsearch_plugin.facet.price'
- method: addFacet
arguments:
- taxon
- '@bitbag_sylius_elasticsearch_plugin.facet.taxon'
8 changes: 4 additions & 4 deletions tests/Behat/Page/Shop/SearchPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ protected function getDefinedElements(): array
'search_facets_price' => '#bitbag_elasticsearch_search_facets_price',
'search_facets_taxon' => '#bitbag_elasticsearch_search_facets_taxon',
'search_facets_filter_button' => '#filters-vertical form button[type="submit"]',
'search_facets_attribute_car_type' => '#bitbag_elasticsearch_search_facets_attribute_car_type',
'search_facets_attribute_motorbike_type' => '#bitbag_elasticsearch_search_facets_attribute_motorbike_type',
'search_facets_attribute_color' => '#bitbag_elasticsearch_search_facets_attribute_color',
'search_facets_option_supply' => '#bitbag_elasticsearch_search_facets_option_supply',
'search_facets_attribute_car_type' => '[data-test-bitbag_elasticsearch_search_facets_car_type]',
'search_facets_attribute_motorbike_type' => '[data-test-bitbag_elasticsearch_search_facets_motorbike_type]',
'search_facets_attribute_color' => '[data-test-bitbag_elasticsearch_search_facets_color]',
'search_facets_option_supply' => '[data-test-bitbag_elasticsearch_search_facets_supply]',
];
}

Expand Down

0 comments on commit 7b68ee2

Please sign in to comment.