diff --git a/src/Sylius/Behat/Page/Shop/Account/RequestPasswordResetPage.php b/src/Sylius/Behat/Page/Shop/Account/RequestPasswordResetPage.php index 9b949e3ad30..fc26cd77e21 100644 --- a/src/Sylius/Behat/Page/Shop/Account/RequestPasswordResetPage.php +++ b/src/Sylius/Behat/Page/Shop/Account/RequestPasswordResetPage.php @@ -28,10 +28,10 @@ public function getRouteName(): string */ public function checkValidationMessageFor(string $element, string $message): bool { - $errorLabel = $this->getElement($element)->getParent()->find('css', '[data-test-sylius-validation-error]'); + $errorLabel = $this->getElement($element)->getParent()->find('css', '[data-test-validation-error]'); if (null === $errorLabel) { - throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '[data-test-sylius-validation-error]'); + throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '[data-test-validation-error]'); } return $message === $errorLabel->getText(); diff --git a/src/Sylius/Behat/Page/Shop/Account/ResetPasswordPage.php b/src/Sylius/Behat/Page/Shop/Account/ResetPasswordPage.php index 8f4edadc867..bb253828575 100644 --- a/src/Sylius/Behat/Page/Shop/Account/ResetPasswordPage.php +++ b/src/Sylius/Behat/Page/Shop/Account/ResetPasswordPage.php @@ -40,10 +40,10 @@ public function specifyConfirmPassword(string $password): void public function checkValidationMessageFor(string $element, string $message): bool { - $errorLabel = $this->getElement($element)->getParent()->find('css', '[data-test-sylius-validation-error]'); + $errorLabel = $this->getElement($element)->getParent()->find('css', '[data-test-validation-error]'); if (null === $errorLabel) { - throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '[data-test-sylius-validation-error]'); + throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '[data-test-validation-error]'); } return $message === $errorLabel->getText(); diff --git a/src/Sylius/Behat/Page/Shop/Checkout/AddressPage.php b/src/Sylius/Behat/Page/Shop/Checkout/AddressPage.php index fb5fda989ce..c6546311c15 100644 --- a/src/Sylius/Behat/Page/Shop/Checkout/AddressPage.php +++ b/src/Sylius/Behat/Page/Shop/Checkout/AddressPage.php @@ -70,7 +70,7 @@ public function chooseDifferentBillingAddress(): void public function checkInvalidCredentialsValidation(): bool { $this->getElement('login_password')->waitFor(5, function () { - $validationElement = $this->getElement('login_password')->getParent()->find('css', '.red.label'); + $validationElement = $this->getElement('login_password')->getParent()->find('css', '[data-test-login-errors]'); if (null === $validationElement) { return false; } @@ -85,12 +85,12 @@ public function checkValidationMessageFor(string $element, string $message): boo { $foundElement = $this->getFieldElement($element); if (null === $foundElement) { - throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '.sylius-validation-error'); + throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '[data-test-validation-error]'); } $validationMessage = $foundElement->find('css', '.sylius-validation-error'); if (null === $validationMessage) { - throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '.sylius-validation-error'); + throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '[data-test-validation-error]'); } return $message === $validationMessage->getText(); @@ -118,7 +118,7 @@ public function selectBillingAddressProvince(string $province): void $this->getElement('billing_country_province')->selectOption($province); } - public function specifyEmail(string $email): void + public function specifyEmail(?string $email): void { $this->getElement('customer_email')->setValue($email); } @@ -164,7 +164,7 @@ public function getItemSubtotal(string $itemName): string $subtotalTable = $this->getElement('checkout_subtotal'); - return $subtotalTable->find('css', sprintf('#sylius-item-%s-subtotal', $itemSlug))->getText(); + return $subtotalTable->find('css', sprintf('[data-test-item-subtotal="%s"]', $itemSlug))->getText(); } public function getShippingAddressCountry(): string @@ -253,31 +253,31 @@ public function getPreFilledBillingAddress(): AddressInterface protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'billing_address_book' => '#sylius-billing-address .ui.dropdown', - 'billing_first_name' => '#sylius_checkout_address_billingAddress_firstName', - 'billing_last_name' => '#sylius_checkout_address_billingAddress_lastName', - 'billing_street' => '#sylius_checkout_address_billingAddress_street', - 'billing_city' => '#sylius_checkout_address_billingAddress_city', - 'billing_country' => '#sylius_checkout_address_billingAddress_countryCode', + 'billing_address_book' => '[data-test-billing-address] .ui.dropdown', + 'billing_city' => '[data-test-billing-city]', + 'billing_country' => '[data-test-billing-country]', 'billing_country_province' => '[name="sylius_checkout_address[billingAddress][provinceCode]"]', - 'billing_postcode' => '#sylius_checkout_address_billingAddress_postcode', + 'billing_first_name' => '[data-test-billing-first-name]', + 'billing_last_name' => '[data-test-billing-last-name]', + 'billing_postcode' => '[data-test-billing-postcode]', 'billing_province' => '[name="sylius_checkout_address[billingAddress][provinceName]"]', - 'checkout_subtotal' => '#sylius-checkout-subtotal', - 'customer_email' => '#sylius_checkout_address_customer_email', - 'different_billing_address' => '#sylius_checkout_address_differentBillingAddress', - 'different_billing_address_label' => '#sylius_checkout_address_differentBillingAddress ~ label', + 'billing_street' => '[data-test-billing-street]', + 'checkout_subtotal' => '[data-test-checkout-subtotal]', + 'customer_email' => '[data-test-login-email]', + 'different_billing_address' => '[data-test-different-billing-address]', + 'different_billing_address_label' => '[data-test-different-billing-address-label]', 'login_button' => '#sylius-api-login-submit', 'login_password' => 'input[type=\'password\']', - 'next_step' => '#next-step', - 'shipping_address_book' => '#sylius-shipping-address .ui.dropdown', - 'shipping_city' => '#sylius_checkout_address_shippingAddress_city', - 'shipping_country' => '#sylius_checkout_address_shippingAddress_countryCode', + 'next_step' => '[data-test-next-step]', + 'shipping_address_book' => '[data-test-address-book]', + 'shipping_city' => '[data-test-shipping-city]', + 'shipping_country' => '[data-test-shipping-country]', 'shipping_country_province' => '[name="sylius_checkout_address[shippingAddress][provinceCode]"]', - 'shipping_first_name' => '#sylius_checkout_address_shippingAddress_firstName', - 'shipping_last_name' => '#sylius_checkout_address_shippingAddress_lastName', - 'shipping_postcode' => '#sylius_checkout_address_shippingAddress_postcode', + 'shipping_first_name' => '[data-test-shipping-first-name]', + 'shipping_last_name' => '[data-test-shipping-last-name]', + 'shipping_postcode' => '[data-test-shipping-postcode]', 'shipping_province' => '[name="sylius_checkout_address[shippingAddress][provinceName]"]', - 'shipping_street' => '#sylius_checkout_address_shippingAddress_street', + 'shipping_street' => '[data-test-shipping-street]', ]); } diff --git a/src/Sylius/Behat/Page/Shop/Checkout/AddressPageInterface.php b/src/Sylius/Behat/Page/Shop/Checkout/AddressPageInterface.php index cfa041b80a1..9a4b55539a9 100644 --- a/src/Sylius/Behat/Page/Shop/Checkout/AddressPageInterface.php +++ b/src/Sylius/Behat/Page/Shop/Checkout/AddressPageInterface.php @@ -32,7 +32,7 @@ public function specifyBillingAddress(AddressInterface $billingAddress): void; public function selectBillingAddressProvince(string $province): void; - public function specifyEmail(string $email): void; + public function specifyEmail(?string $email): void; public function specifyShippingAddressFullName(string $fullName): void; diff --git a/src/Sylius/Behat/Page/Shop/Checkout/SelectShippingPage.php b/src/Sylius/Behat/Page/Shop/Checkout/SelectShippingPage.php index 57669c2b5f2..c43f83e2cc3 100644 --- a/src/Sylius/Behat/Page/Shop/Checkout/SelectShippingPage.php +++ b/src/Sylius/Behat/Page/Shop/Checkout/SelectShippingPage.php @@ -39,7 +39,7 @@ public function selectShippingMethod(string $shippingMethod): void public function getShippingMethods(): array { - $inputs = $this->getSession()->getPage()->findAll('css', '#sylius-shipping-methods .item .content label'); + $inputs = $this->getSession()->getPage()->findAll('css', '[data-test-shipping-method-label]'); $shippingMethods = []; foreach ($inputs as $input) { @@ -51,12 +51,12 @@ public function getShippingMethods(): array public function getSelectedShippingMethodName(): ?string { - $shippingMethods = $this->getSession()->getPage()->findAll('css', '#sylius-shipping-methods .item'); + $shippingMethods = $this->getSession()->getPage()->findAll('css', '[data-test-shipping-item]'); /** @var NodeElement $shippingMethod */ foreach ($shippingMethods as $shippingMethod) { if (null !== $shippingMethod->find('css', 'input:checked')) { - return $shippingMethod->find('css', '.content label')->getText(); + return $shippingMethod->find('css', '[data-test-shipping-method-label]')->getText(); } } @@ -87,7 +87,7 @@ public function getItemSubtotal(string $itemName): string $subtotalTable = $this->getElement('checkout_subtotal'); - return $subtotalTable->find('css', sprintf('#sylius-item-%s-subtotal', $itemSlug))->getText(); + return $subtotalTable->find('css', sprintf('[data-test-item-subtotal="%s"]', $itemSlug))->getText(); } public function nextStep(): void @@ -107,7 +107,7 @@ public function changeAddressByStepLabel(): void public function getPurchaserEmail(): string { - return $this->getElement('purchaser-email')->getText(); + return $this->getElement('purchaser_email')->getText(); } public function getValidationMessageForShipment(): string @@ -117,9 +117,9 @@ public function getValidationMessageForShipment(): string throw new ElementNotFoundException($this->getSession(), 'Items element'); } - $validationMessage = $foundElement->find('css', '.sylius-validation-error'); + $validationMessage = $foundElement->find('css', '[data-test-validation-error]'); if (null === $validationMessage) { - throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '.sylius-validation-error'); + throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '[data-test-validation-error]'); } return $validationMessage->getText(); @@ -137,7 +137,7 @@ public function isNextStepButtonUnavailable(): bool public function hasShippingMethod(string $shippingMethodName): bool { - $inputs = $this->getSession()->getPage()->findAll('css', '#sylius-shipping-methods .item .content label'); + $inputs = $this->getSession()->getPage()->findAll('css', '[data-test-shipping-method-label]'); $shippingMethods = []; foreach ($inputs as $input) { @@ -150,17 +150,17 @@ public function hasShippingMethod(string $shippingMethodName): bool protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'address' => '.steps a:contains("Address")', - 'checkout_subtotal' => '#sylius-checkout-subtotal', - 'next_step' => '#next-step', - 'order_cannot_be_shipped_message' => '#sylius-order-cannot-be-shipped', - 'purchaser-email' => '#purchaser-email', - 'shipment' => '.items', - 'shipping_method' => '[name="sylius_checkout_select_shipping[shipments][0][method]"]', - 'shipping_method_fee' => '.item:contains("%shipping_method%") .fee', - 'shipping_method_select' => '.item:contains("%shipping_method%") > .field > .ui.radio.checkbox', + 'address' => '[data-test-step-address]', + 'checkout_subtotal' => '[data-test-checkout-subtotal]', + 'next_step' => '[data-test-next-step]', + 'order_cannot_be_shipped_message' => '[data-test-order-cannot-be-shipped]', + 'purchaser_email' => '[data-test-purchaser-name-or-email]', + 'shipment' => '[data-test-shipments]', + 'shipping_method' => '[data-test-shipping-method-select]', + 'shipping_method_fee' => '[data-test-shipping-item]:contains("%shipping_method%") [data-test-shipping-method-fee]', + 'shipping_method_select' => '[data-test-shipping-item]:contains("%shipping_method%") > .field > .ui.radio.checkbox', 'shipping_method_option' => '.item:contains("%shipping_method%") input', - 'warning_no_shipping_methods' => '#sylius-order-cannot-be-shipped', + 'warning_no_shipping_methods' => '[data-test-order-cannot-be-shipped]', ]); } } diff --git a/src/Sylius/Bundle/ShopBundle/Resources/views/Checkout/Address/_addressBookSelect.html.twig b/src/Sylius/Bundle/ShopBundle/Resources/views/Checkout/Address/_addressBookSelect.html.twig index 551741499f7..67a1db8c9c1 100644 --- a/src/Sylius/Bundle/ShopBundle/Resources/views/Checkout/Address/_addressBookSelect.html.twig +++ b/src/Sylius/Bundle/ShopBundle/Resources/views/Checkout/Address/_addressBookSelect.html.twig @@ -1,5 +1,5 @@ {% if app.user is not empty and app.user.customer is not empty and app.user.customer.addresses|length > 0 %} -