Index: openacs-4/packages/forums/forums.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/forums/forums.info,v
diff -u -N -r1.54 -r1.55
--- openacs-4/packages/forums/forums.info 23 Jul 2018 19:42:34 -0000 1.54
+++ openacs-4/packages/forums/forums.info 24 Jul 2018 12:45:11 -0000 1.55
@@ -9,7 +9,7 @@
f
t
-
+
OpenACS
Online discussion forums.
2017-08-06
@@ -26,7 +26,7 @@
-
+
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 -N -r1.8 -r1.9
--- openacs-4/packages/forums/tcl/test/forums-procs.tcl 23 Jul 2018 19:42:34 -0000 1.8
+++ openacs-4/packages/forums/tcl/test/forums-procs.tcl 24 Jul 2018 12:45:11 -0000 1.9
@@ -176,99 +176,128 @@
aa_register_case \
-cats {api web smoke} \
-procs {forum::delete} \
- web_forum_new {
+ -urls {
+ /admin/forum-new
+ } web_forum_new {
Testing the creation of a forum via web
} {
+ set forum_id 0
aa_run_with_teardown -test_code {
- #tclwebtest::cookies clear
-
#
# Create a new admin user
#
set user_info [acs::test::user::create -admin]
set user_id [dict get $user_info user_id]
#
- # Get the forums admin page url
+ # Create a new forum
#
- set forums_page [aa_get_first_url -package_key forums]
- set d [acs::test::http \
- -user_id $user_id \
- $forums_page/admin/forum-new]
- aa_equals "Status code valid" [dict get $d status] 200
-
+ set name [ad_generate_random_string]
+ set forum_id [forums::test::new -user_id $user_id $name]
+
+
+ } -teardown_code {
#
- # Get the form specific data (action, method and provided form-fields)
+ # In order to be able to delete the user, we have first to
+ # delete the fresh forum (via API).
#
- acs::test::dom_html root [dict get $d body] {
- set n_form [$root selectNodes {//form[@id="forum"]}]
- set f_action [lindex [$root selectNodes {//form[@id='forum']/@action}] 0 1]
- set f_method [lindex [$root selectNodes {//form[@id='forum']/@method}] 0 1]
- set f_fields [::acs::test::xpath::get_form_values $root {//form[@id='forum']}]
+ 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 {api web smoke} \
+ -procs {forum::delete} \
+ -urls {
+ /admin/forum-new
+ /forum-view
+ } web_forum_view {
+ Testing the creation of a forum via web
+} {
+ set forum_id 0
+ aa_run_with_teardown -test_code {
+
#
- # Fill in a few values into the form
+ # Create a new admin user
#
- set d [::acs::test::form_reply \
- -user_id $user_id \
- -url $f_action \
- -update [subst {
- name "[ad_generate_random_string]"
- charter "[ad_generate_random_string] [ad_generate_random_string]"
- charter.format text/plain
- presentation_type flat
- posting_policy open
- }] \
- $f_fields ]
- set reply [dict get $d body]
- #set F [open /tmp/REPLY.html w]; puts $F $reply; close $F
+ set user_info [acs::test::user::create -admin]
+ set user_id [dict get $user_info user_id]
#
- # Check, if the form was correctly validated
+ # Create a new forum
#
- aa_false "Reply contains form-error" [string match *form-error* $reply]
- aa_equals "Status code valid" [dict get $d status] 302
+ set name [ad_generate_random_string]
+ set forum_id [forums::test::new -user_id $user_id $name]
+ aa_log "Created forum with id $forum_id"
#
- # in order to be able to delete the user, we have first to
- # delete the fresh forum (via API)
+ # View a forum via name.
#
- forum::delete -forum_id [dict get $f_fields forum_id]
+ set response [forums::test::view \
+ -user_id $user_id \
+ -name $name ]
+ #
+ # View a forum via forum_id.
+ #
+ set response [forums::test::view \
+ -user_id $user_id \
+ -forum_id $forum_id ]
} -teardown_code {
+ #
+ # Delete the forum.
+ #
+ 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::edit forums::twt::new} \
+ -urls {
+ /admin/forum-new
+ /admin/forum-edit
+ } \
web_forum_edit {
Testing the edition of an existing forum
} {
-
+ set forum_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]
+ #
# Edit the created forum
- set response [forums::twt::edit $name]
- aa_display_result -response $response -explanation {Webtest for the edition of a forum}
-
- twt::user::logout
+ #
+ set response [forums::test::edit \
+ -user_id $user_id \
+ -forum_id $forum_id \
+ ]
+
+ } -teardown_code {
+ if {$forum_id != 0} {
+ forum::delete -forum_id $forum_id
+ }
+ acs::test::user::delete -user_id [dict get $user_info user_id]
}
}
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 -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/forums/tcl/test/webtest-procs.tcl 24 Jul 2018 12:45:11 -0000 1.1
@@ -0,0 +1,143 @@
+ad_library {
+ Automated tests.
+ @author Gustaf Neumann
+
+ @creation-date 24 July 2018
+}
+
+namespace eval forums::test {
+
+ ad_proc -private new {
+ {-presentation_type flat}
+ {-posting_policy open}
+ {-user_id 0}
+ name
+ } {
+ 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 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]
+
+ #
+ # 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
+
+ return [dict get $form_data fields forum_id]
+ }
+
+ ad_proc -private view {
+ {-user_id 0}
+ {-forum_id 0}
+ {-name ""}
+ } {
+ View a forum via the web interface.
+ } {
+ set forums_page [aa_get_first_url -package_key forums]
+
+ if {$name ne ""} {
+ #
+ # Call to the forums page
+ #
+ 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
+ #
+ set d [::acs::test::follow_link \
+ -user_id $user_id \
+ -base $forums_page \
+ -label $name \
+ -html [dict get $d body]]
+ aa_equals "Status code valid" [dict get $d status] 200
+ }
+
+ #
+ # Check via the forum_id, when provided
+ #
+ if {$forum_id != 0} {
+ aa_log "check via forum_id"
+ set d [::acs::test::http \
+ -user_id $user_id \
+ $forums_page/forum-view?forum_id=$forum_id]
+ aa_equals "Status code valid" [dict get $d status] 200
+ }
+ return $d
+ }
+
+ ad_proc -private edit {
+ {-user_id 0}
+ {-forum_id 0}
+ } {
+ Edit a forum via the web interface.
+ } {
+ set forums_page [aa_get_first_url -package_key forums]
+
+ set d [acs::test::http \
+ -user_id $user_id \
+ $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"]}]
+
+ #
+ # 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::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]]
+ }
+ }
+
+}