+ {% hook 'extra_information' %}
+ {{ form_row(hookable_metadata.context.form.fraudStatus) }}
```
or copy from the path:
```
-vendor/bitbag/blacklist-plugin/tests/Application/templates/bundles/SyliusAdminBundle/Customer/_form.html.twig
+vendor/bitbag/blacklist-plugin/tests/Application/templates/bundles/SyliusAdminBundle/customer/form/sections/extra_information.html.twig
+```
+
+Copy order actions template from the path:
+
+```
+vendor/bitbag/blacklist-plugin/tests/Application/templates/bundles/SyliusAdminBundle/order/show/content/header/title_block/actions.html.twig
```
## Tests
diff --git a/features/admin/adding_automatic_blacklisting_configuration.feature b/features/admin/adding_automatic_blacklisting_configuration.feature
index 1f5a5a9..4b6d42a 100644
--- a/features/admin/adding_automatic_blacklisting_configuration.feature
+++ b/features/admin/adding_automatic_blacklisting_configuration.feature
@@ -12,7 +12,6 @@ Feature: Adding a new automatic blacklisting configuration
Scenario: Successfully adding a new automatic blacklisting configuration with max number of orders
When I go to the create automatic blacklisting configuration page
And I name it "First configuration"
- And I select "United States" as channels
And I enable it
And I add the "Max number of orders" rule configured with count "5" and "Per day" as date modifier
And I do not want to add fraud suspicion row after exceeding limit
@@ -24,7 +23,6 @@ Feature: Adding a new automatic blacklisting configuration
Scenario: Successfully adding a new automatic blacklisting configuration
When I go to the create automatic blacklisting configuration page
And I name it "Second configuration"
- And I select "United States" as channels
And I enable it
And I add the "Max number of payment failures" rule configured with count "3" and "Per day" as date modifier
And I want to add fraud suspicion row after exceeding limit
@@ -38,7 +36,6 @@ Feature: Adding a new automatic blacklisting configuration
Scenario: Successfully adding a new automatic blacklisting configuration with max number of payment failures
When I go to the create automatic blacklisting configuration page
And I name it "Third configuration"
- And I select "United States" as channels
And I enable it
And I add the "Max number of payment failures" rule configured with count "3" and "Per day" as date modifier
And I do not want to add fraud suspicion row after exceeding limit
@@ -55,4 +52,4 @@ Feature: Adding a new automatic blacklisting configuration
And I add the "Max number of orders" rule configured with count "5" and "Per day" as date modifier
And I want to add fraud suspicion row after exceeding limit
And I add it
- Then I should be notified that I need to add settings to fraud suspicion section
\ No newline at end of file
+ Then I should be notified that I need to add settings to fraud suspicion section
diff --git a/features/shop/blocking_user_on_checkout_by_automatic_blacklisting_rule.feature b/features/shop/blocking_user_on_checkout_by_automatic_blacklisting_rule.feature
index 3364ebf..8893f26 100644
--- a/features/shop/blocking_user_on_checkout_by_automatic_blacklisting_rule.feature
+++ b/features/shop/blocking_user_on_checkout_by_automatic_blacklisting_rule.feature
@@ -17,7 +17,7 @@ Feature: Blocking users on checkout
And the customer bought a single "PHP T-Shirt"
And the customer chose "Free" shipping method to "United States" with "Cash on Delivery" payment
- @ui
+ @ui @javascript
Scenario: Successfully complete checkout addressing step
Given I have product "PHP Pullover" in the cart
And there is a automatic blacklisting configuration "First configuration" with rule "orders" configured with count "2" and date modifier "1 day"
@@ -26,7 +26,7 @@ Feature: Blocking users on checkout
And I complete the addressing step
Then I should be on the checkout shipping step
- @ui
+ @ui @javascript
Scenario: Blocking users on checkout by automatic blacklisting rules
Given I have product "PHP Blouse" in the cart
And there is a automatic blacklisting configuration "First configuration" with rule "orders" configured with count "1" and date modifier "1 day"
@@ -34,4 +34,4 @@ Feature: Blocking users on checkout
And I specify the billing address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
And I complete the addressing step
Then I should be notified that something went wrong
- And I should be at the checkout addressing step
\ No newline at end of file
+ And I should be at the checkout addressing step
diff --git a/features/shop/blocking_user_on_checkout_by_manual_blacklisting_rule.feature b/features/shop/blocking_user_on_checkout_by_manual_blacklisting_rule.feature
index 7a9281b..1f874b1 100644
--- a/features/shop/blocking_user_on_checkout_by_manual_blacklisting_rule.feature
+++ b/features/shop/blocking_user_on_checkout_by_manual_blacklisting_rule.feature
@@ -21,7 +21,7 @@ Feature: Blocking users on checkout
And the customer chose "Free" shipping method to "United States" with "Cash on Delivery" payment
And the order "#00000022" is marked as suspicious by fake "billing" address
- @ui
+ @ui @javascript
Scenario: Successfully complete checkout addressing step
Given I have product "PHP Pullover" in the cart
And there is a blacklisting rule with "Country" name and "3" permitted strikes and "country" as a rule attributes
@@ -30,7 +30,7 @@ Feature: Blocking users on checkout
And I complete the addressing step
Then I should be on the checkout shipping step
- @ui
+ @ui @javascript
Scenario: Successfully complete checkout by users for who manual blacklisting rule is not eligible
Given the customer belongs to group "Wholesale"
And I have product "PHP Pullover" in the cart
@@ -41,7 +41,7 @@ Feature: Blocking users on checkout
And I complete the addressing step
Then I should be on the checkout shipping step
- @ui
+ @ui @javascript
Scenario: Successfully complete checkout by users for who manual blacklisting rule is not eligible
Given I have product "PHP Pullover" in the cart
And there is a blacklisting rule with "Country" name and "1" permitted strikes and "country" as a rule attributes
@@ -51,7 +51,7 @@ Feature: Blocking users on checkout
And I complete the addressing step
Then I should be on the checkout shipping step
- @ui
+ @ui @javascript
Scenario: Blocking users on checkout by manual blacklisting rules
Given I have product "PHP Blouse" in the cart
And there is a blacklisting rule with "Country" name and "1" permitted strikes and "country" as a rule attributes
@@ -59,4 +59,4 @@ Feature: Blocking users on checkout
And I specify the billing address as "Francis Underwood", "Groove Street", "91920", "United States" for "Francis Underwood"
And I complete the addressing step
Then I should be notified that something went wrong
- And I should be at the checkout addressing step
\ No newline at end of file
+ And I should be at the checkout addressing step
diff --git a/src/Form/Type/FraudSuspicionType.php b/src/Form/Type/FraudSuspicionType.php
index d73c143..daff852 100644
--- a/src/Form/Type/FraudSuspicionType.php
+++ b/src/Form/Type/FraudSuspicionType.php
@@ -37,6 +37,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'constraints' => [
new NotNull(),
],
+ 'attr' => [
+ 'data-test-fraud-suspicion-customer-autocomplete' => '',
+ ],
])
->add('company', TextType::class, [
'required' => false,
diff --git a/src/Resources/config/routing/admin/fraud_suspicion.yaml b/src/Resources/config/routing/admin/fraud_suspicion.yaml
index fc1a0df..930bdad 100644
--- a/src/Resources/config/routing/admin/fraud_suspicion.yaml
+++ b/src/Resources/config/routing/admin/fraud_suspicion.yaml
@@ -34,8 +34,7 @@ bitbag_sylius_blacklist_plugin_admin_order_mark_suspicious:
parameters:
orderId: $orderId
section: admin
- template: "@SyliusAdmin/Crud/create.html.twig"
- form: BitBag\SyliusBlacklistPlugin\Form\Type\FraudSuspicionOrderType
+ template: "@SyliusAdmin/shared/crud/create.html.twig"
factory:
method: createForOrder
arguments:
diff --git a/src/Resources/config/services/form.xml b/src/Resources/config/services/form.xml
index 95b7e03..0337872 100644
--- a/src/Resources/config/services/form.xml
+++ b/src/Resources/config/services/form.xml
@@ -39,9 +39,9 @@
diff --git a/src/Resources/views/FraudSuspicion/Admin/Show/_order.html.twig b/src/Resources/views/FraudSuspicion/Admin/Show/_order.html.twig
index a9b7aad..6d26b12 100644
--- a/src/Resources/views/FraudSuspicion/Admin/Show/_order.html.twig
+++ b/src/Resources/views/FraudSuspicion/Admin/Show/_order.html.twig
@@ -5,7 +5,6 @@
{% if fraudSuspicion.order != null %}
{% if fraudSuspicion.order.number != null %}
-
{{ 'bitbag_sylius_blacklist_plugin.ui.see_more_info_about_order'|trans ~ ' #' ~ fraudSuspicion.order.number }}
diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Customer/_form.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Customer/_form.html.twig
deleted file mode 100644
index f4e2d6b..0000000
--- a/tests/Application/templates/bundles/SyliusAdminBundle/Customer/_form.html.twig
+++ /dev/null
@@ -1,43 +0,0 @@
-{{ form_errors(form) }}
-
-
-
-
-
- {{ form_row(form.firstName) }}
- {{ form_row(form.lastName) }}
-
- {{ form_row(form.email) }}
- {{ form_row(form.group) }}
-
-
-
- {{ form_row(form.gender) }}
- {{ form_row(form.birthday) }}
- {{ form_row(form.phoneNumber) }}
- {{ form_row(form.subscribedToNewsletter) }}
-
-
-
-
-
- {% if customer.user is empty or customer.user.id is null %}
-
-
- {{ form_row(form.createUser) }}
-
-
- {% endif %}
- {% if form.user is defined %}
-
- {{ form_row(form.user.plainPassword) }}
- {{ form_row(form.user.enabled) }}
-
- {% endif %}
-
-
-
- {{ form_row(form.fraudStatus) }}
-
-
-
diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/customer/form/sections/extra_information.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/customer/form/sections/extra_information.html.twig
new file mode 100644
index 0000000..dd6ddb7
--- /dev/null
+++ b/tests/Application/templates/bundles/SyliusAdminBundle/customer/form/sections/extra_information.html.twig
@@ -0,0 +1,13 @@
+
+
+
+
+ {% hook 'extra_information' %}
+ {{ form_row(hookable_metadata.context.form.fraudStatus) }}
+
+
+
diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/order/show/content/header/title_block/actions.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/order/show/content/header/title_block/actions.html.twig
new file mode 100644
index 0000000..664c5bf
--- /dev/null
+++ b/tests/Application/templates/bundles/SyliusAdminBundle/order/show/content/header/title_block/actions.html.twig
@@ -0,0 +1,20 @@
+{% from '@SyliusAdmin/shared/helper/icon.html.twig' import icon %}
+{% set resource = hookable_metadata.context.resource %}
+
+
diff --git a/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/CreatePage.php b/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/CreatePage.php
index 5ee52c0..10d3b0c 100755
--- a/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/CreatePage.php
+++ b/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/CreatePage.php
@@ -36,13 +36,12 @@ public function selectOption(string $field, string $value): void
public function addRule(string $ruleName): void
{
- $count = count($this->getCollectionItems('rules'));
+ $this->getElement($ruleName)->press();
- $this->getDocument()->clickLink('Add rule');
+ $form = $this->getElement('form');
- $this->getSession()->wait(100);
-
- $this->selectRuleOption('Type', $ruleName);
+ usleep(500000); // we need to sleep, as sometimes the check below is executed faster than the form sets the busy attribute
+ $form->waitFor(1500, fn () => !$form->hasAttribute('busy'));
}
public function selectRuleOption(string $option, string $value, bool $multiple = false): void
@@ -93,6 +92,9 @@ protected function getDefinedElements(): array
{
return [
'rules' => '#bitbag_sylius_blacklist_plugin_automatic_blacklisting_configuration_rules',
+ 'Max number of orders' => '[data-test-add-orders]',
+ 'Max number of payment failures' => '[data-test-add-payment_failures]',
+ 'form' => 'form',
];
}
@@ -110,8 +112,7 @@ private function getLastCollectionItem(string $collection): NodeElement
*/
private function getCollectionItems(string $collection): array
{
- $items = $this->getElement($collection)->findAll('css', 'div[data-form-collection="item"]');
-
+ $items = $this->getElement($collection)->findAll('css', '[data-test-entry-row]');
Assert::isArray($items);
return $items;
diff --git a/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/UpdatePage.php b/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/UpdatePage.php
index c0b5b4c..7c75ad4 100755
--- a/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/UpdatePage.php
+++ b/tests/Behat/Page/Admin/AutomaticBlacklistingConfiguration/UpdatePage.php
@@ -35,7 +35,7 @@ public function uncheckField(string $locator): void
public function update(): void
{
- $this->getDocument()->pressButton('Save changes');
+ $this->getDocument()->pressButton('Update');
}
public function fillRuleOption(string $option, string $value): void
@@ -64,7 +64,7 @@ private function getLastCollectionItem(string $collection): NodeElement
*/
private function getCollectionItems(string $collection): array
{
- $items = $this->getElement($collection)->findAll('css', 'div[data-form-collection="item"]');
+ $items = $this->getElement($collection)->findAll('css', '[data-test-entry-row]');
Assert::isArray($items);
diff --git a/tests/Behat/Page/Admin/Customer/UpdatePage.php b/tests/Behat/Page/Admin/Customer/UpdatePage.php
index 9803a76..2b219df 100755
--- a/tests/Behat/Page/Admin/Customer/UpdatePage.php
+++ b/tests/Behat/Page/Admin/Customer/UpdatePage.php
@@ -20,6 +20,6 @@ public function selectOption(string $field, string $value): void
public function submit(): void
{
- $this->getDocument()->pressButton('Save changes');
+ $this->getDocument()->pressButton('Update');
}
}
diff --git a/tests/Behat/Page/Admin/FraudSuspicion/CreatePage.php b/tests/Behat/Page/Admin/FraudSuspicion/CreatePage.php
index 80e8a4e..616d05e 100755
--- a/tests/Behat/Page/Admin/FraudSuspicion/CreatePage.php
+++ b/tests/Behat/Page/Admin/FraudSuspicion/CreatePage.php
@@ -10,13 +10,26 @@
namespace Tests\BitBag\SyliusBlacklistPlugin\Behat\Page\Admin\FraudSuspicion;
use Behat\Mink\Element\DocumentElement;
+use Behat\Mink\Session;
use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage;
+use Sylius\Behat\Service\Helper\AutocompleteHelperInterface;
+use Symfony\Component\Routing\RouterInterface;
use Tests\BitBag\SyliusBlacklistPlugin\Behat\Behaviour\ContainsErrorTrait;
class CreatePage extends BaseCreatePage implements CreatePageInterface
{
use ContainsErrorTrait;
+ public function __construct(
+ Session $session,
+ $minkParameters,
+ RouterInterface $router,
+ string $routeName,
+ private AutocompleteHelperInterface $autocompleteHelper,
+ ) {
+ parent::__construct($session, $minkParameters, $router, $routeName);
+ }
+
public function fillField(string $field, ?string $value): CreatePageInterface
{
if (empty($value)) {
@@ -37,20 +50,9 @@ public function selectOption(string $field, string $value): CreatePageInterface
public function selectCustomer(string $customerEmail): CreatePageInterface
{
- $dropdown = $this->getElement('customer_dropdown');
- $dropdown->click();
-
- $dropdown->waitFor(5, function () use ($customerEmail) {
- return $this->hasElement('customer_dropdown_item', [
- '%item%' => $customerEmail,
- ]);
- });
-
- $item = $this->getElement('customer_dropdown_item', [
- '%item%' => $customerEmail,
- ]);
+ $productOptionsAutocomplete = $this->getElement('customer_dropdown');
- $item->click();
+ $this->autocompleteHelper->selectByName($this->getDriver(), $productOptionsAutocomplete->getXpath(), $customerEmail);
return $this;
}
@@ -58,8 +60,7 @@ public function selectCustomer(string $customerEmail): CreatePageInterface
protected function getDefinedElements(): array
{
return array_merge(parent::getDefinedElements(), [
- 'customer_dropdown' => '.field > label:contains("Customer") ~ .sylius-autocomplete',
- 'customer_dropdown_item' => '.field > label:contains("Customer") ~ .sylius-autocomplete > div.menu > div.item:contains("%item%")',
+ 'customer_dropdown' => '[data-test-fraud-suspicion-customer-autocomplete]',
]);
}
}
diff --git a/tests/Behat/Resources/services/pages/admin/fraud_suspicion.xml b/tests/Behat/Resources/services/pages/admin/fraud_suspicion.xml
index a370970..88c9ac9 100644
--- a/tests/Behat/Resources/services/pages/admin/fraud_suspicion.xml
+++ b/tests/Behat/Resources/services/pages/admin/fraud_suspicion.xml
@@ -10,6 +10,7 @@
bitbag_sylius_blacklist_plugin_admin_fraud_suspicion_create
+
bitbag_sylius_blacklist_plugin_admin_order_mark_suspicious
-
\ No newline at end of file
+