Index: openacs-4/packages/forums/forums.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/forums/forums.info,v
diff -u -r1.55 -r1.56
--- openacs-4/packages/forums/forums.info 24 Jul 2018 12:45:11 -0000 1.55
+++ openacs-4/packages/forums/forums.info 24 Jul 2018 17:19:58 -0000 1.56
@@ -9,7 +9,7 @@
f
t
-
+
OpenACS
Online discussion forums.
2017-08-06
@@ -19,14 +19,14 @@
2
#forums.Forums#
-
+
-
+
Index: openacs-4/packages/forums/tcl/test/forums-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/test/forums-procs.tcl,v
diff -u -r1.10 -r1.11
--- openacs-4/packages/forums/tcl/test/forums-procs.tcl 24 Jul 2018 14:37:47 -0000 1.10
+++ openacs-4/packages/forums/tcl/test/forums-procs.tcl 24 Jul 2018 17:19:58 -0000 1.11
@@ -196,8 +196,8 @@
#
set name [ad_generate_random_string]
set forum_id [forums::test::new -user_id $user_id $name]
-
-
+
+
} -teardown_code {
#
# In order to be able to delete the user, we have first to
@@ -248,7 +248,7 @@
set response [forums::test::view \
-user_id $user_id \
-forum_id $forum_id ]
-
+
} -teardown_code {
#
# Delete the forum.
@@ -286,13 +286,12 @@
set forum_id [forums::test::new -user_id $user_id $name]
#
- # Edit the created forum
+ # Edit the meta info of the created forum
#
set response [forums::test::edit \
-user_id $user_id \
- -forum_id $forum_id \
- ]
-
+ -forum_id $forum_id ]
+
} -teardown_code {
if {$forum_id != 0} {
forum::delete -forum_id $forum_id
@@ -303,127 +302,69 @@
aa_register_case \
-cats {web smoke} \
- -libraries tclwebtest \
- -procs {forums::twt::new forums::twt::new_post} \
- web_message_new {
- Posting a new message to an existing forum
+ -procs {
+ forum::delete
+ forum::edit
+ forum::get
+ forum::message::delete
+ forum::message::delete
+ forum::message::edit
+ forum::message::get
+ forum::message::new
+ forum::message::set_state
+ forum::new
+ forum::security::require_post_forum
+ } \
+ -urls {
+ /message-post
+ /forum-view
+ /message-view
+ /message-post
+ /moderate/message-edit
+ /moderate/message-delete
+ } \
+ web_forums_message_and_reply {
+ Do various operations in a longer test:
+ - create a forum
+ - add a forums entry
+ - reply to the forum
+ - edit the forums entry
+ - delete the forums entry
} {
-
+ set forum_id 0
+ set message_id 0
aa_run_with_teardown -test_code {
+ #
+ # Create a new admin user
+ #
+ set user_info [acs::test::user::create -admin]
+ set user_id [dict get $user_info user_id]
- tclwebtest::cookies clear
-
- # Login user
- array set user_info [twt::user::create -admin]
- twt::user::login $user_info(email) $user_info(password)
-
- # Create a forum
+ #
+ # Create a new forum
+ #
set name [ad_generate_random_string]
- forums::twt::new "$name"
+ set forum_id [forums::test::new -user_id $user_id $name]
# Post a message in the created forum
- set subject [ad_generate_random_string]
- set response [forums::twt::new_post "$name" "$subject"]
- aa_display_result -response $response -explanation {Webtest for posting a message in a forum}
+ set message_id [forums::test::new_postings \
+ -user_id $user_id \
+ -forum_id $forum_id ]
- twt::user::logout
- }
-}
-aa_register_case \
- -cats {web smoke} \
- -libraries tclwebtest \
- -procs {forums::twt::new_post forums::twt::new_post forums::twt::edit_post} \
- web_message_edit {
- Editing a message of a forum
-} {
-
- aa_run_with_teardown -test_code {
-
- tclwebtest::cookies clear
-
- # Login user
- array set user_info [twt::user::create -admin]
- twt::user::login $user_info(email) $user_info(password)
-
- # Create a forum
- set name [ad_generate_random_string]
- forums::twt::new "$name"
-
- # Post a message in the created forum
- set subject [ad_generate_random_string]
- forums::twt::new_post "$name" "$subject"
-
- # Edit the posted message
- set response [forums::twt::edit_post "$name" "$subject"]
- aa_display_result -response $response -explanation {Webtest for editing the message of a forum}
-
- twt::user::logout
+ } -teardown_code {
+ if {$message_id != 0} {
+ forum::message::delete -message_id $message_id
+ }
+ if {$forum_id != 0} {
+ forum::delete -forum_id $forum_id
+ }
+ acs::test::user::delete -user_id [dict get $user_info user_id]
}
}
-aa_register_case \
- -cats {web smoke} \
- -libraries tclwebtest \
- -procs {forums::twt::new forums::twt::new_post forums::twt::reply_msg} \
- web_message_reply {
- Post a reply a message in the forum
-} {
- aa_run_with_teardown -test_code {
- tclwebtest::cookies clear
-
- # Login user
- array set user_info [twt::user::create -admin]
- twt::user::login $user_info(email) $user_info(password)
-
- # Create a forum
- set name [ad_generate_random_string]
- forums::twt::new "$name"
-
- # Post a message in the created forum
- set subject [ad_generate_random_string]
- forums::twt::new_post "$name" "$subject"
-
- # Edit the posted message
- set response [forums::twt::reply_msg "$name" "$subject"]
- aa_display_result -response $response -explanation {Webtest for posting a reply to a msg in the forum}
-
- twt::user::logout
- }
-}
-
-aa_register_case \
- -cats {web smoke} \
- -libraries tclwebtest \
- -procs {forums::twt::new forums::twt::new_post forums::twt::delete_post} \
- web_message_delete {
- Delete a message in the forum
-} {
- aa_run_with_teardown -test_code {
-
- tclwebtest::cookies clear
-
- # Login user
- array set user_info [twt::user::create -admin]
- twt::user::login $user_info(email) $user_info(password)
-
- # Create a forum
- set name [ad_generate_random_string]
- forums::twt::new "$name"
-
- # Post a message in the created forum
- set subject [ad_generate_random_string]
- forums::twt::new_post "$name" "$subject"
-
- # Edit the posted message
- set response [forums::twt::delete_post "$name" "$subject"]
- aa_display_result -response $response -explanation {Webtest for deleting a message posted in the forum}
-
- twt::user::logout
- }
-}
# Local variables:
# mode: tcl
# tcl-indent-level: 4
Fisheye: Tag 1.7 refers to a dead (removed) revision in file `openacs-4/packages/forums/tcl/test/tclwebtest-procs.tcl'.
Fisheye: No comparison available. Pass `N' to diff?
Index: openacs-4/packages/forums/tcl/test/webtest-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/test/webtest-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/forums/tcl/test/webtest-procs.tcl 24 Jul 2018 12:45:11 -0000 1.1
+++ openacs-4/packages/forums/tcl/test/webtest-procs.tcl 24 Jul 2018 17:19:58 -0000 1.2
@@ -13,46 +13,46 @@
{-user_id 0}
name
} {
- Create a new forum via the web interface.
+ Create a new forum via the web interface.
} {
# Get the forums admin page url
- #
+ #
set forums_page [aa_get_first_url -package_key forums]
- #
- # Get Data and check status code
- #
- set d [acs::test::http -user_id $user_id $forums_page/admin/forum-new]
- aa_equals "Status code valid" [dict get $d status] 200
+ #
+ # Get Data and check status code
+ #
+ set d [acs::test::http -user_id $user_id $forums_page/admin/forum-new]
+ aa_equals "Status code valid" [dict get $d status] 200
- #
- # Get the form specific data (action, method and provided form-fields)
- #
- set form_data [::acs::test::get_form [dict get $d body] {//form[@id="forum"]}]
-
- #
- # Fill in a few values into the form
- #
- set d [::acs::test::form_reply \
- -user_id $user_id \
- -url [dict get $form_data @action] \
- -update [subst {
- name "$name"
- charter "bla [ad_generate_random_string] bla [ad_generate_random_string]"
- charter.format text/plain
- presentation_type $presentation_type
- posting_policy $posting_policy
- }] \
- [dict get $form_data fields]]
- set reply [dict get $d body]
+ #
+ # Get the form specific data (action, method and provided form-fields)
+ #
+ set form_data [::acs::test::get_form [dict get $d body] {//form[@id="forum"]}]
- #
- # Check, if the form was correctly validated.
- #
- aa_false "Reply contains form-error" [string match *form-error* $reply]
- aa_equals "Status code valid" [dict get $d status] 302
+ #
+ # Fill in a few values into the form
+ #
+ set d [::acs::test::form_reply \
+ -user_id $user_id \
+ -url [dict get $form_data @action] \
+ -update [subst {
+ name "$name"
+ charter "bla [ad_generate_random_string] bla [ad_generate_random_string]"
+ charter.format text/plain
+ presentation_type $presentation_type
+ posting_policy $posting_policy
+ }] \
+ [dict get $form_data fields]]
+ set reply [dict get $d body]
+ #
+ # Check, if the form was correctly validated.
+ #
+ acs::test::reply_contains_no $d form-error
+ aa_equals "Status code valid" [dict get $d status] 302
+
return [dict get $form_data fields forum_id]
}
@@ -61,7 +61,7 @@
{-forum_id 0}
{-name ""}
} {
- View a forum via the web interface.
+ View a forum via the web interface.
} {
set forums_page [aa_get_first_url -package_key forums]
@@ -71,7 +71,7 @@
#
set d [::acs::test::http -user_id $user_id $forums_page]
aa_equals "Status code valid" [dict get $d status] 200
-
+
#
# Follow the link with the provided link label
#
@@ -95,12 +95,12 @@
}
return $d
}
-
+
ad_proc -private edit {
{-user_id 0}
{-forum_id 0}
} {
- Edit a forum via the web interface.
+ Edit a forum via the web interface.
} {
set forums_page [aa_get_first_url -package_key forums]
@@ -109,35 +109,170 @@
$forums_page/admin/forum-edit?forum_id=$forum_id]
aa_equals "Status code valid" [dict get $d status] 200
- #
- # Get the form specific data (action, method and provided form-fields)
- #
- set form_data [::acs::test::get_form [dict get $d body] {//form[@id="forum"]}]
+ #
+ # Get the form specific data (action, method and provided form-fields)
+ #
+ set form_data [::acs::test::get_form [dict get $d body] {//form[@id="forum"]}]
- #
- # Fill in a few values into the form
- #
+ #
+ # Fill in a few values into the form
+ #
set old_name [dict get $form_data fields name]
set old_charter [dict get $form_data fields name]
set new_name "Edited $old_name"
set new_charter "Edited $old_charter"
- set d [::acs::test::form_reply \
- -user_id $user_id \
- -url [dict get $form_data @action] \
- -update [subst {
- name "$new_name"
- charter "$new_charter"
- }] \
- [dict get $form_data fields]]
- set reply [dict get $d body]
- aa_false "Reply contains form-error" [string match *form-error* $reply]
- if {[string match *form-error* $reply]} {
- #set F [open $::acs::rootdir/packages/forums/www/REPLY.html w]; puts $F [dict get $d body]; close $F
- } else {
+ set d [::acs::test::form_reply \
+ -user_id $user_id \
+ -url [dict get $form_data @action] \
+ -update [subst {
+ name "$new_name"
+ charter "$new_charter"
+ }] \
+ [dict get $form_data fields]]
+
+ if {[acs::test::reply_contains_no $d form-error]} {
set d [acs::test::http -user_id $user_id $forums_page]
- aa_true "Overview page contains edited name '$new_name'" [string match *$new_name* [dict get $d body]]
- aa_true "Overview page contains edited charter" [string match *$new_charter* [dict get $d body]]
+ acs::test::reply_contains -prefix "Overview page" $d $new_name
+ acs::test::reply_contains -prefix "Overview page" $d $new_charter
}
}
+ ad_proc -private new_postings {
+ {-user_id 0}
+ {-forum_id 0}
+ } {
+ Add a posting to the provided forum via the web interface.
+
+ @return message_id
+ } {
+ set message_id 0
+ set forums_page [aa_get_first_url -package_key forums]
+
+ set d [acs::test::http \
+ -user_id $user_id \
+ $forums_page/message-post?forum_id=$forum_id]
+ aa_equals "Edit Message: Status code valid" [dict get $d status] 200
+
+ #
+ # Get form data from
+ #
+ set form_data [::acs::test::get_form [dict get $d body] {//form[@id="message"]}]
+ aa_true "Found form on reply page" {[llength $form_data] > 0}
+
+ #
+ # Build reply
+ #
+ set subject "subject [ad_generate_random_string]"
+ set message_body "body [ad_generate_random_string 20]"
+
+ set d [::acs::test::form_reply \
+ -user_id $user_id \
+ -url [dict get $form_data @action] \
+ -update [subst {
+ subject "$subject"
+ message_body "$message_body"
+ message_body.format text/plain
+ }] \
+ [dict get $form_data fields]]
+
+ acs::test::reply_contains_no $d form-error
+ aa_equals "Updated message: Status code valid" [dict get $d status] 302
+
+ aa_log [dict get $form_data fields]
+ set message_id [dict get $form_data fields message_id]
+
+ #
+ # Check on the forums overview page, if we find the new subject
+ #
+ set d [acs::test::http -user_id $user_id $forums_page/forum-view?forum_id=$forum_id]
+ aa_equals "View Forum: Status code valid" [dict get $d status] 200
+
+ acs::test::reply_contains $d $subject
+
+ #
+ # Check on the forums view page, if we find the new subject and the new body
+ #
+ set d [acs::test::http -user_id $user_id $forums_page/message-view?message_id=$message_id]
+ aa_equals "View Message: Status code valid" [dict get $d status] 200
+
+ acs::test::reply_contains $d $subject
+ acs::test::reply_contains $d $message_body
+
+ #
+ # Post a reply to the last message
+ #
+ set d [acs::test::http -user_id $user_id $forums_page/message-post?parent_id=$message_id]
+ set form_data [::acs::test::get_form [dict get $d body] {//form[@id="message"]}]
+ aa_true "Found form on edit page for posting reply" {[llength $form_data] > 0}
+ set reply_message_id [dict get $form_data fields message_id]
+
+ set d [::acs::test::form_reply \
+ -user_id $user_id \
+ -url [dict get $form_data @action] \
+ -update [subst {
+ message_body "REPLY $message_body"
+ message_body.format text/plain
+ }] \
+ [dict get $form_data fields]]
+ acs::test::reply_contains_no $d form-error
+ aa_equals "Entered forums reply: Status code valid" [dict get $d status] 302
+
+ #
+ # The reply should show up on the forums thread page
+ #
+ set d [acs::test::http -user_id $user_id $forums_page/message-view?message_id=$message_id]
+ aa_equals "Message overview: Status code valid" [dict get $d status] 200
+ acs::test::reply_contains $d "REPLY $message_body"
+
+ #
+ # Edit the reply
+ #
+ set d [acs::test::http -user_id $user_id $forums_page/moderate/message-edit?message_id=$reply_message_id]
+ set form_data [::acs::test::get_form [dict get $d body] {//form[@id="message"]}]
+ aa_true "Found form on edit page for editing reply" {[llength $form_data] > 0}
+ set old_reply_message_body [dict get $form_data fields message_body]
+ set new_reply_message_body "$old_reply_message_body EDITED"
+ aa_true "old message_body contains REPLY" [string match "*REPLY*" $old_reply_message_body]
+
+ set d [::acs::test::form_reply \
+ -user_id $user_id \
+ -url [dict get $form_data @action] \
+ -update [subst {
+ message_body "$new_reply_message_body"
+ }] \
+ [dict get $form_data fields]]
+ acs::test::reply_contains_no $d form-error
+ aa_equals "Entered forums reply: Status code valid" [dict get $d status] 302
+
+ #
+ # The edited reply should show up on the forums thread page
+ #
+ set d [acs::test::http -user_id $user_id $forums_page/message-view?message_id=$message_id]
+ aa_equals "Message overview: Status code valid" [dict get $d status] 200
+ acs::test::reply_contains $d "$new_reply_message_body"
+
+ #
+ # Delete the reply
+ #
+ set d [acs::test::http -user_id $user_id $forums_page/moderate/message-delete?message_id=$reply_message_id]
+ aa_equals "Message overview: Status code valid" [dict get $d status] 200
+ acs::test::reply_contains $d message-delete?confirm_p
+
+ set d [::acs::test::follow_link \
+ -user_id $user_id \
+ -base $forums_page/moderate \
+ -label Yes \
+ -html [dict get $d body]]
+ aa_equals "Message overview: Status code valid" [dict get $d status] 302
+
+ #
+ # The edited reply should no show up up on the forums thread page
+ #
+ set d [acs::test::http -user_id $user_id $forums_page/message-view?message_id=$message_id]
+ aa_equals "Message overview: Status code valid" [dict get $d status] 200
+ acs::test::reply_contains_no $d "$new_reply_message_body"
+
+ return $message_id
+ }
+
}