diff --git a/completion/tests/behat/behat_completion.php b/completion/tests/behat/behat_completion.php index c0eb174e5e7..68783a28ba7 100644 --- a/completion/tests/behat/behat_completion.php +++ b/completion/tests/behat/behat_completion.php @@ -122,4 +122,40 @@ class behat_completion extends behat_base { new Given('I press "'.get_string('savechanges').'"') ); } + + /** + * Checks if the activity with specified name is maked as complete. + * + * @Given /^the "(?P(?:[^"]|\\")*)" "(?P(?:[^"]|\\")*)" activity with "(manual|auto)" completion should be marked as complete$/ + * @return array + */ + public function activity_marked_as_complete($activityname, $activitytype, $completiontype) { + if ($completiontype == "manual") { + $imgalttext = get_string("completion-alt-manual-y", 'core_completion', $activityname); + } else { + $imgalttext = get_string("completion-alt-auto-y", 'core_completion', $activityname); + } + $csselementforactivitytype = "li.modtype_".strtolower($activitytype); + + return new Given('"//img[contains(@alt, \''.$imgalttext.'\')]" "xpath_element" ' . + 'should exist in the "'.$csselementforactivitytype.'" "css_element"'); + } + + /** + * Checks if the activity with specified name is maked as complete. + * + * @Given /^the "(?P(?:[^"]|\\")*)" "(?P(?:[^"]|\\")*)" activity with "(manual|auto)" completion should be marked as not complete$/ + * @return array + */ + public function activity_marked_as_not_complete($activityname, $activitytype, $completiontype) { + if ($completiontype == "manual") { + $imgalttext = get_string("completion-alt-manual-n", 'core_completion', $activityname); + } else { + $imgalttext = get_string("completion-alt-auto-n", 'core_completion', $activityname); + } + $csselementforactivitytype = "li.modtype_".strtolower($activitytype); + + return new Given('"//img[contains(@alt, \''.$imgalttext.'\')]" "xpath_element" ' . + 'should exist in the "'.$csselementforactivitytype.'" "css_element"'); + } } diff --git a/mod/choice/tests/behat/publish_results_anonymously.feature b/mod/choice/tests/behat/publish_results_anonymously.feature index f195b0f8a3b..374f97d3fc8 100644 --- a/mod/choice/tests/behat/publish_results_anonymously.feature +++ b/mod/choice/tests/behat/publish_results_anonymously.feature @@ -22,7 +22,6 @@ Feature: A teacher can choose whether to publish choice activity results anonymo And I follow "Course 1" And I turn editing mode on - @javascript Scenario: Publish anonymous results Given I add a "Choice" to section "1" and I fill the form with: | Choice name | Choice 1 | @@ -41,9 +40,8 @@ Feature: A teacher can choose whether to publish choice activity results anonymo And I follow "Choice 1" Then I should not see "Student 1" And I should not see "Users who chose this option" - And I hover ".results .graph img" "css_element" + And ".results .graph img" "css_element" should exist - @javascript Scenario: Publish full results Given I add a "Choice" to section "1" and I fill the form with: | Choice name | Choice 1 | diff --git a/mod/forum/tests/behat/completion_condition_number_discussions.feature b/mod/forum/tests/behat/completion_condition_number_discussions.feature index 6a01089db51..ebb9de9b0a2 100644 --- a/mod/forum/tests/behat/completion_condition_number_discussions.feature +++ b/mod/forum/tests/behat/completion_condition_number_discussions.feature @@ -4,7 +4,6 @@ Feature: Set a certain number of discussions as a completion condition for a for As a teacher I need to set a minimum number of discussions to mark the forum activity as completed - @javascript Scenario: Set X number of discussions as a condition Given the following "users" exist: | username | firstname | lastname | email | @@ -36,7 +35,7 @@ Feature: Set a certain number of discussions as a completion condition for a for And I log out And I log in as "student1" And I follow "Course 1" - Then I hover "//li[contains(concat(' ', normalize-space(@class), ' '), ' modtype_forum ')]/descendant::img[@alt='Not completed: Test forum name']" "xpath_element" + Then the "Test forum name" "forum" activity with "auto" completion should be marked as not complete And I add a new discussion to "Test forum name" forum with: | Subject | Post 1 subject | | Message | Body 1 content | @@ -44,7 +43,7 @@ Feature: Set a certain number of discussions as a completion condition for a for | Subject | Post 2 subject | | Message | Body 2 content | And I follow "Course 1" - And I hover "//li[contains(concat(' ', normalize-space(@class), ' '), ' modtype_forum ')]/descendant::img[contains(@alt, 'Completed: Test forum name')]" "xpath_element" + Then the "Test forum name" "forum" activity with "auto" completion should be marked as complete And I log out And I log in as "teacher1" And I follow "Course 1" diff --git a/mod/quiz/tests/behat/completion_condition_attempts_used.feature b/mod/quiz/tests/behat/completion_condition_attempts_used.feature index df20005b76f..6ae8ec00dfa 100644 --- a/mod/quiz/tests/behat/completion_condition_attempts_used.feature +++ b/mod/quiz/tests/behat/completion_condition_attempts_used.feature @@ -58,7 +58,7 @@ Feature: Set a quiz to be marked complete when the student uses all attempts all And I log in as "student1" And I follow "Course 1" - And "//img[contains(@alt, 'Not completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element" + And the "Test quiz name" "quiz" activity with "auto" completion should be marked as not complete And I follow "Test quiz name" And I press "Attempt quiz now" And I should see "Question 1" @@ -68,7 +68,7 @@ Feature: Set a quiz to be marked complete when the student uses all attempts all And I should see "Answer saved" And I press "Submit all and finish" And I follow "C1" - And "//img[contains(@alt, 'Not completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element" + And the "Test quiz name" "quiz" activity with "auto" completion should be marked as not complete And I follow "Test quiz name" And I press "Re-attempt quiz" Then I should see "Question 1" diff --git a/mod/quiz/tests/behat/completion_condition_passing_grade.feature b/mod/quiz/tests/behat/completion_condition_passing_grade.feature index c2691684628..c838b40bd63 100644 --- a/mod/quiz/tests/behat/completion_condition_passing_grade.feature +++ b/mod/quiz/tests/behat/completion_condition_passing_grade.feature @@ -58,7 +58,7 @@ Feature: Set a quiz to be marked complete when the student passes And I log in as "student1" And I follow "Course 1" - And "//img[contains(@alt, 'Not completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element" + And the "Test quiz name" "quiz" activity with "auto" completion should be marked as not complete And I follow "Test quiz name" And I press "Attempt quiz now" Then I should see "Question 1"