xowiki::test::create_form_page (public)
xowiki::test::create_form_page -user_id user_id \ [ -last_request last_request ] -instance instance \ -parent_id parent_id -form_name form_name -path path \ [ -autonamed ] [ -update update ] [ -remove remove ] \ [ -extra_url_parameter extra_url_parameter ] \ [ -expect_validation_error expect_validation_error ]
Defined in packages/xowiki/tcl/test/test-procs.tcl
Create a form page via the web interface. In essence, this calls $instance/$path/$form_name?m=create-new
- Switches:
- -user_id (required, defaults to
"0"
)- -last_request (optional)
- -instance (required)
- -parent_id (required)
- -form_name (required)
- -path (required)
- -autonamed (optional, boolean, defaults to
"false"
)- -update (optional)
- -remove (optional)
- -extra_url_parameter (optional)
- -expect_validation_error (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- create_test_items, xowf, create_composite_test_item, create_folder_with_page, create_workflow_with_instance, create_form_with_form_instance, create_form_with_numeric, form_validate
Source code: # # Create a page under the parent_id # aa_log "create a page in test test folder $parent_id" set url $instance/$path/$form_name?m=create-new&parent_id=$parent_id if {$extra_url_parameter ne ""} { append url &[export_vars $extra_url_parameter] } #aa_log "... create page via url: $url" set d [acs::test::http -last_request $last_request -user_id $user_id $url] acs::test::reply_has_status_code $d 302 set location [::acs::test::get_url_from_location $d] aa_true "create_form_page: location '$location' is valid" {$location ne ""} # # Call "edit" method on the new page # set d [acs::test::http -last_request $last_request -user_id $user_id $location] acs::test::reply_has_status_code $d 200 set formCSSClass [::xowiki::utility formCSSclass $form_name] set response [dict get $d body] acs::test::dom_html root $response { ::acs::test::xpath::non_empty $root [subst { //form\[contains(@class,'$formCSSClass')\]//button }] set form [::acs::test::xpath::get_form $root [subst { //form\[contains(@class,'$formCSSClass')\] }]] #aa_log "FORM_CONTENT !$form!" set fields [acs::test::form_get_fields $form] set f_page_name [dict get $fields _name] set f_creator [dict get $fields _creator] if {$autonamed_p} { aa_true "create_form_page: page_name '$f_page_name' is NOT empty" {$f_page_name ne ""} } else { aa_log "autonamed form pages has page_name '$f_page_name' is empty" dict set form_content _name $f_page_name } aa_true "create_form_page: creator '$f_creator' is nonempty" {$f_creator ne ""} set f_form_action [dict get $form @action] aa_true "create_form_page: form_action '$f_form_action' is nonempty" {$f_form_action ne ""} set names [dict keys $fields] aa_log "create_form_page: form names: [lsort $names]" aa_true "create_form_page: page has at least 9 fields" { [llength $names] >= 9 } } set d [::acs::test::form_reply -last_request $last_request -user_id $user_id -form $form -update $update -remove $remove] if {$expect_validation_error ne ""} { aa_log "HAVE VALIDATION ERROR" acs::test::reply_has_status_code $d 200 set response [dict get $d body] acs::test::dom_html root $response { set errorNodes [$root selectNodes {//div[contains(@class,'form-error')]}] aa_true "errorNodes exist '$errorNodes'" {$errorNodes ne ""} set errorMsgs {} foreach n $errorNodes { aa_log "validation error '[$n text]'" lappend errorMsgs [$n text] } aa_true "contains expected msg '$expect_validation_error'" {$expect_validation_error in $errorMsgs} } } else { acs::test::reply_has_status_code $d 302 #set response [dict get $d body] #ns_log notice "FORM POST\n$response" foreach {key value} $update { dict set form_content $key $value } aa_log "create_form_page: form_content:\n[::xowiki::test::pretty_form_content $form_content]" set location [::acs::test::get_url_from_location $d] aa_true "create_form_page: location '$location' is valid" {$location ne ""} set d [acs::test::http -last_request $last_request -user_id $user_id $location] acs::test::reply_has_status_code $d 200 ::xo::Package initialize -url $location set lang [string range [lang::system::locale] 0 1] set page_info [::$package_id item_ref -default_lang $lang -parent_id $parent_id [dict get $form_content _name] ] set item_id [dict get $page_info item_id] #aa_log "lookup of $folder_name/page -> $item_id" if {$item_id == 0} {error "Page not found"} ::xo::db::CrClass get_instance_from_db -item_id $item_id set d [acs::test::http -last_request $last_request -user_id $user_id $instance/admin/set-publish-state?state=ready&revision_id=[::$item_id revision_id]] acs::test::reply_has_status_code $d 302 aa_log "create_form_page: DONE" dict set d page_info $page_info dict set d instance $instance dict set d item_id $item_id } return $dXQL Not present: Generic, PostgreSQL, Oracle