Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/LogonTest.php
<?php | <?php | ||||
namespace Tests\Browser; | namespace Tests\Browser; | ||||
use Tests\Browser; | use Tests\Browser; | ||||
use Tests\Browser\Components\Menu; | use Tests\Browser\Components\Menu; | ||||
use Tests\Browser\Components\Toast; | use Tests\Browser\Components\Toast; | ||||
use Tests\Browser\Pages\Dashboard; | use Tests\Browser\Pages\Dashboard; | ||||
use Tests\Browser\Pages\Home; | use Tests\Browser\Pages\Home; | ||||
use Tests\Browser\Pages\UserProfile; | |||||
use Tests\TestCaseDusk; | use Tests\TestCaseDusk; | ||||
use Illuminate\Foundation\Testing\DatabaseMigrations; | |||||
class LogonTest extends TestCaseDusk | class LogonTest extends TestCaseDusk | ||||
{ | { | ||||
/** | /** | ||||
* Test menu on logon page | * Test menu on logon page | ||||
*/ | */ | ||||
public function testLogonMenu(): void | public function testLogonMenu(): void | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | class LogonTest extends TestCaseDusk | ||||
*/ | */ | ||||
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', 'simple123', 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-settings') | ||||
->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) { | ||||
$browser->assertMenuItems(['support', 'dashboard', 'logout', 'lang']); | $browser->assertMenuItems(['support', 'dashboard', 'logout', 'lang']); | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | class LogonTest extends TestCaseDusk | ||||
/** | /** | ||||
* Test redirect to the requested page after logon | * Test redirect to the requested page after logon | ||||
* | * | ||||
* @depends test2FA | * @depends test2FA | ||||
*/ | */ | ||||
public function testAfterLogonRedirect(): void | public function testAfterLogonRedirect(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
// User is logged in | // User is logged in, visit the My account page | ||||
$browser->visit(new UserProfile()); | $browser->visit('/settings') | ||||
// invalidate the session token | |||||
// Test redirect if the token is invalid | ->execScript("localStorage.setItem('token', '123')") | ||||
$browser->script("localStorage.setItem('token', '123')"); | // refresh the page | ||||
$browser->refresh() | ->refresh() | ||||
->on(new Home()) | ->on(new Home()) | ||||
// log in the user | |||||
->submitLogon('john@kolab.org', 'simple123', false) | ->submitLogon('john@kolab.org', 'simple123', false) | ||||
->waitForLocation('/profile'); | // wait for a "redirect" to the My account page | ||||
->waitForLocation('/settings'); | |||||
}); | }); | ||||
} | } | ||||
} | } |