From 112f1ab9b02ef4950001052acfabe9685eb9c8fa Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sun, 30 Jun 2013 20:10:11 +0200 Subject: [PATCH] MDL-40392 Navigation -> my courses listing tests This introduces some behat tests to verify that the display of enrolled courses in the navigation block works as expected, both when a plain list or a nested list is configured. Personally I'm not happy with the way to select expected text via css element. I'd love to see something in an higher level like I should see the text|link "xxxxx" in the "yyyy" "element" with element being "block, header, footer, main...." But that's another issue. --- .../tests/behat/view_my_courses.feature | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 blocks/navigation/tests/behat/view_my_courses.feature diff --git a/blocks/navigation/tests/behat/view_my_courses.feature b/blocks/navigation/tests/behat/view_my_courses.feature new file mode 100644 index 00000000000..102a03cef83 --- /dev/null +++ b/blocks/navigation/tests/behat/view_my_courses.feature @@ -0,0 +1,68 @@ +@block @block_navigation +Feature: View my courses in navigation block + In order to navigate to my courses + As a student + I need my courses displayed in the navigation block + + Background: + Given the following "users" exists: + | username | firstname | lastname | email | + | student1 | Student | 1 | student1@asd.com | + And the following "categories" exists: + | name | category | idnumber | + | cat1 | 0 | cat1 | + | cat2 | 0 | cat2 | + | cat3 | 0 | cat3 | + | cat31 | cat3 | cat31 | + | cat32 | cat3 | cat32 | + | cat33 | cat3 | cat33 | + And the following "courses" exists: + | fullname | shortname | category | + | Course1 | c1 | cat1 | + | Course2 | c2 | cat2 | + | Course31 | c31 | cat31 | + | Course32 | c32 | cat32 | + | Course331| c331 | cat33 | + | Course332| c332 | cat33 | + And the following "course enrolments" exists: + | user | course | role | + | student1 | c1 | student | + | student1 | c31 | student | + | student1 | c331 | student | + And I log in as "admin" + + @javascript + Scenario: The plain list of enrolled courses is shown + Given I set the following administration settings values: + | Show my course categories | 0 | + And I log out + And I log in as "student1" + When I follow "My home" + Then I should not see "cat1" in the "div.block_navigation .type_system" "css_element" + And I should not see "cat2" in the "div.block_navigation .type_system" "css_element" + And I should see "c1" in the "div.block_navigation .type_system" "css_element" + And I should see "c31" in the "div.block_navigation .type_system" "css_element" + And I should see "c331" in the "div.block_navigation .type_system" "css_element" + And I should not see "c2" in the "div.block_navigation .type_system" "css_element" + And I should not see "c32" in the "div.block_navigation .type_system" "css_element" + And I should not see "c332" in the "div.block_navigation .type_system" "css_element" + + @javascript + Scenario: The nested list of enrolled courses is shown + Given I set the following administration settings values: + | Show my course categories | 1 | + And I log out + And I log in as "student1" + When I follow "My home" + Then I should see "cat1" in the "div.block_navigation .type_system" "css_element" + And I should see "cat3" in the "div.block_navigation .type_system" "css_element" + And I should not see "cat2" in the "div.block_navigation .type_system" "css_element" + When I expand "cat3" node + Then I should see "cat31" in the "div.block_navigation .type_system" "css_element" + And I should see "cat33" in the "div.block_navigation .type_system" "css_element" + And I should not see "cat32" in the "div.block_navigation .type_system" "css_element" + When I expand "cat31" node + Then I should see "c31" in the "div.block_navigation .type_system" "css_element" + When I expand "cat33" node + And I should see "c331" in the "div.block_navigation .type_system" "css_element" + And I should not see "c332" in the "div.block_navigation .type_system" "css_element"