4 use RT::Test tests => 32;
6 my ($baseurl, $m) = RT::Test->started_ok;
8 use constant ImageFile => $RT::MasonComponentRoot .'/NoAuth/images/bpslogo.png';
9 use constant ImageFileContent => RT::Test->file_content(ImageFile);
11 ok $m->login, 'logged in';
15 $m->follow_link( id => 'tools-config-custom-fields-create');
17 # Test form validation
19 form_name => "ModifyCustomField",
21 TypeComposite => 'Image-0',
22 LookupType => 'RT::Queue-RT::Ticket',
27 $m->text_contains('Invalid value for Name');
30 form_name => "ModifyCustomField",
32 TypeComposite => 'Image-0',
33 LookupType => 'RT::Queue-RT::Ticket',
38 $m->text_contains('Invalid value for Name');
41 form_name => "ModifyCustomField",
43 TypeComposite => 'Image-0',
44 LookupType => 'RT::Queue-RT::Ticket',
49 $m->text_contains('Invalid value for Name');
53 form_name => "ModifyCustomField",
55 TypeComposite => 'Image-0',
56 LookupType => 'RT::Queue-RT::Ticket',
61 $m->text_contains('Object created');
63 # Validation on update
64 $m->form_name("ModifyCustomField");
66 TypeComposite => 'Image-0',
67 LookupType => 'RT::Queue-RT::Ticket',
72 $m->text_contains('Illegal value for Name');
73 $m->form_name("ModifyCustomField");
75 TypeComposite => 'Image-0',
76 LookupType => 'RT::Queue-RT::Ticket',
81 $m->text_contains('Illegal value for Name');
82 $m->form_name("ModifyCustomField");
84 TypeComposite => 'Image-0',
85 LookupType => 'RT::Queue-RT::Ticket',
90 $m->text_contains('Illegal value for Name');
93 diag "apply the CF to General queue";
94 my ( $cf, $cfid, $tid );
96 $m->title_is(q/Editing CustomField img/, 'admin-cf created');
97 $m->follow_link( id => 'tools-config-queues');
98 $m->follow_link( text => 'General' );
99 $m->title_is(q/Configuration for queue General/, 'admin-queue: general');
100 $m->follow_link( id => 'page-ticket-custom-fields');
101 $m->title_is(q/Custom Fields for queue General/, 'admin-queue: general cfid');
102 $m->form_name('EditCustomFields');
104 # Sort by numeric IDs in names
105 my @names = sort grep defined,
106 $m->current_form->find_input('AddCustomField')->possible_values;
108 $cf =~ /(\d+)$/ or die "Hey this is impossible dude";
110 $m->tick( AddCustomField => $cf => 1 ); # Associate the new CF with this queue
111 $m->tick( AddCustomField => $_ => 0 ) for @names; # ...and not any other. ;-)
112 $m->click('UpdateCFs');
114 $m->content_contains('Object created', 'TCF added to the queue' );
117 my $tester = RT::Test->load_or_create_user( Name => 'tester', Password => '123456' );
118 RT::Test->set_rights(
119 { Principal => $tester->PrincipalObj,
120 Right => [qw(SeeQueue ShowTicket CreateTicket)],
123 ok $m->login( $tester->Name, 123456, logout => 1), 'logged in';
125 diag "check that we have no the CF on the create"
126 ." ticket page when user has no SeeCustomField right";
129 form_name => "CreateTicketInQueue",
130 fields => { Queue => 'General' },
132 $m->content_lacks('Upload multiple images', 'has no upload image field');
134 my $form = $m->form_name("TicketCreate");
135 my $upload_field = "Object-RT::Ticket--CustomField-$cfid-Upload";
136 ok !$form->find_input( $upload_field ), 'no form field on the page';
139 form_name => "TicketCreate",
140 fields => { Subject => 'test' },
142 $m->content_like(qr/Ticket \d+ created/, "a ticket is created succesfully");
144 $m->content_lacks('img:', 'has no img field on the page');
145 $m->follow_link( text => 'Custom Fields');
146 $m->content_lacks('Upload multiple images', 'has no upload image field');
149 RT::Test->set_rights(
150 { Principal => $tester->PrincipalObj,
151 Right => [qw(SeeQueue ShowTicket CreateTicket SeeCustomField)],
155 diag "check that we have no the CF on the create"
156 ." ticket page when user has no ModifyCustomField right";
159 form_name => "CreateTicketInQueue",
160 fields => { Queue => 'General' },
162 $m->content_lacks('Upload multiple images', 'has no upload image field');
164 my $form = $m->form_name("TicketCreate");
165 my $upload_field = "Object-RT::Ticket--CustomField-$cfid-Upload";
166 ok !$form->find_input( $upload_field ), 'no form field on the page';
169 form_name => "TicketCreate",
170 fields => { Subject => 'test' },
172 $tid = $1 if $m->content =~ /Ticket (\d+) created/i;
173 ok $tid, "a ticket is created succesfully";
175 $m->follow_link( id => 'page-basics');
176 $m->content_lacks('Upload multiple images', 'has no upload image field');
177 $form = $m->form_name('TicketModify');
178 $upload_field = "Object-RT::Ticket-$tid-CustomField-$cfid-Upload";
179 ok !$form->find_input( $upload_field ), 'no form field on the page';
182 RT::Test->set_rights(
183 { Principal => $tester->PrincipalObj,
184 Right => [qw(SeeQueue ShowTicket CreateTicket SeeCustomField ModifyCustomField)],
188 diag "create a ticket with an image";
191 form_name => "CreateTicketInQueue",
192 fields => { Queue => 'General' },
194 $m->content_contains('Upload multiple images', 'has a upload image field');
196 $cf =~ /(\d+)$/ or die "Hey this is impossible dude";
197 my $upload_field = "Object-RT::Ticket--CustomField-$1-Upload";
200 form_name => "TicketCreate",
202 $upload_field => ImageFile,
203 Subject => 'testing img cf creation',
207 $m->content_like(qr/Ticket \d+ created/, "a ticket is created succesfully");
209 $tid = $1 if $m->content =~ /Ticket (\d+) created/;
211 $m->title_like(qr/testing img cf creation/, "its title is the Subject");
213 $m->follow_link( text => 'bpslogo.png' );
214 $m->content_is(ImageFileContent, "it links to the uploaded image");
217 $m->get( $m->rt_base_url );
218 $m->follow_link( id => 'search-new');
219 $m->title_is(q/Query Builder/, 'Query building');
221 form_name => "BuildQuery",
225 ValueOfQueue => 'General',
227 button => 'AddClause',
230 $m->form_name('BuildQuery');
232 my $col = ($m->current_form->find_input('SelectDisplayColumns'))[-1];
233 $col->value( ($col->possible_values)[-1] );
237 $m->form_name('BuildQuery');
238 $m->click('DoSearch');
240 $m->follow_link( text_regex => qr/bpslogo\.png/ );
241 $m->content_is(ImageFileContent, "it links to the uploaded image");
244 [FC] Bulk Update does not have custom fields.