mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-75837 core_grades: Modify the search widget behat step definitions
This commit is contained in:
parent
24d0beacc7
commit
c501d1ac97
@ -426,38 +426,61 @@ class behat_grade extends behat_base {
|
||||
* Confirm if a value is within the search widget within the gradebook.
|
||||
*
|
||||
* Examples:
|
||||
* - I confirm "User1" in "User" search within the gradebook widget exists
|
||||
* - I confirm "User" in "user" search within the gradebook widget exists
|
||||
* - I confirm "Group" in "group" search within the gradebook widget exists
|
||||
* - I confirm "Grade item" in "grade" search within the gradebook widget exists
|
||||
*
|
||||
* @Given /^I confirm "(?P<needle>(?:[^"]|\\")*)" in "(?P<haystack>(?:[^"]|\\")*)" search within the gradebook widget exists$/
|
||||
* @param string $needle The value to search for.
|
||||
* @param string $haystack The selector to use within the zero state.
|
||||
* @param string $haystack The type of the search widget.
|
||||
*/
|
||||
public function i_confirm_in_search_within_the_gradebook_widget_exists($needle, $haystack) {
|
||||
$this->execute("behat_general::wait_until_exists", [$haystack, "dialogue"]);
|
||||
$this->execute("behat_general::assert_element_contains_text", [$needle, $haystack, "dialogue"]);
|
||||
$triggercssselector = ".search-widget[data-searchtype='{$haystack}']";
|
||||
|
||||
// Make sure that the dropdown menu is visible.
|
||||
$node = $this->find("css_element", "{$triggercssselector} .dropdown-menu");
|
||||
if (!$node->isVisible()) {
|
||||
$this->execute("behat_general::i_click_on", [$triggercssselector, "css_element"]);
|
||||
}
|
||||
|
||||
$this->execute("behat_general::wait_until_the_page_is_ready");
|
||||
$this->execute("behat_general::assert_element_contains_text",
|
||||
[$needle, "{$triggercssselector} .dropdown-menu", "css_element"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm if a value is not within the search widget within the gradebook.
|
||||
*
|
||||
* Examples:
|
||||
* - I confirm "User1" in "User" search within the gradebook widget does not exist
|
||||
* - I confirm "User" in "user" search within the gradebook widget does not exist
|
||||
* - I confirm "Group" in "group" search within the gradebook widget does not exist
|
||||
* - I confirm "Grade item" in "grade" search within the gradebook widget does not exist
|
||||
*
|
||||
* @Given /^I confirm "(?P<needle>(?:[^"]|\\")*)" in "(?P<haystack>(?:[^"]|\\")*)" search within the gradebook widget does not exist$/
|
||||
* @param string $needle The value to search for.
|
||||
* @param string $haystack The selector to use within the zero state.
|
||||
* @param string $haystack The type of the search widget.
|
||||
*/
|
||||
public function i_confirm_in_search_within_the_gradebook_widget_does_not_exist($needle, $haystack) {
|
||||
$this->execute("behat_general::wait_until_exists", [$haystack, "dialogue"]);
|
||||
$this->execute("behat_general::assert_element_not_contains_text", [$needle, $haystack, "dialogue"]);
|
||||
$triggercssselector = ".search-widget[data-searchtype='{$haystack}']";
|
||||
|
||||
// Make sure that the dropdown menu is visible.
|
||||
$node = $this->find("css_element", "{$triggercssselector} .dropdown-menu");
|
||||
if (!$node->isVisible()) {
|
||||
$this->execute("behat_general::i_click_on", [$triggercssselector, "css_element"]);
|
||||
}
|
||||
|
||||
$this->execute("behat_general::wait_until_the_page_is_ready");
|
||||
$this->execute("behat_general::assert_element_not_contains_text",
|
||||
[$needle, "{$triggercssselector} .dropdown-menu", "css_element"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks on an option from the specified search widget in the current gradebook page.
|
||||
*
|
||||
* Examples:
|
||||
* - I click on "Student1" in the "user" search widget
|
||||
* - I click on "Group1" in the "group" search widget
|
||||
* - I click on "Student" in the "user" search widget
|
||||
* - I click on "Group" in the "group" search widget
|
||||
* - I click on "Grade item" in the "grade" search widget
|
||||
*
|
||||
* @Given /^I click on "(?P<needle>(?:[^"]|\\")*)" in the "(?P<haystack>(?:[^"]|\\")*)" search widget$/
|
||||
* @param string $needle The value to search for.
|
||||
@ -466,26 +489,11 @@ class behat_grade extends behat_base {
|
||||
public function i_click_on_in_search_widget(string $needle, string $haystack) {
|
||||
$this->execute("behat_general::wait_until_the_page_is_ready");
|
||||
|
||||
$triggercssselector = '';
|
||||
$dialoguetitle = '';
|
||||
|
||||
switch ($haystack) {
|
||||
case 'user':
|
||||
$triggercssselector = '.userwidget';
|
||||
$dialoguetitle = 'Select a user';
|
||||
break;
|
||||
case 'grade':
|
||||
$triggercssselector = '.gradewidget';
|
||||
$dialoguetitle = 'Select a grade item';
|
||||
break;
|
||||
case 'group':
|
||||
$triggercssselector = '.groupwidget';
|
||||
$dialoguetitle = 'Select a group';
|
||||
break;
|
||||
}
|
||||
$triggercssselector = ".search-widget[data-searchtype='{$haystack}']";
|
||||
|
||||
$this->execute("behat_general::i_click_on", [$triggercssselector, "css_element"]);
|
||||
$this->execute("behat_general::wait_until_exists", [$dialoguetitle, "dialogue"]);
|
||||
$this->execute('behat_general::i_click_on_in_the', [$needle, "link", $dialoguetitle, 'dialogue']);
|
||||
$this->execute("behat_general::wait_until_the_page_is_ready");
|
||||
$this->execute('behat_general::i_click_on_in_the',
|
||||
[$needle, "link", "{$triggercssselector} .dropdown-menu", "css_element"]);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user