user = $this->user(); } /** * Test that a user can login successfully using their email address. */ public function testLoginUsingEmail() { $this->browse(function (PterodactylBrowser $browser) { $browser->visit(new LoginPage) ->waitFor('@username') ->type('@username', $this->user->email) ->type('@password', self::$userPassword) ->click('@loginButton') ->waitForReload() ->assertPathIs('/') ->assertAuthenticatedAs($this->user); }); } /** * Test that a user can login successfully using their username. */ public function testLoginUsingUsername() { $this->browse(function (PterodactylBrowser $browser) { $browser->visit(new LoginPage) ->waitFor('@username') ->type('@username', $this->user->username) ->type('@password', self::$userPassword) ->click('@loginButton') ->waitForReload() ->assertPathIs('/') ->assertAuthenticatedAs($this->user); }); } /** * Test that entering the wrong password shows the expected error and then allows * us to login without clearing the username field. */ public function testLoginWithErrors() { $this->browse(function (PterodactylBrowser $browser) { $browser->logout() ->visit(new LoginPage()) ->waitFor('@username') ->type('@username', $this->user->email) ->type('@password', 'invalid') ->click('@loginButton') ->waitFor('.alert.error') ->assertSeeIn('.alert.error', trans('auth.failed')) ->assertValue('@username', $this->user->email) ->assertValue('@password', '') ->assertFocused('@password') ->type('@password', self::$userPassword) ->keys('@password', [WebDriverKeys::ENTER]) ->waitForReload() ->assertPathIs('/') ->assertAuthenticatedAs($this->user); }); } }