1 |
efrain |
1 |
@mod @mod_data
|
|
|
2 |
Feature: Users can view and search database entries
|
|
|
3 |
In order to find the database entries that I am looking for
|
|
|
4 |
As a user
|
|
|
5 |
I need to list and search the database entries
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "users" exist:
|
|
|
9 |
| username | firstname | lastname | email |
|
|
|
10 |
| student1 | Bob | 1 | student1@example.com |
|
|
|
11 |
| student2 | Alice | 2 | student2@example.com |
|
|
|
12 |
| teacher1 | Teacher | 1 | teacher1@example.com |
|
|
|
13 |
And the following "tags" exist:
|
|
|
14 |
| name | isstandard |
|
|
|
15 |
| Tag1 | 1 |
|
|
|
16 |
And the following "courses" exist:
|
|
|
17 |
| fullname | shortname | category |
|
|
|
18 |
| Course 1 | C1 | 0 |
|
|
|
19 |
And the following "course enrolments" exist:
|
|
|
20 |
| user | course | role |
|
|
|
21 |
| teacher1 | C1 | editingteacher |
|
|
|
22 |
| student1 | C1 | student |
|
|
|
23 |
| student2 | C1 | student |
|
|
|
24 |
And the following "activities" exist:
|
|
|
25 |
| activity | name | intro | course | idnumber |
|
|
|
26 |
| data | Test database name | Database intro | C1 | data1 |
|
|
|
27 |
And the following "mod_data > fields" exist:
|
|
|
28 |
| database | type | name | description |
|
|
|
29 |
| data1 | text | Test field name | Test field description |
|
|
|
30 |
| data1 | text | Test field 2 name | Test field 2 description |
|
|
|
31 |
| data1 | url | Test field 3 name | Test field 3 description |
|
|
|
32 |
|
|
|
33 |
@javascript
|
|
|
34 |
Scenario: Students can view, list and search entries
|
|
|
35 |
Given the following "mod_data > entries" exist:
|
|
|
36 |
| database | Test field name | Test field 2 name | Test field 3 name |
|
|
|
37 |
| data1 | Student entry 1 | | https://moodledev.io |
|
|
|
38 |
| data1 | Student entry 2 | | |
|
|
|
39 |
| data1 | Student entry 3 | | |
|
|
|
40 |
When I log in as "student1"
|
|
|
41 |
And I am on the "Test database name" "data activity" page
|
|
|
42 |
Then I should see "Student entry 1"
|
|
|
43 |
# Confirm that the URL field is displayed as a link.
|
|
|
44 |
And "https://moodledev.io" "link" should exist
|
|
|
45 |
And I should see "Student entry 2"
|
|
|
46 |
And I should see "Student entry 3"
|
|
|
47 |
And I select "Single view" from the "jump" singleselect
|
|
|
48 |
And I should see "Student entry 1"
|
|
|
49 |
# Confirm that the URL field is displayed as a link.
|
|
|
50 |
And "https://moodledev.io" "link" should exist
|
|
|
51 |
And I should not see "Student entry 2"
|
|
|
52 |
And "2" "link" should exist
|
|
|
53 |
And "3" "link" should exist
|
|
|
54 |
And I follow "Next"
|
|
|
55 |
And I should see "Student entry 2"
|
|
|
56 |
And I should not see "Student entry 1"
|
|
|
57 |
And I click on "3" "link" in the "region-main" "region"
|
|
|
58 |
And I should see "Student entry 3"
|
|
|
59 |
And I should not see "Student entry 2"
|
|
|
60 |
And I follow "Previous"
|
|
|
61 |
And I should see "Student entry 2"
|
|
|
62 |
And I should not see "Student entry 1"
|
|
|
63 |
And I should not see "Student entry 3"
|
|
|
64 |
And I select "List view" from the "jump" singleselect
|
|
|
65 |
And I click on "Advanced search" "checkbox"
|
|
|
66 |
And I set the field "Test field name" to "Student entry 1"
|
|
|
67 |
And I click on "Save settings" "button" in the "data_adv_form" "region"
|
|
|
68 |
And I should see "Student entry 1"
|
|
|
69 |
And I should not see "Student entry 2"
|
|
|
70 |
And I should not see "Student entry 3"
|
|
|
71 |
And I set the field "Test field name" to "Student entry"
|
|
|
72 |
And I set the field "Order" to "Descending"
|
|
|
73 |
And I click on "Save settings" "button" in the "data_adv_form" "region"
|
|
|
74 |
And "Student entry 3" "text" should appear before "Student entry 2" "text"
|
|
|
75 |
And "Student entry 2" "text" should appear before "Student entry 1" "text"
|
|
|
76 |
|
|
|
77 |
@javascript
|
|
|
78 |
Scenario: Check that searching by tags works as expected
|
|
|
79 |
Given the following "mod_data > entries" exist:
|
|
|
80 |
| database | user | Test field name | Test field 2 name | Test field 3 name |
|
|
|
81 |
| data1 | student1 | Student original entry untagged | Student original entry untagged 2 | |
|
|
|
82 |
And I am on the "Test database name" "data activity" page logged in as student1
|
|
|
83 |
And I click on "Add entry" "button"
|
|
|
84 |
# This is required for now to prevent the tag suggestion menu from overlapping over the Save & view button.
|
|
|
85 |
And I change window size to "large"
|
|
|
86 |
And I set the following fields to these values:
|
|
|
87 |
| Test field name | Student original entry tagged |
|
|
|
88 |
| Test field 2 name | Student original entry tagged 2 |
|
|
|
89 |
And I set the field with xpath "//div[@class='datatagcontrol']//input[@type='text']" to "Tag1"
|
|
|
90 |
And I press "Save"
|
|
|
91 |
And I should see "Student original entry"
|
|
|
92 |
And I should see "Tag1" in the "div.tag_list" "css_element"
|
|
|
93 |
And I open the action menu in "#defaulttemplate-single" "css_element"
|
|
|
94 |
And I choose "Edit" in the open action menu
|
|
|
95 |
And I should see "Tag1" in the ".form-autocomplete-selection" "css_element"
|
|
|
96 |
And I follow "Cancel"
|
|
|
97 |
And I select "List view" from the "jump" singleselect
|
|
|
98 |
And I should see "Tag1" in the "div.tag_list" "css_element"
|
|
|
99 |
And I click on "Advanced search" "checkbox"
|
|
|
100 |
And I set the field with xpath "//div[@class='datatagcontrol']//input[@type='text']" to "Tag1"
|
|
|
101 |
And I click on "#page-content" "css_element"
|
|
|
102 |
When I click on "Save settings" "button" in the "data_adv_form" "region"
|
|
|
103 |
Then I should see "Student original entry tagged"
|
|
|
104 |
And I should see "Student original entry tagged 2"
|
|
|
105 |
And I should not see "Student original entry untagged"
|
|
|
106 |
And I should not see "Student original entry untagged 2"
|
|
|
107 |
|
|
|
108 |
@javascript
|
|
|
109 |
Scenario: Check that searching by first and last name works as expected
|
|
|
110 |
Given the following "mod_data > entries" exist:
|
|
|
111 |
| database | user | Test field name | Test field 2 name | Test field 3 name |
|
|
|
112 |
| data1 | student1 | Student entry 1 | | |
|
|
|
113 |
| data1 | student2 | Student entry 2 | | |
|
|
|
114 |
When I am on the "Test database name" "data activity" page logged in as teacher1
|
|
|
115 |
And I click on "Advanced search" "checkbox"
|
|
|
116 |
And I set the field "First name" to "Bob"
|
|
|
117 |
And I click on "Save settings" "button" in the "data_adv_form" "region"
|
|
|
118 |
Then I should see "Found 1 out of 2 records."
|
|
|
119 |
And I should see "Student entry 1"
|
|
|
120 |
And I should not see "Student entry 2"
|
|
|
121 |
And I set the field "First name" to ""
|
|
|
122 |
And I set the field "Last name" to "2"
|
|
|
123 |
And I click on "Save settings" "button" in the "data_adv_form" "region"
|
|
|
124 |
And I should see "Found 1 out of 2 records."
|
|
|
125 |
And I should not see "Student entry 1"
|
|
|
126 |
And I should see "Student entry 2"
|
|
|
127 |
# Search: no records found.
|
|
|
128 |
But I set the field "Last name" to ""
|
|
|
129 |
And I set the field "Test field name" to "Student entry 0"
|
|
|
130 |
And I click on "Save settings" "button" in the "data_adv_form" "region"
|
|
|
131 |
And I should see "No records found."
|
|
|
132 |
And I should not see "Student entry 1"
|
|
|
133 |
And I should not see "Student entry 2"
|
|
|
134 |
# Search all the entries.
|
|
|
135 |
And I set the field "Test field name" to "Student entry"
|
|
|
136 |
And I click on "Save settings" "button" in the "data_adv_form" "region"
|
|
|
137 |
And I should not see "Found 2 out of 2 records."
|
|
|
138 |
And I should see "Student entry 1"
|
|
|
139 |
And I should see "Student entry 2"
|
|
|
140 |
|
|
|
141 |
@javascript
|
|
|
142 |
Scenario: Database entries can be deleted in batch if delcheck is present
|
|
|
143 |
Given the following "mod_data > entries" exist:
|
|
|
144 |
| database | user | Test field name | Test field 2 name | Test field 3 name |
|
|
|
145 |
| data1 | student1 | Student entry 1 | Some student content 1 | http://moodle.com |
|
|
|
146 |
| data1 | teacher1 | Teacher entry 2 | Some teacher content 2 | http://moodle.com |
|
|
|
147 |
And I am on the "Test database name" "data activity" page logged in as teacher1
|
|
|
148 |
And I navigate to "Templates" in current page administration
|
|
|
149 |
And I set the field "Templates tertiary navigation" to "List view template"
|
|
|
150 |
And I set the following fields to these values:
|
|
|
151 |
| Repeated entry | ##delcheck##[[Test field name]]! |
|
|
|
152 |
And I click on "Save" "button" in the "sticky-footer" "region"
|
|
|
153 |
When I navigate to "Database" in current page administration
|
|
|
154 |
When I click on "Select all" "button"
|
|
|
155 |
And I click on "Delete selected" "button"
|
|
|
156 |
And I press "Delete"
|
|
|
157 |
And I should see "No entries yet"
|
|
|
158 |
|
|
|
159 |
@javascript
|
|
|
160 |
Scenario: Database entries cannot be deleted in batch if delcheck is not present
|
|
|
161 |
Given the following "mod_data > entries" exist:
|
|
|
162 |
| database | user | Test field name | Test field 2 name | Test field 3 name |
|
|
|
163 |
| data1 | student1 | Student entry 1 | Some student content 1 | http://moodle.com |
|
|
|
164 |
| data1 | teacher1 | Teacher entry 2 | Some teacher content 2 | http://moodle.com |
|
|
|
165 |
And I am on the "Test database name" "data activity" page logged in as teacher1
|
|
|
166 |
Then I should not see "Select all"
|
|
|
167 |
And I should not see "Delete selected"
|
|
|
168 |
|
|
|
169 |
Scenario Outline: Entries are linked based on autolink and open in new window settings
|
|
|
170 |
# Param1 refers to `Autolink`, param3 refers to `Open in new window`.
|
|
|
171 |
Given the following "mod_data > fields" exist:
|
|
|
172 |
| database | type | name | param1 | param3 |
|
|
|
173 |
| data1 | url | URL field name | <param1> | <param3> |
|
|
|
174 |
And the following "mod_data > entries" exist:
|
|
|
175 |
| database | user | Test field name | Test field 2 name | Test field 3 name | URL field name |
|
|
|
176 |
| data1 | teacher1 | Test field entry | Test field 2 entry | http://example.com/ | www.moodle.org |
|
|
|
177 |
When I am on the "Test database name" "data activity" page logged in as teacher1
|
|
|
178 |
Then "www.moodle.org" "link" <autolink> exist
|
|
|
179 |
# Verify that the URL field is rendered as a link with the correct href attribute and target set to _blank.
|
|
|
180 |
And "a[target='_blank'][href='http://www.moodle.org']" "css_element" <autolink> exist
|
|
|
181 |
|
|
|
182 |
Examples:
|
|
|
183 |
| param1 | param3 | autolink |
|
|
|
184 |
| 0 | 0 | should not |
|
|
|
185 |
| 1 | 1 | should |
|
|
|
186 |
|
|
|
187 |
@javascript @accessibility
|
|
|
188 |
Scenario: Check the accessibility of the database entries page (zero state)
|
|
|
189 |
When I am on the "Test database name" "data activity" page logged in as "teacher1"
|
|
|
190 |
Then I should see "No entries yet"
|
|
|
191 |
And the page should meet accessibility standards
|
|
|
192 |
|
|
|
193 |
@javascript @accessibility
|
|
|
194 |
Scenario: Check the accessibility of the database entries page
|
|
|
195 |
Given the following "mod_data > entries" exist:
|
|
|
196 |
| database | user | Test field name | Test field 2 name | Test field 3 name |
|
|
|
197 |
| data1 | student1 | Student entry 1 | Some student content 1 | http://moodle.com |
|
|
|
198 |
| data1 | teacher1 | Teacher entry 2 | Some teacher content 2 | http://moodle.com |
|
|
|
199 |
When I am on the "Test database name" "data activity" page logged in as teacher1
|
|
|
200 |
Then the page should meet accessibility standards
|