_xowf__create_composite_test_item (private)
_xowf__create_composite_test_item
Defined in packages/xowf/tcl/test/test-item-procs.tcl
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: upvar 2 _aa_exports _aa_exports foreach init_class xowf_require_test_instance { if {[llength $init_class] == 2} { lassign $init_class init_class init_package_key } else { set init_package_key xowf } foreach v $_aa_exports([list $init_package_key $init_class]) { upvar 2 $v $v } foreach logpair $::aa_init_class_logs([list $init_package_key $init_class]) { aa_log_result [lindex $logpair 0] [lindex $logpair 1] } } set _aa_export {} set body_count 1 foreach testcase_body {{ set instance $_xowf_test_instance_name set testfolder .testfolder set locale [lang::system::locale] set lang [string range $locale 0 1] # # Setup of test user_id and login # set user_info [::acs::test::user::create -email xowf@acs-testing.test -admin] set d [::acs::test::login $user_info] try { ########################################################### aa_section "Make sure we have a fresh test folder" ############################################################ set folder_info [::xowiki::test::require_test_folder -last_request $d -instance $instance -folder_name $testfolder -fresh ] set folder_id [dict get $folder_info folder_id] set package_id [dict get $folder_info package_id] aa_true "folder_id '$folder_id' is not 0" {$folder_id != 0} ############################################################## aa_section "Create a simple text interaction with a file link" ############################################################## # {config -use test-items} set dt [::xowiki::test::create_form_page -last_request $d -instance $instance -path $testfolder -parent_id $folder_id -form_name en:edit-interaction.wf -extra_url_parameter {{p.item_type Text}} -update { _title "Sample Text Interaction" _name sample_text_0 _nls_language en_US question.points 4 question.interaction.text {Given a text with a file filled out for the page [[file:somefile]] and some unresolved link [[file:unresolved]] and as an image [[image:sample_text_0_image1.png|Some image1]] and a SELF image [[.SELF./image:sample_text_0_image2.png|Some image2]].} }] # # When the text interaction is opened with preview, and a # file is provided of the unresolved link, it is saved as # a child the question. # set text_page [::xo::db::CrClass get_instance_from_db -item_id [dict get $dt item_id]] aa_section "Create file 'file:somefile' as child of '[$text_page name]' [$text_page item_id]" set file_object [::xowiki::File new -destroy_on_cleanup -title "somefile" -name file:somefile -parent_id [$text_page item_id] -mime_type text/plain -package_id $package_id -creation_user [dict get $user_info user_id]] $file_object set import_file $::acs::rootdir/packages/xowf/tcl/test/test-item-procs.tcl $file_object save_new foreach img {image1.png image2.png} { aa_section "Create image 'file:sample_text_0_$img' as child of '[$text_page name]' [$text_page item_id]" set image_object [::xowiki::File new -destroy_on_cleanup -title "sample_text_0_$img" -name file:sample_text_0_$img -parent_id [$text_page item_id] -mime_type image/png -package_id $package_id -creation_user [dict get $user_info user_id]] $image_object set import_file $::acs::rootdir/packages/acs-subsite/www/resources/attach.png $image_object save_new } ############################################################# aa_section "Call preview workflow for '[$text_page name]'" set d [::xowiki::test::edit_form_page -last_request $dt -refetch=0 -path $testfolder/[$text_page name] -update { __action_preview "" __form_action "save-form-data" }] acs::test::reply_has_status_code $d 302 set location /[::acs::test::get_url_from_location $d] set d [acs::test::http -last_request $d $location] acs::test::reply_has_status_code $d 302 set location /[::acs::test::get_url_from_location $d] set d [acs::test::http -last_request $d $location] acs::test::dom_html root [dict get $d body] { set resolved [lmap p [$root selectNodes {//a[@class='file']/@href}] {file tail [lindex $p 1]}] set unresolved [lmap p [$root selectNodes {//a[@class='missing']/@href}] {file tail [lindex $p 1]}] set images [lmap p [$root selectNodes {//img[@class='image']/@src}] {file tail [lindex $p 1]}] } aa_log "RESOLVED='$resolved'" aa_log "UNRESOLVED='$unresolved'" aa_log "IMAGES='$images'" aa_true "link 'somefile' is resolved" {"somefile" in $resolved} aa_true "link 'unresolved' is not resolved" [string match "*file:unresolved*" $unresolved] aa_true "image 'sample_text_0_image1' is resolved" {"sample_text_0_image1.png" in $images} aa_true "image 'sample_text_0_image2' is resolved" {"sample_text_0_image2.png" in $images} ########################################################################################## aa_section "create composite page 'sample_composite_0'" set dt [::xowiki::test::create_form_page -last_request $d -instance $instance -path $testfolder -parent_id $folder_id -form_name en:edit-interaction.wf -extra_url_parameter {{p.item_type Composite}} -update { _title "Sample composite Interaction" _name sample_composite_0 _nls_language en_US question.points 4 question.twocol f question.interaction.text { Given a text with an [[file:otherfile]] img [[image:sample_composite_0_image1.png|Some image]] SELF img [[.SELF./image:sample_composite_0_image2.png|Some image2-self]].} question.interaction.selection .testfolder/en:sample_text_0 }] set composite_page [::xo::db::CrClass get_instance_from_db -item_id [dict get $dt item_id]] aa_section "Create file 'file:somefile' as child of '[$text_page name]'" set file_object [::xowiki::File new -destroy_on_cleanup -title "otherfile" -name file:otherfile -parent_id [$composite_page item_id] -mime_type text/plain -package_id $package_id -creation_user [dict get $user_info user_id]] $file_object set import_file $::acs::rootdir/packages/xowf/tcl/test/test-item-procs.tcl $file_object save_new foreach img {image1.png image2.png} { set image_object [::xowiki::File new -destroy_on_cleanup -title "sample_composite_0_$img" -name file:sample_composite_0_$img -parent_id [$composite_page item_id] -mime_type image/png -package_id $package_id -creation_user [dict get $user_info user_id]] $image_object set import_file $::acs::rootdir/packages/acs-subsite/www/resources/attach.png $image_object save_new } ############################################################# aa_section "Call preview workflow for '[$composite_page name]'" set d [::xowiki::test::edit_form_page -last_request $dt -refetch=0 -path $testfolder/[$composite_page name] -update { __action_preview "" __form_action "save-form-data" }] acs::test::reply_has_status_code $d 302 set location /[::acs::test::get_url_from_location $d] set d [acs::test::http -last_request $d $location] acs::test::reply_has_status_code $d 302 set location /[::acs::test::get_url_from_location $d] set d [acs::test::http -last_request $d $location] acs::test::dom_html root [dict get $d body] { set resolved [lmap p [$root selectNodes {//a[@class='file']/@href}] {file tail [lindex $p 1]}] set unresolved [lmap p [$root selectNodes {//a[@class='missing']/@href}] {file tail [lindex $p 1]}] set images [lmap p [$root selectNodes {//img[@class='image']/@src}] {file tail [lindex $p 1]}] } aa_log "RESOLVED='$resolved'" aa_log "UNRESOLVED='$unresolved'" aa_log "IMAGES='$images'" aa_true "link 'somefile' is resolved" {"somefile" in $resolved} aa_true "link 'otherfile' is resolved" {"otherfile" in $resolved} foreach filename { sample_text_0_image1.png sample_text_0_image2.png sample_composite_0_image1.png sample_composite_0_image2.png } { aa_true "image '$filename' is resolved" {$filename in $images} } } on error {errorMsg} { aa_true "Error msg: $errorMsg" 0 } finally { # # In case something has to be cleaned manually, do it here. # } }} { aa_log "Running testcase body $body_count" set ::__aa_test_indent [info level] set catch_val [catch $testcase_body msg] if {$catch_val != 0 && $catch_val != 2} { aa_log_result "fail" "create_composite_test_item (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo" } incr body_count }XQL Not present: Generic, PostgreSQL, Oracle