Merge branch 'MDL-62643-master' of git://github.com/damyon/moodle
[moodle.git] / user / tests / behat / name_fields.feature
blob4f26b277ae6af2b77da3c071ae8968e406e89f8f
1 @core @core_user
2 Feature: Both first name and surname are always available for every user
3   In order to easily identify and display users on Moodle pages
4   As any user
5   I need to rely on both first name and surname are always available
7   Scenario: Attempting to self-register as a new user with empty names
8     Given the following config values are set as admin:
9       | registerauth    | email |
10       | passwordpolicy  | 0     |
11     And I am on site homepage
12     And I follow "Log in"
13     And I press "Create new account"
14     When I set the following fields to these values:
15       | Username      | mrwhitespace        |
16       | Password      | Gue$$m3ifY0uC&n     |
17       | Email address | mrwhitespace@nas.ty |
18       | Email (again) | mrwhitespace@nas.ty |
19     And I set the field "First name" to " "
20     And I set the field "Surname" to " "
21     And I press "Create my new account"
22     Then I should see "Missing given name"
23     And I should see "Missing surname"
25   Scenario: Attempting to change own names to whitespace
26     Given the following "users" exist:
27       | username | firstname | lastname | email       |
28       | foobar   | Foo       | Bar      | foo@bar.com |
29     And I log in as "foobar"
30     # UI test covering "I open my profile in edit mode" -
31     # This should be one of the very few places where we directly call these 2 steps to open the current users profile
32     # in edit mode, the rest of the time you should use "I open my profile in edit mode" as it is faster.
33     And I follow "Profile" in the user menu
34     And I click on "Edit profile" "link" in the "region-main" "region"
35     # End UI test covering "I open my profile in edit mode"
36     When I set the field "First name" to " "
37     And I set the field "Surname" to " "
38     And I click on "Cancel" "button"
39     And I follow "Profile" in the user menu
40     And I click on "Edit profile" "link" in the "region-main" "region"
41     Then I should see "Foo"
42     And I should see "Bar"
43     When I set the field "First name" to " "
44     And I set the field "Surname" to " "
45     And I click on "Update profile" "button"
46     Then I should see "Missing given name"
47     And I should see "Missing surname"
49   Scenario: Attempting to change someone else's names to whitespace
50     Given the following "users" exist:
51       | username | firstname | lastname | email       |
52       | foobar   | Foo       | Bar      | foo@bar.com |
53     And I log in as "admin"
54     And I navigate to "Browse list of users" node in "Site administration > Users > Accounts"
55     And I follow "Foo Bar"
56     And I click on "Edit profile" "link" in the "region-main" "region"
57     When I set the field "First name" to " "
58     And I set the field "Surname" to " "
59     And I click on "Cancel" "button"
60     And I follow "Foo Bar"
61     And I click on "Edit profile" "link" in the "region-main" "region"
62     Then I should see "Foo"
63     And I should see "Bar"
64     When I set the field "First name" to " "
65     And I set the field "Surname" to " "
66     And I click on "Update profile" "button"
67     Then I should see "Missing given name"
68     And I should see "Missing surname"