MDL-38940 behat: New test
[moodle.git] / mod / glossary / tests / behat / search_entries.feature
blob2f6cd44f5c16d1ef01705e7488fe1d89d45aebb7
1 @mod_glossary @mod
2 Feature: Glossary entries can be searched or browsed by alphabet, category, date or author
3   In order to find entries in a glossary
4   As a moodle user
5   I need to search the entries list by keyword, alphabet, category, date and author
7   Background:
8     Given the following "users" exists:
9       | username | firstname | lastname | email |
10       | teacher1 | Teacher | 1 | teacher1@asd.com |
11       | student1 | Student | 1 | student1@asd.com |
12     And the following "courses" exists:
13       | fullname | shortname | category |
14       | Course 1 | C1 | 0 |
15     And the following "course enrolments" exists:
16       | user | course | role |
17       | teacher1 | C1 | editingteacher |
18       | student1 | C1 | student |
19     And I log in as "teacher1"
20     And I follow "Course 1"
21     And I turn editing mode on
22     And I add a "Glossary" to section "1" and I fill the form with:
23       | Name | Test glossary name |
24       | Description | Test glossary description |
25     And I follow "Test glossary name"
26     And I add a glossary entries category named "The ones I like"
27     And I add a glossary entries category named "All for you"
28     And I add a glossary entry with the following data:
29       | Concept | Eggplant |
30       | Definition | Sour eggplants |
31       | Categories | All for you |
32     And I log out
33     And I log in as "student1"
34     And I follow "Course 1"
35     And I follow "Test glossary name"
36     And I add a glossary entry with the following data:
37       | Concept | Cucumber |
38       | Definition | Sweet cucumber |
39       | Categories | The ones I like |
40     And I log out
41     And I log in as "teacher1"
42     And I follow "Course 1"
43     And I follow "Test glossary name"
45   @javascript
46   Scenario: Search by keyword and browse by alphabet
47     When I fill in "hook" with "cucumber"
48     And I press "Search"
49     Then I should see "Sweet cucumber"
50     And I should see "Search: cucumber"
51     And I follow "Browse by alphabet"
52     And I click on "E" "link" in the ".entrybox" "css_element"
53     And I should see "Sour eggplants"
54     And I should not see "Sweet cucumber"
55     And I click on "X" "link" in the ".entrybox" "css_element"
56     And I should not see "Sweet cucumber"
57     And I should see "No entries found in this section"
59   @javascript
60   Scenario: Browse by category
61     When I follow "Browse by category"
62     And I select "The ones I like" from "Categories"
63     Then I should see "Sweet cucumber"
64     And I should not see "Sour eggplants"
65     And I select "All for you" from "Categories"
66     And I should see "Sour eggplants"
67     And I should not see "Sweet cucumber"
69   @javascript
70   Scenario: Browse by date
71     When I follow "Browse by date"
72     And I follow "By creation date"
73     Then "Delete: Eggplant" "link" should appear before "Delete: Cucumber" "link"
74     And I follow "By last update"
75     And I follow "By last update change to descending"
76     And "Delete: Cucumber" "link" should appear before "Delete: Eggplant" "link"
78   @javascript
79   Scenario: Browse by author
80     When I follow "Browse by Author"
81     And I click on "T" "link" in the ".entrybox" "css_element"
82     Then I should see "Teacher 1"
83     And I should see "Sour eggplants"
84     And I should not see "Sweet cucumber"
85     And I click on "S" "link" in the ".entrybox" "css_element"
86     And I should see "Student 1"
87     And I should see "Sweet cucumber"
88     And I should not see "Sour eggplants"