diff --git a/features/admin/searching_products_via_the_dashboard_search_field.feature b/features/admin/searching_products_via_the_dashboard_search_field.feature new file mode 100644 index 00000000000..2171f1b52d0 --- /dev/null +++ b/features/admin/searching_products_via_the_dashboard_search_field.feature @@ -0,0 +1,19 @@ +@admin_dashboard +Feature: Searching products via the dashboard search field + In order to search for products easily + As an Administrator + I want to be able to search for products via the dashboard search field + + Background: + Given the store operates on a channel named "WEB-POLAND" + And there is product "Onion" available in this channel + And the store ships everywhere for Free + And the store allows paying Offline + And I am logged in as an administrator + + @ui @no-api + Scenario: Searching for a product via the dashboard search field + When I open administration dashboard + And I search for product "Onion" + Then I should see a single product in the list + And I should see a product with name "Onion" diff --git a/src/Sylius/Behat/Context/Ui/Admin/DashboardContext.php b/src/Sylius/Behat/Context/Ui/Admin/DashboardContext.php index 04487a9d708..d7b929bb0a7 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/DashboardContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/DashboardContext.php @@ -17,6 +17,7 @@ use FriendsOfBehat\PageObjectExtension\Page\UnexpectedPageException; use Sylius\Behat\Page\Admin\DashboardPageInterface; use Sylius\Component\Core\Model\ChannelInterface; +use Sylius\Component\Core\Model\ProductInterface; use Webmozart\Assert\Assert; final class DashboardContext implements Context @@ -81,6 +82,14 @@ public function iChooseChannel(string $channelName): void $this->dashboardPage->chooseChannel($channelName); } + /** + * @When I search for product :product + */ + public function iSearchForProduct(ProductInterface $product): void + { + $this->dashboardPage->searchForProduct($product); + } + /** * @When I log out */ diff --git a/src/Sylius/Behat/Page/Admin/DashboardPage.php b/src/Sylius/Behat/Page/Admin/DashboardPage.php index fed132d0bf0..b0a3014bcc3 100644 --- a/src/Sylius/Behat/Page/Admin/DashboardPage.php +++ b/src/Sylius/Behat/Page/Admin/DashboardPage.php @@ -17,6 +17,7 @@ use Behat\Mink\Session; use FriendsOfBehat\PageObjectExtension\Page\SymfonyPage; use Sylius\Behat\Service\Accessor\TableAccessorInterface; +use Sylius\Component\Core\Model\ProductInterface; use Symfony\Component\Routing\RouterInterface; class DashboardPage extends SymfonyPage implements DashboardPageInterface @@ -124,6 +125,12 @@ public function chooseNextPeriod(): void usleep(500000); } + public function searchForProduct(ProductInterface $productName): void + { + $this->getElement('product_search')->setValue($productName->getName()); + $this->getElement('search_button')->click(); + } + public function getRouteName(): string { return 'sylius_admin_dashboard'; @@ -145,6 +152,8 @@ protected function getDefinedElements(): array 'new_customers' => '#new-customers', 'new_orders' => '#new-orders', 'order_list' => '#orders', + 'product_search' => '[data-test-product-search]', + 'search_button' => '[data-test-search-button]', 'sub_header' => '.ui.header .content .sub.header', 'total_sales' => '#total-sales', 'year_split_by_months_statistics_button' => 'button[data-stats-button="year"]', diff --git a/src/Sylius/Behat/Page/Admin/DashboardPageInterface.php b/src/Sylius/Behat/Page/Admin/DashboardPageInterface.php index 24cd7f01569..195dd6a4828 100644 --- a/src/Sylius/Behat/Page/Admin/DashboardPageInterface.php +++ b/src/Sylius/Behat/Page/Admin/DashboardPageInterface.php @@ -14,6 +14,7 @@ namespace Sylius\Behat\Page\Admin; use FriendsOfBehat\PageObjectExtension\Page\SymfonyPageInterface; +use Sylius\Component\Core\Model\ProductInterface; interface DashboardPageInterface extends SymfonyPageInterface { @@ -44,4 +45,6 @@ public function chooseMonthSplitByDaysInterval(): void; public function choosePreviousPeriod(): void; public function chooseNextPeriod(): void; + + public function searchForProduct(ProductInterface $productName): void; } diff --git a/src/Sylius/Behat/Resources/config/suites/ui/admin/dashboard.yaml b/src/Sylius/Behat/Resources/config/suites/ui/admin/dashboard.yaml index 532092de61b..c66a8306890 100644 --- a/src/Sylius/Behat/Resources/config/suites/ui/admin/dashboard.yaml +++ b/src/Sylius/Behat/Resources/config/suites/ui/admin/dashboard.yaml @@ -28,6 +28,7 @@ default: - sylius.behat.context.ui.admin.dashboard - sylius.behat.context.ui.admin.login + - sylius.behat.context.ui.admin.managing_products - sylius.behat.context.ui.admin.notification - sylius.behat.context.ui.browser