4 use Test::More tests => 15;
8 use Test::WWW::Mechanize;
10 $RT::WebURL ||= 0; # avoid stupid warning
11 my $BaseURL = $RT::WebURL;
12 use constant ImageFile => $RT::MasonComponentRoot .'/NoAuth/images/bplogo.gif';
13 use constant ImageFileContent => do {
15 open my $fh, '<', ImageFile or die $!;
20 my $m = Test::WWW::Mechanize->new;
21 isa_ok($m, 'Test::WWW::Mechanize');
23 $m->get( $BaseURL."?user=root;pass=password" );
24 $m->content_like(qr/Logout/, 'we did log in');
25 $m->follow_link( text => 'Configuration' );
26 $m->title_is(q/RT Administration/, 'admin screen');
27 $m->follow_link( text => 'Custom Fields' );
28 $m->title_is(q/Select a Custom Field/, 'admin-cf screen');
29 $m->follow_link( text => 'New custom field' );
31 form_name => "ModifyCustomField",
33 TypeComposite => 'Image-0',
34 LookupType => 'RT::Queue-RT::Ticket',
39 $m->title_is(q/Created CustomField img/, 'admin-cf created');
40 $m->follow_link( text => 'Queues' );
41 $m->title_is(q/Admin queues/, 'admin-queues screen');
42 $m->follow_link( text => 'General' );
43 $m->title_is(q/Editing Configuration for queue General/, 'admin-queue: general');
44 $m->follow_link( text => 'Ticket Custom Fields' );
46 $m->title_is(q/Edit Custom Fields for General/, 'admin-queue: general tcf');
47 $m->form_name('EditCustomFields');
49 # Sort by numeric IDs in names
50 my @names = map { $_->[1] }
51 sort { $a->[0] <=> $b->[0] }
52 map { /Object-1-CF-(\d+)/ ? [ $1 => $_ ] : () }
53 map $_->name, $m->current_form->inputs;
54 my $tcf = pop(@names);
55 $m->field( $tcf => 1 ); # Associate the new CF with this queue
56 $m->field( $_ => undef ) for @names; # ...and not any other. ;-)
59 $m->content_like( qr/Object created/, 'TCF added to the queue' );
62 form_name => "CreateTicketInQueue",
63 fields => { Queue => 'General' },
66 $m->content_like(qr/Upload multiple images/, 'has a upload image field');
68 $tcf =~ /(\d+)$/ or die "Hey this is impossible dude";
69 my $upload_field = "Object-RT::Ticket--CustomField-$1-Upload";
72 form_name => "TicketCreate",
74 $upload_field => ImageFile,
75 Subject => 'testing img cf creation',
79 $m->content_like(qr/Ticket \d+ created/, "a ticket is created succesfully");
81 my $id = $1 if $m->content =~ /Ticket (\d+) created/;
83 $m->title_like(qr/testing img cf creation/, "its title is the Subject");
85 $m->follow_link( text => 'bplogo.gif' );
86 $m->content_is(ImageFileContent, "it links to the uploaded image");
90 $m->follow_link( text => 'Tickets' );
91 $m->follow_link( text => 'New Query' );
93 $m->title_is(q/Query Builder/, 'Query building');
95 form_name => "BuildQuery",
99 ValueOfQueue => 'General',
101 button => 'AddClause',
104 $m->form_name('BuildQuery');
106 my $col = ($m->current_form->find_input('SelectDisplayColumns'))[-1];
107 $col->value( ($col->possible_values)[-1] );
111 $m->form_name('BuildQuery');
112 $m->click('DoSearch');
114 $m->follow_link( text_regex => qr/bplogo\.gif/ );
115 $m->content_is(ImageFileContent, "it links to the uploaded image");
118 [FC] Bulk Update does not have custom fields.