MDL-58788 behat: backport of course navigation with editing step

This commit is contained in:
Dan Poltawski
2017-05-03 17:31:23 +01:00
parent 9ddd0bd72a
commit 5611053587
2 changed files with 35 additions and 2 deletions
@@ -15,7 +15,7 @@ Feature: Backported behat step definitions
And the following "course enrolments" exist:
| user | course | role |
| student1 | C101 | student |
| teacher1 | C101 | teacher |
| teacher1 | C101 | editingteacher |
Scenario: I am on the course homepage
When I log in as "student1"
@@ -23,7 +23,20 @@ Feature: Backported behat step definitions
Then I should see "Topic 1"
@javascript
Scenario: I am on the course homepage
Scenario: I am on the course homepage with JS
When I log in as "teacher1"
And I am on "Course 1" course homepage
Then I should see "Topic 1"
Scenario: I am on the course homepage with editing
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
Then I should see "Topic 1"
And I should see "Add an activity or resource"
@javascript
Scenario: I am on the course homepage with editing and JS
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
Then I should see "Topic 1"
And I should see "Add an activity or resource"
+20
View File
@@ -588,4 +588,24 @@ class behat_navigation extends behat_base {
$url = new moodle_url('/course/view.php', ['id' => $course->id]);
$this->getSession()->visit($this->locate_path($url->out_as_local_url(false)));
}
/**
* Opens the course homepage with editing mode on.
*
* @Given /^I am on "(?P<coursefullname_string>(?:[^"]|\\")*)" course homepage with editing mode on$/
* @throws coding_exception
* @param string $coursefullname The course full name of the course.
* @return void
*/
public function i_am_on_course_homepage_with_editing_mode_on($coursefullname) {
global $DB;
$course = $DB->get_record("course", array("fullname" => $coursefullname), 'id', MUST_EXIST);
$url = new moodle_url('/course/view.php', ['id' => $course->id]);
$this->getSession()->visit($this->locate_path($url->out_as_local_url(false)));
try {
$this->execute("behat_forms::press_button", get_string('turneditingon'));
} catch (Exception $e) {
$this->execute("behat_navigation::i_navigate_to_in_current_page_administration", [get_string('turneditingon')]);
}
}
}