_xowiki__create_form_with_numeric (private)
_xowiki__create_form_with_numeric
Defined in packages/xowiki/tcl/test/xowiki-test-procs.tcl
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set _aa_export {} set body_count 1 foreach testcase_body {{ # # Setup of test user_id and login # set user_info [::acs::test::user::create -email xowiki@acs-testing.test -admin] set request_info [::acs::test::login $user_info] set instance /xowiki-test set package_id [::acs::test::require_package_instance -package_key xowiki -empty -instance_name $instance] set testfolder .testfolder try { ########################################################### aa_section "Require test folder" ########################################################### set folder_info [::xowiki::test::require_test_folder -last_request $request_info -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 "Check locales" ########################################################### set installed_locales [lang::system::get_locales] # en_US must be always in installed_locales # # The tests below check conversion from to values with # decimal points and decimal commas. This test can only be # performed, when the locale of the package # (package_locale) to be tested is installed and loaded, # and its decimal point is a comma. # set package_locale [lang::conn::locale -package_id $package_id] set user_locale en_US foreach locale $installed_locales { if {[lang::message::lookup $locale acs-lang.localization-decimal_point .] eq ","} { set user_locale $locale break } } aa_log "package_locale $package_locale user_locale $user_locale" if {$user_locale ne "en_US"} { aa_log "perform tests with user_locale $user_locale (assuming the decimal point is a comma)" set test_user_id [dict get $user_info user_id] lang::user::set_locale -user_id $test_user_id "en_US" aa_equals "check if locale of test_user can be set to en_US" [lang::user::locale -user_id $test_user_id] en_US lang::user::set_locale -user_id $test_user_id $user_locale aa_equals "check if locale of test_user can be set to $user_locale" [lang::user::locale -user_id $test_user_id] $user_locale set locale [lang::system::locale] set lang [string range $locale 0 1] set form_name en:numeric-testing.form ########################################################### aa_section "Create Form $form_name" ########################################################### # ::xowiki::test::create_form -last_request $request_info -instance $instance -path $testfolder -parent_id $folder_id -name $form_name -update [subst { title "Numeric Testing Form" nls_language en_US text { <p> @numeric@ @nums@ @mycompoundnumeric@ </p> } text.format text/html form { <form> @numeric@ @nums@ @mycompoundnumeric@ </form> } form.format text/html form_constraints { _page_order:omit _title:omit _nls_language:omit _description:omit {numeric:numeric} {nums:numeric,repeat=1..3} mycompoundnumeric:regression_test_compound_numeric } }] aa_log "Form $form_name created" set page_name en:num1 ########################################################### aa_section "Create an instance of $form_name named '$page_name'" ########################################################### # # provide the value "1.2" and "6.66" as the # numeric value in the compound field # ::xowiki::test::create_form_page -last_request $request_info -instance $instance -path $testfolder -parent_id $folder_id -form_name $form_name -update [subst { _name $page_name _title "fresh $page_name" _nls_language $locale numeric 1.2 nums.1 1.1 nums.2 1.2 mycompoundnumeric.anumber 6.66 }] aa_log "Page $page_name created" ########################################################### aa_section "Edit $form_name named '$page_name'" ########################################################### set extra_url_parameter {{m edit}} aa_log "Edit page with $page_name [lang::user::locale -user_id $test_user_id]" set d [acs::test::http -last_request $request_info [export_vars -base $instance/$testfolder/$page_name $extra_url_parameter]] acs::test::reply_has_status_code $d 200 set response [dict get $d body] acs::test::dom_html root $response { set f_id [::xowiki::test::get_object_name $root] set CSSclass [::xowiki::test::get_form_CSSclass $root] aa_true "page_name '$f_id' non empty" {$f_id ne ""} aa_true "CSSclass: '$CSSclass' non empty" {$CSSclass ne ""} set id_part [string map {: _} $page_name] set node [$root getElementById F.$id_part.numeric] aa_true "initial numeric field is found" {$node ne ""} set value [$node getAttribute value] aa_equals "initial numeric value is '$value'" $value "1,20" set node [$root getElementById F.$id_part.mycompoundnumeric.anumber] aa_true "initial compound numeric field is found" {$node ne ""} set value [$node getAttribute value] aa_equals "initial compound numeric value is '$value'" $value "6,66" } ########################################################### aa_section "Edit and change $form_name named '$page_name'" ########################################################### ::xowiki::test::edit_form_page -last_request $d -instance $instance -path $testfolder/$page_name -update [subst { _title "edited $page_name" numeric "1,3" nums.1 "1,11" nums.2 "1,21" mycompoundnumeric.anumber "6,7" }] set d [acs::test::http -last_request $request_info [export_vars -base $instance/$testfolder/$page_name $extra_url_parameter]] acs::test::reply_has_status_code $d 200 set response [dict get $d body] acs::test::dom_html root $response { set f_id [::xowiki::test::get_object_name $root] set id_part [string map {: _} $page_name] set node [$root getElementById F.$id_part.numeric] set value [$node getAttribute value] aa_equals "edit numeric value is '$value'" $value "1,30" set node [$root getElementById F.$id_part.nums.1] set value [$node getAttribute value] aa_equals "edit compound numeric value is '$value'" $value "1,11" set compoundNumNode [$root getElementById F.$id_part.mycompoundnumeric.anumber] set compoundNumValue [$compoundNumNode getAttribute value] aa_equals "edit compound numeric value is '$compoundNumValue'" $compoundNumValue "6,70" } ########################################################### aa_section "Edit in en_US $form_name named '$page_name'" ########################################################### # # We have now the numeric value with the comma, now # change language to en. The value displayed (in edit # field, or in view should be now the value with the # period). # lang::user::set_locale -user_id $test_user_id "en_US" set d [acs::test::http -last_request $request_info [export_vars -base $instance/$testfolder/$page_name $extra_url_parameter]] acs::test::reply_has_status_code $d 200 set response [dict get $d body] acs::test::dom_html root $response { set f_id [::xowiki::test::get_object_name $root] set id_part [string map {: _} $page_name] set node [$root getElementById F.$id_part.numeric] set value [$node getAttribute value] aa_equals "en_US numeric value is '$value'" $value "1.30" set node [$root getElementById F.$id_part.nums.1] set value [$node getAttribute value] aa_equals "en_US compound numeric value is '$value'" $value "1.11" set node [$root getElementById F.$id_part.mycompoundnumeric.anumber] set value [$node getAttribute value] aa_equals "en_US compound numeric value is '$value'" $value "6.70" } } else { aa_log "This test needs a locale with the decimal point set to comma, installed locales '[lang::system::get_locales]'" } } on error {errorMsg} { aa_true "Error msg: $errorMsg" 0 } finally { # # In case something has to be cleaned manually, do it here. # if {$package_id ne "" && $instance ne ""} { set node_id [site_node::get_element -url $instance -element node_id] site_node::delete -node_id $node_id -delete_package } } }} { 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_form_with_numeric (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo" } incr body_count }XQL Not present: Generic, PostgreSQL, Oracle