1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
use strict;
use warnings;
use RT::Test tests => 32;
my ($baseurl, $m) = RT::Test->started_ok;
use constant ImageFile => $RT::StaticPath .'/images/bpslogo.png';
use constant ImageFileContent => RT::Test->file_content(ImageFile);
ok $m->login, 'logged in';
diag "Create a CF";
{
$m->follow_link( id => 'admin-custom-fields-create');
# Test form validation
$m->submit_form(
form_name => "ModifyCustomField",
fields => {
TypeComposite => 'Image-0',
LookupType => 'RT::Queue-RT::Ticket',
Name => '',
Description => 'img',
},
);
$m->text_contains('Invalid value for Name');
$m->submit_form(
form_name => "ModifyCustomField",
fields => {
TypeComposite => 'Image-0',
LookupType => 'RT::Queue-RT::Ticket',
Name => '0',
Description => 'img',
},
);
$m->text_contains('Invalid value for Name');
$m->submit_form(
form_name => "ModifyCustomField",
fields => {
TypeComposite => 'Image-0',
LookupType => 'RT::Queue-RT::Ticket',
Name => '1',
Description => 'img',
},
);
$m->text_contains('Invalid value for Name');
# The real submission
$m->submit_form(
form_name => "ModifyCustomField",
fields => {
TypeComposite => 'Image-0',
LookupType => 'RT::Queue-RT::Ticket',
Name => 'img',
Description => 'img',
EntryHint => 'Upload multiple images',
},
);
$m->text_contains('Object created');
# Validation on update
$m->form_name("ModifyCustomField");
$m->set_fields(
TypeComposite => 'Image-0',
LookupType => 'RT::Queue-RT::Ticket',
Name => '',
Description => 'img',
);
$m->click('Update');
$m->text_contains('Illegal value for Name');
$m->form_name("ModifyCustomField");
$m->set_fields(
TypeComposite => 'Image-0',
LookupType => 'RT::Queue-RT::Ticket',
Name => '0',
Description => 'img',
);
$m->click('Update');
$m->text_contains('Illegal value for Name');
$m->form_name("ModifyCustomField");
$m->set_fields(
TypeComposite => 'Image-0',
LookupType => 'RT::Queue-RT::Ticket',
Name => '1',
Description => 'img',
);
$m->click('Update');
$m->text_contains('Illegal value for Name');
}
diag "apply the CF to General queue";
my ( $cf, $cfid, $tid );
{
$m->title_is(q/Editing CustomField img/, 'admin-cf created');
$m->follow_link( id => 'admin-queues');
$m->follow_link( text => 'General' );
$m->title_is(q/Configuration for queue General/, 'admin-queue: general');
$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');
# Sort by numeric IDs in names
my @names = sort grep defined,
$m->current_form->find_input('AddCustomField')->possible_values;
$cf = pop(@names);
$cf =~ /(\d+)$/ or die "Hey this is impossible dude";
$cfid = $1;
$m->tick( AddCustomField => $cf => 1 ); # Associate the new CF with this queue
$m->tick( AddCustomField => $_ => 0 ) for @names; # ...and not any other. ;-)
$m->click('UpdateCFs');
$m->content_contains("Added custom field img to General", 'TCF added to the queue' );
}
my $tester = RT::Test->load_or_create_user( Name => 'tester', Password => '123456' );
RT::Test->set_rights(
{ Principal => $tester->PrincipalObj,
Right => [qw(SeeQueue ShowTicket CreateTicket)],
},
);
ok $m->login( $tester->Name, 123456, logout => 1), 'logged in';
diag "check that we have no the CF on the create"
." ticket page when user has no SeeCustomField right";
{
$m->submit_form( form_name => "CreateTicketInQueue" );
$m->content_lacks('Upload multiple images', 'has no upload image field');
my $form = $m->form_name("TicketCreate");
my $upload_field = "Object-RT::Ticket--CustomField-$cfid-Upload";
ok !$form->find_input( $upload_field ), 'no form field on the page';
$m->submit_form(
form_name => "TicketCreate",
fields => { Subject => 'test' },
button => 'SubmitTicket',
);
$m->content_like(qr/Ticket \d+ created/, "a ticket is created succesfully");
$m->content_lacks('img:', 'has no img field on the page');
$m->follow_link( text => 'Custom Fields');
$m->content_lacks('Upload multiple images', 'has no upload image field');
}
RT::Test->set_rights(
{ Principal => $tester->PrincipalObj,
Right => [qw(SeeQueue ShowTicket CreateTicket SeeCustomField)],
},
);
diag "check that we have no the CF on the create"
." ticket page when user has no ModifyCustomField right";
{
$m->submit_form( form_name => "CreateTicketInQueue" );
$m->content_lacks('Upload multiple images', 'has no upload image field');
my $form = $m->form_name("TicketCreate");
my $upload_field = "Object-RT::Ticket--CustomField-$cfid-Upload";
ok !$form->find_input( $upload_field ), 'no form field on the page';
$m->submit_form(
form_name => "TicketCreate",
fields => { Subject => 'test' },
button => 'SubmitTicket',
);
$tid = $1 if $m->content =~ /Ticket (\d+) created/i;
ok $tid, "a ticket is created succesfully";
$m->follow_link( id => 'page-basics');
$m->content_lacks('Upload multiple images', 'has no upload image field');
$form = $m->form_name('TicketModify');
$upload_field = "Object-RT::Ticket-$tid-CustomField-$cfid-Upload";
ok !$form->find_input( $upload_field ), 'no form field on the page';
}
RT::Test->set_rights(
{ Principal => $tester->PrincipalObj,
Right => [qw(SeeQueue ShowTicket CreateTicket SeeCustomField ModifyCustomField)],
},
);
diag "create a ticket with an image";
{
$m->submit_form( form_name => "CreateTicketInQueue" );
$m->content_contains('Upload multiple images', 'has a upload image field');
$cf =~ /(\d+)$/ or die "Hey this is impossible dude";
my $upload_field = "Object-RT::Ticket--CustomField-$1-Upload";
$m->submit_form(
form_name => "TicketCreate",
fields => {
$upload_field => ImageFile,
Subject => 'testing img cf creation',
},
button => 'SubmitTicket',
);
$m->content_like(qr/Ticket \d+ created/, "a ticket is created succesfully");
$tid = $1 if $m->content =~ /Ticket (\d+) created/;
$m->title_like(qr/testing img cf creation/, "its title is the Subject");
$m->follow_link( text => 'bpslogo.png' );
$m->content_is(ImageFileContent, "it links to the uploaded image");
}
$m->get( $m->rt_base_url );
$m->follow_link( id => 'search-tickets-new');
$m->title_is(q/Query Builder/, 'Query building');
$m->submit_form(
form_name => "BuildQuery",
fields => {
idOp => '=',
ValueOfid => $tid,
ValueOfQueue => 'General',
QueueOp => '=',
},
button => 'AddClause',
);
$m->form_name('BuildQuery');
my ($col) = grep { ($_->possible_values)[-1] =~ /CustomField/ } $m->find_all_inputs( name => 'SelectDisplayColumns' );
$col->value( ($col->possible_values)[-1] );
$m->click('AddCol');
$m->form_name('BuildQuery');
$m->click('DoSearch');
$m->follow_link( text_regex => qr/bpslogo\.png/ );
$m->content_is(ImageFileContent, "it links to the uploaded image");
__END__
[FC] Bulk Update does not have custom fields.
|