import rt 3.8.8
[freeside.git] / rt / lib / t / regression / 23-web_attachments.t
1 #!/usr/bin/perl -w
2 use strict;
3
4 use Test::More tests => 15;
5 use RT;
6 RT::LoadConfig;
7 RT::Init;
8 use Test::WWW::Mechanize;
9
10 $RT::WebURL ||= 0; # avoid stupid warning
11 my $BaseURL = $RT::WebURL;
12 use constant LogoFile => $RT::MasonComponentRoot .'/NoAuth/images/bplogo.gif';
13 use constant FaviconFile => $RT::MasonComponentRoot .'/NoAuth/images/favicon.png';
14
15 my $queue_name = 'General';
16
17 my $m = Test::WWW::Mechanize->new;
18 isa_ok($m, 'Test::WWW::Mechanize');
19
20 $m->get_ok( $BaseURL."?user=root;pass=password" );
21 $m->content_like(qr/Logout/, 'we did log in');
22
23 my $qid;
24 {
25     $m->content =~ /<SELECT\s+NAME\s*="Queue"\s*>.*?<OPTION\s+VALUE="(\d+)".*?>\s*\Q$queue_name\E\s*<\/OPTION>/msig;
26     ok( $qid = $1, "found id of the '$queue_name' queue");
27 }
28
29 $m->form_name('CreateTicketInQueue');
30 $m->field('Queue', $qid);
31 $m->submit;
32 is($m->status, 200, "request successful");
33 $m->content_like(qr/Create a new ticket/, 'ticket create page');
34
35 $m->form_name('TicketCreate');
36 $m->field('Subject', 'Attachments test');
37 $m->field('Attach',  LogoFile);
38 $m->field('Content', 'Some content');
39 $m->submit;
40 is($m->status, 200, "request successful");
41
42 $m->content_like(qr/Attachments test/, 'we have subject on the page');
43 $m->content_like(qr/Some content/, 'and content');
44 $m->content_like(qr/Download bplogo\.gif/, 'page has file name');
45
46 $m->follow_link_ok({text => 'Reply'}, "reply to the ticket");
47 $m->form_name('TicketUpdate');
48 $m->field('Attach',  LogoFile);
49 $m->click('AddMoreAttach');
50 is($m->status, 200, "request successful");
51
52 $m->form_name('TicketUpdate');
53 $m->field('Attach',  FaviconFile);
54 $m->field('UpdateContent', 'Message');
55 $m->click('SubmitTicket');
56 is($m->status, 200, "request successful");
57
58 $m->content_like(qr/Download bplogo\.gif/, 'page has file name');
59 $m->content_like(qr/Download favicon\.png/, 'page has file name');
60