Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UsersTest.php
Show First 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | public function testInfo(): void | ||||
->with(new ListInput('#aliases'), function (Browser $browser) { | ->with(new ListInput('#aliases'), function (Browser $browser) { | ||||
$browser->assertListInputValue(['john.doe@kolab.org']) | $browser->assertListInputValue(['john.doe@kolab.org']) | ||||
->assertValue('@input', ''); | ->assertValue('@input', ''); | ||||
}) | }) | ||||
->assertSeeIn('div.row:nth-child(7) label', 'Password') | ->assertSeeIn('div.row:nth-child(7) label', 'Password') | ||||
->assertValue('div.row:nth-child(7) input[type=password]', '') | ->assertValue('div.row:nth-child(7) input[type=password]', '') | ||||
->assertSeeIn('div.row:nth-child(8) label', 'Confirm password') | ->assertSeeIn('div.row:nth-child(8) label', 'Confirm password') | ||||
->assertValue('div.row:nth-child(8) input[type=password]', '') | ->assertValue('div.row:nth-child(8) 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', '') | ->vueClear('#first_name') | ||||
->type('#last_name', '') | ->vueClear('#last_name') | ||||
->click('button[type=submit]'); | ->click('button[type=submit]'); | ||||
}) | }) | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.') | ||||
->on(new UserList()) | |||||
->click('@table tr:nth-child(3) a') | |||||
->on(new UserInfo()) | |||||
->assertSeeIn('#user-info .card-title', 'User account') | |||||
->with('@form', function (Browser $browser) { | |||||
// Test error handling (password) | // Test error handling (password) | ||||
$browser->with('@form', function (Browser $browser) { | |||||
$browser->type('#password', 'aaaaaa') | $browser->type('#password', 'aaaaaa') | ||||
->type('#password_confirmation', '') | ->vueClear('#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'); | ->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->with('@form', function (Browser $browser) { | $browser->vueClear('#password') | ||||
// TODO: For some reason, clearing the input value | ->vueClear('#password_confirmation') | ||||
// with ->type('#password', '') does not work, maybe some dusk/vue intricacy | |||||
// For now we just use the default password | |||||
$browser->type('#password', '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'); | ->assertToast(Toast::TYPE_ERROR, 'Form validation error'); | ||||
}) | |||||
->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(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.'); | ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ||||
}); | }) | ||||
->on(new UserList()) | |||||
->click('@table tr:nth-child(3) a') | |||||
->on(new UserInfo()); | |||||
$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) { | ||||
$browser->assertSeeIn('div.row:nth-child(9) label', 'Subscriptions') | $browser->assertSeeIn('div.row:nth-child(9) label', 'Subscriptions') | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | public function testInfo(): void | ||||
'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.'); | ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.'); | ||||
}); | }) | ||||
->on(new UserList()) | |||||
->click('@table tr:nth-child(3) a') | |||||
->on(new UserInfo()); | |||||
$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) { | ||||
// Uncheck 'groupware', expect activesync unchecked | // Uncheck 'groupware', expect activesync unchecked | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | public function testNewUser(): void | ||||
->with(new ListInput('#aliases'), function (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]'); | ||||
}) | }) | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User created successfully.') | ->assertToast(Toast::TYPE_SUCCESS, 'User created successfully.') | ||||
// check redirection to users list | // check redirection to users list | ||||
->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'); | ||||
}); | }); | ||||
$julia = User::where('email', 'julia.roberts@kolab.org')->first(); | $julia = User::where('email', 'julia.roberts@kolab.org')->first(); | ||||
$alias = UserAlias::where('user_id', $julia->id)->where('alias', 'julia.roberts2@kolab.org')->first(); | $alias = UserAlias::where('user_id', $julia->id)->where('alias', 'julia.roberts2@kolab.org')->first(); | ||||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |