From 0fd226006938a51d5fb50c1024906230a534a395 Mon Sep 17 00:00:00 2001 From: Stephen Bourget Date: Wed, 18 May 2016 09:08:24 -0400 Subject: [PATCH] MDL-54578 Behat: Add tests for the myprofile block --- .../tests/behat/block_myprofile.feature | 309 ++++++++++++++++++ .../behat/block_myprofile_activity.feature | 25 ++ .../behat/block_myprofile_course.feature | 21 ++ .../behat/block_myprofile_dashboard.feature | 14 + .../behat/block_myprofile_frontpage.feature | 25 ++ 5 files changed, 394 insertions(+) create mode 100644 blocks/myprofile/tests/behat/block_myprofile.feature create mode 100644 blocks/myprofile/tests/behat/block_myprofile_activity.feature create mode 100644 blocks/myprofile/tests/behat/block_myprofile_course.feature create mode 100644 blocks/myprofile/tests/behat/block_myprofile_dashboard.feature create mode 100644 blocks/myprofile/tests/behat/block_myprofile_frontpage.feature diff --git a/blocks/myprofile/tests/behat/block_myprofile.feature b/blocks/myprofile/tests/behat/block_myprofile.feature new file mode 100644 index 00000000000..8bd076c80c8 --- /dev/null +++ b/blocks/myprofile/tests/behat/block_myprofile.feature @@ -0,0 +1,309 @@ +@block @block_myprofile +Feature: The logged in user block allows users to view their profile information + In order to enable the logged in user block + As a user + I can add the logged in user block and configure it to show my information + + Scenario: Configure the logged in user block to show / hide the users country + Given the following "users" exist: + | username | firstname | lastname | email | country | + | teacher1 | Teacher | One | teacher1@example.com | AU | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display country | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "Australia" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display country | Yes | + And I press "Save changes" + And I should see "Australia" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users city + Given the following "users" exist: + | username | firstname | lastname | email | city | + | teacher1 | Teacher | One | teacher1@example.com | Perth | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display city | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "Perth" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display city | Yes | + And I press "Save changes" + And I should see "Perth" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users email + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | One | teacher1@example.com | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display email | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "teacher1@example.com" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display email | Yes | + And I press "Save changes" + And I should see "teacher1@example.com" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users ICQ + Given the following "users" exist: + | username | firstname | lastname | email | icq | + | teacher1 | Teacher | One | teacher1@example.com | myicq | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display ICQ | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "myicq" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display ICQ | Yes | + And I press "Save changes" + And I should see "myicq" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users Skype + Given the following "users" exist: + | username | firstname | lastname | email | skype | + | teacher1 | Teacher | One | teacher1@example.com | myskype | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display Skype | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "myskype" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display Skype | Yes | + And I press "Save changes" + And I should see "myskype" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users Yahoo + Given the following "users" exist: + | username | firstname | lastname | email | yahoo | + | teacher1 | Teacher | One | teacher1@example.com | myyahoo | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display Yahoo | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "myyahoo" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display Yahoo | Yes | + And I press "Save changes" + And I should see "myyahoo" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users AIM + Given the following "users" exist: + | username | firstname | lastname | email | aim | + | teacher1 | Teacher | One | teacher1@example.com | myaim | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display AIM | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "myaim" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display AIM | Yes | + And I press "Save changes" + And I should see "myaim" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users MSN + Given the following "users" exist: + | username | firstname | lastname | email | msn | + | teacher1 | Teacher | One | teacher1@example.com | mymsn | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display MSN | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "mymsn" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display MSN | Yes | + And I press "Save changes" + And I should see "mymsn" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users phone + Given the following "users" exist: + | username | firstname | lastname | email | phone1 | + | teacher1 | Teacher | One | teacher1@example.com | 555-5555 | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display phone | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "555-5555" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display phone | Yes | + And I press "Save changes" + And I should see "555-5555" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users mobile phone + Given the following "users" exist: + | username | firstname | lastname | email | phone2 | + | teacher1 | Teacher | One | teacher1@example.com | 555-5555 | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display mobile phone | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "555-5555" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display mobile phone | Yes | + And I press "Save changes" + And I should see "555-5555" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users Institution + Given the following "users" exist: + | username | firstname | lastname | email | institution | + | teacher1 | Teacher | One | teacher1@example.com | myinstitution | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display institution | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "myinstitution" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display institution | Yes | + And I press "Save changes" + And I should see "myinstitution" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users address + Given the following "users" exist: + | username | firstname | lastname | email | address | + | teacher1 | Teacher | One | teacher1@example.com | myaddress | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display address | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "myaddress" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display address | Yes | + And I press "Save changes" + And I should see "myaddress" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users first access + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | One | teacher1@example.com | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display first access | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "First access:" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display first access | Yes | + And I press "Save changes" + And I should see "First access:" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users last access + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | One | teacher1@example.com | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display last access | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "Last access:" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display last access | Yes | + And I press "Save changes" + And I should see "Last access:" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users current login + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | One | teacher1@example.com | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display current login | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "Log in:" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display current login | Yes | + And I press "Save changes" + And I should see "Log in:" in the "Logged in user" "block" + + Scenario: Configure the logged in user block to show / hide the users last ip + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | One | teacher1@example.com | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display last IP | No | + And I press "Save changes" + Then I should see "Teacher One" in the "Logged in user" "block" + And I should not see "IP:" in the "Logged in user" "block" + And I configure the "Logged in user" block + And I set the following fields to these values: + | Display last IP | Yes | + And I press "Save changes" + And I should see "IP:" in the "Logged in user" "block" diff --git a/blocks/myprofile/tests/behat/block_myprofile_activity.feature b/blocks/myprofile/tests/behat/block_myprofile_activity.feature new file mode 100644 index 00000000000..fb7cfd2d084 --- /dev/null +++ b/blocks/myprofile/tests/behat/block_myprofile_activity.feature @@ -0,0 +1,25 @@ +@block @block_myprofile +Feature: The logged in user block allows users to view their profile information in an activity + In order to enable the logged in user block in an activity + As a teacher + I can add the logged in user block to an activity and view my information + + Scenario: View the logged in user block by a user in an activity + Given the following "users" exist: + | username | firstname | lastname | email | idnumber | + | teacher1 | Teacher | One | teacher1@example.com | T1 | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + And the following "activities" exist: + | activity | course | idnumber | name | intro | + | page | C1 | page1 | Test page name | Test page description | + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + And I follow "Test page name" + When I add the "Logged in user" block + Then I should see "Teacher One" in the "Logged in user" "block" diff --git a/blocks/myprofile/tests/behat/block_myprofile_course.feature b/blocks/myprofile/tests/behat/block_myprofile_course.feature new file mode 100644 index 00000000000..81d22767a6c --- /dev/null +++ b/blocks/myprofile/tests/behat/block_myprofile_course.feature @@ -0,0 +1,21 @@ +@block @block_myprofile +Feature: The logged in user block allows users to view their profile information in a course + In order to enable the logged in user block in a course + As a teacher + I can add the logged in user block to a course and view my information + + Scenario: View the logged in user block by a user in a course + Given the following "users" exist: + | username | firstname | lastname | email | idnumber | + | teacher1 | Teacher | One | teacher1@example.com | T1 | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + When I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + And I add the "Logged in user" block + Then I should see "Teacher One" in the "Logged in user" "block" diff --git a/blocks/myprofile/tests/behat/block_myprofile_dashboard.feature b/blocks/myprofile/tests/behat/block_myprofile_dashboard.feature new file mode 100644 index 00000000000..e1305226ce1 --- /dev/null +++ b/blocks/myprofile/tests/behat/block_myprofile_dashboard.feature @@ -0,0 +1,14 @@ +@block @block_myprofile +Feature: The logged in user block allows users to view their profile information in on the dashboard + In order to enable the logged in user block on the dashboard + As a user + I can add the logged in user block to a the dashboard and view my information + + Scenario: View the logged in user block by a user on the dashboard + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | One | teacher1@example.com | + And I log in as "teacher1" + And I press "Customise this page" + When I add the "Logged in user" block + Then I should see "Teacher One" in the "Logged in user" "block" diff --git a/blocks/myprofile/tests/behat/block_myprofile_frontpage.feature b/blocks/myprofile/tests/behat/block_myprofile_frontpage.feature new file mode 100644 index 00000000000..5b14df39959 --- /dev/null +++ b/blocks/myprofile/tests/behat/block_myprofile_frontpage.feature @@ -0,0 +1,25 @@ +@block @block_myprofile +Feature: The logged in user block allows users to view their profile information on the front page + In order to enable the logged in user block on the frontpage + As an admin + I can add the logged in user block to the frontpage and view my information + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | idnumber | + | teacher1 | Teacher | One | teacher1@example.com | T1 | + And I log in as "admin" + And I am on site homepage + And I navigate to "Turn editing on" node in "Front page settings" + And I add the "Logged in user" block + And I log out + + Scenario: Try to view the logged in user block as a guest + Given I log in as "guest" + When I am on site homepage + Then I should not see "Logged in user" + + Scenario: View the logged in user block by a logged in user + Given I log in as "teacher1" + When I am on site homepage + Then I should see "Teacher One" in the "Logged in user" "block"