Do you really want to delete this user permanently?
+ This will delete all account data and withdraw the permission to access the email account.
+ Please note that this action cannot be undone.
Do you really want to delete this user permanently?
- This will delete all account data and withdraw the permission to access the email account.
- Please note that this action cannot be undone.
-
-
-
-
-
@@ -86,46 +52,6 @@
this.users = response.data
})
.catch(this.$root.errorHandler)
- },
- methods: {
- deleteUser(id) {
- let dialog = $('#delete-warning').modal('hide')
-
- // Delete the user from the confirm dialog
- if (!id && this.current_user) {
- id = this.current_user.id
- axios.delete('/api/v4/users/' + id)
- .then(response => {
- if (response.data.status == 'success') {
- this.$toast.success(response.data.message)
- $('#user' + id).remove()
- }
- })
-
- return
- }
-
- // Deleting self, redirect to /profile/delete page
- if (id == this.$store.state.authInfo.id) {
- this.$router.push({ name: 'profile-delete' })
- return
- }
-
- // Display the warning
- if (this.current_user = this.getUser(id)) {
- dialog.find('.modal-title').text('Delete ' + this.current_user.email)
- dialog.on('shown.bs.modal', () => {
- dialog.find('button.modal-cancel').focus()
- }).modal()
- }
- },
- getUser(id) {
- for (let i = 0; i < this.users.length; i++) {
- if (this.users[i].id == id) {
- return this.users[i]
- }
- }
- }
}
}
diff --git a/src/resources/vue/User/Profile.vue b/src/resources/vue/User/Profile.vue
--- a/src/resources/vue/User/Profile.vue
+++ b/src/resources/vue/User/Profile.vue
@@ -2,7 +2,16 @@
-
Your profile
+
+ Your profile
+
+ Delete account
+
+
- Delete account
diff --git a/src/tests/Browser/UsersTest.php b/src/tests/Browser/UsersTest.php
--- a/src/tests/Browser/UsersTest.php
+++ b/src/tests/Browser/UsersTest.php
@@ -119,10 +119,6 @@
->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(4) a', 'ned@kolab.org')
- ->assertVisible('tbody tr:nth-child(1) button.button-delete')
- ->assertVisible('tbody tr:nth-child(2) button.button-delete')
- ->assertVisible('tbody tr:nth-child(3) button.button-delete')
- ->assertVisible('tbody tr:nth-child(4) button.button-delete')
->assertMissing('tfoot');
});
});
@@ -473,13 +469,11 @@
$john->assignPackage($package_kolab, $julia);
// Test deleting non-controller user
- $this->browse(function (Browser $browser) {
- $browser->visit(new UserList())
- ->whenAvailable('@table', function (Browser $browser) {
- $browser->assertElementsCount('tbody tr', 5)
- ->assertSeeIn('tbody tr:nth-child(4) a', 'julia.roberts@kolab.org')
- ->click('tbody tr:nth-child(4) button.button-delete');
- })
+ $this->browse(function (Browser $browser) use ($julia) {
+ $browser->visit('/user/' . $julia->id)
+ ->on(new UserInfo())
+ ->assertSeeIn('button.button-delete', 'Delete user')
+ ->click('button.button-delete')
->with(new Dialog('#delete-warning'), function (Browser $browser) {
$browser->assertSeeIn('@title', 'Delete julia.roberts@kolab.org')
->assertFocused('@button-cancel')
@@ -487,13 +481,14 @@
->assertSeeIn('@button-action', 'Delete')
->click('@button-cancel');
})
- ->whenAvailable('@table', function (Browser $browser) {
- $browser->click('tbody tr:nth-child(4) button.button-delete');
- })
+ ->waitUntilMissing('#delete-warning')
+ ->click('button.button-delete')
->with(new Dialog('#delete-warning'), function (Browser $browser) {
$browser->click('@button-action');
})
+ ->waitUntilMissing('#delete-warning')
->assertToast(Toast::TYPE_SUCCESS, 'User deleted successfully.')
+ ->on(new UserList())
->with('@table', function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 4)
->assertSeeIn('tbody tr:nth-child(1) a', 'jack@kolab.org')
@@ -504,17 +499,9 @@
$julia = User::where('email', 'julia.roberts@kolab.org')->first();
$this->assertTrue(empty($julia));
-
- // Test clicking Delete on the controller record redirects to /profile/delete
- $browser
- ->with('@table', function (Browser $browser) {
- $browser->click('tbody tr:nth-child(3) button.button-delete');
- })
- ->waitForLocation('/profile/delete');
});
// Test that non-controller user cannot see/delete himself on the users list
- // Note: Access to /profile/delete page is tested in UserProfileTest.php
$this->browse(function (Browser $browser) {
$browser->visit('/logout')
->on(new Home())
@@ -526,15 +513,14 @@
});
});
- // Test that controller user (Ned) can see/delete all the users ???
+ // Test that controller user (Ned) can see all the users
$this->browse(function (Browser $browser) {
$browser->visit('/logout')
->on(new Home())
->submitLogon('ned@kolab.org', 'simple123', true)
->visit(new UserList())
->whenAvailable('@table', function (Browser $browser) {
- $browser->assertElementsCount('tbody tr', 4)
- ->assertElementsCount('tbody button.button-delete', 4);
+ $browser->assertElementsCount('tbody tr', 4);
});
// TODO: Test the delete action in details