no need for FS calendar buttons in RT 4.2
[freeside.git] / rt / t / web / cf_datetime.t
index 4580c4a..da938ab 100644 (file)
@@ -24,7 +24,7 @@ if ( ( $ENV{RT_TEST_WEB_HANDLER} || '' ) =~ /^apache(\+mod_perl)?$/
 my $cfid;
 diag "Create a CF";
 {
-    $m->follow_link( id => 'tools-config-custom-fields-create');
+    $m->follow_link( id => 'admin-custom-fields-create');
     $m->submit_form(
         form_name => "ModifyCustomField",
         fields => {
@@ -47,7 +47,7 @@ ok $queue && $queue->id, 'loaded or created queue';
     $m->title_is(q/Admin queues/, 'admin-queues screen');
     $m->follow_link( text => 'General' );
     $m->title_is(q/Configuration for queue General/, 'admin-queue: general');
-    $m->follow_link( text => 'Ticket Custom Fields' );
+    $m->follow_link( id => 'page-custom-fields-tickets' );
     $m->title_is(q/Custom Fields for queue General/, 'admin-queue: general cfid');
 
     $m->form_name('EditCustomFields');
@@ -212,7 +212,93 @@ diag 'check invalid inputs';
 
     my @warnings = $m->get_warnings;
     chomp @warnings;
-    is_deeply( @warnings, q{Couldn't parse date 'foodate' by Time::ParseDate} );
+    is_deeply( [@warnings], [(q{Couldn't parse date 'foodate' by Time::ParseDate})x2] );
+}
+
+diag 'retain values when adding attachments';
+{
+    my ( $ticket, $id );
+
+    my $txn_cf = RT::CustomField->new( RT->SystemUser );
+    my ( $ret, $msg ) = $txn_cf->Create(
+        Name          => 'test txn cf datetime',
+        TypeComposite => 'DateTime-1',
+        LookupType    => 'RT::Queue-RT::Ticket-RT::Transaction',
+    );
+    ok( $ret, "created 'txn datetime': $msg" );
+    $txn_cf->AddToObject(RT::Queue->new(RT->SystemUser));
+    my $txn_cfid = $txn_cf->id;
+
+    $m->submit_form(
+        form_name => "CreateTicketInQueue",
+        fields    => { Queue => 'General' },
+    );
+    $m->content_contains('test cf datetime', 'has cf' );
+    $m->content_contains('test txn cf datetime', 'has txn cf' );
+
+    $m->submit_form_ok(
+        {
+            form_name => "TicketCreate",
+            fields    => {
+                Subject => 'test 2015-06-04',
+                Content => 'test',
+                "Object-RT::Ticket--CustomField-$cfid-Values" => '2015-06-04 08:30:00',
+                "Object-RT::Transaction--CustomField-$txn_cfid-Values" => '2015-08-15 12:30:30',
+            },
+            button => 'AddMoreAttach',
+        },
+        'Create test ticket'
+    );
+    $m->form_name("TicketCreate");
+    is( $m->value( "Object-RT::Ticket--CustomField-$cfid-Values" ),
+        "2015-06-04 08:30:00", "ticket cf date value still on form" );
+    $m->content_contains( "Jun 04 08:30:00 2015", 'date in parens' );
+    is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
+        "2015-08-15 12:30:30", "txn cf date date value still on form" );
+    $m->content_contains( "Aug 15 12:30:30 2015", 'date in parens' );
+
+    $m->submit_form();
+    ok( ($id) = $m->content =~ /Ticket (\d+) created/, "Created ticket $id" );
+
+    $m->follow_link_ok( {text => 'Reply'} );
+    $m->title_like( qr/Update/ );
+    $m->content_contains('test txn cf date', 'has txn cf');
+    $m->submit_form_ok(
+        {
+            form_name => "TicketUpdate",
+            fields    => {
+                Content => 'test',
+                "Object-RT::Transaction--CustomField-$txn_cfid-Values" => '2015-09-16 09:30:40',
+            },
+            button => 'AddMoreAttach',
+        },
+        'Update test ticket'
+    );
+    $m->form_name("TicketUpdate");
+    is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
+        "2015-09-16 09:30:40", "Date value still on form" );
+    $m->content_contains( "Sep 16 09:30:40 2015", 'date in parens' );
+
+    $m->follow_link_ok( {text => 'Jumbo'} );
+    $m->title_like( qr/Jumbo/ );
+
+    $m->submit_form_ok(
+        {
+            form_name => "TicketModifyAll",
+            fields    => {
+                "Object-RT::Transaction--CustomField-$txn_cfid-Values" =>
+                  '2015-12-16 03:00:00',
+            },
+            button => 'AddMoreAttach',
+        },
+        'jumbo form'
+    );
+    $m->save_content('/tmp/x.html');
+
+    $m->form_name("TicketModifyAll");
+    is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
+        "2015-12-16 03:00:00", "txn date value still on form" );
+    $m->content_contains( "Dec 16 03:00:00 2015", 'date in parens' );
 }
 
 sub is_results_number {