4 use RT::Test tests => undef;
6 plan skip_all => 'GD required'
10 my $ticket = RT::Ticket->new( RT->SystemUser );
11 my $req = 'root' . ($n % 2) . '@localhost';
12 my ( $ret, $msg ) = $ticket->Create(
13 Subject => "base ticket $_",
17 MIMEObj => MIME::Entity->build(
20 Subject => "base ticket $_",
24 ok( $ret, "ticket $n created: $msg" );
27 my ($url, $m) = RT::Test->started_ok;
28 ok( $m->login, "Logged in" );
30 # Test that defaults work
31 $m->get_ok( "/Search/Chart.html?Query=id>0" );
32 $m->content_like(qr{<th[^>]*>Status\s*</th>\s*<th[^>]*>Ticket count\s*</th>}, "Grouped by status");
33 $m->content_like(qr{new\s*</th>\s*<td[^>]*>\s*<a[^>]*>7</a>}, "Found results in table");
34 $m->content_like(qr{<img src="/Search/Chart\?}, "Found image");
36 $m->get_ok( "/Search/Chart?Query=id>0" );
37 is( $m->content_type, "image/png" );
38 ok( length($m->content), "Has content" );
42 $m->get_ok( "/Search/Chart.html?Query=id>0&GroupBy=Queue" );
43 $m->content_like(qr{<th[^>]*>Queue\s*</th>\s*<th[^>]*>Ticket count\s*</th>}, "Grouped by queue");
44 $m->content_like(qr{General\s*</th>\s*<td[^>]*>\s*<a[^>]*>7</a>}, "Found results in table");
45 $m->content_like(qr{<img src="/Search/Chart\?}, "Found image");
47 $m->get_ok( "/Search/Chart?Query=id>0&GroupBy=Queue" );
48 is( $m->content_type, "image/png" );
49 ok( length($m->content), "Has content" );
52 # Group by Requestor email
53 $m->get_ok( "/Search/Chart.html?Query=id>0&GroupBy=Requestor.EmailAddress" );
54 $m->content_like(qr{<th[^>]*>Requestor\s+EmailAddress</th>\s*<th[^>]*>Ticket count\s*</th>},
55 "Grouped by requestor");
56 $m->content_like(qr{root0\@localhost\s*</th>\s*<td[^>]*>\s*<a[^>]*>3</a>}, "Found results in table");
57 $m->content_like(qr{<img src="/Search/Chart\?}, "Found image");
59 $m->get_ok( "/Search/Chart?Query=id>0&GroupBy=Requestor.EmailAddress" );
60 is( $m->content_type, "image/png" );
61 ok( length($m->content), "Has content" );
63 # Group by Requestor phone -- which is bogus, and falls back to queue
65 $m->get_ok( "/Search/Chart.html?Query=id>0&GroupBy=Requestor.Phone" );
66 $m->warning_like( qr{'Requestor\.Phone' is not a valid grouping for reports} );
69 local $TODO = "UI should show that it's group by status";
70 $m->content_like(qr{new\s*</th>\s*<td[^>]*>\s*<a[^>]*>7</a>},
71 "Found queue results in table, as a default");
73 $m->content_like(qr{<img src="/Search/Chart\?}, "Found image");
75 $m->get_ok( "/Search/Chart?Query=id>0&GroupBy=Requestor.Phone" );
76 $m->warning_like( qr{'Requestor\.Phone' is not a valid grouping for reports} );
77 is( $m->content_type, "image/png" );
78 ok( length($m->content), "Has content" );
80 diag "Confirm subnav links use Query param before saved search in session.";
82 $m->get_ok( "/Search/Chart.html?Query=id>0" );
83 my $advanced = $m->find_link( text => 'Advanced' )->URI->equery;
84 like( $advanced, qr{Query=id%3E0},
85 'Advanced link has Query param with id search'
88 # Load the session with another search.
89 $m->get_ok( "/Search/Results.html?Query=Queue='General'" );
91 $m->get_ok( "/Search/Chart.html?Query=id>0" );
92 $advanced = $m->find_link( text => 'Advanced' )->URI->equery;
93 like( $advanced, qr{Query=id%3E0},
94 'Advanced link still has Query param with id search'