Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/LogonTest.php
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | class LogonTest extends TestCaseDusk | ||||
/** | /** | ||||
* Successful logon test | * Successful logon test | ||||
*/ | */ | ||||
public function testLogonSuccessful(): void | public function testLogonSuccessful(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit(new Home()) | $browser->visit(new Home()) | ||||
->submitLogon('john@kolab.org', 'simple123', true) | ->submitLogon('john@kolab.org', \App\Utils::generatePassphrase(), true) | ||||
// Checks if we're really on Dashboard page | // Checks if we're really on Dashboard page | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertVisible('@links a.link-profile') | ->assertVisible('@links a.link-profile') | ||||
->assertVisible('@links a.link-domains') | ->assertVisible('@links a.link-domains') | ||||
->assertVisible('@links a.link-users') | ->assertVisible('@links a.link-users') | ||||
->assertVisible('@links a.link-wallet') | ->assertVisible('@links a.link-wallet') | ||||
->assertVisible('@links a.link-webmail') | ->assertVisible('@links a.link-webmail') | ||||
->within(new Menu(), function ($browser) { | ->within(new Menu(), function ($browser) { | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | class LogonTest extends TestCaseDusk | ||||
/** | /** | ||||
* Logout by URL test | * Logout by URL test | ||||
*/ | */ | ||||
public function testLogoutByURL(): void | public function testLogoutByURL(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit(new Home()) | $browser->visit(new Home()) | ||||
->submitLogon('john@kolab.org', 'simple123', true); | ->submitLogon('john@kolab.org', \App\Utils::generatePassphrase(), true); | ||||
// Checks if we're really on Dashboard page | // Checks if we're really on Dashboard page | ||||
$browser->on(new Dashboard()); | $browser->on(new Dashboard()); | ||||
// Use /logout url, and expect the logon page | // Use /logout url, and expect the logon page | ||||
$browser->visit('/logout') | $browser->visit('/logout') | ||||
->waitForLocation('/login') | ->waitForLocation('/login') | ||||
->on(new Home()); | ->on(new Home()); | ||||
Show All 14 Lines | class LogonTest extends TestCaseDusk | ||||
* @depends testLogoutByURL | * @depends testLogoutByURL | ||||
*/ | */ | ||||
public function test2FA(): void | public function test2FA(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
// Test missing 2fa code | // Test missing 2fa code | ||||
$browser->on(new Home()) | $browser->on(new Home()) | ||||
->type('@email-input', 'ned@kolab.org') | ->type('@email-input', 'ned@kolab.org') | ||||
->type('@password-input', 'simple123') | ->type('@password-input', \App\Utils::generatePassphrase()) | ||||
->press('form button') | ->press('form button') | ||||
->waitFor('@second-factor-input.is-invalid + .invalid-feedback') | ->waitFor('@second-factor-input.is-invalid + .invalid-feedback') | ||||
->assertSeeIn( | ->assertSeeIn( | ||||
'@second-factor-input.is-invalid + .invalid-feedback', | '@second-factor-input.is-invalid + .invalid-feedback', | ||||
'Second factor code is required.' | 'Second factor code is required.' | ||||
) | ) | ||||
->assertFocused('@second-factor-input') | ->assertFocused('@second-factor-input') | ||||
->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ||||
Show All 31 Lines | public function testAfterLogonRedirect(): void | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
// User is logged in | // User is logged in | ||||
$browser->visit(new UserProfile()); | $browser->visit(new UserProfile()); | ||||
// Test redirect if the token is invalid | // Test redirect if the token is invalid | ||||
$browser->script("localStorage.setItem('token', '123')"); | $browser->script("localStorage.setItem('token', '123')"); | ||||
$browser->refresh() | $browser->refresh() | ||||
->on(new Home()) | ->on(new Home()) | ||||
->submitLogon('john@kolab.org', 'simple123', false) | ->submitLogon('john@kolab.org', \App\Utils::generatePassphrase(), false) | ||||
->waitForLocation('/profile'); | ->waitForLocation('/profile'); | ||||
}); | }); | ||||
} | } | ||||
} | } |