Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UsersTest.php
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | class UsersTest extends TestCaseDusk | ||||
*/ | */ | ||||
public function testInfo(): void | public function testInfo(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$jack = $this->getTestUser('jack@kolab.org'); | $jack = $this->getTestUser('jack@kolab.org'); | ||||
$john->verificationcodes()->delete(); | $john->verificationcodes()->delete(); | ||||
$jack->verificationcodes()->delete(); | $jack->verificationcodes()->delete(); | ||||
$john->setSetting('password_policy', 'min:10,upper,digit'); | |||||
// Test that the page requires authentication | // Test that the page requires authentication | ||||
$browser->visit('/user/' . $john->id) | $browser->visit('/user/' . $john->id) | ||||
->on(new Home()) | ->on(new Home()) | ||||
->submitLogon('john@kolab.org', 'simple123', false) | ->submitLogon('john@kolab.org', 'simple123', false) | ||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
->assertSeeIn('#user-info .card-title', 'User account') | ->assertSeeIn('#user-info .card-title', 'User account') | ||||
->with('@general', function (Browser $browser) { | ->with('@general', function (Browser $browser) { | ||||
Show All 31 Lines | public function testInfo(): void | ||||
}) | }) | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.') | ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.') | ||||
->on(new UserList()) | ->on(new UserList()) | ||||
->click('@table tr:nth-child(3) a') | ->click('@table tr:nth-child(3) a') | ||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
->assertSeeIn('#user-info .card-title', 'User account') | ->assertSeeIn('#user-info .card-title', 'User account') | ||||
->with('@general', function (Browser $browser) { | ->with('@general', function (Browser $browser) { | ||||
// Test error handling (password) | // Test error handling (password) | ||||
$browser->type('#password', 'aaaaaa') | $browser->type('#password', 'aaaaaA') | ||||
->vueClear('#password_confirmation') | ->vueClear('#password_confirmation') | ||||
->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") | |||||
->waitFor('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"); | |||||
}) | |||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->waitFor('#password_confirmation + .invalid-feedback') | ->waitFor('#password_confirmation + .invalid-feedback') | ||||
->assertSeeIn( | ->assertSeeIn( | ||||
'#password_confirmation + .invalid-feedback', | '#password_confirmation + .invalid-feedback', | ||||
'The password confirmation does not match.' | 'The password confirmation does not match.' | ||||
) | ) | ||||
->assertFocused('#password') | ->assertFocused('#password') | ||||
->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ||||
// TODO: Test password change | // TODO: Test password change | ||||
// Test form error handling (aliases) | // Test form error handling (aliases) | ||||
$browser->vueClear('#password') | $browser->vueClear('#password') | ||||
->vueClear('#password_confirmation') | ->vueClear('#password_confirmation') | ||||
->with(new ListInput('#aliases'), function (Browser $browser) { | ->with(new ListInput('#aliases'), function (Browser $browser) { | ||||
$browser->addListEntry('invalid address'); | $browser->addListEntry('invalid address'); | ||||
}) | }) | ||||
->scrollTo('button[type=submit]')->pause(500) | |||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ||||
$browser->with(new ListInput('#aliases'), function (Browser $browser) { | $browser->with(new ListInput('#aliases'), function (Browser $browser) { | ||||
$browser->assertFormError(2, 'The specified alias is invalid.', false); | $browser->assertFormError(2, 'The specified alias is invalid.', false); | ||||
}); | }); | ||||
// Test adding aliases | // Test adding aliases | ||||
▲ Show 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | class UsersTest extends TestCaseDusk | ||||
/** | /** | ||||
* Test user adding page | * Test user adding page | ||||
* | * | ||||
* @depends testInfo | * @depends testInfo | ||||
*/ | */ | ||||
public function testNewUser(): void | public function testNewUser(): void | ||||
{ | { | ||||
$john = $this->getTestUser('john@kolab.org'); | |||||
$john->setSetting('password_policy', null); | |||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit(new UserList()) | $browser->visit(new UserList()) | ||||
->assertSeeIn('button.create-user', 'Create user') | ->assertSeeIn('button.create-user', 'Create user') | ||||
->click('button.create-user') | ->click('button.create-user') | ||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
->assertSeeIn('#user-info .card-title', 'New user account') | ->assertSeeIn('#user-info .card-title', 'New user account') | ||||
->with('@general', function (Browser $browser) { | ->with('@general', function (Browser $browser) { | ||||
// Assert form content | // Assert form content | ||||
▲ Show 20 Lines • Show All 414 Lines • ▼ Show 20 Lines | public function testBetaEntitlements(): void | ||||
->assertSeeIn('tr:nth-child(9) td.price', '0,00 CHF/month') | ->assertSeeIn('tr:nth-child(9) td.price', '0,00 CHF/month') | ||||
->assertNotChecked('tbody tr:nth-child(9) td.selection input') | ->assertNotChecked('tbody tr:nth-child(9) td.selection input') | ||||
->assertEnabled('tbody tr:nth-child(9) td.selection input') | ->assertEnabled('tbody tr:nth-child(9) td.selection input') | ||||
->assertTip( | ->assertTip( | ||||
'tbody tr:nth-child(9) td.buttons button', | 'tbody tr:nth-child(9) td.buttons button', | ||||
'Access to calendaring resources' | 'Access to calendaring resources' | ||||
) | ) | ||||
// Shared folders SKU | // Shared folders SKU | ||||
->scrollTo('tbody tr:nth-child(10)')->pause(500) | |||||
->assertSeeIn('tbody tr:nth-child(10) td.name', 'Shared folders') | ->assertSeeIn('tbody tr:nth-child(10) td.name', 'Shared folders') | ||||
->assertSeeIn('tr:nth-child(10) td.price', '0,00 CHF/month') | ->assertSeeIn('tr:nth-child(10) td.price', '0,00 CHF/month') | ||||
->assertNotChecked('tbody tr:nth-child(10) td.selection input') | ->assertNotChecked('tbody tr:nth-child(10) td.selection input') | ||||
->assertEnabled('tbody tr:nth-child(10) td.selection input') | ->assertEnabled('tbody tr:nth-child(10) td.selection input') | ||||
->assertTip( | ->assertTip( | ||||
'tbody tr:nth-child(10) td.buttons button', | 'tbody tr:nth-child(10) td.buttons button', | ||||
'Access to shared folders' | 'Access to shared folders' | ||||
) | ) | ||||
Show All 23 Lines | public function testBetaEntitlements(): void | ||||
]; | ]; | ||||
$this->assertEntitlements($john, $expected); | $this->assertEntitlements($john, $expected); | ||||
$browser->visit('/user/' . $john->id) | $browser->visit('/user/' . $john->id) | ||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
->waitFor('#sku-input-beta') | ->waitFor('#sku-input-beta') | ||||
->click('#sku-input-beta') | ->click('#sku-input-beta') | ||||
->scrollTo('@general button[type=submit]') | ->scrollTo('@general button[type=submit]')->pause(500) | ||||
->click('@general button[type=submit]') | ->click('@general button[type=submit]') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ||||
$expected = [ | $expected = [ | ||||
'groupware', | 'groupware', | ||||
'mailbox', | 'mailbox', | ||||
'storage', 'storage', 'storage', 'storage', 'storage' | 'storage', 'storage', 'storage', 'storage', 'storage' | ||||
]; | ]; | ||||
Show All 9 Lines |