-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
230 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
@search_products | ||
Feature: Search products | ||
In order to find products that fits my needs | ||
As a Visitor | ||
I want to be able to search products from a keyword | ||
|
||
Background: | ||
Given the store operates on a channel named "US Channel" with hostname "127.0.0.1" | ||
And that channel allows to shop using "English (United States)" and "Italian (Italy)" locales | ||
And it uses the "English (United States)" locale by default | ||
And the store operates on another channel named "IT Channel" with hostname "shop.it" | ||
And that channel allows to shop using "English (United States)" and "Italian (Italy)" locales | ||
And it uses the "Italian (Italy)" locale by default | ||
|
||
And the store has a product "T-Shirt Banana" with code "T_SHIRT_BANANA" | ||
And this product is available in "US Channel" channel | ||
And this product is also available in "IT Channel" channel | ||
And this product is named "Maglietta Banana" in the "Italian (Italy)" locale | ||
|
||
And the store has a product "T-Shirt Apple" available in "US Channel" channel | ||
And this product is also available in "IT Channel" channel | ||
And this product is named "Maglietta Mela" in the "Italian (Italy)" locale | ||
|
||
And the store has a "T-Shirt Orange" configurable product | ||
And this product has a "T-Shirt Orange - Medium size" variant with code "T_SHIRT_ORANGE_M" | ||
And this product is available in "US Channel" channel | ||
And this product is also available in "IT Channel" channel | ||
And this product is named "Maglietta Arancia" in the "Italian (Italy)" locale | ||
|
||
And the store is indexed on Elasticsearch | ||
And I am browsing the channel "US Channel" | ||
|
||
@ui | ||
Scenario: Search products by code | ||
When I search for "T_SHIRT_BANANA" | ||
Then I should be redirected to the product "T-Shirt Banana" page | ||
|
||
@ui | ||
Scenario: Search products by variant code | ||
When I search for "T_SHIRT_ORANGE_M" | ||
Then I should be redirected to the product "T-Shirt Orange" page | ||
|
||
@ui | ||
Scenario: Search products by name | ||
When I search for "shirt" | ||
Then I should see "3" results | ||
And I should see the product "T-Shirt Banana" | ||
And I should see the product "T-Shirt Apple" | ||
And I should see the product "T-Shirt Orange" | ||
|
||
@ui | ||
Scenario: Search products by name in different locale | ||
Given I am browsing the channel "IT Channel" | ||
When I search for "maglietta" | ||
Then I should see "3" results | ||
And I should see the product "Maglietta Banana" | ||
And I should see the product "Maglietta Mela" | ||
And I should see the product "Maglietta Arancia" | ||
|
||
@ui | ||
Scenario: Search products by variant name | ||
When I search for "medium" | ||
Then I should be redirected to the product "T-Shirt Orange" page | ||
|
||
@ui | ||
Scenario: Search only enabled products | ||
Given the store has a product "T-Shirt disabled" available in "US Channel" channel | ||
And this product has been disabled | ||
And the store is indexed on Elasticsearch | ||
When I search for "shirt" | ||
Then I should see "3" results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Webgriffe\SyliusElasticsearchPlugin\Behat\Context\Ui\Shop; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Sylius\Behat\Service\SharedStorageInterface; | ||
use Tests\Webgriffe\SyliusElasticsearchPlugin\Behat\Page\Shop\Search\ResultsPageInterface; | ||
use Webmozart\Assert\Assert; | ||
|
||
final readonly class SearchContext implements Context | ||
{ | ||
public function __construct( | ||
private ResultsPageInterface $searchResultPage, | ||
private SharedStorageInterface $sharedStorage, | ||
) { | ||
} | ||
|
||
/** | ||
* @When /^I search for "([^"]*)"$/ | ||
*/ | ||
public function iSearchFor(string $searchTerm): void | ||
{ | ||
$currentLocaleCode = $this->sharedStorage->get('current_locale_code'); | ||
|
||
$this->searchResultPage->tryToOpen(['_locale' => $currentLocaleCode, 'query' => $searchTerm]); | ||
} | ||
|
||
/** | ||
* @Then /^I should see "([^"]*)" results$/ | ||
*/ | ||
public function iShouldSeeResults(int $count): void | ||
{ | ||
Assert::eq($this->searchResultPage->countResults(), $count); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Webgriffe\SyliusElasticsearchPlugin\Behat\Page\Shop\Search; | ||
|
||
use FriendsOfBehat\PageObjectExtension\Page\SymfonyPage; | ||
|
||
final class ResultsPage extends SymfonyPage implements ResultsPageInterface | ||
{ | ||
public function getRouteName(): string | ||
{ | ||
return 'sylius_shop_search'; | ||
} | ||
|
||
public function countResults(): int | ||
{ | ||
return count($this->getDocument()->findAll('css', '[data-test-result]')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Webgriffe\SyliusElasticsearchPlugin\Behat\Page\Shop\Search; | ||
|
||
use FriendsOfBehat\PageObjectExtension\Page\PageInterface; | ||
|
||
interface ResultsPageInterface extends PageInterface | ||
{ | ||
public function countResults(): int; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
imports: | ||
- suites/viewing_products.yaml | ||
- suites/filter_products.yaml | ||
- suites/search_products.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
default: | ||
suites: | ||
ui_search_products: | ||
contexts: | ||
- sylius.behat.context.hook.doctrine_orm | ||
- sylius.behat.context.hook.session | ||
|
||
- sylius.behat.context.transform.channel | ||
- sylius.behat.context.transform.currency | ||
- sylius.behat.context.transform.customer | ||
- sylius.behat.context.transform.lexical | ||
- sylius.behat.context.transform.locale | ||
- sylius.behat.context.transform.product | ||
- sylius.behat.context.transform.product_association_type | ||
- sylius.behat.context.transform.product_option | ||
- sylius.behat.context.transform.product_variant | ||
- sylius.behat.context.transform.shared_storage | ||
- sylius.behat.context.transform.shipping_category | ||
- sylius.behat.context.transform.tax_category | ||
- sylius.behat.context.transform.taxon | ||
- Sylius\Behat\Context\Transform\CatalogPromotionContext | ||
|
||
- sylius.behat.context.setup.admin_security | ||
- sylius.behat.context.setup.admin_user | ||
- sylius.behat.context.setup.channel | ||
- sylius.behat.context.setup.currency | ||
- sylius.behat.context.setup.customer | ||
- sylius.behat.context.setup.locale | ||
- sylius.behat.context.setup.product | ||
- sylius.behat.context.setup.product_association | ||
- sylius.behat.context.setup.product_attribute | ||
- sylius.behat.context.setup.product_review | ||
- sylius.behat.context.setup.product_taxon | ||
- sylius.behat.context.setup.shop_security | ||
- sylius.behat.context.setup.shipping_category | ||
- sylius.behat.context.setup.taxonomy | ||
- sylius.behat.context.setup.taxation | ||
- sylius.behat.context.setup.product_option | ||
- Sylius\Behat\Context\Setup\CatalogPromotionContext | ||
- webgriffe.sylius_elasticsearch_plugin.behat.context.setup.elasticsearch | ||
- webgriffe.sylius_elasticsearch_plugin.behat.context.setup.product_attribute | ||
|
||
- sylius.behat.context.ui.admin.managing_product_attributes | ||
- sylius.behat.context.ui.admin.product_showpage | ||
- sylius.behat.context.ui.channel | ||
- sylius.behat.context.ui.shop.locale | ||
- sylius.behat.context.ui.shop.product | ||
- sylius.behat.context.ui.shop.product_attribute | ||
- sylius.behat.context.ui.shop.browsing_product | ||
- webgriffe.sylius_elasticsearch_plugin.behat.context.ui.shop.product | ||
- webgriffe.sylius_elasticsearch_plugin.behat.context.ui.shop.search | ||
filters: | ||
tags: "@search_products&&@ui" |