From 28c1597e5ad2bd19d377d19aa2531796ec6bee28 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Wed, 7 Dec 2022 10:35:05 +0800 Subject: [PATCH] MDL-76542 behat: create custom profile fields using data generators This commit also adds a new test to verify the custom profile fields works using the user interface. --- user/tests/behat/custom_profile_fields.feature | 55 +++++---------------- .../behat/custom_profile_fields_manual.feature | 56 ++++++++++++++++++++++ 2 files changed, 67 insertions(+), 44 deletions(-) create mode 100644 user/tests/behat/custom_profile_fields_manual.feature diff --git a/user/tests/behat/custom_profile_fields.feature b/user/tests/behat/custom_profile_fields.feature index b05f405cd9b..859ae609ff1 100644 --- a/user/tests/behat/custom_profile_fields.feature +++ b/user/tests/behat/custom_profile_fields.feature @@ -11,55 +11,22 @@ Feature: Custom profile fields should be visible and editable by those with the And the following "course enrolments" exist: | user | course | role | | userwithinformation | C1 | student | - And the following config values are set as admin: | registerauth | email | - + And the following "custom profile fields" exist: + | datatype | shortname | name | signup | visible | + | text | notvisible_field | notvisible_field | 1 | 0 | + | text | uservisible_field | uservisible_field | 1 | 1 | + | text | everyonevisible_field | everyonevisible_field | 0 | 2 | + | text | teachervisible_field | teachervisible_field | 1 | 3 | And I log in as "admin" - And I navigate to "Users > Accounts > User profile fields" in site administration - And I click on "Create a new profile field" "link" - And I click on "Text input" "link" - And I set the following fields to these values: - | Short name | notvisible_field | - | Name | notvisible_field | - | Display on signup page? | Yes | - | Who is this field visible to? | Not visible | - And I click on "Save changes" "button" - - And I click on "Create a new profile field" "link" - And I click on "Text input" "link" - And I set the following fields to these values: - | Short name | uservisible_field | - | Name | uservisible_field | - | Display on signup page? | Yes | - | Who is this field visible to? | Visible to user | - And I click on "Save changes" "button" - - And I click on "Create a new profile field" "link" - And I click on "Text input" "link" - And I set the following fields to these values: - | Short name | everyonevisible_field | - | Name | everyonevisible_field | - | Display on signup page? | No | - | Who is this field visible to? | Visible to everyone | - And I click on "Save changes" "button" - - And I click on "Create a new profile field" "link" - And I click on "Text input" "link" - And I set the following fields to these values: - | Short name | teachervisible_field | - | Name | teachervisible_field | - | Display on signup page? | Yes | - | Who is this field visible to? | Visible to user, teachers and admins | - And I click on "Save changes" "button" - And I navigate to "Users > Accounts > Browse list of users" in site administration And I click on ".icon[title=Edit]" "css_element" in the "userwithinformation@example.com" "table_row" - And I expand all fieldsets - And I set the field "notvisible_field" to "notvisible_field_information" - And I set the field "uservisible_field" to "uservisible_field_information" - And I set the field "everyonevisible_field" to "everyonevisible_field_information" - And I set the field "teachervisible_field" to "teachervisible_field_information" + And I set the following fields to these values: + | notvisible_field | notvisible_field_information | + | uservisible_field | uservisible_field_information | + | everyonevisible_field | everyonevisible_field_information | + | teachervisible_field | teachervisible_field_information | And I click on "Update profile" "button" And I log out diff --git a/user/tests/behat/custom_profile_fields_manual.feature b/user/tests/behat/custom_profile_fields_manual.feature new file mode 100644 index 00000000000..77ec582b6eb --- /dev/null +++ b/user/tests/behat/custom_profile_fields_manual.feature @@ -0,0 +1,56 @@ +@core @core_user +Feature: Custom profile fields creation using UI + + @javascript + Scenario Outline: Manual creation of basic custom profile fields + Given I log in as "admin" + And I navigate to "Users > Accounts > User profile fields" in site administration + And I click on "Create a new profile field" "link" + And I click on "" "link" + And I set the following fields to these values: + | Short name | | + | Name | | + When I click on "Save changes" "button" + Then I should see "" + + Examples: + | shortname | name | + | datetime | Date/Time | + | textarea | Text area | + | textinput | Text input | + + @javascript + Scenario: Manual creation of drop-down menu custom profile field type + Given I log in as "admin" + And I navigate to "Users > Accounts > User profile fields" in site administration + And I click on "Create a new profile field" "link" + And I click on "Drop-down menu" "link" + And I set the following fields to these values: + | Short name | dropdownmenu | + | Name | Drop-down menu field | + And I set the field "Menu options (one per line)" to multiline: + """ + a + b + """ + When I click on "Save changes" "button" + Then I should see "Drop-down menu field" + + @javascript + Scenario: Manual creation of checkbox and social custom profile field type + Given I log in as "admin" + And I navigate to "Users > Accounts > User profile fields" in site administration + And I click on "Create a new profile field" "link" + And I click on "Social" "link" + And I set the following fields to these values: + | Network type | Web page | + | Short name | social | + When I click on "Save changes" "button" + Then I should see "Web page" + And I click on "Create a new profile field" "link" + And I click on "Checkbox" "link" + And I set the following fields to these values: + | Short name | checkbox | + | Name | Checkbox | + When I click on "Save changes" "button" + Then I should see "Checkbox" -- 2.11.4.GIT