Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch '1.3'
* 1.3:
  Add Sylius core team as codeowners
  [Core] Make implicit dependency explicit
  Limit products shown in associated products autocomplete field
  Ask for confirmation when cancelling an order
  fix element not found exception use
  [Behat] Add scenarios on resetting password validation feature
  Fix doubled province id on checkout addressing page
  Trigger deprecation when deprecated image fixture definition is used
  • Loading branch information
pamil committed Oct 5, 2018
2 parents bbe0aad + ccc4707 commit 0277ac4
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -0,0 +1 @@
/ @Sylius/core-team
19 changes: 19 additions & 0 deletions features/account/resetting_password_validation.feature
Expand Up @@ -6,10 +6,29 @@ Feature: Resetting a password validation

Background:
Given the store operates on a single channel in "United States"
And there is a user "goodman@example.com" identified by "heisenberg"

@ui
Scenario: Trying to reset password without specifying email
When I want to reset password
And I do not specify the email
And I try to reset it
Then I should be notified that the email is required

@ui
Scenario: Trying to reset password with a wrong confirmation password
Given I have already received a resetting password email
When I follow link on my email to reset my password
And I specify my new password as "newp@ssw0rd"
And I confirm my new password as "wrongp@ssw0rd"
And I try to reset it
Then I should be notified that the entered passwords do not match

@ui
Scenario: Trying to reset my password with a too short password
Given I have already received a resetting password email
When I follow link on my email to reset my password
And I specify my new password as "fu"
And I confirm my new password as "fu"
And I try to reset it
Then I should be notified that the password should be at least 4 characters long
22 changes: 22 additions & 0 deletions src/Sylius/Behat/Context/Ui/Shop/LoginContext.php
Expand Up @@ -256,4 +256,26 @@ public function iShouldBeAbleToLogInAsWithPassword($email, $password)

$this->iShouldBeLoggedIn();
}

/**
* @Then I should be notified that the entered passwords do not match
*/
public function iShouldBeNotifiedThatTheEnteredPasswordsDoNotMatch()
{
Assert::true($this->resetPasswordPage->checkValidationMessageFor(
'password',
'The entered passwords don\'t match'
));
}

/**
* @Then I should be notified that the password should be at least 4 characters long
*/
public function iShouldBeNotifiedThatThePasswordShouldBeAtLeastCharactersLong()
{
Assert::true($this->resetPasswordPage->checkValidationMessageFor(
'password',
'Password must be at least 4 characters long.'
));
}
}
15 changes: 15 additions & 0 deletions src/Sylius/Behat/Page/Shop/Account/ResetPasswordPage.php
Expand Up @@ -13,6 +13,7 @@

namespace Sylius\Behat\Page\Shop\Account;

use Behat\Mink\Exception\ElementNotFoundException;
use Sylius\Behat\Page\SymfonyPage;

class ResetPasswordPage extends SymfonyPage implements ResetPasswordPageInterface
Expand Down Expand Up @@ -49,6 +50,20 @@ public function specifyConfirmPassword(string $password): void
$this->getElement('confirm_password')->setValue($password);
}

/**
* {@inheritdoc}
*/
public function checkValidationMessageFor(string $element, string $message): bool
{
$errorLabel = $this->getElement($element)->getParent()->find('css', '.sylius-validation-error');

if (null === $errorLabel) {
throw new ElementNotFoundException($this->getSession(), 'Validation message', 'css', '.sylius-validation-error');
}

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

/**
* {@inheritdoc}
*/
Expand Down
Expand Up @@ -28,4 +28,12 @@ public function specifyNewPassword(string $password): void;
* @param string $password
*/
public function specifyConfirmPassword(string $password): void;

/**
* @param string $element
* @param string $message
*
* @return bool
*/
public function checkValidationMessageFor(string $element, string $message): bool;
}
Expand Up @@ -93,6 +93,7 @@ public function createMenu(array $options): ItemInterface
],
])
->setAttribute('type', 'transition')
->setAttribute('confirmation', true)
->setLabel('sylius.ui.cancel')
->setLabelAttribute('icon', 'ban')
->setLabelAttribute('color', 'yellow')
Expand Down
Expand Up @@ -4,8 +4,8 @@
{% for associationForm in form.associations %}
<div class="field">
{{- form_label(associationForm) -}}
<div class="product-select ui fluid multiple search selection dropdown" data-url="{{ path('sylius_admin_ajax_product_index') }}">
{{ form_widget(associationForm, {'attr': {'class' : 'autocomplete'}}) }}
<div class="product-select ui fluid multiple search selection dropdown" data-url="{{ path('sylius_admin_ajax_product_index', {'limit': 20}) }}">
{{ form_widget(associationForm, {'attr': {'class': 'autocomplete'}}) }}
<i class="dropdown icon"></i>
<div class="default text">{{'sylius.ui.select_products'|trans}}</div>
<div class="menu">
Expand Down
Expand Up @@ -359,8 +359,13 @@ private function createChannelPricings(ProductVariantInterface $productVariant,
private function createImages(ProductInterface $product, array $options): void
{
foreach ($options['images'] as $image) {
// BC, to be deprecated in 1.3 and removed in 2.0
if (!array_key_exists('path', $image)) {
@trigger_error(
'It is deprecated since Sylius 1.3 to pass indexed array as an image definition. ' .
'Please use associative array with "path" and "type" keys instead.',
\E_USER_DEPRECATED
);

$imagePath = array_shift($image);
$imageType = array_pop($image);
} else {
Expand Down
Expand Up @@ -24,6 +24,9 @@ $.fn.extend({
const provinceSelectFieldName = select.attr('name').replace('country', 'province');
const provinceInputFieldName = select.attr('name').replace('countryCode', 'provinceName');

const provinceSelectFieldId = select.attr('id').replace('country', 'province');
const provinceInputFieldId = select.attr('id').replace('countryCode', 'provinceName');

if (select.val() === '' || select.val() == undefined) {
provinceContainer.fadeOut('slow', () => {
provinceContainer.html('');
Expand All @@ -50,6 +53,7 @@ $.fn.extend({
provinceContainer.html((
response.content
.replace('name="sylius_address_province"', `name="${provinceSelectFieldName}"${provinceSelectValue}`)
.replace('id="sylius_address_province"', `id="${provinceSelectFieldId}"`)
.replace('option value="" selected="selected"', 'option value=""')
.replace(`option ${provinceSelectValue}`, `option ${provinceSelectValue}" selected="selected"`)
));
Expand All @@ -65,6 +69,7 @@ $.fn.extend({
provinceContainer.html((
response.content
.replace('name="sylius_address_province"', `name="${provinceInputFieldName}"${provinceInputValue}`)
.replace('id="sylius_address_province"', `id="${provinceInputFieldId}"`)
));

provinceContainer.removeAttr('data-loading');
Expand Down
Expand Up @@ -46,7 +46,7 @@

<form action="{{ item.uri }}" method="post" style="float: right;">
<input type="hidden" name="_method" value="PUT">
<button class="ui {% if color %}{{ color }} {% endif %}labeled icon loadable button" type="submit">
<button class="ui {% if color %}{{ color }} {% endif %}labeled icon {% if not item.attribute('confirmation')|default(false) %}loadable{% endif %} button" type="submit" {% if item.attribute('confirmation')|default(false) %}data-requires-confirmation{% endif %}>
{{ block('icon') }}
{{ item.label|trans }}
</button>
Expand Down
1 change: 1 addition & 0 deletions src/Sylius/Component/Core/composer.json
Expand Up @@ -43,6 +43,7 @@
"sylius/taxation": "^1.2",
"sylius/taxonomy": "^1.2",
"sylius/user": "^1.2",
"symfony/http-foundation": "^3.4|^4.1.1",
"webmozart/assert": "^1.0",
"zendframework/zend-stdlib": "^3.1"
},
Expand Down

0 comments on commit 0277ac4

Please sign in to comment.