Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/PoliciesTest.php
- This file was copied from src/tests/Browser/SettingsTest.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\Settings; | use Tests\Browser\Pages\Policies; | ||||
use Tests\TestCaseDusk; | use Tests\TestCaseDusk; | ||||
class SettingsTest extends TestCaseDusk | class PoliciesTest extends TestCaseDusk | ||||
{ | { | ||||
/** | /** | ||||
* Test settings page (unauthenticated) | * Test Policies page (unauthenticated) | ||||
*/ | */ | ||||
public function testSettingsUnauth(): void | public function testPoliciesUnauth(): void | ||||
{ | { | ||||
// Test that the page requires authentication | // Test that the page requires authentication | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit('/settings')->on(new Home()); | $browser->visit('/policies')->on(new Home()); | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test settings "box" on Dashboard | * Test Policies "box" on Dashboard | ||||
*/ | */ | ||||
public function testDashboard(): void | public function testDashboard(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
// Test a user that is not an account owner | // Test a user that is not an account owner | ||||
$browser->visit(new Home()) | $browser->visit(new Home()) | ||||
->submitLogon('jack@kolab.org', 'simple123', true) | ->submitLogon('jack@kolab.org', 'simple123', true) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertMissing('@links .link-settings') | ->assertMissing('@links .link-policies') | ||||
->visit('/settings') | ->visit('/policies') | ||||
->assertErrorPage(403) | ->assertErrorPage(403) | ||||
->within(new Menu(), function (Browser $browser) { | ->within(new Menu(), function (Browser $browser) { | ||||
$browser->clickMenuItem('logout'); | $browser->clickMenuItem('logout'); | ||||
}); | }); | ||||
// Test the account owner | // Test the account owner | ||||
$browser->waitForLocation('/login') | $browser->waitForLocation('/login') | ||||
->on(new Home()) | ->on(new Home()) | ||||
->submitLogon('john@kolab.org', 'simple123', true) | ->submitLogon('john@kolab.org', 'simple123', true) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertSeeIn('@links .link-settings svg + span', 'Settings'); | ->assertSeeIn('@links .link-policies svg + span', 'Policies'); | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test Settings page | * Test Policies page | ||||
* | * | ||||
* @depends testDashboard | * @depends testDashboard | ||||
*/ | */ | ||||
public function testSettings(): void | public function testPolicies(): void | ||||
{ | { | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$john->setSetting('password_policy', 'min:5,max:100,lower'); | $john->setSetting('password_policy', 'min:5,max:100,lower'); | ||||
$john->setSetting('max_password_age', null); | $john->setSetting('max_password_age', null); | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->click('@links .link-settings') | $browser->click('@links .link-policies') | ||||
->on(new Settings()) | ->on(new Policies()) | ||||
->assertSeeIn('#settings .card-title', 'Settings') | ->assertSeeIn('#policies .card-title', 'Policies') | ||||
// Password policy | // Password policy | ||||
->assertSeeIn('@form .row:nth-child(1) > label', 'Password Policy') | ->assertSeeIn('@form .row:nth-child(1) > label', 'Password Policy') | ||||
->with('@form #password_policy', function (Browser $browser) { | ->with('@form #password_policy', function (Browser $browser) { | ||||
$browser->assertElementsCount('li', 7) | $browser->assertElementsCount('li', 7) | ||||
->assertSeeIn('li:nth-child(1) label', 'Minimum password length') | ->assertSeeIn('li:nth-child(1) label', 'Minimum password length') | ||||
->assertChecked('li:nth-child(1) input[type=checkbox]') | ->assertChecked('li:nth-child(1) input[type=checkbox]') | ||||
->assertDisabled('li:nth-child(1) input[type=checkbox]') | ->assertDisabled('li:nth-child(1) input[type=checkbox]') | ||||
->assertValue('li:nth-child(1) input[type=text]', '5') | ->assertValue('li:nth-child(1) input[type=text]', '5') | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |