MDL-61135 mod_quiz: add behat test for tag filtering in qbank modal
[moodle.git] / mod / quiz / tests / behat / editing_add_from_question_bank.feature
blob3db5abdd018ac07d15983be8ddbd934f372a9196
1 @core @core_question
2 Feature: Adding questions to a quiz from the question bank
3   In order to re-use questions
4   As a teacher
5   I want to add questions from the question bank
7   Background:
8     Given the following "users" exist:
9       | username | firstname | lastname | email |
10       | teacher1 | Teacher | 1 | teacher1@example.com |
11     And the following "courses" exist:
12       | fullname | shortname | format |
13       | Course 1 | C1 | weeks |
14     And the following "course enrolments" exist:
15       | user | course | role |
16       | teacher1 | C1 | editingteacher |
17     And the following "activities" exist:
18       | activity   | name   | intro                           | course | idnumber |
19       | quiz       | Quiz 1 | Quiz 1 for testing the Add menu | C1     | quiz1    |
20     And the following "question categories" exist:
21       | contextlevel | reference | name           |
22       | Course       | C1        | Test questions |
23     And the following "questions" exist:
24       | questioncategory | qtype     | name              | user     | questiontext    |
25       | Test questions   | essay     | question 1 name | admin    | Question 1 text |
26       | Test questions   | essay     | question 2 name | teacher1 | Question 2 text |
27     And I log in as "teacher1"
28     And I am on "Course 1" course homepage
29     And I navigate to "Questions" node in "Course administration > Question bank"
30     And I click on "Edit" "link" in the "question 1 name" "table_row"
31     And I set the following fields to these values:
32       | Tags | foo |
33     And I press "id_submitbutton"
34     And I click on "Edit" "link" in the "question 2 name" "table_row"
35     And I set the following fields to these values:
36       | Tags | bar |
37     And I press "id_submitbutton"
38     And I am on "Course 1" course homepage
39     And I follow "Quiz 1"
40     And I navigate to "Edit quiz" in current page administration
41     And I open the "last" add to quiz menu
42     And I follow "from question bank"
44   @javascript
45   Scenario: The questions can be filtered by tag
46     When I set the field "Filter by tags..." to "foo"
47     And I press key "13" in the field "Filter by tags..."
48     Then I should see "question 1 name" in the "categoryquestions" "table"
49     And I should not see "question 2 name" in the "categoryquestions" "table"