Skip to content

Commit

Permalink
OP-466 - Fix behat
Browse files Browse the repository at this point in the history
  • Loading branch information
JanPalen committed Aug 6, 2024
1 parent b45ef64 commit 7f661df
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Form/Type/CustomerAutocompleteChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function configureOptions(OptionsResolver $resolver): void
public function buildView(
FormView $view,
FormInterface $form,
array $options
array $options,
): void {
$view->vars['remote_criteria_type'] = 'contains';
$view->vars['remote_criteria_name'] = 'email';
Expand Down
2 changes: 1 addition & 1 deletion tests/Behat/Context/Ui/Admin/FraudSuspicionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function iFillAllRequiredFieldsBasingOnOrderAddress(string $orderNumber):
$customerLastUsedAddress = $order->getBillingAddress();

$this->resolveCurrentPage()
->selectOption('Customer', $order->getCustomer()->getEmail())
->selectCustomer($order->getCustomer()->getEmail())
->fillField('Company', $customerLastUsedAddress->getCompany())
->fillField('Company', $customerLastUsedAddress->getCompany())
->fillField('First name', $customerLastUsedAddress->getFirstName())
Expand Down
27 changes: 27 additions & 0 deletions tests/Behat/Page/Admin/FraudSuspicion/CreatePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,31 @@ public function selectOption(string $field, string $value): CreatePageInterface

return $this;
}

public function selectCustomer(string $customerEmail): void
{

$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,
]);

$item->click();
}

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%")',
]);
}
}
2 changes: 2 additions & 0 deletions tests/Behat/Page/Admin/FraudSuspicion/CreatePageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ interface CreatePageInterface extends BaseCreatePageInterface, ContainsErrorInte
public function fillField(string $field, ?string $value): self;

public function selectOption(string $field, string $value): self;

public function selectCustomer(string $customerEmail): void;
}

0 comments on commit 7f661df

Please sign in to comment.