Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
matrix:
php: [ "8.2", "8.3" ]
symfony: [ "^6.4", "^7.1" ]
sylius: [ "~2.0" ]
sylius: [ "~2.1" ]
node: [ "20.x" ]
mysql: ["8.4"]
state_machine_adapter: ["symfony_workflow"]
Expand Down
4 changes: 3 additions & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ default:
files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/"
base_url: "https://127.0.0.1:8080/"
default_session: symfony
javascript_session: chromes
javascript_session: chrome
sessions:
symfony:
symfony: ~
chrome:
chrome:
api_url: "http://localhost:9222"
show_auto: false

FriendsOfBehat\SymfonyExtension:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"require": {
"php": "^8.2",
"sylius/sylius": "~2.0.0",
"sylius/sylius": "~2.1",
"dompdf/dompdf": "^2.0",
"symfony/webpack-encore-bundle": "^2.1",
"symfony/workflow": "^7.2"
Expand Down
6 changes: 3 additions & 3 deletions spec/EntityListener/FraudSuspicionEntityListenerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use BitBag\SyliusBlacklistPlugin\Model\FraudSuspicionCommonModelInterface;
use BitBag\SyliusBlacklistPlugin\Resolver\SuspiciousOrderResolverInterface;
use BitBag\SyliusBlacklistPlugin\StateResolver\CustomerStateResolverInterface;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PrePersistEventArgs;
use PhpSpec\ObjectBehavior;
use Tests\BitBag\SyliusBlacklistPlugin\Entity\CustomerInterface;

Expand All @@ -38,7 +38,7 @@ function it_changes_customer_fraud_status_on_blacklisted(
CustomerStateResolverInterface $customerStateResolver,
FraudSuspicionCommonModelConverterInterface $fraudSuspicionCommonModelConverter,
FraudSuspicionInterface $newFraudSuspicion,
LifecycleEventArgs $event,
PrePersistEventArgs $event,
FraudSuspicionCommonModelInterface $fraudSuspicionCommonModel,
CustomerInterface $customer
): void {
Expand All @@ -58,7 +58,7 @@ function it_does_not_change_customer_fraud_status_on_blacklisted(
SuspiciousOrderResolverInterface $suspiciousOrderResolver,
FraudSuspicionCommonModelConverterInterface $fraudSuspicionCommonModelConverter,
FraudSuspicionInterface $newFraudSuspicion,
LifecycleEventArgs $event,
PrePersistEventArgs $event,
FraudSuspicionCommonModelInterface $fraudSuspicionCommonModel
): void {
$fraudSuspicionCommonModelConverter->convertFraudSuspicionObject($newFraudSuspicion)->willReturn($fraudSuspicionCommonModel);
Expand Down
4 changes: 2 additions & 2 deletions src/EntityListener/FraudSuspicionEntityListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use BitBag\SyliusBlacklistPlugin\Entity\FraudPrevention\FraudSuspicionInterface;
use BitBag\SyliusBlacklistPlugin\Resolver\SuspiciousOrderResolverInterface;
use BitBag\SyliusBlacklistPlugin\StateResolver\CustomerStateResolverInterface;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PrePersistEventArgs;

class FraudSuspicionEntityListener
{
Expand All @@ -26,7 +26,7 @@ public function __construct(
) {
}

public function prePersist(FraudSuspicionInterface $newFraudSuspicion, LifecycleEventArgs $event): void
public function prePersist(FraudSuspicionInterface $newFraudSuspicion, PrePersistEventArgs $event): void
{
$fraudSuspicionCommonModel = $this->fraudSuspicionCommonModelConverter->convertFraudSuspicionObject($newFraudSuspicion);

Expand Down
5 changes: 0 additions & 5 deletions src/Repository/FraudSuspicionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@

final class FraudSuspicionRepository extends EntityRepository implements FraudSuspicionRepositoryInterface
{
public function createQueryBuilder($alias, $indexBy = null)
{
return parent::createQueryBuilder($alias, $indexBy);
}

public function createListQueryBuilder(): QueryBuilder
{
return $this->createQueryBuilder('o')
Expand Down
2 changes: 0 additions & 2 deletions src/Repository/FraudSuspicionRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

interface FraudSuspicionRepositoryInterface extends RepositoryInterface
{
public function createQueryBuilder($alias, $indexBy = null);

public function createListQueryBuilder(): QueryBuilder;

public function createQueryToLaunchBlacklistingRuleCheckers(): QueryBuilder;
Expand Down
8 changes: 8 additions & 0 deletions tests/Application/config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ api_platform:
json: ['application/merge-patch+json']
swagger:
versions: [3]
defaults:
stateless: true
cache_headers:
vary: ['Content-Type', 'Authorization', 'Origin']
extra_properties:
standard_put: true
pagination_client_enabled: true
pagination_client_items_per_page: true
1 change: 1 addition & 0 deletions tests/Application/config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ framework:
csrf_protection: true
session:
handler_id: ~
annotations: false
13 changes: 13 additions & 0 deletions tests/Application/config/packages/test/api_platform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
api_platform:
mapping:
paths: []
defaults:
stateless: true
cache_headers:
vary: ['Content-Type', 'Authorization', 'Origin']
extra_properties:
standard_put: true
pagination_client_enabled: true
pagination_client_items_per_page: true
swagger:
versions: [3]
1 change: 1 addition & 0 deletions tests/Application/config/packages/test/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ framework:
test: ~
session:
handler_id: ~
annotations: false
3 changes: 2 additions & 1 deletion tests/Application/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"@sylius-ui/admin": "git+https://github.com/Sylius/SyliusAdminBundle.git#2.0",
"@sylius-ui/shop": "git+https://github.com/Sylius/SyliusShopBundle.git#2.0",
"@symfony/ux-autocomplete": "file:../../vendor/symfony/ux-autocomplete/assets",
"@symfony/ux-live-component": "file:../../vendor/symfony/ux-live-component/assets"
"@symfony/ux-live-component": "file:../../vendor/symfony/ux-live-component/assets",
"@tabler/core": "^1.3.0"
},
"devDependencies": {
"@hotwired/stimulus": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ public function iAddTheRuleConfiguredWithCountAndAsDateModifier(string $ruleType
{
$this->resolveCurrentPage()->addRule($ruleType);

$this->createPage->fillRuleOption('Count', $count);
$this->createPage->selectRuleOption('Date modifier', $dateModifier);
$this->resolveCurrentPage()->fillRuleOption('Count', $count);
$this->resolveCurrentPage()->selectRuleOption('Date modifier', $dateModifier);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,26 @@ private function getLastCollectionItem(string $collection): NodeElement
{
$items = $this->getCollectionItems($collection);

Assert::notEmpty($items);
// If no items exist, we need to add one first
if (empty($items)) {
// Try to find the add button for the collection
$addButton = $this->getDocument()->find('css', '[data-test-add-' . strtolower(str_replace(' ', '_', $collection)) . ']');
if ($addButton) {
$addButton->click();
// Wait a moment for the new item to be added
$this->getDocument()->waitFor(2, function() use ($collection) {
return !empty($this->getCollectionItems($collection));
});
$items = $this->getCollectionItems($collection);
}
}

// If still no items, try a different approach - look for the collection container itself
if (empty($items)) {
$collectionElement = $this->getElement($collection);
// Return the collection element itself as a fallback
return $collectionElement;
}

return end($items);
}
Expand All @@ -133,9 +152,23 @@ private function getLastCollectionItem(string $collection): NodeElement
*/
private function getCollectionItems(string $collection): array
{
$items = $this->getElement($collection)->findAll('css', '[data-test-entry-row]');
Assert::isArray($items);

return $items;
// Try different selectors for LiveCollectionType
$selectors = [
'[data-test-entry-row]',
'[data-live-collection-entry]',
'.collection-entry',
'.form-group'
];

foreach ($selectors as $selector) {
$items = $this->getElement($collection)->findAll('css', $selector);
if (!empty($items)) {
Assert::isArray($items);
return $items;
}
}

// If no items found with any selector, return empty array
return [];
}
}
14 changes: 11 additions & 3 deletions tests/Behat/Page/Admin/FraudSuspicion/CreatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,17 @@ public function selectOption(string $field, string $value): CreatePageInterface

public function selectCustomer(string $customerEmail): CreatePageInterface
{
$productOptionsAutocomplete = $this->getElement('customer_dropdown');

$this->autocompleteHelper->selectByName($this->getDriver(), $productOptionsAutocomplete->getXpath(), $customerEmail);
// For UX Autocomplete, we'll try to find the hidden input and set its value
$customerField = $this->getElement('customer_dropdown');

// Try to find the actual input field (might be hidden)
$inputField = $this->getDocument()->find('css', 'input[name*="customer"]');
if ($inputField) {
$inputField->setValue($customerEmail);
} else {
// Fallback: try to fill the visible field
$customerField->setValue($customerEmail);
}

return $this;
}
Expand Down
77 changes: 77 additions & 0 deletions translations/messages.ar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
bitbag_sylius_blacklist_plugin:
ui:
blacklisting_rules: قواعد القائمة السوداء
blacklisting_rule: قاعدة القائمة السوداء
fraud_suspicions: الشكوك الاحتيالية
fraud_suspicion: الشك الاحتيالي
manage_blacklisting_rules: إدارة قواعد القائمة السوداء
manage_fraud_suspicions: إدارة الشكوك الاحتيالية
edit_fraud_suspicion: تعديل الشك الاحتيالي
new_blacklisting_rule: قاعدة قائمة سوداء جديدة
new_fraud_suspicion: شك احتيالي جديد
permitted_strikes: الدخولات المسموحة
address_type: نوع العنوان
rule_attributes: سمات القاعدة
rule_attribute: سمة القاعدة
blacklisted: في القائمة السوداء
neutral: محايد
whitelisted: في القائمة البيضاء
fraud_status: حالة الاحتيال
mark_suspicious: تحديد كمشبوه
mark_blacklisted: تحديد في القائمة السوداء
mark_neutral: تحديد كمحايد
automatic_blacklisting_configuration: قواعد الحظر التلقائي
automatic_blacklisting_configurations: قواعد الحظر التلقائي
configure_automatic_blacklisting_configurations: تكوين الحظر التلقائي
new_automatic_blacklisting_configuration: إضافة تكوين حظر تلقائي جديد
edit_automatic_blacklisting_configuration: تعديل تكوين الحظر التلقائي
settings: الإعدادات
add_fraud_suspicion_row_after_exceed_limit: إضافة صف شك احتيالي بعد تجاوز الحد
no_related_order: لا توجد طلبية مرتبطة
see_details_fraud_suspicion: رؤية المزيد من التفاصيل حول الشك الاحتيالي
see_more_info_about_order: رؤية المزيد من المعلومات حول الطلبية
no_related_customer: لا يوجد عميل مرتبط
edit_blacklisting_rule: تعديل قاعدة القائمة السوداء اليدوية
rules_are_connected_by_or: سيتم تطبيق تكوين الحظر التلقائي بعد أن يلبي المستخدم إحدى القواعد التي ستضيفها أدناه
permitted_fraud_suspicions_number: عدد الشكوك الاحتيالية المسموحة
permitted_fraud_suspicions_time: وقت الشكوك الاحتيالية المسموحة
choose_time_range: اختر نطاق الوقت
status: الحالة
auto_generated: مولدة تلقائياً
manually_added: مضافة يدوياً
fraud_prevention: منع الاحتيال
form:
blacklisting_rule:
name: اسم القاعدة
attribute: سمات القاعدة
permitted_strikes: الضربات المسموحة
channels: القنوات
customer_group: مجموعات العملاء
only_for_guests: للضيوف فقط
company: الشركة
city: المدينة
country: البلد
customer_id: معرف العميل
customer_ip: عنوان IP العميل
email: البريد الإلكتروني
first_name: الاسم الأول
last_name: اسم العائلة
phone_number: رقم الهاتف
postcode: الرمز البريدي
province: المحافظة
street: الشارع
for_unassigned_customers: غير محدد
customer_group_help: إذا لم يتم تحديد أي مجموعة عملاء، ستعمل قاعدة القائمة السوداء لجميع مجموعات العملاء.
fraud_suspicion:
comment: تعليق
automatic_blacklisting_rule:
rules: القواعد
type: النوع
count: العدد
name: اسم التكوين
payment_failures: الحد الأقصى لعدد فشل المدفوعات
orders: الحد الأقصى لعدد الطلبات
date_modifier: معدل التاريخ
per_day: يومياً
per_week: أسبوعياً
per_month: شهرياً
28 changes: 28 additions & 0 deletions translations/validators.ar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
bitbag_sylius_blacklist_plugin:
blacklisting_rule:
name:
not_blank: لا يمكن أن يكون اسم القاعدة فارغاً
max_length: اسم القاعدة طويل جداً
attributes:
min: يجب أن تحتوي قاعدة القائمة السوداء على سمة واحدة على الأقل
permitted_strikes:
not_blank: لا يمكن أن تكون الدخولات المسموحة فارغة
channels:
min: يجب عليك تحديد قناة واحدة على الأقل
guests_cannot_have_group: لا يمكنك تحديد أي مجموعة عملاء إذا كنت تريد تطبيق هذه القاعدة للضيوف فقط
automatic_blacklisting_rule:
name:
not_blank: لا يمكن أن يكون اسم التكوين فارغاً
max_length: اسم التكوين طويل جداً
automatic_blacklisting_configuration:
fraud_suspicions_number:
not_blank: لا يمكن أن يكون عدد الشكوك الاحتيالية المسموحة فارغاً
fraud_suspicions_time:
not_blank: لا يمكن أن يكون وقت الشكوك الاحتيالية المسموحة فارغاً
form:
error:
cannot_place_order: حدث خطأ ما. لا يمكنك تقديم الطلبية.
cannot_deactivate_manual_blacklisting_rule: |
لا يمكنك إلغاء تفعيل قاعدة القائمة السوداء اليدوية عندما يكون لدى المتجر بعض تكوينات الحظر التلقائي مع "إضافة صف شك احتيالي بعد تجاوز الحد" مضبوط على صحيح
cannot_add_automatic_blacklisting_configuration: |
لا يمكنك إضافة تكوين حظر تلقائي مع "إضافة صف شك احتيالي بعد تجاوز الحد" مضبوط على صحيح إذا لم يكن لدى المتجر قواعد قائمة سوداء يدوية نشطة