mardi 4 octobre 2016

How to wait for a page reload in Laravel integration testing

We have a action to edit the user profile which redirects to the same page. Here seePageIs() does not seem to wait for the new page to load.

The following test fails, as the new user name is not found in the response. When we load the profile page manually after the test, it was updated properly.

public function testCanEditUserProfileAsConsumer()
{
    $this->loginConsumer();

    $this->visit('/user/profile');
    $firstName = $this->faker->firstname;
    $name = $this->faker->name;


    $this->within('#userEditForm', function() use ($firstName, $name) {
        $this->type($firstName, 'firstname');
        $this->type($name, 'surname');
        $this->press('Speichern');
    });

    // here: how to wait for page reload ?
    $this->seePageIs('/user/profile');
    $this->see($firstName);
    $this->see($name);
}

Aucun commentaire:

Enregistrer un commentaire