Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/SettingsTest.php
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | class SettingsTest extends TestCaseDusk | ||||
* Test Settings page | * Test Settings page | ||||
* | * | ||||
* @depends testDashboard | * @depends testDashboard | ||||
*/ | */ | ||||
public function testSettings(): void | public function testSettings(): 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); | |||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->click('@links .link-settings') | $browser->click('@links .link-settings') | ||||
->on(new Settings()) | ->on(new Settings()) | ||||
->assertSeeIn('#settings .card-title', 'Settings') | ->assertSeeIn('#settings .card-title', 'Settings') | ||||
// 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) { | ||||
Show All 24 Lines | public function testSettings(): void | ||||
->assertSelected('li:nth-child(7) select', 3) | ->assertSelected('li:nth-child(7) select', 3) | ||||
->assertSelectHasOptions('li:nth-child(7) select', [1,2,3,4,5,6]) | ->assertSelectHasOptions('li:nth-child(7) select', [1,2,3,4,5,6]) | ||||
// Change the policy | // Change the policy | ||||
->type('li:nth-child(1) input[type=text]', '11') | ->type('li:nth-child(1) input[type=text]', '11') | ||||
->type('li:nth-child(2) input[type=text]', '120') | ->type('li:nth-child(2) input[type=text]', '120') | ||||
->click('li:nth-child(3) input[type=checkbox]') | ->click('li:nth-child(3) input[type=checkbox]') | ||||
->click('li:nth-child(4) input[type=checkbox]'); | ->click('li:nth-child(4) input[type=checkbox]'); | ||||
}) | }) | ||||
->assertSeeIn('@form .row:nth-child(2) > label', 'Password Retention') | |||||
->with('@form #password_retention', function (Browser $browser) { | |||||
$browser->assertElementsCount('li', 1) | |||||
->assertSeeIn('li:nth-child(1) label', 'Require a password change every') | |||||
->assertNotChecked('li:nth-child(1) input[type=checkbox]') | |||||
->assertSelected('li:nth-child(1) select', 3) | |||||
->assertSelectHasOptions('li:nth-child(1) select', [3, 6, 9, 12]) | |||||
// change the policy | |||||
->check('li:nth-child(1) input[type=checkbox]') | |||||
->select('li:nth-child(1) select', 6); | |||||
}) | |||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.'); | ->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.'); | ||||
}); | }); | ||||
$this->assertSame('min:11,max:120,upper', $john->getSetting('password_policy')); | $this->assertSame('min:11,max:120,upper', $john->getSetting('password_policy')); | ||||
$this->assertSame('6', $john->getSetting('max_password_age')); | |||||
} | } | ||||
} | } |