weekly release 5.0dev
[moodle.git] / user / tests / behat / delete_users.feature
blob6bd0716e7ba362f8d64ac0783ab16e1df2c92687
1 @core @core_user
2 Feature: Deleting users
3   In order to manage a Moodle site
4   As an admin
5   I need to be able to delete users
7   Background:
8     Given the following "users" exist:
9       | username | firstname | lastname | email             |
10       | user1    | User      | One      | one@example.com   |
11       | user2    | User      | Two      | two@example.com   |
12       | user3    | User      | Three    | three@example.com |
13       | user4    | User      | Four     | four@example.com  |
14     And the following "courses" exist:
15       | fullname | shortname |
16       | Course 1 | C1        |
17     And the following "course enrolments" exist:
18       | user     | course | role           |
19       | user1    | C1     | student        |
20       | user2    | C1     | student        |
21       | user3    | C1     | student        |
22       | user4    | C1     | student        |
23     And the following config values are set as admin:
24       | messaging | 1 |
26   @javascript
27   Scenario: Deleting one user at a time
28     When I log in as "admin"
29     And I navigate to "Users > Accounts > Bulk user actions" in site administration
30     And the "Available" select box should contain "User Four"
31     And I set the field "Available" to "User Four"
32     And I press "Add to selection"
33     And I set the field "id_action" to "Delete"
34     And I press "Go"
35     And I should see "Are you absolutely sure you want to completely delete the user User Four, including their enrolments, activity and other user data?"
36     And I press "Yes"
37     And I should see "Changes saved"
38     And I press "Continue"
39     Then the "Available" select box should not contain "User Four"
40     And the "Available" select box should contain "User One"
42   @javascript
43   Scenario: Deleting more than one user at a time
44     When I log in as "admin"
45     And I navigate to "Users > Accounts > Bulk user actions" in site administration
46     And I set the field "Available" to "User Four"
47     And I press "Add to selection"
48     And I set the field "Available" to "User Three"
49     And I press "Add to selection"
50     And I set the field "id_action" to "Delete"
51     And I press "Go"
52     And I should see "Are you absolutely sure you want to completely delete the user User Four, User Three, including their enrolments, activity and other user data?"
53     And I press "Yes"
54     And I should see "Changes saved"
55     And I press "Continue"
56     Then the "Available" select box should not contain "User Four"
57     And the "Available" select box should not contain "User Three"
58     And the "Available" select box should contain "User One"
60   @javascript
61   Scenario: Deleting users from bulk actions in the user list
62     When I log in as "admin"
63     And I navigate to "Users > Accounts > Browse list of users" in site administration
64     And I click on "User Four" "checkbox"
65     And I click on "User Three" "checkbox"
66     And I set the field "Bulk user actions" to "Delete"
67     And I should see "Are you absolutely sure you want to completely delete the user User Four, User Three, including their enrolments, activity and other user data?"
68     And I press "Yes"
69     And I should see "Changes saved"
70     And I press "Continue"
71     And I should see "Browse list of users"
72     And I should not see "User Four"
73     And I should not see "User Three"
74     And I should see "User One"
76   @javascript @core_message
77   Scenario: Deleting users who have unread messages sent or received
78     When I log in as "user1"
79     And I send "Message 1 from user1 to user2" message to "User Two" user
80     And I log out
81     And I log in as "user3"
82     And I send "Message 2 from user3 to user4" message to "User Four" user
83     And I log out
84     And I log in as "admin"
85     And I navigate to "Users > Accounts > Bulk user actions" in site administration
86     And I set the field "Available" to "User One"
87     And I press "Add to selection"
88     And I set the field "Available" to "User Four"
89     And I press "Add to selection"
90     And I set the field "id_action" to "Delete"
91     And I press "Go"
92     And I press "Yes"
93     Then I should see "Changes saved"
94     And I navigate to "Users > Accounts > Bulk user actions" in site administration
95     And I set the field "Available" to "User Two"
96     And I press "Add to selection"
97     And I set the field "Available" to "User Three"
98     And I press "Add to selection"
99     And I set the field "id_action" to "Delete"
100     And I press "Go"
101     And I press "Yes"
102     And I should see "Changes saved"
103     And I press "Continue"
104     And the "Available" select box should not contain "User Four"
105     And the "Available" select box should not contain "User Three"
106     And the "Available" select box should not contain "User One"
107     And the "Available" select box should not contain "User Two"
109   @javascript
110   Scenario: Deleting a bulked user
111     When I log in as "admin"
112     And I navigate to "Users > Accounts > Bulk user actions" in site administration
113     And I set the field "Available" to "User Two"
114     And I press "Add to selection"
115     And I set the field "Available" to "User One"
116     And I press "Add to selection"
117     Then I should see "User One"
118     And I navigate to "Users > Accounts > Browse list of users" in site administration
119     And I press "Delete" action in the "User One" report row
120     And I click on "Delete" "button" in the "Delete user" "dialogue"
121     And I navigate to "Users > Accounts > Bulk user actions" in site administration
122     Then I should not see "User One"