Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to search products from dashboard #16381

Merged
merged 4 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@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 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"
9 changes: 9 additions & 0 deletions src/Sylius/Behat/Context/Ui/Admin/DashboardContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down
9 changes: 9 additions & 0 deletions src/Sylius/Behat/Page/Admin/DashboardPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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';
Expand All @@ -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"]',
Expand Down
3 changes: 3 additions & 0 deletions src/Sylius/Behat/Page/Admin/DashboardPageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Sylius\Behat\Page\Admin;

use FriendsOfBehat\PageObjectExtension\Page\SymfonyPageInterface;
use Sylius\Component\Core\Model\ProductInterface;

interface DashboardPageInterface extends SymfonyPageInterface
{
Expand Down Expand Up @@ -44,4 +45,6 @@ public function chooseMonthSplitByDaysInterval(): void;
public function choosePreviousPeriod(): void;

public function chooseNextPeriod(): void;

public function searchForProduct(ProductInterface $productName): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<form action="#" method="get" autocomplete="off" novalidate="">
<div class="input-icon">
<input type="text" placeholder="Search..." aria-label="Search in website" class="form-control ">
<span class="input-icon-addon">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"></path>
<path d="M21 21l-6 -6"></path>
<form action="{{ path('sylius_admin_product_index') }}" method="get">
<div class="input-group">
<input type="text" name="criteria[search][value]" placeholder="{{ 'sylius.ui.search_products'|trans }}..." class="form-control" {{ sylius_test_html_attribute('product-search') }}>
<button type="submit" class="btn" {{ sylius_test_html_attribute('search-button') }}>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-search" viewBox="0 0 16 16">
<path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0"/>
</svg>
NoResponseMate marked this conversation as resolved.
Show resolved Hide resolved
</span>
</button>
</div>
</form>
Loading