[Rt-commit] rt branch, 4.0/custom-fields-groups, updated. rt-4.0.4-252-g3a262ec

Thomas Sibley trs at bestpractical.com
Sat Nov 3 02:18:26 EDT 2012


The branch, 4.0/custom-fields-groups has been updated
       via  3a262ec94f6801ca0c1b63bccc48662b9061b004 (commit)
      from  6fd71d6e63319ea4090836457a5464102cbffaa4 (commit)

Summary of changes:
 t/web/cf_groups.t | 47 ++++++++++++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 19 deletions(-)

- Log -----------------------------------------------------------------
commit 3a262ec94f6801ca0c1b63bccc48662b9061b004
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Nov 2 23:12:01 2012 -0700

    Replace form_name/input/click pattern with a simple usage of submit_form_ok
    
    The "with_fields" form selection is more robust than relying on the form
    name, which may change when this branch is merged.  Additionally,
    submit_form_ok validates that it was able to a) find a form, b) find the
    fields to fill in, and c) click the button.  None of previously used
    methods were error checked.
    
    Two uses of form_name still exist, but they are a slightly more complex
    pattern of selecting a form and building up inputs in a loop.
    Additionally, the DOM is checked more rigorously for correct inputs in
    those test blocks.
    
    For ease of development, switch to a "done_testing()" approach to the
    test plan rather than a static count.

diff --git a/t/web/cf_groups.t b/t/web/cf_groups.t
index 7f09e6d..88bd4ef 100644
--- a/t/web/cf_groups.t
+++ b/t/web/cf_groups.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 67;
+use RT::Test tests => undef;
 
 RT->Config->Set( 'CustomFieldGroupings',
     'RT::Ticket' => {
@@ -93,50 +93,56 @@ ok $m->login, 'logged in as root';
     note "testing Basics/People/Dates/Links pages";
     { # Basics
         $m->follow_link_ok({id => 'page-basics'}, 'Ticket -> Basics');
-        $m->form_name("TicketModify");
         is $m->dom->find(qq{input[name^="$prefix"][name\$="-Value"]})->size, 2,
             "only one CF input on the page";
         my $input_name = $prefix . $CF{'TestBasics'}->id .'-Value';
         ok $m->dom->at(qq{.ticket-info-basics input[name="$input_name"]}),
             "CF is in the right place";
-        $m->field( $input_name, "TestBasicsChanged" );
-        $m->click('SubmitTicket');
+        $m->submit_form_ok({
+            with_fields => { $input_name => "TestBasicsChanged" },
+            button      => 'SubmitTicket',
+        });
         $m->content_like(qr{to TestBasicsChanged});
 
-        $m->form_name("TicketModify");
-        $m->field( $input_name, "bad value" );
-        $m->click('SubmitTicket');
+        $m->submit_form_ok({
+            with_fields => { $input_name => "bad value" },
+            button      => 'SubmitTicket',
+        });
         $m->content_like(qr{Input must match});
     }
     { # Custom group 'More'
         $m->follow_link_ok({id => 'page-basics'}, 'Ticket -> Basics');
-        $m->form_name("TicketModify");
         my $input_name = $prefix . $CF{'TestMore'}->id .'-Value';
         ok $m->dom->at(qq{.ticket-info-cfs input[name="$input_name"]}),
             "CF is in the right place";
-        $m->field( $input_name, "TestMoreChanged" );
-        $m->click('SubmitTicket');
+        $m->submit_form_ok({
+            with_fields => { $input_name => "TestMoreChanged" },
+            button      => 'SubmitTicket',
+        });
         $m->content_like(qr{to TestMoreChanged});
 
-        $m->form_name("TicketModify");
-        $m->field( $input_name, "bad value" );
-        $m->click('SubmitTicket');
+        $m->submit_form_ok({
+            with_fields => { $input_name => "bad value" },
+            button      => 'SubmitTicket',
+        });
         $m->content_like(qr{Input must match});
     }
 
     foreach my $name ( qw(People Dates Links) ) {
         $m->follow_link_ok({id => "page-\L$name"}, "Ticket's $name page");
-        $m->form_name("Ticket$name");
         is $m->dom->find(qq{input[name^="$prefix"][name\$="-Value"]})->size, 1,
             "only one CF input on the page";
         my $input_name = $prefix . $CF{"Test$name"}->id .'-Value';
-        $m->field( $input_name, "Test${name}Changed" );
-        $m->click('SubmitTicket');
+        $m->submit_form_ok({
+            with_fields => { $input_name => "Test${name}Changed" },
+            button      => 'SubmitTicket',
+        });
         $m->content_like(qr{to Test${name}Changed});
 
-        $m->form_name("Ticket$name");
-        $m->field( $input_name, "bad value" );
-        $m->click('SubmitTicket');
+        $m->submit_form_ok({
+            with_fields => { $input_name => "bad value" },
+            button      => 'SubmitTicket',
+        });
         $m->content_like(qr{Input must match});
     }
 
@@ -156,3 +162,6 @@ ok $m->login, 'logged in as root';
         $m->content_like(qr{to Test${name}Again});
     }
 }
+
+undef $m;
+done_testing;

-----------------------------------------------------------------------


More information about the Rt-commit mailing list