From f7040fef9144d051bdc8f2844fea6f62a711d2ee Mon Sep 17 00:00:00 2001 From: David Monllao Date: Thu, 11 Apr 2013 10:46:11 +0800 Subject: [PATCH 1/2] MDL-38940 behat: Step definition to create glossary categories --- .../tests/behat/behat_mod_glossary.php | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/mod/glossary/tests/behat/behat_mod_glossary.php b/mod/glossary/tests/behat/behat_mod_glossary.php index 4d272685cab..a692634dfd4 100644 --- a/mod/glossary/tests/behat/behat_mod_glossary.php +++ b/mod/glossary/tests/behat/behat_mod_glossary.php @@ -28,8 +28,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\ElementNotFoundException as ElementNotFoundException; + Behat\Gherkin\Node\TableNode as TableNode; /** * Glossary-related steps definitions. @@ -55,4 +54,21 @@ class behat_mod_glossary extends behat_base { ); } + /** + * Adds a category with the specified name to the current glossary. You need to be in the glossary page. + * + * @Given /^I add a glossary entries category named "(?P(?:[^"]|\\")*)"$/ + * @param string $categoryname Category name + */ + public function i_add_a_glossary_entries_category_named($categoryname) { + + return array( + new Given('I follow "' . get_string('categoryview', 'mod_glossary') . '"'), + new Given('I press "' . get_string('editcategories', 'mod_glossary') . '"'), + new Given('I press "Add Category"'), + new Given('I fill in "name" with "' . $categoryname . '"'), + new Given('I press "' . get_string('savechanges') . '"'), + new Given('I press "' . get_string('back', 'mod_glossary') . '"') + ); + } } From 58c2fae5257f2acafec40e567034a1d0c1c899c8 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Thu, 11 Apr 2013 10:47:10 +0800 Subject: [PATCH 2/2] MDL-38940 behat: New test According to MDLQA-32, glossary entries can be searched or browsed by alphabet, category, date or author. --- .../tests/behat/search_entries.feature | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 mod/glossary/tests/behat/search_entries.feature diff --git a/mod/glossary/tests/behat/search_entries.feature b/mod/glossary/tests/behat/search_entries.feature new file mode 100644 index 00000000000..2f6cd44f5c1 --- /dev/null +++ b/mod/glossary/tests/behat/search_entries.feature @@ -0,0 +1,88 @@ +@mod_glossary @mod +Feature: Glossary entries can be searched or browsed by alphabet, category, date or author + In order to find entries in a glossary + As a moodle user + I need to search the entries list by keyword, alphabet, category, date and author + + Background: + 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 | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exists: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + And I add a "Glossary" to section "1" and I fill the form with: + | Name | Test glossary name | + | Description | Test glossary description | + And I follow "Test glossary name" + And I add a glossary entries category named "The ones I like" + And I add a glossary entries category named "All for you" + And I add a glossary entry with the following data: + | Concept | Eggplant | + | Definition | Sour eggplants | + | Categories | All for you | + And I log out + And I log in as "student1" + And I follow "Course 1" + And I follow "Test glossary name" + And I add a glossary entry with the following data: + | Concept | Cucumber | + | Definition | Sweet cucumber | + | Categories | The ones I like | + And I log out + And I log in as "teacher1" + And I follow "Course 1" + And I follow "Test glossary name" + + @javascript + Scenario: Search by keyword and browse by alphabet + When I fill in "hook" with "cucumber" + And I press "Search" + Then I should see "Sweet cucumber" + And I should see "Search: cucumber" + And I follow "Browse by alphabet" + And I click on "E" "link" in the ".entrybox" "css_element" + And I should see "Sour eggplants" + And I should not see "Sweet cucumber" + And I click on "X" "link" in the ".entrybox" "css_element" + And I should not see "Sweet cucumber" + And I should see "No entries found in this section" + + @javascript + Scenario: Browse by category + When I follow "Browse by category" + And I select "The ones I like" from "Categories" + Then I should see "Sweet cucumber" + And I should not see "Sour eggplants" + And I select "All for you" from "Categories" + And I should see "Sour eggplants" + And I should not see "Sweet cucumber" + + @javascript + Scenario: Browse by date + When I follow "Browse by date" + And I follow "By creation date" + Then "Delete: Eggplant" "link" should appear before "Delete: Cucumber" "link" + And I follow "By last update" + And I follow "By last update change to descending" + And "Delete: Cucumber" "link" should appear before "Delete: Eggplant" "link" + + @javascript + Scenario: Browse by author + When I follow "Browse by Author" + And I click on "T" "link" in the ".entrybox" "css_element" + Then I should see "Teacher 1" + And I should see "Sour eggplants" + And I should not see "Sweet cucumber" + And I click on "S" "link" in the ".entrybox" "css_element" + And I should see "Student 1" + And I should see "Sweet cucumber" + And I should not see "Sour eggplants"