Skip to content

Commit

Permalink
Rework behats - AddressPage
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKasp committed Dec 11, 2019
1 parent 1ec76ea commit 40799fd
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 50 deletions.
54 changes: 27 additions & 27 deletions src/Sylius/Behat/Page/Shop/Checkout/AddressPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public function specifyShippingAddress(AddressInterface $shippingAddress): void

public function selectShippingAddressProvince(string $province): void
{
$this->waitForElement(5, 'shipping_country_province');
$this->getElement('shipping_country_province')->selectOption($province);
$this->waitForElement(5, 'shipping_country_province_code');
$this->getElement('shipping_province_code')->selectOption($province);
}

public function specifyBillingAddress(AddressInterface $billingAddress):void
Expand All @@ -114,8 +114,8 @@ public function specifyBillingAddress(AddressInterface $billingAddress):void

public function selectBillingAddressProvince(string $province): void
{
$this->waitForElement(5, 'billing_country_province');
$this->getElement('billing_country_province')->selectOption($province);
$this->waitForElement(5, 'billing_province_code');
$this->getElement('billing_province_code')->selectOption($province);
}

public function specifyEmail(string $email): void
Expand Down Expand Up @@ -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_country_province' => '[name="sylius_checkout_address[billingAddress][provinceCode]"]',
'billing_postcode' => '#sylius_checkout_address_billingAddress_postcode',
'billing_address_book' => '[data-test-billing-address] .ui.dropdown',
'billing_city' => '[data-test-billing-city]',
'billing_country' => '[data-test-billing-country]',
'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',
'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',
'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',
'billing_province_code' => '[data-test-billing-province-code]',
'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' => '[data-test-shipping-api-login-button]',
'login_password' => '[data-test-login-password]',
'next_step' => '[data-test-next-step]',
'shipping__province_code' => '[data-test-shipping-province-code]',
'shipping_address_book' => '[data-test-shipping-address] .ui.dropdown',
'shipping_city' => '[data-test-shipping-city]',
'shipping_country' => '[data-test-shipping-country]',
'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]',
]);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<div id="sylius-shipping-address">
<div id="sylius-shipping-address" {{ sylius_test_html_attribute('shipping-address') }}>
{% include '@SyliusShop/Checkout/Address/_addressBookSelect.html.twig' %}
<h3 class="ui dividing header">{{ 'sylius.ui.shipping_address'|trans }}</h3>
{% if form.customer is defined %}
{% include '@SyliusShop/Common/Form/_login.html.twig' with {'form': form.customer} %}
{% endif %}
{% include '@SyliusShop/Common/Form/_address.html.twig' with {'form': form.shippingAddress, 'order': order} %}
{{ form_row(form.differentBillingAddress, {'attr': {'data-toggles': 'sylius-billing-address'}}) }}
{% include '@SyliusShop/Common/Form/_address.html.twig' with {'form': form.shippingAddress, 'order': order, 'type': 'shipping'} %}
{{ form_row(form.differentBillingAddress, {'attr': {'data-toggles': 'sylius-billing-address'}}, sylius_test_form_attribute('different-billing-address')) }}

{{ sonata_block_render_event('sylius.shop.checkout.address.shipping_address_form', {'order': order}) }}
</div>

<div id="sylius-billing-address">
<div id="sylius-billing-address" {{ sylius_test_html_attribute('billing-address') }}>
<div class="ui hidden divider"></div>
{% include '@SyliusShop/Checkout/Address/_addressBookSelect.html.twig' %}
<h3 class="ui dividing header">{{ 'sylius.ui.billing_address'|trans }}</h3>
{% include '@SyliusShop/Common/Form/_address.html.twig' with {'form': form.billingAddress, 'order': order} %}
{% include '@SyliusShop/Common/Form/_address.html.twig' with {'form': form.billingAddress, 'order': order, 'type': 'billing'} %}

{{ sonata_block_render_event('sylius.shop.checkout.address.billing_address_form', {'order': order}) }}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<a href="{{ path('sylius_shop_homepage') }}" class="ui large icon labeled button"><i class="arrow left icon"></i> {{ 'sylius.ui.back_to_store'|trans }}</a>
</div>
<div class="right aligned column">
<button type="submit" id="next-step" class="ui large primary icon labeled button"><i class="arrow right icon"></i> {{ 'sylius.ui.next'|trans }}</button>
<button type="submit" id="next-step" class="ui large primary icon labeled button" {{ sylius_test_html_attribute('next-step') }}><i class="arrow right icon"></i> {{ 'sylius.ui.next'|trans }}</button>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{% endif %}
</div>
<div class="right aligned column">
<button type="submit" id="next-step" class="ui large primary icon labeled{% if not enabled %} disabled{% endif %} button">
<button type="submit" id="next-step" class="ui large primary icon labeled{% if not enabled %} disabled{% endif %} button" {{ sylius_test_html_attribute('next-step') }}>
<i class="arrow right icon"></i>
{{ 'sylius.ui.next'|trans }}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<a href="{{ path('sylius_shop_checkout_address') }}" class="ui large icon labeled button"><i class="arrow left icon"></i> {{ 'sylius.ui.change_address'|trans }}</a>
</div>
<div class="right aligned column">
<button type="submit" id="next-step" class="ui large primary icon labeled{% if not enabled %} disabled{% endif %} button">
<button type="submit" id="next-step" class="ui large primary icon labeled{% if not enabled %} disabled{% endif %} button" {{ sylius_test_html_attribute('next-step') }}>
<i class="arrow right icon"></i>
{{ 'sylius.ui.next'|trans }}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% set taxExcluded = sylius_order_tax_excluded(order) %}

<div class="ui segment">
<table class="ui very basic table" id="sylius-checkout-subtotal">
<table class="ui very basic table" id="sylius-checkout-subtotal" {{ sylius_test_html_attribute('checkout-subtotal') }}>
<thead>
<tr>
<th class="sylius-table-column-item">{{ 'sylius.ui.item'|trans }}</th>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
{% if type is not defined %}
{% set type = null %}
{% endif %}

<div class="two fields">
{{ form_row(form.firstName) }}
{{ form_row(form.lastName) }}
{{ form_row(form.firstName, sylius_test_form_attribute(type ~ '-first-name')) }}
{{ form_row(form.lastName, sylius_test_form_attribute(type ~ '-last-name')) }}
</div>
{{ form_row(form.company) }}
{{ form_row(form.street) }}
{{ form_row(form.company, sylius_test_form_attribute(type ~ '-company')) }}
{{ form_row(form.street, sylius_test_form_attribute(type ~ '-street')) }}

{% include '@SyliusShop/Common/Form/_countryCode.html.twig' with {'form': form.countryCode} %}

<div class="province-container field" data-url="{{ path('sylius_shop_ajax_render_province_form') }}">
{% if form.provinceCode is defined %}
{{ form_row(form.provinceCode, {'attr': {'class': 'ui dropdown'}}) }}
{{ form_row(form.provinceCode, {'attr': {'class': 'ui dropdown'}}, sylius_test_form_attribute(type ~ '-province-code')) }}
{% elseif form.provinceName is defined %}
{{ form_row(form.provinceName) }}
{{ form_row(form.provinceName, sylius_test_form_attribute(type ~ '-province')) }}
{% endif %}
</div>

{% if form.provinceCode is defined %}
{% if form.provinceCode is defined %}a
{{ form_errors(form) }}
{% endif %}

<div class="two fields">
{{ form_row(form.city) }}
{{ form_row(form.postcode) }}
{{ form_row(form.city, sylius_test_form_attribute(type ~ '-city')) }}
{{ form_row(form.postcode, sylius_test_form_attribute(type ~ '-postcode')) }}
</div>
{{ form_row(form.phoneNumber) }}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if form.vars.choices|length == 1 %}
{{ form_row(form, {'value': form.vars.choices[0].value}) }}
{{ form_row(form, sylius_test_form_attribute(type ~ '-country')|merge({'value': form.vars.choices[0].value})) }}
{% else %}
{{ form_row(form) }}
{{ form_row(form, sylius_test_form_attribute(type ~ '-country')) }}
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="one field" id="sylius-api-login">
{{ form_errors(form.email) }}
{{ form_row(form.email, {'attr': {'data-url': path('sylius_shop_ajax_user_check_action')}}) }}
{{ form_row(form.email, {'attr': {'data-url': path('sylius_shop_ajax_user_check_action')}}, sylius_test_form_attribute('login-email')) }}

<div class="ui action input" id="sylius-api-login-form">
<input type="password" placeholder="{{ 'sylius.ui.password'|trans }}">
<div class="ui action input" id="sylius-api-login-form" {{ sylius_test_html_attribute('api-login-button') }}>
<input type="password" placeholder="{{ 'sylius.ui.password'|trans }} {{ sylius_test_html_attribute('login-password') }}">
<input type="hidden" name="_csrf_shop_security_token" value="{{ csrf_token('shop_authenticate') }}">
<a class="ui blue button" href="#" id="sylius-api-login-submit" data-url="{{ path('sylius_shop_login_check') }}">
{{ 'sylius.ui.sign_in'|trans }}
Expand Down

0 comments on commit 40799fd

Please sign in to comment.