2016-10-04 4 views
5

同じページにリダイレクトするユーザープロファイルを編集する操作があります。 seePageIs()は、新しいページが読み込まれるのを待っていないようです。Laravel統合テストでページを読み込むのを待つ方法

応答で新しいユーザー名が見つからないため、次のテストは失敗します。テスト後にプロファイルページを手動で読み込むと、正しく更新されました。

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); 
} 

編集

$this->within('#userEditForm', function() use ($firstName, $lastname) { 
     $this->type($firstName, 'firstname'); 
     $this->type($lastname, 'surname'); 
     $this->press('Speichern') 
      ->seePageIs('/user/profile') 
      ->see($firstName) 
      ->see($lastname); 
    }); 

も問題は別のものだった

+0

内でコードを移動し、プレスで(おそらく)チェーンしてください。一般的に、報道陣が呼ばれた後は待たずにいるようです。 – apokryfos

答えて

0

を働いていません。 Laravel です。ボタンを押すとページがリロードされます。

ユーザープロファイルの観点からは、Auth::user()を使用して情報を表示しています。

私は、ユーザーのコントローラで

Auth::setUser(Auth::user()->fresh()); 

を行うと、それが動作します。

非常に満足できる解決策ではありませんが、元の質問が明確になります。

関連する問題