Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UsersTest.php
Show First 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | public function testInfo(): void | ||||
->assertValue('div.row:nth-child(7) input[type=password]', '') | ->assertValue('div.row:nth-child(7) input[type=password]', '') | ||||
->assertSeeIn('button[type=submit]', 'Submit'); | ->assertSeeIn('button[type=submit]', 'Submit'); | ||||
// Clear some fields and submit | // Clear some fields and submit | ||||
$browser->type('#first_name', '') | $browser->type('#first_name', '') | ||||
->type('#last_name', '') | ->type('#last_name', '') | ||||
->click('button[type=submit]'); | ->click('button[type=submit]'); | ||||
}) | }) | ||||
->with(new Toast(Toast::TYPE_SUCCESS), function (Browser $browser) { | ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ||||
$browser->assertToastTitle('') | |||||
->assertToastMessage('User data updated successfully') | |||||
->closeToast(); | |||||
}); | |||||
// Test error handling (password) | // Test error handling (password) | ||||
$browser->with('@form', function (Browser $browser) { | $browser->with('@form', function (Browser $browser) { | ||||
$browser->type('#password', 'aaaaaa') | $browser->type('#password', 'aaaaaa') | ||||
->type('#password_confirmation', '') | ->type('#password_confirmation', '') | ||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->waitFor('#password + .invalid-feedback') | ->waitFor('#password + .invalid-feedback') | ||||
->assertSeeIn('#password + .invalid-feedback', 'The password confirmation does not match.') | ->assertSeeIn('#password + .invalid-feedback', 'The password confirmation does not match.') | ||||
->assertFocused('#password'); | ->assertFocused('#password') | ||||
}) | ->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ||||
->with(new Toast(Toast::TYPE_ERROR), function (Browser $browser) { | |||||
$browser->assertToastTitle('Error') | |||||
->assertToastMessage('Form validation error') | |||||
->closeToast(); | |||||
}); | }); | ||||
// TODO: Test password change | // TODO: Test password change | ||||
// Test form error handling (aliases) | // Test form error handling (aliases) | ||||
$browser->with('@form', function (Browser $browser) { | $browser->with('@form', function (Browser $browser) { | ||||
// TODO: For some reason, clearing the input value | // TODO: For some reason, clearing the input value | ||||
// with ->type('#password', '') does not work, maybe some dusk/vue intricacy | // with ->type('#password', '') does not work, maybe some dusk/vue intricacy | ||||
// For now we just use the default password | // For now we just use the default password | ||||
$browser->type('#password', 'simple123') | $browser->type('#password', 'simple123') | ||||
->type('#password_confirmation', 'simple123') | ->type('#password_confirmation', 'simple123') | ||||
->with(new ListInput('#aliases'), function (Browser $browser) { | ->with(new ListInput('#aliases'), function (Browser $browser) { | ||||
$browser->addListEntry('invalid address'); | $browser->addListEntry('invalid address'); | ||||
}) | }) | ||||
->click('button[type=submit]'); | ->click('button[type=submit]') | ||||
}) | ->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ||||
->with(new Toast(Toast::TYPE_ERROR), function (Browser $browser) { | |||||
$browser->assertToastTitle('Error') | |||||
->assertToastMessage('Form validation error') | |||||
->closeToast(); | |||||
}) | }) | ||||
->with('@form', function (Browser $browser) { | ->with('@form', function (Browser $browser) { | ||||
$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 | ||||
$browser->with('@form', function (Browser $browser) { | $browser->with('@form', function (Browser $browser) { | ||||
$browser->with(new ListInput('#aliases'), function (Browser $browser) { | $browser->with(new ListInput('#aliases'), function (Browser $browser) { | ||||
$browser->removeListEntry(2) | $browser->removeListEntry(2) | ||||
->addListEntry('john.test@kolab.org'); | ->addListEntry('john.test@kolab.org'); | ||||
}) | }) | ||||
->click('button[type=submit]'); | ->click('button[type=submit]') | ||||
}) | ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ||||
->with(new Toast(Toast::TYPE_SUCCESS), function (Browser $browser) { | |||||
$browser->assertToastTitle('') | |||||
->assertToastMessage('User data updated successfully') | |||||
->closeToast(); | |||||
}); | }); | ||||
$john = User::where('email', 'john@kolab.org')->first(); | $john = User::where('email', 'john@kolab.org')->first(); | ||||
$alias = UserAlias::where('user_id', $john->id)->where('alias', 'john.test@kolab.org')->first(); | $alias = UserAlias::where('user_id', $john->id)->where('alias', 'john.test@kolab.org')->first(); | ||||
$this->assertTrue(!empty($alias)); | $this->assertTrue(!empty($alias)); | ||||
// Test subscriptions | // Test subscriptions | ||||
$browser->with('@form', function (Browser $browser) { | $browser->with('@form', function (Browser $browser) { | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | public function testInfo(): void | ||||
->assertEnabled('tbody tr:nth-child(5) td.selection input') | ->assertEnabled('tbody tr:nth-child(5) td.selection input') | ||||
->assertTip( | ->assertTip( | ||||
'tbody tr:nth-child(5) td.buttons button', | 'tbody tr:nth-child(5) td.buttons button', | ||||
'Two factor authentication for webmail and administration panel' | 'Two factor authentication for webmail and administration panel' | ||||
) | ) | ||||
->click('tbody tr:nth-child(4) td.selection input'); | ->click('tbody tr:nth-child(4) td.selection input'); | ||||
}) | }) | ||||
->assertMissing('@skus table + .hint') | ->assertMissing('@skus table + .hint') | ||||
->click('button[type=submit]'); | ->click('button[type=submit]') | ||||
}) | ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ||||
->with(new Toast(Toast::TYPE_SUCCESS), function (Browser $browser) { | |||||
$browser->assertToastTitle('') | |||||
->assertToastMessage('User data updated successfully') | |||||
->closeToast(); | |||||
}); | }); | ||||
$expected = ['activesync', 'groupware', 'mailbox', 'storage', 'storage', 'storage']; | $expected = ['activesync', 'groupware', 'mailbox', 'storage', 'storage', 'storage']; | ||||
$this->assertUserEntitlements($john, $expected); | $this->assertUserEntitlements($john, $expected); | ||||
// Test subscriptions interaction | // Test subscriptions interaction | ||||
$browser->with('@form', function (Browser $browser) { | $browser->with('@form', function (Browser $browser) { | ||||
$browser->with('@skus', function ($browser) { | $browser->with('@skus', function ($browser) { | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | public function testNewUser(): void | ||||
->assertFocused('#email') | ->assertFocused('#email') | ||||
->type('#email', 'invalid email') | ->type('#email', 'invalid email') | ||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->assertFocused('#password') | ->assertFocused('#password') | ||||
->type('#password', 'simple123') | ->type('#password', 'simple123') | ||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->assertFocused('#password_confirmation') | ->assertFocused('#password_confirmation') | ||||
->type('#password_confirmation', 'simple') | ->type('#password_confirmation', 'simple') | ||||
->click('button[type=submit]'); | ->click('button[type=submit]') | ||||
}) | ->assertToast(Toast::TYPE_ERROR, 'Form validation error') | ||||
->with(new Toast(Toast::TYPE_ERROR), function (Browser $browser) { | ->assertSeeIn('#email + .invalid-feedback', 'The specified email is invalid.') | ||||
$browser->assertToastTitle('Error') | |||||
->assertToastMessage('Form validation error') | |||||
->closeToast(); | |||||
}) | |||||
->with('@form', function (Browser $browser) { | |||||
$browser->assertSeeIn('#email + .invalid-feedback', 'The specified email is invalid.') | |||||
->assertSeeIn('#password + .invalid-feedback', 'The password confirmation does not match.'); | ->assertSeeIn('#password + .invalid-feedback', 'The password confirmation does not match.'); | ||||
}); | }); | ||||
// Test form error handling (aliases) | // Test form error handling (aliases) | ||||
$browser->with('@form', function (Browser $browser) { | $browser->with('@form', function (Browser $browser) { | ||||
$browser->type('#email', 'julia.roberts@kolab.org') | $browser->type('#email', 'julia.roberts@kolab.org') | ||||
->type('#password_confirmation', 'simple123') | ->type('#password_confirmation', 'simple123') | ||||
->with(new ListInput('#aliases'), function (Browser $browser) { | ->with(new ListInput('#aliases'), function (Browser $browser) { | ||||
$browser->addListEntry('invalid address'); | $browser->addListEntry('invalid address'); | ||||
}) | }) | ||||
->click('button[type=submit]'); | ->click('button[type=submit]') | ||||
}) | ->assertToast(Toast::TYPE_ERROR, 'Form validation error') | ||||
->with(new Toast(Toast::TYPE_ERROR), function (Browser $browser) { | ->with(new ListInput('#aliases'), function (Browser $browser) { | ||||
$browser->assertToastTitle('Error') | |||||
->assertToastMessage('Form validation error') | |||||
->closeToast(); | |||||
}) | |||||
->with('@form', function (Browser $browser) { | |||||
$browser->with(new ListInput('#aliases'), function (Browser $browser) { | |||||
$browser->assertFormError(1, 'The specified alias is invalid.', false); | $browser->assertFormError(1, 'The specified alias is invalid.', false); | ||||
}); | }); | ||||
}); | }); | ||||
// Successful account creation | // Successful account creation | ||||
$browser->with('@form', function (Browser $browser) { | $browser->with('@form', function (Browser $browser) { | ||||
$browser->with(new ListInput('#aliases'), function (Browser $browser) { | $browser->with(new ListInput('#aliases'), function (Browser $browser) { | ||||
$browser->removeListEntry(1) | $browser->removeListEntry(1) | ||||
->addListEntry('julia.roberts2@kolab.org'); | ->addListEntry('julia.roberts2@kolab.org'); | ||||
}) | }) | ||||
->click('button[type=submit]'); | ->click('button[type=submit]'); | ||||
}) | }) | ||||
->with(new Toast(Toast::TYPE_SUCCESS), function (Browser $browser) { | ->assertToast(Toast::TYPE_SUCCESS, 'User created successfully.') | ||||
$browser->assertToastTitle('') | |||||
->assertToastMessage('User created successfully') | |||||
->closeToast(); | |||||
}) | |||||
// check redirection to users list | // check redirection to users list | ||||
->waitForLocation('/users') | ->waitForLocation('/users') | ||||
->on(new UserList()) | ->on(new UserList()) | ||||
->whenAvailable('@table', function (Browser $browser) { | ->whenAvailable('@table', function (Browser $browser) { | ||||
$browser->assertElementsCount('tbody tr', 5) | $browser->assertElementsCount('tbody tr', 5) | ||||
->assertSeeIn('tbody tr:nth-child(4) a', 'julia.roberts@kolab.org'); | ->assertSeeIn('tbody tr:nth-child(4) a', 'julia.roberts@kolab.org'); | ||||
}); | }); | ||||
Show All 33 Lines | public function testDeleteUser(): void | ||||
->click('@button-cancel'); | ->click('@button-cancel'); | ||||
}) | }) | ||||
->whenAvailable('@table', function (Browser $browser) { | ->whenAvailable('@table', function (Browser $browser) { | ||||
$browser->click('tbody tr:nth-child(4) button.button-delete'); | $browser->click('tbody tr:nth-child(4) button.button-delete'); | ||||
}) | }) | ||||
->with(new Dialog('#delete-warning'), function (Browser $browser) { | ->with(new Dialog('#delete-warning'), function (Browser $browser) { | ||||
$browser->click('@button-action'); | $browser->click('@button-action'); | ||||
}) | }) | ||||
->with(new Toast(Toast::TYPE_SUCCESS), function (Browser $browser) { | ->assertToast(Toast::TYPE_SUCCESS, 'User deleted successfully.') | ||||
$browser->assertToastTitle('') | |||||
->assertToastMessage('User deleted successfully') | |||||
->closeToast(); | |||||
}) | |||||
->with('@table', function (Browser $browser) { | ->with('@table', function (Browser $browser) { | ||||
$browser->assertElementsCount('tbody tr', 4) | $browser->assertElementsCount('tbody tr', 4) | ||||
->assertSeeIn('tbody tr:nth-child(1) a', 'jack@kolab.org') | ->assertSeeIn('tbody tr:nth-child(1) a', 'jack@kolab.org') | ||||
->assertSeeIn('tbody tr:nth-child(2) a', 'joe@kolab.org') | ->assertSeeIn('tbody tr:nth-child(2) a', 'joe@kolab.org') | ||||
->assertSeeIn('tbody tr:nth-child(3) a', 'john@kolab.org') | ->assertSeeIn('tbody tr:nth-child(3) a', 'john@kolab.org') | ||||
->assertSeeIn('tbody tr:nth-child(4) a', 'ned@kolab.org'); | ->assertSeeIn('tbody tr:nth-child(4) a', 'ned@kolab.org'); | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |