Index: openacs-4/packages/file-storage/tcl/test/file-storage-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/test/file-storage-procs.tcl,v diff -u -r1.10.2.1 -r1.10.2.2 --- openacs-4/packages/file-storage/tcl/test/file-storage-procs.tcl 16 Apr 2019 20:08:23 -0000 1.10.2.1 +++ openacs-4/packages/file-storage/tcl/test/file-storage-procs.tcl 17 Apr 2019 11:00:16 -0000 1.10.2.2 @@ -10,6 +10,7 @@ -cats {web smoke} \ -procs { file_storage::test::create_new_folder + file_storage::test::delete_current_folder } \ fs_create_folder { @@ -19,7 +20,7 @@ } { try { - # Create a test user + aa_section "Create a test user" set user_info [acs::test::user::create -admin] aa_run_with_teardown -test_code { @@ -55,50 +56,75 @@ # # Get rid of the user # + aa_section "Delete test user" acs::test::user::delete -user_id [dict get $user_info user_id] } } - aa_register_case \ -cats {web smoke} \ - -libraries tclwebtest \ -procs { - file_storage::twt::call_fs_page - file_storage::twt::create_new_folder - file_storage::twt::edit_folder + file_storage::test::create_new_folder + file_storage::test::edit_folder + file_storage::test::delete_current_folder } \ fs_edit_folder { Test Edit a Folder. @author Mounir Lallali } { - aa_run_with_teardown -test_code { - tclwebtest::cookies clear + try { + aa_section "Create a test user" + set user_info [acs::test::user::create -admin] - # Login user - array set user_info [twt::user::create -admin] - twt::user::login $user_info(email) $user_info(password) + aa_run_with_teardown -test_code { + # + # Go to the first instance of the file storage + # + set fs_page [aa_get_first_url -package_key file-storage] + set d [acs::test::http -user_info $user_info $fs_page] - file_storage::twt::call_fs_page + # + # Create a new folder with a random name in this instance + # + aa_section "Create a fresh folder" + set folder_name [ad_generate_random_string] + set folder_description [ad_generate_random_string] + set d [file_storage::test::create_new_folder \ + -last_request $d \ + $folder_name $folder_description] - # Create a new folder - set folder_name [ad_generate_random_string] - set folder_description [ad_generate_random_string] - file_storage::twt::create_new_folder $folder_name $folder_description + acs::test::reply_has_status_code $d 200 + aa_log "Folder $folder_name was created successfully" - # Edit a folder - set new_folder_name [ad_generate_random_string] - set response [file_storage::twt::edit_folder $new_folder_name] + aa_section "Edit folder" - aa_display_result -response $response -explanation {for editing a folder} + set folder_name [ad_generate_random_string] + set d [file_storage::test::edit_folder \ + -last_request $d \ + $folder_name] - twt::user::logout + acs::test::reply_has_status_code $d 200 + aa_log "Folder $folder_name was edited successfully" + + # + # Finally, delete the folder + # + aa_section "Delete the empty folder" + file_storage::test::delete_current_folder -last_request $d + } + } finally { + # + # Get rid of the user + # + aa_section "Delete test user" + acs::test::user::delete -user_id [dict get $user_info user_id] } } + aa_register_case \ -cats {web smoke} \ -libraries tclwebtest \ Index: openacs-4/packages/file-storage/tcl/test/tclwebtest-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/test/tclwebtest-procs.tcl,v diff -u -r1.9 -r1.9.2.1 --- openacs-4/packages/file-storage/tcl/test/tclwebtest-procs.tcl 15 Aug 2018 16:35:22 -0000 1.9 +++ openacs-4/packages/file-storage/tcl/test/tclwebtest-procs.tcl 17 Apr 2019 11:00:16 -0000 1.9.2.1 @@ -37,16 +37,16 @@ Creates a new folder from the UI. } { set response 0 - + tclwebtest::link follow {New Folder} - + tclwebtest::form find ~n "folder-ae" tclwebtest::field find ~n "folder_name" tclwebtest::field fill $folder_name tclwebtest::field find ~n "description" tclwebtest::field fill $folder_description tclwebtest::form submit - + set response_url [tclwebtest::response url] if { [string match "*/\?folder_id*" $response_url] } { @@ -70,7 +70,7 @@ set response 0 tclwebtest::link follow {Delete this folder} - + tclwebtest::form find ~n "folder-delete" tclwebtest::form submit ~n {formbutton:ok} @@ -91,35 +91,7 @@ return $response } -ad_proc file_storage::twt::edit_folder { folder_name } { - Edits a folder from the UI. -} { - set response 0 - tclwebtest::link follow {Edit Folder} - - tclwebtest::form find ~a "folder-edit-2" - tclwebtest::field find ~n "folder_name" - tclwebtest::field fill $folder_name - tclwebtest::form submit - - set response_url [tclwebtest::response url] - - if { [string match "*\?folder_id*" $response_url] } { - - if { [catch {tclwebtest::assert text $folder_name} errmsg]} { - aa_error "file_storage::twt::edit_folder failed $errmsg : Didn't Edit a Folder" - } else { - aa_log "a Folder edited" - set response 1 - } - } else { - aa_error "file_storage::twt::edit_folder failed, bad response url : $response_url" - } - - return $response -} - ad_proc file_storage::twt::add_file_to_folder { folder_name file_name file_description } { Adds a file to a folder from the UI. } { @@ -214,7 +186,7 @@ if { [string match "*\?folder*id*" $response_url] } { - set list_words [split "$file_name" /] + set list_words [split "$file_name" /] set short_file_name [lindex $list_words [llength $list_words]-1] if {[catch {tclwebtest::link find $short_file_name} errmsg]} { @@ -226,14 +198,14 @@ } else { aa_error "file_storage::twt::upload_file failed, bad response url : $response_url" } - + return $response } ad_proc file_storage::twt::delete_uploaded_file { file_name } { Deletes a file from the UI. } { - + set response 0 # Follow the Delete File Link @@ -247,9 +219,9 @@ if { [string match "*\?folder*id*" $response_url] } { - # Get the short file name - set list_words [split "$file_name" /] - set short_file_name [lindex $list_words [llength $list_words]-1] + # Get the short file name + set list_words [split "$file_name" /] + set short_file_name [lindex $list_words [llength $list_words]-1] if {![catch {tclwebtest::link find $short_file_name} errmsg]} { aa_error "file_storage::twt::delete_file failed $errmsg : Didn't delete a File" @@ -260,7 +232,7 @@ } else { aa_error "file_storage::twt::delete_file failed, bad response url : $response_url" } - + return $response } @@ -387,18 +359,18 @@ set response_url [tclwebtest::response url] if { [string match "*\?folder*id*" $response_url] } { - + if {[catch {tclwebtest::link find $url_title} errmsg]} { aa_error "file_storage::twt::create_url $errmsg : Didn't create a URL" } else { aa_log "a URL created" set response 1 } - + } else { - aa_error "file_storage::twt::create_url failed, bad response url : $response_url" + aa_error "file_storage::twt::create_url failed, bad response url : $response_url" } - + return $response } @@ -433,7 +405,7 @@ aa_log "a URL edited" set response 1 } - + } else { aa_error "file_storage::twt::edit_url failed, bad response url : $response_url" } @@ -451,7 +423,7 @@ # Follow the Delete URL link tclwebtest::link follow {delete} - + set response_url [tclwebtest::response url] if { [string match "*/dotlrn/file-storage/\?folder*id*" $response_url] } { Index: openacs-4/packages/file-storage/tcl/test/webtest-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/test/webtest-procs.tcl,v diff -u -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/file-storage/tcl/test/webtest-procs.tcl 16 Apr 2019 20:08:23 -0000 1.1.2.1 +++ openacs-4/packages/file-storage/tcl/test/webtest-procs.tcl 17 Apr 2019 11:00:16 -0000 1.1.2.2 @@ -22,6 +22,7 @@ set response [dict get $d body] set form [acs::test::get_form $response {//form[@id='folder-ae']}] + aa_true "create form was returned" {[llength $form] > 2} set d [::acs::test::form_reply \ -last_request $d \ @@ -44,6 +45,43 @@ return $d } + ad_proc ::file_storage::test::edit_folder { + -last_request:required + folder_name + } { + Create a new folder via Web UI. + } { + # + # Create a new folder based on the current page, which is from + # a file-storage instance + # + set d [acs::test::follow_link -last_request $last_request -label {Edit Folder}] + acs::test::reply_has_status_code $d 200 + + set response [dict get $d body] + set form [acs::test::get_form $response {//form[@id='folder-edit']}] + aa_true "edit form was returned" {[llength $form] > 2} + aa_log form=$form + set d [::acs::test::form_reply \ + -last_request $d \ + -url [dict get $form @action] \ + -update [subst { + folder_name "$folder_name" + }] \ + [dict get $form fields]] + acs::test::reply_has_status_code $d 302 + set location [::xowiki::test::get_url_from_location $d] + + if { [string match "*/\?folder_id*" $location] } { + set d [acs::test::http -last_request $d $location] + acs::test::reply_contains $d $folder_name + } else { + aa_error "file_storage::test::create_new_folder failed, bad response url : $location" + } + + return $d + } + ad_proc ::file_storage::test::delete_current_folder { -last_request:required } { @@ -55,6 +93,7 @@ set d [acs::test::follow_link -last_request $last_request -label {Delete this folder}] acs::test::reply_has_status_code $d 200 set form [acs::test::get_form [dict get $d body] {//form[@id='folder-delete']}] + aa_true "delete form was returned" {[llength $form] > 2} set d [::acs::test::form_reply \ -last_request $d \