Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Admin] Fix user fields disappearing on validation fails #6926

Merged
merged 4 commits into from
Dec 1, 2016

Conversation

tuka217
Copy link
Contributor

@tuka217 tuka217 commented Nov 29, 2016

Q A
Bug fix? yes
New feature? no
BC breaks? yes
Related tickets fixes #6725
License MIT

@tuka217 tuka217 force-pushed the user-disappear branch 2 times, most recently from 8766e8a to 947c293 Compare November 29, 2016 10:59
@tuka217 tuka217 changed the title [WIP][Admin] Fix user fields disappearing on validation fails [Admin] Fix user fields disappearing on validation fails Nov 29, 2016
}

/**
* @Then I should not be able to specify it password
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its

{
Assert::false(
$this->createPage->hasPasswordField(),
'There should not be password field, but it is.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, nooooo, no no no, nope nope, this is the most annoying message while debugging :( :( :( 🌮

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how looks proper message?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The step does say what behaviour is expected and if it's failing, it says that expected behaviour didn't occur. No message is the best message 🌯 🎉

{
Assert::true(
$this->createPage->isOpen(),
'The customer creation page should be open, but it is not.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

{
Assert::false(
$this->createPage->hasCheckedCreateOption(),
'The create account option should not be selected, but it is.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@tuka217 tuka217 changed the title [Admin] Fix user fields disappearing on validation fails [WIP][Admin] Fix user fields disappearing on validation fails Nov 29, 2016
@tuka217 tuka217 force-pushed the user-disappear branch 4 times, most recently from 409fef9 to bf6cf8a Compare November 30, 2016 13:03
@tuka217 tuka217 changed the title [WIP][Admin] Fix user fields disappearing on validation fails [Admin] Fix user fields disappearing on validation fails Nov 30, 2016
And I do not specify any information
And I try to add it
Then I should still be on the customer creation page
And I should be able to specify it password
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should be able to specify its password

Given I am logged in as an administrator

@ui @javascript
Scenario: Trying add new customer with an account without required information
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be Trying to add...?

Feature: Create account option availability
In order to correctly administrate customers
As an Administrator
I want not see create account option if the customer account already exist
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exists

}

/**
* @Given /^I should not be able to select create account option$/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unneeded /^ and $/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and @Then

}

/**
* @Given I do not choose create account option
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@When

@@ -14,7 +14,7 @@
'containerSelector': '#sylius_calculator_container'
});

$('#sylius_customer_create_user').change(function(){
$('#sylius_customer_createUser').change(function(){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changing it?

Copy link
Contributor Author

@tuka217 tuka217 Nov 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we use camelCase to named field in FormType. So we have sylius_nameOfEntity_nameOfField. Before this field was in twig template and it had the id "sylius_customer_create_user".


return;
}
if(null === $form->get('createUser')->getViewData()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after if.

$form->get('createUser')->willReturn($createUserCheckForm);
$createUserCheckForm->getViewData()->willReturn(null);


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double blank line.

@tuka217 tuka217 force-pushed the user-disappear branch 3 times, most recently from 3728876 to e3b0daf Compare November 30, 2016 15:35
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Sylius\Bundle\UserBundle\Form\EventSubscriber;
namespace Sylius\Bundle\ApiBundle\Form\EventSubscriber;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you moved this to ApiBundle?

Copy link
Contributor Author

@tuka217 tuka217 Dec 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it truly a part of UserBundle? Before we use this subscriber for Core CustomerType. After this fix this type has new subscriber, but the old one is still needed in ApiBundle.

Copy link
Contributor Author

@tuka217 tuka217 Dec 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And probably should be fixed for api, but I'm not sure that it should be done in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having two separate form types is the only valid solution, since we expect a different behavior on API and Web, so that's correct! 👍

@@ -19,6 +19,8 @@ sylius_api_customer_show:
_controller: sylius.controller.customer:showAction
_sylius:
serialization_groups: [Detailed]
form:
type: Sylius\Bundle\ApiBundle\Form\Extension\ApiCustomerType
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont need to configure form for show action

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix it in a separate PR.

@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Sylius\Bundle\UserBundle\Form\EventSubscriber;
namespace Sylius\Bundle\ApiBundle\Form\EventSubscriber;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having two separate form types is the only valid solution, since we expect a different behavior on API and Web, so that's correct! 👍

@michalmarcinkowski michalmarcinkowski merged commit 9af5c7a into Sylius:master Dec 1, 2016
@michalmarcinkowski
Copy link
Contributor

Great job Ania! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Admin] Manage customer - problem with user fields (v1.0.0-alpha1)
5 participants