Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UserProfileTest.php
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | public function testProfileUnauth(): void | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test profile page | * Test profile page | ||||
*/ | */ | ||||
public function testProfile(): void | public function testProfile(): void | ||||
{ | { | ||||
$user = $this->getTestUser('john@kolab.org'); | |||||
$user->setSetting('password_policy', 'min:10,upper,digit'); | |||||
$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) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertSeeIn('@links .link-profile', 'Your profile') | ->assertSeeIn('@links .link-profile', 'Your profile') | ||||
->click('@links .link-profile') | ->click('@links .link-profile') | ||||
->on(new UserProfile()) | ->on(new UserProfile()) | ||||
->assertSeeIn('#user-profile .button-delete', 'Delete account') | ->assertSeeIn('#user-profile .button-delete', 'Delete account') | ||||
Show All 17 Lines | public function testProfile(): void | ||||
->assertValue('div.row:nth-child(7) textarea', $this->profile['billing_address']) | ->assertValue('div.row:nth-child(7) textarea', $this->profile['billing_address']) | ||||
->assertSeeIn('div.row:nth-child(8) label', 'Country') | ->assertSeeIn('div.row:nth-child(8) label', 'Country') | ||||
->assertValue('div.row:nth-child(8) select', $this->profile['country']) | ->assertValue('div.row:nth-child(8) select', $this->profile['country']) | ||||
->assertSeeIn('div.row:nth-child(9) label', 'Password') | ->assertSeeIn('div.row:nth-child(9) label', 'Password') | ||||
->assertValue('div.row:nth-child(9) input#password', '') | ->assertValue('div.row:nth-child(9) input#password', '') | ||||
->assertValue('div.row:nth-child(9) input#password_confirmation', '') | ->assertValue('div.row:nth-child(9) input#password_confirmation', '') | ||||
->assertAttribute('#password', 'placeholder', 'Password') | ->assertAttribute('#password', 'placeholder', 'Password') | ||||
->assertAttribute('#password_confirmation', 'placeholder', 'Confirm Password') | ->assertAttribute('#password_confirmation', 'placeholder', 'Confirm Password') | ||||
->whenAvailable('#password_policy', function (Browser $browser) { | |||||
$browser->assertElementsCount('li', 3) | |||||
->assertMissing('li:nth-child(1) svg.text-success') | |||||
->assertSeeIn('li:nth-child(1) small', "Minimum password length: 10 characters") | |||||
->assertMissing('li:nth-child(2) svg.text-success') | |||||
->assertSeeIn('li:nth-child(2) small', "Password contains an upper-case character") | |||||
->assertMissing('li:nth-child(3) svg.text-success') | |||||
->assertSeeIn('li:nth-child(3) small', "Password contains a digit"); | |||||
}) | |||||
->assertSeeIn('button[type=submit]', 'Submit'); | ->assertSeeIn('button[type=submit]', 'Submit'); | ||||
// Test password policy checking | |||||
$browser->type('#password', '1A') | |||||
->whenAvailable('#password_policy', function (Browser $browser) { | |||||
$browser->waitFor('li:nth-child(2) svg.text-success') | |||||
->waitFor('li:nth-child(3) svg.text-success') | |||||
->assertMissing('li:nth-child(1) svg.text-success'); | |||||
}) | |||||
->vueClear('#password'); | |||||
// Test form error handling | // Test form error handling | ||||
$browser->type('#phone', 'aaaaaa') | $browser->type('#phone', 'aaaaaa') | ||||
->type('#external_email', 'bbbbb') | ->type('#external_email', 'bbbbb') | ||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->waitFor('#phone + .invalid-feedback') | ->waitFor('#phone + .invalid-feedback') | ||||
->assertSeeIn('#phone + .invalid-feedback', 'The phone format is invalid.') | ->assertSeeIn('#phone + .invalid-feedback', 'The phone format is invalid.') | ||||
->assertSeeIn( | ->assertSeeIn( | ||||
'#external_email + .invalid-feedback', | '#external_email + .invalid-feedback', | ||||
Show All 19 Lines | public function testProfile(): void | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test profile of non-controller user | * Test profile of non-controller user | ||||
*/ | */ | ||||
public function testProfileNonController(): void | public function testProfileNonController(): void | ||||
{ | { | ||||
$user = $this->getTestUser('john@kolab.org'); | |||||
$user->setSetting('password_policy', 'min:10,upper,digit'); | |||||
// Test acting as non-controller | // Test acting as non-controller | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit('/logout') | $browser->visit('/logout') | ||||
->visit(new Home()) | ->visit(new Home()) | ||||
->submitLogon('jack@kolab.org', 'simple123', true) | ->submitLogon('jack@kolab.org', 'simple123', true) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertSeeIn('@links .link-profile', 'Your profile') | ->assertSeeIn('@links .link-profile', 'Your profile') | ||||
->click('@links .link-profile') | ->click('@links .link-profile') | ||||
->on(new UserProfile()) | ->on(new UserProfile()) | ||||
->assertMissing('#user-profile .button-delete') | ->assertMissing('#user-profile .button-delete') | ||||
->whenAvailable('@form', function (Browser $browser) { | ->whenAvailable('@form', function (Browser $browser) { | ||||
// TODO: decide on what fields the non-controller user should be able | // TODO: decide on what fields the non-controller user should be able | ||||
// to see/change | // to see/change | ||||
}) | |||||
// Check that the account policy is used | |||||
->whenAvailable('#password_policy', function (Browser $browser) { | |||||
$browser->assertElementsCount('li', 3) | |||||
->assertMissing('li:nth-child(1) svg.text-success') | |||||
->assertSeeIn('li:nth-child(1) small', "Minimum password length: 10 characters") | |||||
->assertMissing('li:nth-child(2) svg.text-success') | |||||
->assertSeeIn('li:nth-child(2) small', "Password contains an upper-case character") | |||||
->assertMissing('li:nth-child(3) svg.text-success') | |||||
->assertSeeIn('li:nth-child(3) small', "Password contains a digit"); | |||||
}); | }); | ||||
// Test that /profile/delete page is not accessible | // Test that /profile/delete page is not accessible | ||||
$browser->visit('/profile/delete') | $browser->visit('/profile/delete') | ||||
->assertErrorPage(403); | ->assertErrorPage(403); | ||||
}); | }); | ||||
} | } | ||||
Show All 39 Lines |