MDL-38477 behat: New test
[moodle.git] / mod / forum / tests / behat / edit_post_teacher.feature
CommitLineData
2d9cbe88
DM
1@mod_forum
2Feature: Teachers can edit or delete any forum post
3 In order to refine the forum contents
4 As a moodle teacher
5 I need to edit or delete any user's forum posts
6
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 "forum" to section "1" and I fill the form with:
23 | Forum name | Test forum name |
24 | Description | Test forum description |
25 And I add a new discussion to "Test forum name" forum with:
26 | Subject | Teacher post subject |
27 | Message | Teacher post message |
28 And I log out
29 And I log in as "student1"
30 And I follow "Course 1"
31 And I reply "Teacher post subject" post from "Test forum name" forum with:
32 | Subject | Student post subject |
33 | Message | Student post message |
34
35 @javascript
36 Scenario: A teacher can delete another user's posts
37 Given I log out
38 And I log in as "teacher1"
39 When I follow "Course 1"
40 And I follow "Test forum name"
41 And I follow "Teacher post subject"
42 And I click on "Delete" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ')][contains(., 'Student post subject')]" "xpath_element"
43 And I press "Continue"
44 And I wait "4" seconds
45 Then I should not see "Student post subject"
46 And I should not see "Student post message"
47
48 @javascript
49 Scenario: A teacher can edit another user's posts
50 Given I log out
51 And I log in as "teacher1"
52 When I follow "Course 1"
53 And I follow "Test forum name"
54 And I follow "Teacher post subject"
55 And I click on "Edit" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ')][contains(., 'Student post subject')]" "xpath_element"
56 And I fill the moodle form with:
57 | Subject | Edited student subject |
58 And I press "Save changes"
59 And I wait "4" seconds
60 Then I should see "Edited student subject"
61 And I should see "Edited by Teacher 1 - original submission"
62
63 @javascript
64 Scenario: A student can't edit or delete another user's posts
65 When I follow "Teacher post subject"
66 Then I should not see "Edit" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ')][contains(., 'Teacher post subject')]" "xpath_element"
67 And I should not see "Delete" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' forumpost ')][contains(., 'Teacher post subject')]" "xpath_element"