1use strict; 2use warnings; 3 4use RT::Test tests => undef; 5 6my $ticket = RT::Test->create_ticket( 7 Subject => 'test ticket basics', 8 Queue => 1, 9); 10 11my ( $url, $m ) = RT::Test->started_ok; 12ok( $m->login, 'logged in' ); 13 14my $root = RT::Test->load_or_create_user( Name => 'root' ); 15 16# Failing test where the time units are not preserved when you 17# click 'Add more files' on Display 18my @form_tries = ( 19 {Subject => "hello rt"}, 20 {Status => "open"}, 21 {Owner => $root->id}, 22 23 ( 24 map +{ 25 "Time$_" => undef, 26 "Time$_-TimeUnits" => 'hours', 27 }, qw/Estimated Worked Left/ 28 ), 29 ( 30 map +{ 31 "Time$_" => '1', 32 "Time$_-TimeUnits" => 'hours', 33 }, qw/Estimated Worked Left/ 34 ), 35 36 {InitialPriority => "10"}, 37 {FinalPriority => "10"}, 38); 39 40for my $try (@form_tries) { 41 $m->goto_create_ticket(1); 42 $m->form_name('TicketCreate'); 43 $m->set_fields(%$try); 44 $m->click('AddMoreAttach'); 45 $m->form_name('TicketCreate'); 46 for my $field (keys %$try) { 47 is( 48 $m->value($field), 49 defined($try->{$field}) ? $try->{$field} : '', 50 "field $field is the same after the form was submitted" 51 ); 52 } 53} 54 55# Test for time unit preservation in Jumbo 56for my $try (@form_tries) { 57 my $jumbo_ticket = RT::Test->create_ticket( 58 Subject => 'test jumbo ticket basics', 59 Queue => 1, 60 ); 61 62 local($try->{Priority}) = delete local($try->{InitialPriority}) 63 if exists $try->{InitialPriority}; 64 65 $m->get( $url . "/Ticket/ModifyAll.html?id=" . $jumbo_ticket->id ); 66 $m->form_name('TicketModifyAll'); 67 $m->set_fields(%$try); 68 $m->click('AddMoreAttach'); 69 $m->form_name('TicketModifyAll'); 70 for my $field (keys %$try) { 71 is( 72 $m->value($field), 73 defined($try->{$field}) ? $try->{$field} : '', 74 "field $field is the same after the Jumbo form was submitted" 75 ); 76 } 77} 78 79my $cf = RT::Test->load_or_create_custom_field( 80 Name => 'CF1', 81 Type => 'Freeform', 82 Pattern => '.', # mandatory 83 Queue => 'General', 84); 85 86# More time unit testing by a failing CF validation 87$m->get_ok($url.'/Admin/CustomFields/Objects.html?id='.$cf->id); 88$m->form_with_fields('UpdateObjs'); 89$m->tick('AddCustomField-'.$cf->id => '0'); # Make CF global 90$m->click('UpdateObjs'); 91$m->text_contains("Globally added custom field CF1", 'CF applied globally'); 92 93# Test for preservation when a ticket is submitted and CF validation fails 94for my $try (@form_tries) { 95 $m->goto_create_ticket(1); 96 $m->form_name('TicketCreate'); 97 $m->set_fields(%$try); 98 $m->submit(); 99 $m->form_name('TicketCreate'); 100 for my $field (keys %$try) { 101 is( 102 $m->value($field), 103 defined($try->{$field}) ? $try->{$field} : '', 104 "field $field is the same after the form was submitted" 105 ); 106 } 107} 108 109done_testing(); 110