-
Notifications
You must be signed in to change notification settings - Fork 73
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
Broken forms – values filled in from former scenarios #55
Comments
Well.. sorry for the complicated description above. I decided to provide a simple project that shows the problem and proves at least one of the errors. You can find the project here: https://github.com/tpraxl/laracasts-behat-bug-example Setup and confirmation of the bug is easy: Setup
Test
If you wish to test the form behavior manually, just run I would very much appreciate any help here. Thanks in advance. |
Testing on my Homestead environment everything works fine:
Note that I changed last scenario step to |
Thanks for looking into this! However, I'm sorry, this is a misleading error in my test. Also: my test fails one step before yours. It fails on "And I should be on "/plain-form", because this is exactly what the test is supposed to show: When you fill in "first name" and "last name", submit, change the page and go to the form again, then enter the "email" and submit, you'd expect an error message. But the fields "first name" and "last name" are mistakenly still filled in and that is the bug. I'll correct the unfortunate last step in my example project and tell you when this is done. In the meantime, please try the following. It should fail, which proves that the bug is present.
|
@karlomikus I updated the project on https://github.com/tpraxl/laracasts-behat-bug-example |
Yeah, I see the problem, maybe it's because of browserkit driver or something, I'll look into it more, but for now you can use: /**
* @When I restart session
*/
public function iRestartSession()
{
session()->clear();
$this->getSession()->reload();
} to restart the session completly. |
Thanks for your hint. Great! I'll try that asap. BTW: Originally, I had this problem even between scenarios (one scenario fills in, another scenario has to deal with filled in forms), however, the example project didn't reproduce this error, so it must have another cause. Thanks @karlomikus ! |
Sorry for the delay. I tried your approach and it works.
and implemented
Thanks for the hint. It isn't really a solution of this issue, but at least a workaround for the time being. |
@tpraxl in the mean time I merge in that PR from before that might help with the Cache::flush after the scenario |
I have been researching this for some hours now and I'm stuck. I'm working with laravel 5.3. Other specs are listed below.
Calling
$this->visit(route('customer.add'))
returns cached page content, which is very bad when you try to test UI behavior for missing mandatory fields.This is true for scenarios as well as outlines (example tables for scenarios). The second scenario dumps page content for filled in fields of the former scenarios although nothing has been saved.
To be clear about that behavior:
With behat: I visit the form. I fill in the field, hit submit, that produces an error. The model is not saved. An error message is shown. I switch the page. Then I visit the form again. I see the last state of the form with the filled in field instead of an empty form. This includes the error message.
This behavior differs from my manual tests, where I get an empty form as expected.
I would expect
$this->visit(route('myroute'))
to return an empty form (which is only true for the very first scenario). But it seems to take whatever it had before.Also tried to force reloading with
$this->visit('/customer/edit?ts='.random_bytes(20))
– without success. I've added the following line to my template{{ isset($_GET['ts'])?$_GET['ts']:'x' }}
just to make sure, there's no other error-source, but the output is alwaysx
when using behat (so thets
parameter is not passed). However, manual tests of course show the passed parameter value instead.In my template, I'm using the Form facade (
Collective\Html\FormFacade
) like so:Example:
I have two scenarios.
The first one:
Result:
Then the first one:
The second scenario:
Result:
BTW: This also is true when dealing with one scenario only:
-> Field is filled in. But it shouldn't be.
Also tried all of the options below, in all combinations:
BTW: I've also seen this pull request: #6
I'm stuck and I would very much appreciate any help from the great laravel community. Thanks in advance.
My routes:
My .env.behat contains
My behat.yml
My composer.json
The text was updated successfully, but these errors were encountered: