From 125765ed18ecc3fdf98520d600bb4f94af08ccb1 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Tue, 12 Mar 2013 15:48:27 +0800 Subject: [PATCH] MDL-38437 behat: Behat feature for mod_forum Basic add an activity, MDLQA-2 (students can edit or delete their forum posts within a set time limit). --- mod/forum/tests/behat/add_forum.feature | 29 +++++++++ .../tests/behat/edit_post_student.feature | 62 +++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 mod/forum/tests/behat/add_forum.feature create mode 100644 mod/forum/tests/behat/edit_post_student.feature diff --git a/mod/forum/tests/behat/add_forum.feature b/mod/forum/tests/behat/add_forum.feature new file mode 100644 index 00000000000..80466ea6097 --- /dev/null +++ b/mod/forum/tests/behat/add_forum.feature @@ -0,0 +1,29 @@ +@mod_forum +Feature: Add forum activities and discussions + In order to discuss topics with other users + As a moodle teacher + I need to add forum activities to moodle courses + + @javascript + Scenario: Add a forum and a discussion + Given the following "users" exists: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@asd.com | + And the following "courses" exists: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exists: + | user | course | role | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + And I add a "forum" to section "1" and I fill the form with: + | Forum name | Test forum name | + | Forum type | Standard forum for general use | + | Description | Test forum description | + When I add a new discussion to "Test forum name" forum with: + | Subject | Forum post 1 | + | Message | This is the body | + And I wait "6" seconds + Then I should see "Test forum name" diff --git a/mod/forum/tests/behat/edit_post_student.feature b/mod/forum/tests/behat/edit_post_student.feature new file mode 100644 index 00000000000..e693af64230 --- /dev/null +++ b/mod/forum/tests/behat/edit_post_student.feature @@ -0,0 +1,62 @@ +@mod_forum +Feature: Students can edit or delete their forum posts within a set time limit + In order to refine forum posts + As a moodle user + I need to edit or delete my forum posts within a certain period of time after posting + + Background: + Given the following "users" exists: + | username | firstname | lastname | email | + | student1 | Student | 1 | student1@asd.com | + And the following "courses" exists: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exists: + | user | course | role | + | student1 | C1 | student | + And I log in as "admin" + And I expand "Site administration" node + And I expand "Security" node + And I follow "Site policies" + And I select "1 minutes" from "Maximum time to edit posts" + And I press "Save changes" + And I am on homepage + And I follow "Course 1" + And I turn editing mode on + And I add a "forum" to section "1" and I fill the form with: + | Forum name | Test forum name | + | Forum type | Standard forum for general use | + | Description | Test forum description | + And I log out + And I follow "Course 1" + And I log in as "student1" + And I add a new discussion to "Test forum name" forum with: + | Subject | Forum post subject | + | Message | This is the body | + And I wait "6" seconds + + @javascript + Scenario: Edit forum post + When I follow "Forum post subject" + And I follow "Edit" + And I fill the moodle form with: + | Subject | Edited post subject | + | Message | Edited post body | + And I press "Save changes" + And I wait "6" seconds + Then I should see "Edited post subject" + And I should see "Edited post body" + + @javascript + Scenario: Delete forum post + When I follow "Forum post subject" + And I follow "Delete" + And I press "Continue" + Then I should not see "Forum post subject" + + @javascript + Scenario: Time limit expires + When I wait "70" seconds + And I follow "Forum post subject" + Then I should not see "Edit" + And I should not see "Delete"