MDL-71691 core_behat: behat fixes for changed course design
This commit is contained in:
@@ -102,8 +102,8 @@ Feature: display_availability
|
||||
And I log in as "student1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
# Page 1 display still there but should be dimmed and not a link.
|
||||
Then I should see "Page 1" in the "#section-1 .dimmed_text" "css_element"
|
||||
# Page 1 display still there but should not be a link.
|
||||
Then I should see "Page 1" in the "#section-1" "css_element"
|
||||
And ".activity-instance a" "css_element" should not exist in the "Topic 1" "section"
|
||||
|
||||
# Date display should be present.
|
||||
|
||||
@@ -41,7 +41,6 @@ Feature: Restrict activity availability through date conditions
|
||||
When I am on the "Course 1" course page logged in as student1
|
||||
Then I should see "Available from 31 December 2037"
|
||||
And "Test assignment 1" "link" should not exist in the "page" "region"
|
||||
And "Test assignment 1" activity should be dimmed
|
||||
|
||||
@javascript
|
||||
Scenario: Show activity hidden to students when available until date is in past
|
||||
|
||||
@@ -44,7 +44,7 @@ Feature: Restrict activity availability through grade conditions
|
||||
|
||||
When I am on the "Course 1" course page logged in as student1
|
||||
Then I should see "Not available unless: You achieve a required score in Grade assignment"
|
||||
And "Test page name" activity should be dimmed
|
||||
And I should see "Test page name"
|
||||
And "Test page name" "link" should not exist
|
||||
And I am on the "Grade assignment" "assign activity" page
|
||||
And I press "Add submission"
|
||||
|
||||
@@ -34,7 +34,7 @@ Feature: Edit activity name in-place
|
||||
And I should see "Good news"
|
||||
And I should not see "Test forum name"
|
||||
# Cancel renaming
|
||||
And I click on "Edit title" "link" in the "//div[contains(@class,'activityinstance') and contains(.,'Good news')]" "xpath_element"
|
||||
And I click on "Edit title" "link" in the "[data-value='Good news']" "css_element"
|
||||
And I type "Terrible news"
|
||||
And I press the escape key
|
||||
And "New name for activity Good news" "field" should not exist
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
@core @core_course @_cross_browser
|
||||
Feature: Toggle activities groups mode from the course page
|
||||
In order to split activities in groups
|
||||
As a teacher
|
||||
I need to change quickly the group mode of an activity
|
||||
|
||||
@javascript
|
||||
Scenario: Groups mode toggle with javascript enabled
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | topics |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum name |
|
||||
| Description | Test forum description |
|
||||
And I navigate to "Settings" in current page administration
|
||||
And I set the following fields to these values:
|
||||
| Group mode | No groups |
|
||||
| Force group mode | No |
|
||||
When I press "Save and display"
|
||||
Then "No groups (Click to change)" "link" should exist
|
||||
And I click on "No groups (Click to change)" "link" in the "Test forum name" activity
|
||||
And "Separate groups (Click to change)" "link" should exist
|
||||
And I reload the page
|
||||
And "Separate groups (Click to change)" "link" should exist
|
||||
And I click on "Separate groups (Click to change)" "link" in the "Test forum name" activity
|
||||
And "Visible groups (Click to change)" "link" should exist
|
||||
And I reload the page
|
||||
And "Visible groups (Click to change)" "link" should exist
|
||||
And I click on "Visible groups (Click to change)" "link" in the "Test forum name" activity
|
||||
And "No groups (Click to change)" "link" should exist
|
||||
@@ -408,7 +408,7 @@ class behat_course extends behat_base {
|
||||
|
||||
// Click on un-highlight topic link.
|
||||
$this->execute('behat_general::i_click_on_in_the',
|
||||
array($stredit, "link", "#section-" . $sectionnumber, "css_element")
|
||||
array($stredit, "link", "#section-" . $sectionnumber . " .action-menu", "css_element")
|
||||
);
|
||||
|
||||
}
|
||||
@@ -515,11 +515,10 @@ class behat_course extends behat_base {
|
||||
// If there are activities they should be hidden and the visibility icon should not be available.
|
||||
if ($activities = $this->get_section_activities($sectionxpath)) {
|
||||
|
||||
$dimmedexception = new ExpectationException('There are activities that are not dimmed', $this->getSession());
|
||||
$dimmedexception = new ExpectationException('There are activities that are not hidden', $this->getSession());
|
||||
foreach ($activities as $activity) {
|
||||
// Dimmed.
|
||||
$this->find('xpath', "//div[contains(concat(' ', normalize-space(@class), ' '), ' activityinstance ')]" .
|
||||
"//a[contains(concat(' ', normalize-space(@class), ' '), ' dimmed ')]", $dimmedexception, $activity);
|
||||
// Hidden from students.
|
||||
$this->find('named_partial', array('badge', get_string('hiddenfromstudents')), $dimmedexception, $activity);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -625,11 +624,9 @@ class behat_course extends behat_base {
|
||||
|
||||
if ($this->is_course_editor()) {
|
||||
|
||||
// The activity should not be dimmed.
|
||||
// The activity should not be hidden from students.
|
||||
try {
|
||||
$xpath = "/descendant-or-self::a[contains(concat(' ', normalize-space(@class), ' '), ' dimmed ')] | ".
|
||||
"/descendant-or-self::div[contains(concat(' ', normalize-space(@class), ' '), ' dimmed_text ')]";
|
||||
$this->find('xpath', $xpath, false, $activitynode);
|
||||
$this->find('named_partial', array('badge', get_string('hiddenfromstudents')), null, $activitynode);
|
||||
throw new ExpectationException('"' . $activityname . '" is hidden', $this->getSession());
|
||||
} catch (ElementNotFoundException $e) {
|
||||
// All ok.
|
||||
@@ -660,20 +657,17 @@ class behat_course extends behat_base {
|
||||
// The activity must exists and be visible.
|
||||
$activitynode = $this->get_activity_node($activityname);
|
||||
|
||||
// The activity should not be dimmed.
|
||||
// Should not have the "Hidden from students" badge.
|
||||
try {
|
||||
$xpath = "/descendant-or-self::a[contains(concat(' ', normalize-space(@class), ' '), ' dimmed ')] | " .
|
||||
"/descendant-or-self::div[contains(concat(' ', normalize-space(@class), ' '), ' dimmed_text ')]";
|
||||
$this->find('xpath', $xpath, false, $activitynode);
|
||||
$this->find('named_partial', array('badge', get_string('hiddenfromstudents')), null, $activitynode);
|
||||
throw new ExpectationException('"' . $activityname . '" is hidden', $this->getSession());
|
||||
} catch (ElementNotFoundException $e) {
|
||||
// All ok.
|
||||
}
|
||||
|
||||
// Should has "stealth" class.
|
||||
$exception = new ExpectationException('"' . $activityname . '" does not have CSS class "stealth"', $this->getSession());
|
||||
$xpath = "/descendant-or-self::a[contains(concat(' ', normalize-space(@class), ' '), ' stealth ')]";
|
||||
$this->find('xpath', $xpath, $exception, $activitynode);
|
||||
// Should have the "Available but not shown on course page" badge.
|
||||
$exception = new ExpectationException('"' . $activityname . '" is not Available', $this->getSession());
|
||||
$this->find('named_partial', array('badge', get_string('hiddenoncoursepage')), $exception, $activitynode);
|
||||
|
||||
// Additional check if this is a teacher in editing mode.
|
||||
if ($this->is_editing_on()) {
|
||||
@@ -712,10 +706,8 @@ class behat_course extends behat_base {
|
||||
$activitynode = $this->get_activity_node($activityname);
|
||||
|
||||
// Should be hidden.
|
||||
$exception = new ExpectationException('"' . $activityname . '" is not dimmed', $this->getSession());
|
||||
$xpath = "/descendant-or-self::a[contains(concat(' ', normalize-space(@class), ' '), ' dimmed ')] | ".
|
||||
"/descendant-or-self::div[contains(concat(' ', normalize-space(@class), ' '), ' dimmed_text ')]";
|
||||
$this->find('xpath', $xpath, $exception, $activitynode);
|
||||
$exception = new ExpectationException('"' . $activityname . '" is not hidden', $this->getSession());
|
||||
$this->find('named_partial', array('badge', get_string('hiddenfromstudents')), $exception, $activitynode);
|
||||
|
||||
// Additional check if this is a teacher in editing mode.
|
||||
if ($this->is_editing_on()) {
|
||||
@@ -742,23 +734,21 @@ class behat_course extends behat_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the specified activity is dimmed. You need to be in the course page.
|
||||
* Checks that the specified label is hidden from students. You need to be in the course page.
|
||||
*
|
||||
* @Then /^"(?P<activity_or_resource_string>(?:[^"]|\\")*)" activity should be dimmed$/
|
||||
* @Then /^"(?P<activity_or_resource_string>(?:[^"]|\\")*)" label should be hidden$/
|
||||
* @param string $activityname
|
||||
* @throws ExpectationException
|
||||
*/
|
||||
public function activity_should_be_dimmed($activityname) {
|
||||
|
||||
// The activity should exist.
|
||||
$activitynode = $this->get_activity_node($activityname);
|
||||
|
||||
// Should be hidden.
|
||||
$exception = new ExpectationException('"' . $activityname . '" is not dimmed', $this->getSession());
|
||||
$xpath = "/descendant-or-self::a[contains(concat(' ', normalize-space(@class), ' '), ' dimmed ')] | ".
|
||||
"/descendant-or-self::div[contains(concat(' ', normalize-space(@class), ' '), ' dimmed_text ')]";
|
||||
$this->find('xpath', $xpath, $exception, $activitynode);
|
||||
public function label_should_be_hidden($activityname) {
|
||||
if ($this->is_course_editor()) {
|
||||
// The activity should exist.
|
||||
$activitynode = $this->get_activity_node($activityname);
|
||||
|
||||
// Should be hidden.
|
||||
$exception = new ExpectationException('"' . $activityname . '" is not hidden', $this->getSession());
|
||||
$this->find('named_partial', array('badge', get_string('hiddenfromstudents')), $exception, $activitynode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2006,8 +1996,8 @@ class behat_course extends behat_base {
|
||||
* @param string $text The text to be searched in the activity date.
|
||||
*/
|
||||
public function activity_date_in_activity_should_contain_text(string $activityname, string $text): void {
|
||||
$containerselector = "//div[@data-region='activity-information'][@data-activityname='$activityname']";
|
||||
$containerselector .= " /div[@data-region='activity-dates']";
|
||||
$containerselector = "//div[@data-activityname='$activityname']";
|
||||
$containerselector .= "//div[@data-region='activity-dates']";
|
||||
|
||||
$params = [$text, $containerselector, 'xpath_element'];
|
||||
$this->execute("behat_general::assert_element_contains_text", $params);
|
||||
@@ -2020,8 +2010,8 @@ class behat_course extends behat_base {
|
||||
* @param string $activityname The activity name.
|
||||
*/
|
||||
public function activity_dates_information_in_activity_should_exist(string $activityname): void {
|
||||
$containerselector = "//div[@data-region='activity-information'][@data-activityname='$activityname']";
|
||||
$elementselector = "/div[@data-region='activity-dates']";
|
||||
$containerselector = "//div[@data-activityname='$activityname']";
|
||||
$elementselector = "//div[@data-region='activity-dates']";
|
||||
$params = [$elementselector, "xpath_element", $containerselector, "xpath_element"];
|
||||
$this->execute("behat_general::should_exist_in_the", $params);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ Feature: Collapse course sections
|
||||
And I should see "Available until" in the "#section-4 .availabilityinfo" "css_element"
|
||||
And I should see "2013" in the "#section-4 .availabilityinfo" "css_element"
|
||||
And I should not see "Forum 4"
|
||||
And I should see "Not available" in the "#section-5 .availabilityinfo" "css_element"
|
||||
And I should see "Not available" in the "#section-5" "css_element"
|
||||
And I should not see "Forum 5"
|
||||
When I click on "#collapssesection3" "css_element"
|
||||
And I should see "Assignment 1" in the "region-main" "region"
|
||||
@@ -84,7 +84,6 @@ Feature: Collapse course sections
|
||||
And I should not see "Book 2" in the "region-main" "region"
|
||||
And I should not see "Book 3" in the "region-main" "region"
|
||||
And I should not see "Available until" in the "#section-4 .availabilityinfo" "css_element"
|
||||
And I should not see "Not available" in the "#section-5 .availabilityinfo" "css_element"
|
||||
And I click on "#collapssesection1" "css_element"
|
||||
And I click on "#collapssesection2" "css_element"
|
||||
And I click on "#collapssesection3" "css_element"
|
||||
@@ -95,7 +94,6 @@ Feature: Collapse course sections
|
||||
And I should see "Book 2" in the "region-main" "region"
|
||||
And I should see "Book 3" in the "region-main" "region"
|
||||
And I should see "Available until" in the "#section-4 .availabilityinfo" "css_element"
|
||||
And I should see "Not available" in the "#section-5 .availabilityinfo" "css_element"
|
||||
|
||||
@javascript
|
||||
Scenario: Expand/collapse sections for Weeks format.
|
||||
@@ -113,7 +111,7 @@ Feature: Collapse course sections
|
||||
And I should see "Available until" in the "#section-4 .availabilityinfo" "css_element"
|
||||
And I should see "2013" in the "#section-4 .availabilityinfo" "css_element"
|
||||
And I should see "Forum 4"
|
||||
And I should see "Hidden from students" in the "#section-5 .availabilityinfo" "css_element"
|
||||
And I should see "Hidden from students" in the "#section-5" "css_element"
|
||||
And I should see "Forum 5"
|
||||
When I click on "#collapssesection3" "css_element"
|
||||
And I should see "Assignment 1" in the "region-main" "region"
|
||||
@@ -129,7 +127,7 @@ Feature: Collapse course sections
|
||||
And I should not see "Book 2" in the "region-main" "region"
|
||||
And I should not see "Book 3" in the "region-main" "region"
|
||||
And I should not see "Available until" in the "#section-4 .availabilityinfo" "css_element"
|
||||
And I should not see "Not available" in the "#section-5 .availabilityinfo" "css_element"
|
||||
And I should not see "Not available" in the "#section-5" "css_element"
|
||||
And I click on "#collapssesection1" "css_element"
|
||||
And I click on "#collapssesection2" "css_element"
|
||||
And I click on "#collapssesection3" "css_element"
|
||||
@@ -142,7 +140,7 @@ Feature: Collapse course sections
|
||||
And I should see "Available until" in the "#section-4 .availabilityinfo" "css_element"
|
||||
And I should see "2013" in the "#section-4 .availabilityinfo" "css_element"
|
||||
And I should see "Forum 4"
|
||||
And I should see "Hidden from students" in the "#section-5 .availabilityinfo" "css_element"
|
||||
And I should see "Hidden from students" in the "#section-5" "css_element"
|
||||
And I should see "Forum 5"
|
||||
|
||||
@javascript
|
||||
@@ -164,7 +162,7 @@ Feature: Collapse course sections
|
||||
And I should see "Available until" in the "#section-4 .availabilityinfo" "css_element"
|
||||
And I should see "2013" in the "#section-4 .availabilityinfo" "css_element"
|
||||
And I should see "Forum 4"
|
||||
And I should see "Hidden from students" in the "#section-5 .availabilityinfo" "css_element"
|
||||
And I should see "Hidden from students" in the "#section-5" "css_element"
|
||||
And I should see "Forum 5"
|
||||
|
||||
@javascript
|
||||
@@ -189,5 +187,5 @@ Feature: Collapse course sections
|
||||
And I should see "Available until" in the "#section-4 .availabilityinfo" "css_element"
|
||||
And I should see "2013" in the "#section-4 .availabilityinfo" "css_element"
|
||||
And I should not see "Forum 4"
|
||||
And I should see "Not available" in the "#section-5 .availabilityinfo" "css_element"
|
||||
And I should see "Not available" in the "#section-5" "css_element"
|
||||
And I should not see "Forum 5"
|
||||
|
||||
@@ -86,6 +86,7 @@ class behat_partial_named_selector extends \Behat\Mink\Selector\PartialNamedSele
|
||||
*/
|
||||
protected static $allowedselectors = array(
|
||||
'activity' => 'activity',
|
||||
'badge' => 'badge',
|
||||
'block' => 'block',
|
||||
'button' => 'button',
|
||||
'checkbox' => 'checkbox',
|
||||
@@ -136,6 +137,9 @@ class behat_partial_named_selector extends \Behat\Mink\Selector\PartialNamedSele
|
||||
protected static $moodleselectors = array(
|
||||
'activity' => <<<XPATH
|
||||
.//li[contains(concat(' ', normalize-space(@class), ' '), ' activity ')][descendant::*[contains(normalize-space(.), %locator%)]]
|
||||
XPATH
|
||||
, 'badge' => <<<XPATH
|
||||
.//span[(contains(@class, 'badge')) and text()[contains(., %locator%)]]
|
||||
XPATH
|
||||
, 'block' => <<<XPATH
|
||||
.//*[@data-block][contains(concat(' ', normalize-space(@class), ' '), concat(' ', %locator%, ' ')) or
|
||||
|
||||
@@ -6,37 +6,37 @@ Feature: Display the book description in the book and optionally in the course
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | topics |
|
||||
| Course 1 | C1 | topics |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And the following "activities" exist:
|
||||
| activity | name | intro | course | idnumber | section |
|
||||
| book | Test book | A book about dreams! | C1 | book1 | 1 |
|
||||
And I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test book"
|
||||
And I am on the "Test book" "book activity" page
|
||||
And I should see "Add new chapter"
|
||||
And I set the following fields to these values:
|
||||
| Chapter title | Dummy first chapter |
|
||||
| Content | Dream is the start of a journey |
|
||||
| Chapter title | Dummy first chapter |
|
||||
| Content | Dream is the start of a journey |
|
||||
And I press "Save changes"
|
||||
|
||||
Scenario: Description is displayed in the book
|
||||
Given I am on "Course 1" course homepage
|
||||
When I follow "Test book"
|
||||
When I am on the "Test book" "book activity" page
|
||||
Then I should see "A book about dreams!"
|
||||
|
||||
Scenario: Show book description in the course homepage
|
||||
Given I am on "Course 1" course homepage
|
||||
And I follow "Test book"
|
||||
And I am on the "Test book" "book activity" page
|
||||
And I navigate to "Settings" in current page administration
|
||||
And the following fields match these values:
|
||||
| Display description on course page | |
|
||||
| Display description on course page | |
|
||||
And I set the following fields to these values:
|
||||
| Display description on course page | 1 |
|
||||
And I press "Save and return to course"
|
||||
@@ -45,10 +45,10 @@ Feature: Display the book description in the book and optionally in the course
|
||||
|
||||
Scenario: Hide book description in the course homepage
|
||||
Given I am on "Course 1" course homepage
|
||||
And I follow "Test book"
|
||||
And I am on the "Test book" "book activity" page
|
||||
And I navigate to "Settings" in current page administration
|
||||
And the following fields match these values:
|
||||
| Display description on course page | |
|
||||
| Display description on course page | |
|
||||
And I press "Save and return to course"
|
||||
When I am on "Course 1" course homepage
|
||||
Then I should not see "A book about dreams!"
|
||||
|
||||
@@ -109,7 +109,7 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos
|
||||
When I log in as "student1"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "1 unread post"
|
||||
And I follow "1 unread post"
|
||||
And I am on the "Test forum name" "forum activity" page
|
||||
And I should not see "Don't track unread posts"
|
||||
And I follow "Test post subject"
|
||||
And I am on "Course 1" course homepage
|
||||
@@ -135,7 +135,7 @@ Feature: A teacher can set one of 3 possible options for tracking read forum pos
|
||||
When I log in as "student2"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "1 unread post"
|
||||
And I follow "1 unread post"
|
||||
And I am on the "Test forum name" "forum activity" page
|
||||
And I should not see "Don't track unread posts"
|
||||
And I follow "Test post subject"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
@@ -23,9 +23,9 @@ Feature: Check label visibility works
|
||||
When I add a "label" to section "1" and I fill the form with:
|
||||
| Label text | Swanky label |
|
||||
| Availability | Hide from students |
|
||||
Then "Swanky label" activity should be hidden
|
||||
Then "Swanky label" label should be hidden
|
||||
And I turn editing mode off
|
||||
And "Swanky label" activity should be hidden
|
||||
And "Swanky label" label should be hidden
|
||||
And I log out
|
||||
And I log in as "student"
|
||||
And I am on "Test" course homepage
|
||||
@@ -76,7 +76,7 @@ Feature: Check label visibility works
|
||||
| Label text | Swanky label |
|
||||
| Availability | Show on course page |
|
||||
And I hide section "1"
|
||||
Then "Swanky label" activity should be dimmed
|
||||
Then "Swanky label" label should be hidden
|
||||
And I open "Swanky label" actions menu
|
||||
And "Swanky label" actions menu should not have "Show" item
|
||||
And "Swanky label" actions menu should not have "Hide" item
|
||||
|
||||
Reference in New Issue
Block a user