Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/SettingsTest.php
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | public function testSettings(): void | ||||
$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) { | ||||
$browser->assertElementsCount('li', 6) | $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]') | ||||
->assertValue('li:nth-child(1) input[type=text]', '5') | ->assertValue('li:nth-child(1) input[type=text]', '5') | ||||
->assertSeeIn('li:nth-child(2) label', 'Maximum password length') | ->assertSeeIn('li:nth-child(2) label', 'Maximum password length') | ||||
->assertChecked('li:nth-child(2) input[type=checkbox]') | ->assertChecked('li:nth-child(2) input[type=checkbox]') | ||||
->assertValue('li:nth-child(2) input[type=text]', '100') | ->assertValue('li:nth-child(2) input[type=text]', '100') | ||||
->assertSeeIn('li:nth-child(3) label', 'Password contains a lower-case character') | ->assertSeeIn('li:nth-child(3) label', 'Password contains a lower-case character') | ||||
->assertChecked('li:nth-child(3) input[type=checkbox]') | ->assertChecked('li:nth-child(3) input[type=checkbox]') | ||||
->assertMissing('li:nth-child(3) input[type=text]') | ->assertMissing('li:nth-child(3) input[type=text]') | ||||
->assertSeeIn('li:nth-child(4) label', 'Password contains an upper-case character') | ->assertSeeIn('li:nth-child(4) label', 'Password contains an upper-case character') | ||||
->assertNotChecked('li:nth-child(4) input[type=checkbox]') | ->assertNotChecked('li:nth-child(4) input[type=checkbox]') | ||||
->assertMissing('li:nth-child(4) input[type=text]') | ->assertMissing('li:nth-child(4) input[type=text]') | ||||
->assertSeeIn('li:nth-child(5) label', 'Password contains a digit') | ->assertSeeIn('li:nth-child(5) label', 'Password contains a digit') | ||||
->assertNotChecked('li:nth-child(5) input[type=checkbox]') | ->assertNotChecked('li:nth-child(5) input[type=checkbox]') | ||||
->assertMissing('li:nth-child(5) input[type=text]') | ->assertMissing('li:nth-child(5) input[type=text]') | ||||
->assertSeeIn('li:nth-child(6) label', 'Password contains a special character') | ->assertSeeIn('li:nth-child(6) label', 'Password contains a special character') | ||||
->assertNotChecked('li:nth-child(6) input[type=checkbox]') | ->assertNotChecked('li:nth-child(6) input[type=checkbox]') | ||||
->assertMissing('li:nth-child(6) input[type=text]') | ->assertMissing('li:nth-child(6) input[type=text]') | ||||
->assertSeeIn('li:nth-child(7) label', 'Password cannot be the same as the last') | |||||
->assertNotChecked('li:nth-child(7) input[type=checkbox]') | |||||
->assertMissing('li:nth-child(7) input[type=text]') | |||||
->assertSelected('li:nth-child(7) select', 3) | |||||
->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]'); | ||||
}) | }) | ||||
->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')); | ||||
} | } | ||||
} | } |