import rt 3.8.10
[freeside.git] / rt / t / web / charting.t
1 use strict;
2 use warnings;
3
4 use RT::Test no_plan => 1;
5
6 for my $n (1..7) {
7     my $ticket = RT::Ticket->new( RT->SystemUser );
8     my $req = 'root' . ($n % 2) . '@localhost';
9     my ( $ret, $msg ) = $ticket->Create(
10         Subject   => "base ticket $_",
11         Queue     => "General",
12         Owner     => "root",
13         Requestor => $req,
14         MIMEObj   => MIME::Entity->build(
15             From    => $req,
16             To      => 'rt@localhost',
17             Subject => "base ticket $_",
18             Data    => "Content $_",
19         ),
20     );
21     ok( $ret, "ticket $n created: $msg" );
22 }
23
24 my ($url, $m) = RT::Test->started_ok;
25 ok( $m->login, "Logged in" );
26
27 # Test that defaults work
28 $m->get_ok( "/Search/Chart.html?Query=id>0" );
29 $m->content_like(qr{<th[^>]*>\s*Queue\s*</th>\s*<th[^>]*>\s*Tickets\s*</th>}, "Grouped by queue");
30 $m->content_like(qr{General</a>\s*</td>\s*<td[^>]*>\s*7}, "Found results in table");
31 $m->content_like(qr{<img src="/Search/Chart\?}, "Found image");
32
33 $m->get_ok( "/Search/Chart?Query=id>0" );
34 is( $m->content_type, "image/png" );
35 ok( length($m->content), "Has content" );
36
37
38 # Group by Queue
39 $m->get_ok( "/Search/Chart.html?Query=id>0&PrimaryGroupBy=Queue" );
40 $m->content_like(qr{<th[^>]*>\s*Queue\s*</th>\s*<th[^>]*>\s*Tickets\s*</th>}, "Grouped by queue");
41 $m->content_like(qr{General</a>\s*</td>\s*<td[^>]*>\s*7}, "Found results in table");
42 $m->content_like(qr{<img src="/Search/Chart\?}, "Found image");
43
44 $m->get_ok( "/Search/Chart?Query=id>0&PrimaryGroupBy=Queue" );
45 is( $m->content_type, "image/png" );
46 ok( length($m->content), "Has content" );
47
48
49 # Group by Requestor email
50 $m->get_ok( "/Search/Chart.html?Query=id>0&PrimaryGroupBy=Requestor.EmailAddress" );
51 $m->content_like(qr{<th[^>]*>\s*Requestor\.EmailAddress\s*</th>\s*<th[^>]*>\s*Tickets\s*</th>},
52                  "Grouped by requestor");
53 $m->content_like(qr{root0\@localhost</a>\s*</td>\s*<td[^>]*>\s*3}, "Found results in table");
54 $m->content_like(qr{<img src="/Search/Chart\?}, "Found image");
55
56 $m->get_ok( "/Search/Chart?Query=id>0&PrimaryGroupBy=Requestor.Email" );
57 is( $m->content_type, "image/png" );
58 ok( length($m->content), "Has content" );
59
60
61 # Group by Requestor phone -- which is bogus, and falls back to queue
62 $m->get_ok( "/Search/Chart.html?Query=id>0&PrimaryGroupBy=Requestor.Phone" );
63 $m->content_like(qr{General</a>\s*</td>\s*<td[^>]*>\s*7},
64                  "Found queue results in table, as a default");
65 $m->content_like(qr{<img src="/Search/Chart\?}, "Found image");
66
67 $m->get_ok( "/Search/Chart?Query=id>0&PrimaryGroupBy=Requestor.Phone" );
68 is( $m->content_type, "image/png" );
69 ok( length($m->content), "Has content" );