_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):
%3 _ _ (public) aa_equals aa_equals (public) aa_log aa_log (public) aa_log_result aa_log_result (public) aa_section aa_section (public) _xowiki__create_form_with_numeric _xowiki__create_form_with_numeric _xowiki__create_form_with_numeric->_ _xowiki__create_form_with_numeric->aa_equals _xowiki__create_form_with_numeric->aa_log _xowiki__create_form_with_numeric->aa_log_result _xowiki__create_form_with_numeric->aa_section

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}

            set installed_locales [lang::system::get_locales]
            # en_US must be always in installed_locales
            set enabled_locale_with_decimal_point_comma ""
            foreach locale $installed_locales {
                if {$locale in {de_DE it_IT es_ES}} {
                    set enabled_locale_with_decimal_point_comma $locale
                    break
                }
            }
            if {$enabled_locale_with_decimal_point_comma ne ""} {
                set test_user_id [dict get $user_info user_id]

                lang::user::set_locale -user_id $test_user_id "en_US"
                aa_equals "check 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 $enabled_locale_with_decimal_point_comma
                aa_equals "check test_user can be set to $enabled_locale_with_decimal_point_comma"  [lang::user::locale -user_id $test_user_id$enabled_locale_with_decimal_point_comma

                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 locales with decimal point set to comma, installed are '[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
[ hide source ] | [ make this the default ]
Show another procedure: