Skip to content

Commit

Permalink
Merge branch 'MDL-59548-master' of git://github.com/damyon/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Jul 17, 2017
2 parents 57f869c + dda64b6 commit c899bfb
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 22 deletions.
12 changes: 0 additions & 12 deletions admin/tool/lp/tests/behat/behat_tool_lp.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,4 @@ public function select_of_the_competency_tree($competencyname) {
$this->execute('behat_general::i_click_on', [$xpathtarget, 'xpath_element']);
}

/**
* Select item from autocomplete list.
*
* @Given /^I click on "([^"]*)" item in the autocomplete list$/
*
* @param string $item
*/
public function i_click_on_item_in_the_autocomplete_list($item) {
$xpathtarget = "//ul[@class='form-autocomplete-suggestions']//li//span//span[contains(.,'" . $item . "')]";

$this->execute('behat_general::i_click_on', [$xpathtarget, 'xpath_element']);
}
}
2 changes: 1 addition & 1 deletion admin/tool/lp/tests/behat/plan_crud.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Feature: Manage plearning plan
And I follow "Home"
And I navigate to "Competencies > Learning plan templates" in site administration
And I click on ".template-userplans" "css_element" in the "Science template" "table_row"
And I click on ".form-autocomplete-downarrow" "css_element"
And I open the autocomplete suggestions list
And I click on "Admin" item in the autocomplete list
And I press key "27" in the field "Select users to create learning plans for"
When I click on "Create learning plans" "button"
Expand Down
8 changes: 4 additions & 4 deletions enrol/tests/behat/add_to_group.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ Feature: Users can be added to multiple groups at once
And I am on "Course 1" course homepage
And I follow "Participants"
And I click on "Edit groups for \"Student 1\"" "link" in the "student1" "table_row"
And I click on ".form-autocomplete-downarrow" "css_element"
And I click on ".form-autocomplete-suggestions [role=option]" "css_element"
And I click on ".form-autocomplete-downarrow" "css_element"
And I click on ".form-autocomplete-suggestions [role=option]" "css_element"
And I open the autocomplete suggestions list
And I click on "Group 1" item in the autocomplete list
And I open the autocomplete suggestions list
And I click on "Group 2" item in the autocomplete list
And I click on "Save changes" "link"
Then I should see "Group 1, Group 2"

Expand Down
1 change: 0 additions & 1 deletion lib/behat/behat_field_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,5 +293,4 @@ protected static function get_node_type(NodeElement $fieldnode, $locator, Sessio

return self::get_field_node_type($fieldnode, $session);
}

}
1 change: 1 addition & 0 deletions lib/behat/form_field/behat_form_autocomplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ public function set_value($value) {
$id = $this->field->getAttribute('id');
$js = ' require(["jquery"], function($) { $(document.getElementById("'.$id.'")).trigger("behat:set-value"); }); ';
$this->session->executeScript($js);
$this->key_press(27);
}
}
25 changes: 25 additions & 0 deletions lib/tests/behat/behat_forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,4 +524,29 @@ public function i_select_from_the_singleselect($option, $singleselect) {
}
}

/**
* Select item from autocomplete list.
*
* @Given /^I click on "([^"]*)" item in the autocomplete list$/
*
* @param string $item
*/
public function i_click_on_item_in_the_autocomplete_list($item) {
$xpathtarget = "//ul[@class='form-autocomplete-suggestions']//*[contains(.,'" . $item . "')]";

$this->execute('behat_general::i_click_on', [$xpathtarget, 'xpath_element']);

$this->execute('behat_general::i_press_key_in_element', ['13', 'body', 'xpath_element']);
}

/**
* Open the auto-complete suggestions list (Assuming there is only one on the page.).
*
* @Given /^I open the autocomplete suggestions list$/
*/
public function i_open_the_autocomplete_suggestions_list() {
$csstarget = ".form-autocomplete-downarrow";
$this->execute('behat_general::i_click_on', [$csstarget, 'css_element']);
}

}
2 changes: 1 addition & 1 deletion mod/book/tests/behat/edit_tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Feature: Edited book chapters handle tags correctly
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test book"
And I click on ".form-autocomplete-downarrow" "css_element"
And I open the autocomplete suggestions list
And I should see "OT1" in the ".form-autocomplete-suggestions" "css_element"
And I should see "OT2" in the ".form-autocomplete-suggestions" "css_element"
And I should see "OT3" in the ".form-autocomplete-suggestions" "css_element"
Expand Down
2 changes: 1 addition & 1 deletion mod/forum/tests/behat/edit_tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Feature: Edited forum posts handle tags correctly
And I follow "Test forum"
And I click on "Add a new discussion topic" "button"
And I expand all fieldsets
And I click on ".form-autocomplete-downarrow" "css_element"
And I open the autocomplete suggestions list
And I should see "OT1" in the ".form-autocomplete-suggestions" "css_element"
And I should see "OT2" in the ".form-autocomplete-suggestions" "css_element"
And I should see "OT3" in the ".form-autocomplete-suggestions" "css_element"
Expand Down
2 changes: 1 addition & 1 deletion mod/glossary/tests/behat/edit_tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Feature: Edited glossary entries handle tags correctly
And I follow "Test glossary"
And I press "Add a new entry"
And I expand all fieldsets
And I click on ".form-autocomplete-downarrow" "css_element"
And I open the autocomplete suggestions list
And I should see "OT1" in the ".form-autocomplete-suggestions" "css_element"
And I should see "OT2" in the ".form-autocomplete-suggestions" "css_element"
And I should see "OT3" in the ".form-autocomplete-suggestions" "css_element"
Expand Down
2 changes: 1 addition & 1 deletion mod/wiki/tests/behat/edit_tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Feature: Edited wiki pages handle tags correctly
And I am on "Course 1" course homepage
And I follow "Test wiki name"
And I press "Create page"
And I click on ".form-autocomplete-downarrow" "css_element"
And I open the autocomplete suggestions list
And I should see "OT1" in the ".form-autocomplete-suggestions" "css_element"
And I should see "OT2" in the ".form-autocomplete-suggestions" "css_element"
And I should see "OT3" in the ".form-autocomplete-suggestions" "css_element"
Expand Down

0 comments on commit c899bfb

Please sign in to comment.