[Admin][PaymentMethod] Upgrade index

[Admin][Behat][PaymentMethod] Fix sorting and cover filtration
This commit is contained in:
Jan Goralski 2024-07-05 11:27:00 +02:00 committed by Grzegorz Sadowski
parent 635a97978d
commit 7eca096718
7 changed files with 59 additions and 9 deletions

View file

@ -0,0 +1,33 @@
@managing_payment_methods
Feature: Filtering payment methods
In order to quickly find the payment method I need
As an Administrator
I want to filter available payment methods
Background:
Given the store operates on a single channel in "United States"
And the store has a payment method "PayPal Express Checkout" with a code "paypal_xyz" and "Paypal Express Checkout" gateway
And the store has a payment method "Offline" with a code "offline_abc"
And this payment method is disabled
And the store has a payment method "Cash on Delivery" with a code "cash_on_delivery_xyz"
And I am logged in as an administrator
And I am browsing payment methods
@todo-api @ui
Scenario: Filtering payment methods by name
When I search by "PayPal" name
Then I should see a single payment method in the list
And I should see the payment method "PayPal Express Checkout"
@todo-api @ui
Scenario: Filtering payment methods by code
When I search by "xyz" code
Then I should see 2 payment methods in the list
And I should not see the payment method "Offline"
@todo-api @ui
Scenario: Filtering enabled payment methods
When I choose enabled filter
And I filter
Then I should see 2 payment methods in the list
And I should not see the payment method "Offline"

View file

@ -7,9 +7,9 @@ Feature: Sorting listed payment methods
Background:
Given the store operates on a single channel in "United States"
And that channel allows to shop using "English (United States)" and "Polish (Poland)" locales
And the store has a payment method "PayPal Express Checkout" with a code "PAYPAL" and "Paypal Express Checkout" gateway
And the store has a payment method "PayPal Express Checkout" with a code "paypal" and "Paypal Express Checkout" gateway
And this payment method is named "Ekspresowy Paypal" in the "Polish (Poland)" locale
And the store has a payment method "Offline" with a code "Offline"
And the store has a payment method "Offline" with a code "offline"
And this payment method is named "Płatność Offline" in the "Polish (Poland)" locale
And the store has a payment method "Cash on Delivery" with a code "cash_on_delivery"
And this payment method is named "Płatność Przy Odbiorze" in the "Polish (Poland)" locale
@ -28,7 +28,7 @@ Feature: Sorting listed payment methods
And the payment methods are already sorted by code
When I switch the way payment methods are sorted to descending by code
Then I should see 3 payment methods in the list
And the first payment method on the list should have code "PAYPAL"
And the first payment method on the list should have code "paypal"
@api @ui
Scenario: Payment methods can be sorted by their names

View file

@ -128,7 +128,7 @@ final readonly class PaymentContext implements Context
/**
* @Given the payment method :paymentMethod is disabled
* @Given /^(this payment method) has been disabled$/
* @Given /^(this payment method) (?:has been|is) disabled$/
* @When the payment method :paymentMethod gets disabled
*/
public function theStoreHasAPaymentMethodDisabled(PaymentMethodInterface $paymentMethod)

View file

@ -255,6 +255,22 @@ final readonly class ManagingPaymentMethodsContext implements Context
$this->indexPage->bulkDelete();
}
/**
* @Then I should see the payment method :paymentMethodName
*/
public function IShouldSeeThePaymentMethod(string $paymentMethodName): void
{
Assert::true($this->indexPage->isSingleResourceOnPage(['name' => $paymentMethodName]));
}
/**
* @Then I should not see the payment method :paymentMethodName
*/
public function IShouldNotSeeThePaymentMethod(string $paymentMethodName): void
{
Assert::false($this->indexPage->isSingleResourceOnPage(['name' => $paymentMethodName]));
}
/**
* @Then the payment method :paymentMethodName should appear in the registry
* @Then the payment method :paymentMethodName should be in the registry
@ -262,9 +278,7 @@ final readonly class ManagingPaymentMethodsContext implements Context
*/
public function thePaymentMethodShouldAppearInTheRegistry(string $paymentMethodName): void
{
$this->indexPage->open();
Assert::true($this->indexPage->isSingleResourceOnPage(['name' => $paymentMethodName]));
$this->thereShouldStillBeOnlyOnePaymentMethodWith('name', $paymentMethodName);
}
/**

View file

@ -29,6 +29,7 @@ default:
- sylius.behat.context.ui.admin.managing_payment_methods
- sylius.behat.context.ui.admin.notification
- sylius.behat.context.ui.admin.search_filter
- sylius.behat.context.ui.shop.locale
filters:

View file

@ -54,6 +54,8 @@ sylius_grid:
label: sylius.ui.search
options:
fields: [code, translation.name]
form_options:
type: !php/const Sylius\Component\Grid\Filter\StringFilter::TYPE_CONTAINS
enabled:
type: boolean
label: sylius.ui.enabled

View file

@ -2,9 +2,9 @@
{% set configuration = hookable_metadata.context.configuration %}
{% set index_url = path(
{% set index_url = sylius_generate_redirect_path(app.request.headers.get('referer')|default(path(
configuration.vars.index.route.name|default(configuration.getRouteName('index')),
configuration.vars.index.route.parameters|default(configuration.vars.route.parameters|default({}))
) %}
))) %}
{{ _button.cancel(sylius_test_form_attribute('cancel-changes-button')|merge({ text: 'sylius.ui.cancel'|trans, url: index_url, class: 'btn' })) }}