From b65f535a47173293459035126f27df6259795a10 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 20 Feb 2014 16:08:26 +0800 Subject: [PATCH] MDL-44337 glossary: behat test for glossary categories --- mod/glossary/tests/behat/categories.feature | 125 ++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 mod/glossary/tests/behat/categories.feature diff --git a/mod/glossary/tests/behat/categories.feature b/mod/glossary/tests/behat/categories.feature new file mode 100644 index 00000000000..64b59ad49c3 --- /dev/null +++ b/mod/glossary/tests/behat/categories.feature @@ -0,0 +1,125 @@ +@mod @mod_glossary +Feature: Glossary entries can be organised in categories + In order to organise glossary entries + As a teacher + I need to be able to create, edit and delete categories + + @javascript + Scenario: Glossary entries can be organised in categories and categories can be autolinked + 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 the following "activities" exists: + | activity | name | intro | course | idnumber | + | label | name | check autolinking of CategoryAutoLinks and CategoryNoLinks text | C1 | label1 | +# Log in as admin and enable autolinking filter + And I log in as "admin" + And I expand "Site administration" node + And I expand "Plugins" node + And I expand "Filters" node + And I follow "Manage filters" + And I click on "On" "option" in the "Glossary auto-linking" "table_row" + And I log out +# Log in as a teacher and make sure nothing is yet autolinked + And I log in as "teacher1" + When I follow "Course 1" + Then I should see "CategoryAutoLinks" + And I should see "CategoryNoLinks" + And "a.glossary.autolink" "css_element" should not exists + And I turn editing mode on + And I add a "Glossary" to section "1" and I fill the form with: + | Name | MyGlossary | + | Description | Test glossary description | +# Create, edit and delete categories + And I follow "MyGlossary" + And I follow "Browse by category" + And I press "Edit categories" + And I press "Add Category" + And I set the field "name" to "CategoryNoLinks" + And I press "Save changes" + And I should see "0 Entries" in the "CategoryNoLinks" "table_row" + And I press "Add Category" + And I set the field "name" to "CategoryAutoLinks" + And I set the field "usedynalink" to "Yes" + And I press "Save changes" + And I should see "0 Entries" in the "CategoryAutoLinks" "table_row" + And I press "Add Category" + And I set the field "name" to "Category2" + And I press "Save changes" + And I click on "Edit" "link" in the "Category2" "table_row" + And I set the field "name" to "Category3" + And I press "Save changes" + And I should see "Category3" + And I should not see "Category2" + And I click on "Delete" "link" in the "Category3" "table_row" + And I press "No" + And I should see "Category3" + And I click on "Delete" "link" in the "Category3" "table_row" + And I press "Yes" + And I should not see "Category3" + And I press "Back" +# Add glossary entries in categories and outside + And I add a glossary entry with the following data: + | Concept | EntryNoCategory | + | Definition | Definition | + And I add a glossary entry with the following data: + | Concept | EntryCategoryNL | + | Definition | Definition | + | Categories | CategoryNoLinks | + And I add a glossary entry with the following data: + | Concept | EntryCategoryAL | + | Definition | Definition | + | Categories | CategoryAutoLinks | + And I press "Add a new entry" + And I set the following fields to these values: + | Concept | EntryCategoryBoth | + | Definition | Definition | + | Categories | CategoryAutoLinks,CategoryNoLinks | + And I press "Save changes" +# Make sure entries appear in their categories + And I follow "Browse by category" + And "//h2[contains(.,'CATEGORYAUTOLINKS')]" "xpath_element" should appear before "//h2[contains(.,'CATEGORYNOLINKS')]" "xpath_element" + And "//h3[contains(.,'EntryCategoryAL')]" "xpath_element" should appear before "//h2[contains(.,'CATEGORYNOLINKS')]" "xpath_element" + And "//h3[contains(.,'EntryCategoryBoth')]" "xpath_element" should appear before "//h2[contains(.,'CATEGORYNOLINKS')]" "xpath_element" + And "//h2[contains(.,'CATEGORYNOLINKS')]" "xpath_element" should appear before "//h3[contains(.,'EntryCategoryBoth')]" "xpath_element" + And "//h3[contains(.,'EntryCategoryNL')]" "xpath_element" should appear after "//h2[contains(.,'CATEGORYNOLINKS')]" "xpath_element" + And I should not see "EntryNoCategory" + And I set the field "hook" to "Not categorised" + And I click on "Not categorised" "option" in the "#catmenu select" "css_element" + And I should see "EntryNoCategory" + And I should not see "EntryCategoryNL" + And I should not see "EntryCategoryAL" + And I should not see "EntryCategoryBoth" +# Check that category is autolinked from the text in the course + And I follow "Course 1" + And I should see "CategoryAutoLinks" + And I should see "CategoryAutoLinks" in the "a.glossary.autolink" "css_element" + And I should see "CategoryNoLinks" + And "//a[contains(.,'CategoryNoLinks')]" "xpath_element" should not exists +# Delete a category with entries + And I follow "Course 1" + And I follow "MyGlossary" + And I follow "Browse by category" + And I press "Edit categories" + And I should see "2 Entries" in the "CategoryNoLinks" "table_row" + And I should see "2 Entries" in the "CategoryAutoLinks" "table_row" + And I click on "Delete" "link" in the "CategoryAutoLinks" "table_row" + And I press "Yes" + And I follow "Browse by category" + And I should see "EntryCategoryNL" + And I should not see "EntryNoCategory" + And I should not see "EntryCategoryAL" + And I should see "EntryCategoryBoth" + And I click on "Not categorised" "option" in the "#catmenu select" "css_element" + And I should see "EntryNoCategory" + And I should see "EntryCategoryAL" + And I should not see "EntryCategoryBoth" + And I log out