MDL-40976 behat: Updating tests according to new behaviour

We only open the actions menu when is collapsed.
This commit is contained in:
David Monllao 2013-10-23 16:19:33 +08:00
parent 90eb4ddd9a
commit 2a9275c4c5
2 changed files with 31 additions and 10 deletions

View File

@ -499,13 +499,37 @@ class behat_course extends behat_base {
// Adding chr(10) to save changes.
$activity = $this->escape($activityname);
return array(
new Given('I click on "' . get_string('actions', 'moodle') . '" "link" in the "' . $activity . '" activity'),
new Given('I open "' . $activity . '" actions menu'),
new Given('I click on "' . get_string('edittitle') . '" "link" in the "' . $activity .'" activity'),
new Given('I fill in "title" with "' . $this->escape($newactivityname) . chr(10) . '"'),
new Given('I wait "2" seconds')
);
}
/**
* Opens an activity actions menu if it is not already opened.
*
* @Given /^I open "(?P<activity_name_string>(?:[^"]|\\")*)" actions menu$/
* @throws DriverException The step is not available when Javascript is disabled
* @param string $activityname
* @return Given
*/
public function i_open_actions_menu($activityname) {
if (!$this->running_javascript()) {
throw new DriverException('Activities actions menu not available when Javascript is disabled');
}
// If it is already opened we do nothing.
$activitynode = $this->get_activity_node($activityname);
$classes = array_flip(explode(' ', $activitynode->getAttribute('class')));
if (!empty($classes['action-menu-shown'])) {
return;
}
return new Given('I click on "' . get_string('actions', 'moodle') . '" "link" in the "' . $this->escape($activityname) . '" activity');
}
/**
* Indents to the right the activity or resource specified by it's name. Editing mode should be on.
*
@ -518,7 +542,7 @@ class behat_course extends behat_base {
$steps = array();
$activity = $this->escape($activityname);
if ($this->running_javascript()) {
$steps[] = new Given('I click on "' . get_string('actions', 'moodle') . '" "link" in the "' . $activity . '" activity');
$steps[] = new Given('I open "' . $activity . '" actions menu');
}
$steps[] = new Given('I click on "' . get_string('moveright') . '" "link" in the "' . $activity . '" activity');
@ -541,7 +565,7 @@ class behat_course extends behat_base {
$steps = array();
$activity = $this->escape($activityname);
if ($this->running_javascript()) {
$steps[] = new Given('I click on "' . get_string('actions', 'moodle') . '" "link" in the "' . $activity . '" activity');
$steps[] = new Given('I open "' . $activity . '" actions menu');
}
$steps[] = new Given('I click on "' . get_string('moveleft') . '" "link" in the "' . $activity . '" activity');
@ -599,7 +623,7 @@ class behat_course extends behat_base {
$steps = array();
$activity = $this->escape($activityname);
if ($this->running_javascript()) {
$steps[] = new Given('I click on "' . get_string('actions', 'moodle') . '" "link" in the "' . $activity . '" activity');
$steps[] = new Given('I open "' . $activity . '" actions menu');
}
$steps[] = new Given('I click on "' . get_string('duplicate') . '" "link" in the "' . $activity . '" activity');
$steps[] = new Given('I press "' . get_string('continue') .'"');
@ -619,7 +643,7 @@ class behat_course extends behat_base {
$steps = array();
$activity = $this->escape($activityname);
if ($this->running_javascript()) {
$steps[] = new Given('I click on "' . get_string('actions', 'moodle') . '" "link" in the "' . $activity . '" activity');
$steps[] = new Given('I open "' . $activity . '" actions menu');
}
$steps[] = new Given('I click on "' . get_string('duplicate') . '" "link" in the "' . $activity . '" activity');
$steps[] = new Given('I press "' . get_string('continue') .'"');

View File

@ -55,13 +55,13 @@ Feature: Course activity controls works as expected
And "#section-2" "css_element" <should_see_other_sections> exists
And I indent left "Test forum name 1" activity
And "#section-2" "css_element" <should_see_other_sections> exists
And I click on "Actions" "link" in the "Test forum name 1" activity
And I open "Test forum name 1" actions menu
And I click on "Update" "link" in the "Test forum name 1" activity
And I should see "Updating Forum"
And I should see "Display description on course page"
And I press "Save and return to course"
And "#section-2" "css_element" <should_see_other_sections> exists
And I click on "Actions" "link" in the "Test forum name 1" activity
And I open "Test forum name 1" actions menu
And I click on "Hide" "link" in the "Test forum name 1" activity
And "#section-2" "css_element" <should_see_other_sections> exists
And I duplicate "Test forum name 2" activity editing the new copy with:
@ -90,7 +90,6 @@ Feature: Course activity controls works as expected
| weeks | 1 | "1 January - 7 January" | should not | should not |
| weeks | 1 | "Course 1" | should | should not |
Scenario Outline: General activities course controls using topics and weeks formats, and paged mode and not paged mode works as expected
Given the following "users" exists:
| username | firstname | lastname | email |
@ -129,13 +128,11 @@ Feature: Course activity controls works as expected
And "#section-2" "css_element" <should_see_other_sections> exists
And I indent left "Test forum name 1" activity
And "#section-2" "css_element" <should_see_other_sections> exists
And I click on "Actions" "link" in the "Test forum name 1" activity
And I click on "Update" "link" in the "Test forum name 1" activity
And I should see "Updating Forum"
And I should see "Display description on course page"
And I press "Save and return to course"
And "#section-2" "css_element" <should_see_other_sections> exists
And I click on "Actions" "link" in the "Test forum name 1" activity
And I click on "Hide" "link" in the "Test forum name 1" activity
And "#section-2" "css_element" <should_see_other_sections> exists
And I delete "Test forum name 1" activity