6 use RT::Test tests => 35;
8 my ( $baseurl, $m ) = RT::Test->started_ok;
9 ok $m->login, 'logged in as root';
10 my $root = RT::User->new(RT->SystemUser);
11 ok( $root->Load('root'), 'load root user' );
13 my $cf_name = 'test cf date';
18 $m->follow_link( id => 'tools-config-custom-fields-create');
20 form_name => "ModifyCustomField",
23 TypeComposite => 'Date-1',
24 LookupType => 'RT::Queue-RT::Ticket',
27 $m->content_contains('Object created', 'created CF sucessfully' );
28 $cfid = $m->form_name('ModifyCustomField')->value('id');
29 ok $cfid, "found id of the CF in the form, it's #$cfid";
32 diag "apply the CF to General queue";
33 my $queue = RT::Test->load_or_create_queue( Name => 'General' );
34 ok $queue && $queue->id, 'loaded or created queue';
37 $m->follow_link( id => 'tools-config-queues-select');
38 $m->title_is( q/Admin queues/, 'admin-queues screen' );
39 $m->follow_link( text => 'General' );
40 $m->title_is( q/Configuration for queue General/,
41 'admin-queue: general' );
42 $m->follow_link( text => 'Ticket Custom Fields' );
43 $m->title_is( q/Custom Fields for queue General/,
44 'admin-queue: general cfid' );
46 $m->form_name('EditCustomFields');
47 $m->tick( "AddCustomField" => $cfid );
48 $m->click('UpdateCFs');
50 $m->content_contains('Object created', 'TCF added to the queue' );
53 diag 'check valid inputs with various timezones in ticket create page';
58 form_name => "CreateTicketInQueue",
59 fields => { Queue => 'General' },
61 $m->content_contains('Select date', 'has cf field' );
64 form_name => "TicketCreate",
66 Subject => 'test 2010-05-04',
68 "Object-RT::Ticket--CustomField-$cfid-Values" => '2010-05-04',
71 ok( ($id) = $m->content =~ /Ticket (\d+) created/, "created ticket $id" );
73 $ticket = RT::Ticket->new(RT->SystemUser);
75 is( $ticket->CustomFieldValues($cfid)->First->Content,
76 '2010-05-04', 'date in db' );
78 $m->content_contains('test cf date:', 'has no cf date field on the page' );
79 $m->content_contains('Tue May 04 2010',
80 'has cf date value on the page' );
83 diag 'check search build page';
85 $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
87 $m->form_name('BuildQuery');
89 $m->find_all_inputs( type => 'option', name_regex => qr/test cf date/ );
91 [ $cf_op->possible_values ],
97 $m->find_all_inputs( type => 'text', name_regex => qr/test cf date/ );
101 $cf_field->name => '2010-05-04'
103 button => 'DoSearch',
106 $m->content_contains( 'Found 1 ticket', 'Found 1 ticket' );
107 $m->content_contains( '2010-05-04', 'got the right ticket' );
108 $m->content_lacks( '2010-05-06', 'did not get the wrong ticket' );
110 $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
111 $m->form_name('BuildQuery');
115 $cf_field->name => '2010-05-05'
117 button => 'DoSearch',
119 $m->content_contains( 'Found 1 ticket', 'Found 1 ticket' );
121 $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
122 $m->form_name('BuildQuery');
126 $cf_field->name => '2010-05-03',
128 button => 'DoSearch',
130 $m->content_contains( 'Found 1 ticket', 'Found 1 ticket' );
132 $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
133 $m->form_name('BuildQuery');
137 $cf_field->name => '2010-05-05',
139 button => 'DoSearch',
141 $m->content_contains( 'Found 0 tickets', 'Found 0 tickets' );
143 $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
144 $m->form_name('BuildQuery');
148 $cf_field->name => '2010-05-03',
150 button => 'DoSearch',
152 $m->content_contains( 'Found 0 tickets', 'Found 0 tickets' );
154 $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
155 $m->form_name('BuildQuery');
159 $cf_field->name => '2010-05-05',
161 button => 'DoSearch',
163 $m->content_contains( 'Found 0 tickets', 'Found 0 tickets' );
166 diag 'check invalid inputs';
169 form_name => "CreateTicketInQueue",
170 fields => { Queue => 'General' },
172 my $form = $m->form_name("TicketCreate");
175 form_name => "TicketCreate",
179 "Object-RT::Ticket--CustomField-$cfid-Values" => 'foodate',
182 $m->content_like( qr/Ticket \d+ created/,
183 "a ticket is created succesfully" );
185 $m->content_contains('test cf date:', 'has no cf date field on the page' );
186 $m->content_lacks('foodate', 'invalid dates not set' );