on-demand release 4.0dev+
[moodle.git] / mod / data / tests / behat / add_entries.feature
CommitLineData
f2cc870f
DM
1@mod @mod_data
2Feature: Users can add entries to database activities
3 In order to populate databases
4 As a user
5 I need to add entries to databases
6
1be2350a 7 Background:
f2cc870f
DM
8 Given the following "users" exist:
9 | username | firstname | lastname | email |
0fe86bbd
RT
10 | student1 | Student | 1 | student1@example.com |
11 | teacher1 | Teacher | 1 | teacher1@example.com |
f2cc870f
DM
12 And the following "courses" exist:
13 | fullname | shortname | category |
14 | Course 1 | C1 | 0 |
15 And the following "course enrolments" exist:
16 | user | course | role |
17 | teacher1 | C1 | editingteacher |
18 | student1 | C1 | student |
19 And the following "activities" exist:
20 | activity | name | intro | course | idnumber |
21 | data | Test database name | n | C1 | data1 |
1be2350a
SA
22
23 @javascript
24 Scenario: Students can add entries to a database
776f4bd8 25 Given I am on the "Course 1" course page logged in as teacher1
f2cc870f
DM
26 And I add a "Text input" field to "Test database name" database and I fill the form with:
27 | Field name | Test field name |
28 | Field description | Test field description |
9b5e702a
JO
29 And I add a "Text input" field to "Test database name" database and I fill the form with:
30 | Field name | Test field 2 name |
31 | Field description | Test field 2 description |
f2cc870f 32 # To generate the default templates.
6c0e1eee 33 And I navigate to "Templates" in current page administration
dc90838a 34 And I wait until the page is ready
f2cc870f 35 And I log out
776f4bd8 36 When I am on the "Course 1" course page logged in as student1
f2cc870f 37 And I add an entry to "Test database name" database with:
1c3b2058 38 | Test field name | Student original entry |
9b5e702a 39 | Test field 2 name | Student original entry 2 |
6c0e1eee 40 And I press "Save"
f2cc870f
DM
41 Then I should see "Student original entry"
42 And I follow "Edit"
9b5e702a
JO
43 And I set the following fields to these values:
44 | Test field name | Student original entry |
45 | Test field 2 name | |
6c0e1eee 46 And I press "Save"
9b5e702a
JO
47 Then I should not see "Student original entry 2"
48 And I follow "Edit"
f2cc870f 49 And I set the following fields to these values:
1c3b2058 50 | Test field name | Student edited entry |
6c0e1eee 51 And I press "Save"
f2cc870f
DM
52 And I should see "Student edited entry"
53 And I add an entry to "Test database name" database with:
1c3b2058 54 | Test field name | Student second entry |
f2cc870f 55 And I press "Save and add another"
f27ca945 56 And the field "Test field name" does not match value "Student second entry"
f2cc870f 57 And I add an entry to "Test database name" database with:
1c3b2058 58 | Test field name | Student third entry |
6c0e1eee
MG
59 And I press "Save"
60 And I select "List view" from the "jump" singleselect
f2cc870f
DM
61 And I should see "Student edited entry"
62 And I should see "Student second entry"
63 And I should see "Student third entry"
64 # Will delete the first one.
65 And I follow "Delete"
66 And I press "Delete"
67 And I should not see "Student edited entry"
68 And I should see "Student second entry"
69 And I should see "Student third entry"
c1d222fc
AG
70 # Now I will bulk delete the rest of the entries.
71 And I log out
776f4bd8 72 And I am on the "Test database name" "data activity" page logged in as teacher1
c1d222fc
AG
73 And I press "Select all"
74 And I press "Delete selected"
75 And I press "Delete"
7afd16ad 76 And I should see "No entries in database"
1be2350a
SA
77
78 @javascript @editor @editor_atto @atto @atto_h5p
79 Scenario: If a new text area entry is added, the filepicker is displayed in the H5P Atto button
776f4bd8 80 Given I am on the "Course 1" course page logged in as teacher1
1be2350a
SA
81 And I add a "Text area" field to "Test database name" database and I fill the form with:
82 | Field name | Textarea field name |
6c0e1eee 83 And I am on "Course 1" course homepage
1be2350a
SA
84 When I add an entry to "Test database name" database with:
85 | Textarea field name | This is the content |
86 And I click on "Insert H5P" "button"
87 Then I should see "Browse repositories..."