Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e65ccae

Browse files
committed
Add atributes to registrationpage ans fix summary page
1 parent 3442fc8 commit e65ccae

5 files changed

Lines changed: 48 additions & 54 deletions

File tree

src/Sylius/Behat/Context/Setup/OrderContext.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use Sylius\Component\Core\Model\ShopUserInterface;
3030
use Sylius\Component\Core\OrderCheckoutTransitions;
3131
use Sylius\Component\Core\OrderPaymentTransitions;
32+
use Sylius\Component\Core\OrderShippingTransitions;
3233
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
3334
use Sylius\Component\Customer\Model\CustomerInterface;
3435
use Sylius\Component\Order\Modifier\OrderItemQuantityModifierInterface;

src/Sylius/Behat/Page/Shop/Account/RegisterPage.php

Lines changed: 27 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -19,104 +19,80 @@
1919

2020
class RegisterPage extends SymfonyPage implements RegisterPageInterface
2121
{
22-
/**
23-
* {@inheritdoc}
24-
*/
2522
public function getRouteName(): string
2623
{
2724
return 'sylius_shop_register';
2825
}
2926

3027
/**
31-
* {@inheritdoc}
32-
*
3328
* @throws ElementNotFoundException
3429
*/
35-
public function checkValidationMessageFor($element, $message)
30+
public function checkValidationMessageFor(string $element, string $message): bool
3631
{
3732
$errorLabel = $this
3833
->getElement(StringInflector::nameToCode($element))
3934
->getParent()
40-
->find('css', '.sylius-validation-error')
35+
->find('css', '[data-test-validation-error]')
4136
;
4237

4338
if (null === $errorLabel) {
44-
throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '.sylius-validation-error');
39+
throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '[data-test-validation-error]');
4540
}
4641

4742
return $message === $errorLabel->getText();
4843
}
4944

50-
public function register()
45+
public function register(): void
5146
{
52-
$this->getDocument()->pressButton('Create an account');
47+
$this->getElement('create_account_button')->press();
5348
}
5449

55-
/**
56-
* {@inheritdoc}
57-
*/
58-
public function specifyEmail($email)
50+
public function specifyEmail(string $email): void
5951
{
60-
$this->getDocument()->fillField('Email', $email);
52+
$this->getElement('email')->setValue($email);
6153
}
6254

63-
/**
64-
* {@inheritdoc}
65-
*/
66-
public function specifyFirstName($firstName)
55+
public function specifyFirstName(string $firstName): void
6756
{
68-
$this->getDocument()->fillField('First name', $firstName);
57+
$this->getElement('first_name')->setValue($firstName);
6958
}
7059

71-
/**
72-
* {@inheritdoc}
73-
*/
74-
public function specifyLastName($lastName)
60+
public function specifyLastName(string $lastName): void
7561
{
76-
$this->getDocument()->fillField('Last name', $lastName);
62+
$this->getElement('last_name')->setValue($lastName);
7763
}
7864

79-
/**
80-
* {@inheritdoc}
81-
*/
82-
public function specifyPassword($password)
65+
public function specifyPassword(string $password): void
8366
{
84-
$this->getDocument()->fillField('Password', $password);
67+
$this->getElement('password')->setValue($password);
8568
}
8669

87-
/**
88-
* {@inheritdoc}
89-
*/
90-
public function specifyPhoneNumber($phoneNumber)
70+
public function specifyPhoneNumber(string $phoneNumber): void
9171
{
92-
$this->getDocument()->fillField('Phone number', $phoneNumber);
72+
$this->getElement('phone_number')->setValue($phoneNumber);
9373
}
9474

95-
/**
96-
* {@inheritdoc}
97-
*/
98-
public function verifyPassword($password)
75+
public function verifyPassword(string $password): void
9976
{
100-
$this->getDocument()->fillField('Verification', $password);
77+
$this->getElement('password_verification')->setValue($password);
10178
}
10279

103-
public function subscribeToTheNewsletter()
80+
public function subscribeToTheNewsletter(): void
10481
{
105-
$this->getDocument()->checkField('Subscribe to the newsletter');
82+
$this->getElement('subscribe_newsletter')->check();
10683
}
10784

108-
/**
109-
* {@inheritdoc}
110-
*/
11185
protected function getDefinedElements(): array
11286
{
11387
return array_merge(parent::getDefinedElements(), [
114-
'email' => '#sylius_customer_registration_email',
115-
'first_name' => '#sylius_customer_registration_firstName',
116-
'last_name' => '#sylius_customer_registration_lastName',
117-
'password_verification' => '#sylius_customer_registration_user_plainPassword_second',
118-
'password' => '#sylius_customer_registration_user_plainPassword_first',
119-
'phone_number' => '#sylius_customer_registration_phoneNumber',
88+
'create_account_button' => '[data-test-register-button]',
89+
'email' => '[data-test-email]',
90+
'first_name' => '[data-test-first-name]',
91+
'last_name' => '[data-test-last-name]',
92+
'password' => '[data-test-password-first]',
93+
'password_verification' => '[data-test-password-second]',
94+
'phone_number' => '[data-test-phone-number]',
95+
'subscribe_newsletter' => '[data-test-subscribed-to-newsletter]',
12096
]);
12197
}
12298
}

src/Sylius/Behat/Page/Shop/Account/RegisterPageInterface.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,21 @@
1717

1818
interface RegisterPageInterface extends SymfonyPageInterface
1919
{
20+
public function getRouteName(): string;
21+
22+
public function checkValidationMessageFor(string $element, string $message): bool;
23+
24+
public function register(): void;
25+
26+
public function specifyEmail(string $email): void;
27+
28+
public function specifyFirstName(string $firstName): void;
29+
30+
public function specifyPassword(string $password): void;
31+
32+
public function specifyPhoneNumber(string $phoneNumber): void;
33+
34+
public function verifyPassword(string $password): void;
35+
36+
public function subscribeToTheNewsletter(): void;
2037
}

src/Sylius/Behat/Page/Shop/Cart/SummaryPage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ public function isItemDiscounted(string $productName): bool
117117

118118
public function removeProduct(string $productName): void
119119
{
120-
$itemElement = $this->getElement('product_row', ['%name%' => $productName]);
121-
$itemElement->find('css', 'button.sylius-cart-remove-button')->press();
120+
$this->getElement('delete_button', ['%name%' => $productName])->press();
122121
}
123122

124123
public function applyCoupon(string $couponCode): void
@@ -232,6 +231,7 @@ protected function getDefinedElements(): array
232231
'cart_total' => '[data-test-cart-total]',
233232
'clear_button' => '[data-test-cart-clear-button]',
234233
'coupon_field' => '[data-test-cart-promotion-coupon-input]',
234+
'delete_button' => '[data-test-cart-remove-button="%name%"]',
235235
'flash_message' => '[data-test-flash-message]',
236236
'grand_total' => '[data-test-cart-grand-total]',
237237
'item_image' => '[data-test-cart-item="%number%"] [data-test-main-image]',

src/Sylius/Bundle/ShopBundle/Resources/views/Cart/Summary/_item.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<form action="{{ path('sylius_shop_cart_item_remove', {'id': item.id}) }}" method="post">
2222
<input type="hidden" name="_method" value="DELETE" />
2323
<input type="hidden" name="_csrf_token" value="{{ csrf_token(item.id) }}" />
24-
<button type="submit" class="ui circular icon button sylius-cart-remove-button" ><i class="remove icon"></i></button>
24+
<button type="submit" class="ui circular icon button sylius-cart-remove-button" {{ sylius_test_html_attribute('cart-remove-button', item.productName) }} ><i class="remove icon"></i></button>
2525
</form>
2626
</td>
2727
<td class="right aligned">

0 commit comments

Comments
 (0)