Merge branch 'MDL-39051_master' of git://github.com/dmonllao/moodle
This commit is contained in:
@@ -28,20 +28,20 @@ Feature: Toggle activities groups mode from the course page
|
||||
When I press "Save changes"
|
||||
Then "No groups (Click to change)" "link" should exists
|
||||
And ".//a//img[contains(@src, 'groupn')]" "xpath_element" should exists
|
||||
And I click on "No groups (Click to change)" "link" in the "li.activity.forum" "css_element"
|
||||
And I click on "No groups (Click to change)" "link" in the "Test forum name" activity
|
||||
And I wait "3" seconds
|
||||
And "Separate groups (Click to change)" "link" should exists
|
||||
And ".//a//img[contains(@src, 'groups')]" "xpath_element" should exists
|
||||
And I reload the page
|
||||
And "Separate groups (Click to change)" "link" should exists
|
||||
And ".//a//img[contains(@src, 'groups')]" "xpath_element" should exists
|
||||
And I click on "Separate groups (Click to change)" "link" in the "li.activity.forum" "css_element"
|
||||
And I click on "Separate groups (Click to change)" "link" in the "Test forum name" activity
|
||||
And I wait "3" seconds
|
||||
And "Visible groups (Click to change)" "link" should exists
|
||||
And ".//a//img[contains(@src, 'groupv')]" "xpath_element" should exists
|
||||
And I reload the page
|
||||
And "Visible groups (Click to change)" "link" should exists
|
||||
And ".//a//img[contains(@src, 'groupv')]" "xpath_element" should exists
|
||||
And I click on "Visible groups (Click to change)" "link" in the "li.activity.forum" "css_element"
|
||||
And I click on "Visible groups (Click to change)" "link" in the "Test forum name" activity
|
||||
And "No groups (Click to change)" "link" should exists
|
||||
And ".//a//img[contains(@src, 'groupn')]" "xpath_element" should exists
|
||||
|
||||
@@ -23,19 +23,15 @@ Feature: Indent items on the course page
|
||||
And I add a "Glossary" to section "1" and I fill the form with:
|
||||
| Name | Test glossary name |
|
||||
| Description | Test glossary description |
|
||||
When I click on "Move right" "link" in the "#section-1 li.glossary" "css_element"
|
||||
And I wait "2" seconds
|
||||
When I indent right "Test glossary name" activity
|
||||
Then "#section-1 li.glossary div.mod-indent-1" "css_element" should exists
|
||||
And I click on "Move right" "link" in the "#section-1 li.glossary" "css_element"
|
||||
And I wait "2" seconds
|
||||
And I indent right "Test glossary name" activity
|
||||
And "//*[@id='section-1']/descendant::li[contains(concat(' ', @class, ' '), ' glossary ')]/descendant::a[@title='Move left']" "xpath_element" should exists
|
||||
And "#section-1 li.glossary div.mod-indent-2" "css_element" should exists
|
||||
And I reload the page
|
||||
And "#section-1 li.glossary div.mod-indent-2" "css_element" should exists
|
||||
And I click on "Move left" "link" in the "#section-1 li.glossary" "css_element"
|
||||
And I wait "2" seconds
|
||||
And I click on "Move left" "link" in the "#section-1 li.glossary" "css_element"
|
||||
And I wait "2" seconds
|
||||
And I indent left "Test glossary name" activity
|
||||
And I indent left "Test glossary name" activity
|
||||
And "#section-1 li.glossary div.mod-indent-2" "css_element" should not exists
|
||||
And "#section-1 li.glossary div.mod-indent-1" "css_element" should not exists
|
||||
And "//*[@id='section-1']/descendant::li[contains(concat(' ', @class, ' '), ' glossary ')]/descendant::a[@title='Move left']" "xpath_element" should not exists
|
||||
|
||||
@@ -24,11 +24,11 @@ Feature: Toggle activities visibility from the course page
|
||||
| Forum name | Test forum name |
|
||||
| Description | Test forum description |
|
||||
| Visible | Show |
|
||||
When I click on "Hide" "link" in the "li.activity.forum" "css_element"
|
||||
When I click on "Hide" "link" in the "Test forum name" activity
|
||||
Then "Test forum name" activity should be hidden
|
||||
And I click on "Show" "link" in the "li.activity.forum" "css_element"
|
||||
And I click on "Show" "link" in the "Test forum name" activity
|
||||
And "Test forum name" activity should be visible
|
||||
And I click on "Hide" "link" in the "li.activity.forum" "css_element"
|
||||
And I click on "Hide" "link" in the "Test forum name" activity
|
||||
And "Test forum name" activity should be hidden
|
||||
And I reload the page
|
||||
And "Test forum name" activity should be hidden
|
||||
|
||||
@@ -30,6 +30,7 @@ require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
|
||||
use Behat\Behat\Context\Step\Given as Given,
|
||||
Behat\Gherkin\Node\TableNode as TableNode,
|
||||
Behat\Mink\Exception\ExpectationException as ExpectationException,
|
||||
Behat\Mink\Exception\DriverException as DriverException,
|
||||
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
|
||||
|
||||
/**
|
||||
@@ -93,7 +94,7 @@ class behat_course extends behat_base {
|
||||
*
|
||||
* @When /^I add a "(?P<activity_or_resource_name_string>(?:[^"]|\\")*)" to section "(?P<section_number>\d+)" and I fill the form with:$/
|
||||
* @param string $activity The activity name
|
||||
* @param string $section The section number
|
||||
* @param int $section The section number
|
||||
* @param TableNode $data The activity field/value data
|
||||
*/
|
||||
public function i_add_to_section_and_i_fill_the_form_with($activity, $section, TableNode $data) {
|
||||
@@ -111,7 +112,7 @@ class behat_course extends behat_base {
|
||||
* @Given /^I add a "(?P<activity_or_resource_name_string>(?:[^"]|\\")*)" to section "(?P<section_number>\d+)"$/
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
* @param string $activity
|
||||
* @param string $section
|
||||
* @param int $section
|
||||
*/
|
||||
public function i_add_to_section($activity, $section) {
|
||||
|
||||
@@ -190,11 +191,13 @@ class behat_course extends behat_base {
|
||||
* @param int $sectionnumber
|
||||
*/
|
||||
public function i_show_section($sectionnumber) {
|
||||
$showicon = $this->show_section_icon_exists($sectionnumber);
|
||||
$showicon->click();
|
||||
$showlink = $this->show_section_icon_exists($sectionnumber);
|
||||
$showlink->click();
|
||||
|
||||
// It requires time.
|
||||
$this->getSession()->wait(5000, false);
|
||||
if ($this->running_javascript()) {
|
||||
$this->getSession()->wait(5000, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,11 +207,13 @@ class behat_course extends behat_base {
|
||||
* @param int $sectionnumber
|
||||
*/
|
||||
public function i_hide_section($sectionnumber) {
|
||||
$hideicon = $this->hide_section_icon_exists($sectionnumber);
|
||||
$hideicon->click();
|
||||
$hidelink = $this->hide_section_icon_exists($sectionnumber);
|
||||
$hidelink->click();
|
||||
|
||||
// It requires time.
|
||||
$this->getSession()->wait(5000, false);
|
||||
if ($this->running_javascript()) {
|
||||
$this->getSession()->wait(5000, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,9 +287,12 @@ class behat_course extends behat_base {
|
||||
$this->find('xpath', "//div[contains(concat(' ', @class, ' '), ' activityinstance ')]" .
|
||||
"/a[contains(concat(' ', @class, ' '), ' dimmed ')]", $dimmedexception, $activity);
|
||||
|
||||
// To check that the visibility is not clickable we check the funcionality rather than the applied style.
|
||||
$visibilityiconnode = $this->find('css', 'a.editing_show img', false, $activity);
|
||||
$visibilityiconnode->click();
|
||||
// Non-JS browsers can not click on img elements.
|
||||
if ($this->running_javascript()) {
|
||||
// To check that the visibility is not clickable we check the funcionality rather than the applied style.
|
||||
$visibilityiconnode = $this->find('css', 'a.editing_show img', false, $activity);
|
||||
$visibilityiconnode->click();
|
||||
}
|
||||
|
||||
// We ensure that we still see the show icon.
|
||||
$visibilityiconnode = $this->find('css', 'a.editing_show img', $visibilityexception, $activity);
|
||||
@@ -321,6 +329,48 @@ class behat_course extends behat_base {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves up the specified section, this step only works with Javascript disabled. Editing mode should be on.
|
||||
*
|
||||
* @Given /^I move up section "(?P<section_number>\d+)"$/
|
||||
* @throws DriverException Step not available when Javascript is enabled
|
||||
* @param int $sectionnumber
|
||||
*/
|
||||
public function i_move_up_section($sectionnumber) {
|
||||
|
||||
if ($this->running_javascript()) {
|
||||
throw new DriverException('Move a section up step is not available with Javascript enabled');
|
||||
}
|
||||
|
||||
// Ensures the section exists.
|
||||
$sectionxpath = $this->section_exists($sectionnumber);
|
||||
|
||||
// Follows the link
|
||||
$moveuplink = $this->get_node_in_container('link', get_string('moveup'), 'xpath_element', $sectionxpath);
|
||||
$moveuplink->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves down the specified section, this step only works with Javascript disabled. Editing mode should be on.
|
||||
*
|
||||
* @Given /^I move down section "(?P<section_number>\d+)"$/
|
||||
* @throws DriverException Step not available when Javascript is enabled
|
||||
* @param int $sectionnumber
|
||||
*/
|
||||
public function i_move_down_section($sectionnumber) {
|
||||
|
||||
if ($this->running_javascript()) {
|
||||
throw new DriverException('Move a section down step is not available with Javascript enabled');
|
||||
}
|
||||
|
||||
// Ensures the section exists.
|
||||
$sectionxpath = $this->section_exists($sectionnumber);
|
||||
|
||||
// Follows the link
|
||||
$movedownlink = $this->get_node_in_container('link', get_string('movedown'), 'xpath_element', $sectionxpath);
|
||||
$movedownlink->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the specified activity is visible. You need to be in the course page. It can be used being logged as a student and as a teacher on editing mode.
|
||||
*
|
||||
@@ -382,6 +432,198 @@ class behat_course extends behat_base {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the specified activity to the first slot of a section. Editing mode should be on.
|
||||
*
|
||||
* @Given /^I move "(?P<activity_name_string>(?:[^"]|\\")*)" activity to section "(?P<section_number>\d+)"$/
|
||||
* @param string $activityname The activity name
|
||||
* @param int $sectionnumber The number of section
|
||||
*/
|
||||
public function i_move_activity_to_section($activityname, $sectionnumber) {
|
||||
|
||||
// Ensure the destination is valid.
|
||||
$sectionxpath = $this->section_exists($sectionnumber);
|
||||
|
||||
$activitynode = $this->get_activity_element('.editing_move img', 'css_element', $activityname);
|
||||
|
||||
// JS enabled.
|
||||
if ($this->running_javascript()) {
|
||||
|
||||
$destinationxpath = $sectionxpath . "/descendant::ul[contains(@class, 'yui3-dd-drop')]";
|
||||
|
||||
return array(
|
||||
new Given('I drag "' . $activitynode->getXpath() . '" "xpath_element" and I drop it in "' . $destinationxpath . '" "xpath_element"'),
|
||||
);
|
||||
|
||||
} else {
|
||||
// Following links with no-JS.
|
||||
|
||||
// Moving to the fist spot of the section (before all other section's activities).
|
||||
return array(
|
||||
new Given('I click on "a.editing_move" "css_element" in the "' . $activityname . '" activity'),
|
||||
new Given('I click on "li.movehere a" "css_element" in the "' . $sectionxpath . '" "xpath_element"'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edits the activity name through the edit activity; this step only works with Javascript enabled. Editing mode should be on.
|
||||
*
|
||||
* @Given /^I change "(?P<activity_name_string>(?:[^"]|\\")*)" activity name to "(?P<new_name_string>(?:[^"]|\\")*)"$/
|
||||
* @throws DriverException Step not available when Javascript is disabled
|
||||
* @param string $activityname
|
||||
* @param string $newactivityname
|
||||
*/
|
||||
public function i_change_activity_name_to($activityname, $newactivityname) {
|
||||
|
||||
if (!$this->running_javascript()) {
|
||||
throw new DriverException('Change activity name step is not available with Javascript disabled');
|
||||
}
|
||||
|
||||
// Adding chr(10) to save changes.
|
||||
return array(
|
||||
new Given('I click on "' . get_string('edittitle') . '" "link" in the "' . $activityname .'" activity'),
|
||||
new Given('I fill in "title" with "' . $newactivityname . chr(10) . '"'),
|
||||
new Given('I wait "2" seconds')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indents to the right the activity or resource specified by it's name. Editing mode should be on.
|
||||
*
|
||||
* @Given /^I indent right "(?P<activity_name_string>(?:[^"]|\\")*)" activity$/
|
||||
* @param string $activityname
|
||||
*/
|
||||
public function i_indent_right_activity($activityname) {
|
||||
|
||||
$steps = array(
|
||||
new Given('I click on "' . get_string('moveright') . '" "link" in the "' . $activityname . '" activity')
|
||||
);
|
||||
|
||||
if ($this->running_javascript()) {
|
||||
$steps[] = new Given('I wait "2" seconds');
|
||||
}
|
||||
|
||||
return $steps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indents to the left the activity or resource specified by it's name. Editing mode should be on.
|
||||
*
|
||||
* @Given /^I indent left "(?P<activity_name_string>(?:[^"]|\\")*)" activity$/
|
||||
* @param string $activityname
|
||||
*/
|
||||
public function i_indent_left_activity($activityname) {
|
||||
|
||||
$steps = array(
|
||||
new Given('I click on "' . get_string('moveleft') . '" "link" in the "' . $activityname . '" activity')
|
||||
);
|
||||
|
||||
if ($this->running_javascript()) {
|
||||
$steps[] = new Given('I wait "2" seconds');
|
||||
}
|
||||
|
||||
return $steps;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the activity or resource specified by it's name. You should be in the course page with editing mode on.
|
||||
*
|
||||
* @Given /^I delete "(?P<activity_name_string>(?:[^"]|\\")*)" activity$/
|
||||
* @param string $activityname
|
||||
*/
|
||||
public function i_delete_activity($activityname) {
|
||||
|
||||
$deletestring = get_string('delete');
|
||||
|
||||
// JS enabled.
|
||||
// Not using chain steps here because the exceptions catcher have problems detecting
|
||||
// JS modal windows and avoiding interacting them at the same time.
|
||||
if ($this->running_javascript()) {
|
||||
|
||||
$element = $this->get_activity_element($deletestring, 'link', $activityname);
|
||||
$element->click();
|
||||
|
||||
$this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
|
||||
|
||||
$this->getSession()->wait(2 * 1000, false);
|
||||
|
||||
} else {
|
||||
|
||||
// With JS disabled.
|
||||
$steps = array(
|
||||
new Given('I click on "' . $deletestring . '" "link" in the "' . $activityname . '" activity'),
|
||||
new Given('I press "' . get_string('yes') . '"')
|
||||
);
|
||||
|
||||
return $steps;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicates the activity or resource specified by it's name. You should be in the course page with editing mode on.
|
||||
*
|
||||
* @Given /^I duplicate "(?P<activity_name_string>(?:[^"]|\\")*)" activity$/
|
||||
* @param string $activityname
|
||||
*/
|
||||
public function i_duplicate_activity($activityname) {
|
||||
return array(
|
||||
new Given('I click on "' . get_string('duplicate') . '" "link" in the "' . $activityname . '" activity'),
|
||||
new Given('I press "' . get_string('continue') .'"'),
|
||||
new Given('I press "' . get_string('duplicatecontcourse') .'"')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicates the activity or resource and modifies the new activity with the provided data. You should be in the course page with editing mode on.
|
||||
*
|
||||
* @Given /^I duplicate "(?P<activity_name_string>(?:[^"]|\\")*)" activity editing the new copy with:$/
|
||||
* @param string $activityname
|
||||
* @param TableNode $data
|
||||
*/
|
||||
public function i_duplicate_activity_editing_the_new_copy_with($activityname, TableNode $data) {
|
||||
return array(
|
||||
new Given('I click on "' . get_string('duplicate') . '" "link" in the "' . $activityname . '" activity'),
|
||||
new Given('I press "' . get_string('continue') .'"'),
|
||||
new Given('I press "' . get_string('duplicatecontedit') . '"'),
|
||||
new Given('I fill the moodle form with:', $data),
|
||||
new Given('I press "' . get_string('savechangesandreturntocourse') . '"')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks on the specified element of the activity. You should be in the course page with editing mode turned on.
|
||||
*
|
||||
* @Given /^I click on "(?P<element_string>(?:[^"]|\\")*)" "(?P<selector_string>[^"]*)" in the "(?P<activity_name_string>[^"]*)" activity$/
|
||||
* @param string $element
|
||||
* @param string $selectortype
|
||||
* @param string $activityname
|
||||
*/
|
||||
public function i_click_on_in_the_activity($element, $selectortype, $activityname) {
|
||||
$element = $this->get_activity_element($element, $selectortype, $activityname);
|
||||
$element->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks on the specified element inside the activity container.
|
||||
*
|
||||
* @throws ElementNotFoundException
|
||||
* @param string $element
|
||||
* @param string $selectortype
|
||||
* @param string $activityname
|
||||
* @return NodeElement
|
||||
*/
|
||||
protected function get_activity_element($element, $selectortype, $activityname) {
|
||||
$activitynode = $this->get_activity_node($activityname);
|
||||
|
||||
// Transforming to Behat selector/locator.
|
||||
list($selector, $locator) = $this->transform_selector($selectortype, $element);
|
||||
$exception = new ElementNotFoundException($this->getSession(), '"' . $element . '" "' . $selectortype . '" in "' . $activityname . '" ');
|
||||
|
||||
return $this->find($selector, $locator, $exception, $activitynode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the course section exists.
|
||||
*
|
||||
@@ -415,10 +657,15 @@ class behat_course extends behat_base {
|
||||
$courseformat = $this->get_course_format();
|
||||
|
||||
// Checking the show button alt text and show icon.
|
||||
$xpath = $xpath . "/descendant::a/descendant::img[@alt='". get_string('showfromothers', $courseformat) ."'][contains(@src, 'show')]";
|
||||
$showtext = get_string('showfromothers', $courseformat);
|
||||
$linkxpath = $xpath . "/descendant::a[@title='". $showtext ."']";
|
||||
$imgxpath = $linkxpath . "/descendant::img[@alt='". $showtext ."'][contains(@src, 'show')]";
|
||||
|
||||
$exception = new ElementNotFoundException($this->getSession(), 'Show section icon ');
|
||||
return $this->find('xpath', $xpath, $exception);
|
||||
$this->find('xpath', $imgxpath, $exception);
|
||||
|
||||
// Returing the link so both Non-JS and JS browsers can interact with it.
|
||||
return $this->find('xpath', $linkxpath, $exception);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -437,10 +684,15 @@ class behat_course extends behat_base {
|
||||
$courseformat = $this->get_course_format();
|
||||
|
||||
// Checking the hide button alt text and hide icon.
|
||||
$xpath = $xpath . "/descendant::a/descendant::img[@alt='". get_string('hidefromothers', $courseformat) ."'][contains(@src, 'hide')]";
|
||||
$hidetext = get_string('hidefromothers', $courseformat);
|
||||
$linkxpath = $xpath . "/descendant::a[@title='" . $hidetext . "']";
|
||||
$imgxpath = $linkxpath . "/descendant::img[@alt='" . $hidetext ."'][contains(@src, 'hide')]";
|
||||
|
||||
$exception = new ElementNotFoundException($this->getSession(), 'Hide section icon ');
|
||||
return $this->find('xpath', $xpath, $exception);
|
||||
$this->find('xpath', $imgxpath, $exception);
|
||||
|
||||
// Returing the link so both Non-JS and JS browsers can interact with it.
|
||||
return $this->find('xpath', $linkxpath, $exception);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
@core @core_course
|
||||
Feature: Course activity controls works as expected
|
||||
In order to manage my course's activities
|
||||
As a teacher
|
||||
I need to edit, hide, show and indent activities inside course sections
|
||||
|
||||
# This two scenario outlines contains exactly the same steps, the
|
||||
# only difference is whether JS is enabled or not; we can not use
|
||||
# Background sections when using Scenario Outlines because of Behat
|
||||
# framework restrictions.
|
||||
|
||||
# We are testing:
|
||||
# * Javascript on and off
|
||||
# * Topics and weeks course formats
|
||||
# * Course controls without paged mode
|
||||
# * Course controls with paged mode in the course home page
|
||||
# * Course controls with paged mode in a section's page
|
||||
|
||||
@javascript @_cross_browser
|
||||
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 |
|
||||
| teacher1 | Teacher | 1 | teacher1@asd.com |
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname | format | coursedisplay | numsections |
|
||||
| Course 1 | C1 | <courseformat> | <coursedisplay> | 5 |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
When I follow <targetpage>
|
||||
And I press "Turn editing on"
|
||||
Then I should see "Turn editing off"
|
||||
And I press "Turn editing off"
|
||||
And "Turn editing on" "button" should exists
|
||||
And I follow "Turn editing on"
|
||||
And "Turn editing off" "button" should exists
|
||||
And I follow "Turn editing off"
|
||||
And I should see "Turn editing on"
|
||||
And "Turn editing on" "button" should exists
|
||||
And I turn editing mode on
|
||||
And I click on "Delete Recent activity block" "link"
|
||||
And I press "Yes"
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum name 1 |
|
||||
| Description | Test forum description 1 |
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum name 2 |
|
||||
| Description | Test forum description 2 |
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And I indent right "Test forum name 1" activity
|
||||
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 "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 "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
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And I should not see "Test forum name 1" in the ".region-content" "css_element"
|
||||
And I duplicate "Test forum name 2" activity editing the new copy with:
|
||||
| Forum name | Edited test forum name 2 |
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And I should see "Test forum name 2"
|
||||
And I should see "Edited test forum name 2"
|
||||
And I hide section "1"
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And section "1" should be hidden
|
||||
And I show section "1"
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And section "1" should be visible
|
||||
And I add the "Section links" block
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And I should see "1 2 3 4 5" in the ".block_section_links" "css_element"
|
||||
And I click on "2" "link" in the ".block_section_links" "css_element"
|
||||
And I <should_see_other_sections_following_block_sections_links> see "Test forum name 2"
|
||||
|
||||
Examples:
|
||||
| courseformat | coursedisplay | targetpage | should_see_other_sections | should_see_other_sections_following_block_sections_links |
|
||||
| topics | 0 | "Course 1" | should | should |
|
||||
| topics | 1 | "Topic 1" | should not | should not |
|
||||
| topics | 1 | "Course 1" | should | should not |
|
||||
| weeks | 0 | "Course 1" | should | should |
|
||||
| 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 |
|
||||
| teacher1 | Teacher | 1 | teacher1@asd.com |
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname | format | coursedisplay | numsections |
|
||||
| Course 1 | C1 | <courseformat> | <coursedisplay> | 5 |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
When I follow <targetpage>
|
||||
And I press "Turn editing on"
|
||||
Then I should see "Turn editing off"
|
||||
And I press "Turn editing off"
|
||||
And "Turn editing on" "button" should exists
|
||||
And I follow "Turn editing on"
|
||||
And "Turn editing off" "button" should exists
|
||||
And I follow "Turn editing off"
|
||||
And I should see "Turn editing on"
|
||||
And "Turn editing on" "button" should exists
|
||||
And I turn editing mode on
|
||||
And I click on "Delete Recent activity block" "link"
|
||||
And I press "Yes"
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum name 1 |
|
||||
| Description | Test forum description 1 |
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum name 2 |
|
||||
| Description | Test forum description 2 |
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And I indent right "Test forum name 1" activity
|
||||
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 "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 "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
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And I should not see "Test forum name 1" in the ".region-content" "css_element"
|
||||
And I duplicate "Test forum name 2" activity editing the new copy with:
|
||||
| Forum name | Edited test forum name 2 |
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And I should see "Test forum name 2"
|
||||
And I should see "Edited test forum name 2"
|
||||
And I hide section "1"
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And section "1" should be hidden
|
||||
And I show section "1"
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And section "1" should be visible
|
||||
And I add the "Section links" block
|
||||
And "#section-2" "css_element" <should_see_other_sections> exists
|
||||
And I should see "1 2 3 4 5" in the ".block_section_links" "css_element"
|
||||
And I click on "2" "link" in the ".block_section_links" "css_element"
|
||||
And I <should_see_other_sections_following_block_sections_links> see "Test forum name 2"
|
||||
|
||||
Examples:
|
||||
| courseformat | coursedisplay | targetpage | should_see_other_sections | should_see_other_sections_following_block_sections_links |
|
||||
| topics | 0 | "Course 1" | should | should |
|
||||
| topics | 1 | "Topic 1" | should not | should not |
|
||||
| topics | 1 | "Course 1" | should | should not |
|
||||
| weeks | 0 | "Course 1" | should | should |
|
||||
| weeks | 1 | "1 January - 7 January" | should not | should not |
|
||||
| weeks | 1 | "Course 1" | should | should not |
|
||||
@@ -0,0 +1,73 @@
|
||||
@core @core_course
|
||||
Feature: Activities can be moved between sections
|
||||
In order to rearrange my course contents
|
||||
As a teacher
|
||||
I need to move activities between sections
|
||||
|
||||
Background:
|
||||
Given the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@asd.com |
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname | format | coursedisplay | numsections |
|
||||
| Course 1 | C1 | topics | 0 | 5 |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I follow "Delete Recent activity block"
|
||||
And I press "Yes"
|
||||
And I follow "Configure Navigation block"
|
||||
And I fill the moodle form with:
|
||||
| Visible | Yes |
|
||||
And I press "Save changes"
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum name |
|
||||
| Description | Test forum description |
|
||||
|
||||
@javascript @_cross_browser
|
||||
Scenario: Move activities in a single page course with Javascript enabled
|
||||
When I move "Test forum name" activity to section "2"
|
||||
And I reload the page
|
||||
Then I should see "Test forum name" in the "#section-2" "css_element"
|
||||
And I should not see "Test forum name" in the "#section-1" "css_element"
|
||||
|
||||
@javascript @_cross_browser
|
||||
Scenario: Move activities in the course home with Javascript enabled using paged mode
|
||||
Given I follow "Edit settings"
|
||||
And I fill the moodle form with:
|
||||
| Course layout | Show one section per page |
|
||||
And I press "Save changes"
|
||||
When I move "Test forum name" activity to section "2"
|
||||
# This reload step is added because of drap&drop & yui dd problem
|
||||
And I reload the page
|
||||
Then I should see "Test forum name" in the "#section-2" "css_element"
|
||||
And I should not see "Test forum name" in the "#section-1" "css_element"
|
||||
|
||||
Scenario: Move activities in a single page course with Javascript disabled
|
||||
When I move "Test forum name" activity to section "2"
|
||||
Then I should see "Test forum name" in the "#section-2" "css_element"
|
||||
And I should not see "Test forum name" in the "#section-1" "css_element"
|
||||
|
||||
Scenario: Move activities in the course home with Javascript disabled using paged mode
|
||||
Given I follow "Edit settings"
|
||||
And I fill the moodle form with:
|
||||
| Course layout | Show one section per page |
|
||||
And I press "Save changes"
|
||||
When I move "Test forum name" activity to section "2"
|
||||
Then I should see "Test forum name" in the "#section-2" "css_element"
|
||||
And I should not see "Test forum name" in the "#section-1" "css_element"
|
||||
|
||||
Scenario: Move activities in a course section with Javascript disabled using paged mode
|
||||
Given I follow "Edit settings"
|
||||
And I fill the moodle form with:
|
||||
| Course layout | Show one section per page |
|
||||
And I press "Save changes"
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Second forum name |
|
||||
| Description | Second forum description |
|
||||
And I follow "Topic 1"
|
||||
When I move "Second forum name" activity to section "1"
|
||||
Then "Second forum name" "link" should appear before "Test forum name" "link"
|
||||
@@ -0,0 +1,55 @@
|
||||
@core @core_course
|
||||
Feature: Sections can be moved
|
||||
In order to rearrange my course contents
|
||||
As a teacher
|
||||
I need to move sections up and down
|
||||
|
||||
Background:
|
||||
Given the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@asd.com |
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname | format | coursedisplay | numsections |
|
||||
| Course 1 | C1 | topics | 0 | 5 |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
|
||||
Scenario: Move up and down a section with Javascript disabled in a single page course
|
||||
Given I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum name |
|
||||
| Description | Test forum description |
|
||||
When I move down section "1"
|
||||
Then I should see "Test forum name" in the "#section-2" "css_element"
|
||||
And I move up section "2"
|
||||
And I should see "Test forum name" in the "#section-1" "css_element"
|
||||
|
||||
Scenario: Move up and down a section with Javascript disabled in the course home of a course using paged mode
|
||||
Given I follow "Edit settings"
|
||||
And I fill the moodle form with:
|
||||
| Course layout | Show one section per page |
|
||||
And I press "Save changes"
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum name |
|
||||
| Description | Test forum description |
|
||||
When I move down section "1"
|
||||
Then I should see "Test forum name" in the "#section-2" "css_element"
|
||||
And I move up section "2"
|
||||
And I should see "Test forum name" in the "#section-1" "css_element"
|
||||
|
||||
Scenario: Sections can not be moved with Javascript disabled in a section page of a course using paged mode
|
||||
Given I follow "Edit settings"
|
||||
And I fill the moodle form with:
|
||||
| Course layout | Show one section per page |
|
||||
And I press "Save changes"
|
||||
And I add a "Forum" to section "2" and I fill the form with:
|
||||
| Forum name | Test forum name |
|
||||
| Description | Test forum description |
|
||||
When I follow "Topic 2"
|
||||
Then "#section-1" "css_element" should not exists
|
||||
And "#section-3" "css_element" should not exists
|
||||
And "Move down" "link" should not exists
|
||||
And "Move up" "link" should not exists
|
||||
@@ -5,14 +5,14 @@ Feature: Topic's course sections highlighting
|
||||
I need to highlight one specific section
|
||||
|
||||
@javascript
|
||||
Scenario: Highlight a topic's course section
|
||||
Scenario Outline: Highlight a topic's course section with course paged mode and without it
|
||||
Given the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@asd.com |
|
||||
| student1 | Student | 1 | student1@asd.com |
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | topics |
|
||||
| fullname | shortname | format | coursedisplay |
|
||||
| Course 1 | C1 | topics | <coursedisplay> |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
@@ -41,3 +41,8 @@ Feature: Topic's course sections highlighting
|
||||
And I follow "Course 1"
|
||||
And section "1" should not be highlighted
|
||||
And section "2" should not be highlighted
|
||||
|
||||
Examples:
|
||||
| coursedisplay |
|
||||
| 0 |
|
||||
| 1 |
|
||||
|
||||
@@ -49,6 +49,13 @@ class behat_form_select extends behat_form_field {
|
||||
// Adding a click as Selenium requires it to fire some JS events.
|
||||
if ($this->running_javascript()) {
|
||||
|
||||
// In some browsers the selectOption actions can perform a page reload
|
||||
// so we need to ensure the element is still available to continue interacting
|
||||
// with it. We don't wait here.
|
||||
if (!$this->session->getDriver()->find($this->field->getXpath())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Single select needs an extra click in the option.
|
||||
if (!$this->field->hasAttribute('multiple')) {
|
||||
// Using the driver direcly because Element methods are messy when dealing
|
||||
|
||||
@@ -179,6 +179,13 @@ class behat_forms extends behat_base {
|
||||
// Adding a click as Selenium requires it to fire some JS events.
|
||||
if ($this->running_javascript()) {
|
||||
|
||||
// In some browsers the selectOption actions can perform a page reload
|
||||
// so we need to ensure the element is still available to continue interacting
|
||||
// with it. We don't wait here.
|
||||
if (!$this->getSession()->getDriver()->find($selectnode->getXpath())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$selectnode->hasAttribute('multiple')) {
|
||||
// Single select needs an extra click in the option.
|
||||
$xpath = ".//option[(./@value = '" . $option . "' or contains(normalize-space(string(.)), '" . $option . "'))]";
|
||||
|
||||
@@ -82,6 +82,14 @@ class behat_general extends behat_base {
|
||||
$this->getSession()->switchToWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts the currently displayed alert dialog.
|
||||
* @Given /^I accept the currently displayed dialog$/
|
||||
*/
|
||||
public function accept_currently_displayed_alert_dialog() {
|
||||
$this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks link with specified id|title|alt|text.
|
||||
*
|
||||
@@ -179,6 +187,30 @@ class behat_general extends behat_base {
|
||||
$elementnode->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Drags and drops the specified element to the specified container. This step is experimental.
|
||||
*
|
||||
* The steps definitions calling this step as part of them should
|
||||
* manage the wait times by themselves as the times and when the
|
||||
* waits should be done depends on what is being dragged & dropper.
|
||||
*
|
||||
* @Given /^I drag "(?P<element_string>(?:[^"]|\\")*)" "(?P<selector1_string>(?:[^"]|\\")*)" and I drop it in "(?P<container_element_string>(?:[^"]|\\")*)" "(?P<selector2_string>(?:[^"]|\\")*)"$/
|
||||
* @param string $element
|
||||
* @param string $selectortype
|
||||
* @param string $containerelement
|
||||
* @param string $containerselectortype
|
||||
*/
|
||||
public function i_drag_and_i_drop_it_in($element, $selectortype, $containerelement, $containerselectortype) {
|
||||
|
||||
list($sourceselector, $sourcelocator) = $this->transform_selector($selectortype, $element);
|
||||
$sourcexpath = $this->getSession()->getSelectorsHandler()->selectorToXpath($sourceselector, $sourcelocator);
|
||||
|
||||
list($containerselector, $containerlocator) = $this->transform_selector($containerselectortype, $containerelement);
|
||||
$destinationxpath = $this->getSession()->getSelectorsHandler()->selectorToXpath($containerselector, $containerlocator);
|
||||
|
||||
$this->getSession()->getDriver()->dragTo($sourcexpath, $destinationxpath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks, that page contains specified text.
|
||||
*
|
||||
|
||||
@@ -208,48 +208,55 @@ class behat_hooks extends behat_base {
|
||||
*/
|
||||
public function i_look_for_exceptions() {
|
||||
|
||||
// Exceptions.
|
||||
if ($errormsg = $this->getSession()->getPage()->find('css', '.errorbox p.errormessage')) {
|
||||
// Wrap in try in case we were interacting with a closed window.
|
||||
try {
|
||||
|
||||
// Getting the debugging info and the backtrace.
|
||||
$errorinfoboxes = $this->getSession()->getPage()->findAll('css', 'div.notifytiny');
|
||||
$errorinfo = $this->get_debug_text($errorinfoboxes[0]->getHtml()) . "\n" .
|
||||
$this->get_debug_text($errorinfoboxes[1]->getHtml());
|
||||
// Exceptions.
|
||||
if ($errormsg = $this->getSession()->getPage()->find('css', '.errorbox p.errormessage')) {
|
||||
|
||||
$msg = "Moodle exception: " . $errormsg->getText() . "\n" . $errorinfo;
|
||||
throw new \Exception(html_entity_decode($msg));
|
||||
}
|
||||
// Getting the debugging info and the backtrace.
|
||||
$errorinfoboxes = $this->getSession()->getPage()->findAll('css', 'div.notifytiny');
|
||||
$errorinfo = $this->get_debug_text($errorinfoboxes[0]->getHtml()) . "\n" .
|
||||
$this->get_debug_text($errorinfoboxes[1]->getHtml());
|
||||
|
||||
// Debugging messages.
|
||||
if ($debuggingmessages = $this->getSession()->getPage()->findAll('css', '.debuggingmessage')) {
|
||||
$msgs = array();
|
||||
foreach ($debuggingmessages as $debuggingmessage) {
|
||||
$msgs[] = $this->get_debug_text($debuggingmessage->getHtml());
|
||||
$msg = "Moodle exception: " . $errormsg->getText() . "\n" . $errorinfo;
|
||||
throw new \Exception(html_entity_decode($msg));
|
||||
}
|
||||
$msg = "debugging() message/s found:\n" . implode("\n", $msgs);
|
||||
throw new \Exception(html_entity_decode($msg));
|
||||
}
|
||||
|
||||
// PHP debug messages.
|
||||
if ($phpmessages = $this->getSession()->getPage()->findAll('css', '.phpdebugmessage')) {
|
||||
|
||||
$msgs = array();
|
||||
foreach ($phpmessages as $phpmessage) {
|
||||
$msgs[] = $this->get_debug_text($phpmessage->getHtml());
|
||||
// Debugging messages.
|
||||
if ($debuggingmessages = $this->getSession()->getPage()->findAll('css', '.debuggingmessage')) {
|
||||
$msgs = array();
|
||||
foreach ($debuggingmessages as $debuggingmessage) {
|
||||
$msgs[] = $this->get_debug_text($debuggingmessage->getHtml());
|
||||
}
|
||||
$msg = "debugging() message/s found:\n" . implode("\n", $msgs);
|
||||
throw new \Exception(html_entity_decode($msg));
|
||||
}
|
||||
$msg = "PHP debug message/s found:\n" . implode("\n", $msgs);
|
||||
throw new \Exception(html_entity_decode($msg));
|
||||
}
|
||||
|
||||
// Any other backtrace.
|
||||
$backtracespattern = '/(line [0-9]* of [^:]*: call to [\->&;:a-zA-Z_\x7f-\xff][\->&;:a-zA-Z0-9_\x7f-\xff]*)/';
|
||||
if (preg_match_all($backtracespattern, $this->getSession()->getPage()->getContent(), $backtraces)) {
|
||||
$msgs = array();
|
||||
foreach ($backtraces[0] as $backtrace) {
|
||||
$msgs[] = $backtrace . '()';
|
||||
// PHP debug messages.
|
||||
if ($phpmessages = $this->getSession()->getPage()->findAll('css', '.phpdebugmessage')) {
|
||||
|
||||
$msgs = array();
|
||||
foreach ($phpmessages as $phpmessage) {
|
||||
$msgs[] = $this->get_debug_text($phpmessage->getHtml());
|
||||
}
|
||||
$msg = "PHP debug message/s found:\n" . implode("\n", $msgs);
|
||||
throw new \Exception(html_entity_decode($msg));
|
||||
}
|
||||
$msg = "Other backtraces found:\n" . implode("\n", $msgs);
|
||||
throw new \Exception(htmlentities($msg));
|
||||
|
||||
// Any other backtrace.
|
||||
$backtracespattern = '/(line [0-9]* of [^:]*: call to [\->&;:a-zA-Z_\x7f-\xff][\->&;:a-zA-Z0-9_\x7f-\xff]*)/';
|
||||
if (preg_match_all($backtracespattern, $this->getSession()->getPage()->getContent(), $backtraces)) {
|
||||
$msgs = array();
|
||||
foreach ($backtraces[0] as $backtrace) {
|
||||
$msgs[] = $backtrace . '()';
|
||||
}
|
||||
$msg = "Other backtraces found:\n" . implode("\n", $msgs);
|
||||
throw new \Exception(htmlentities($msg));
|
||||
}
|
||||
|
||||
} catch (NoSuchWindow $e) {
|
||||
// If we were interacting with a popup window it will not exists after closing it.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user