7 if (eval { require GD; 1 }) {
8 RT::Test->import(plan => 'no_plan');
11 RT::Test->import(skip_all => 'GD required.');
16 my $ticket = RT::Ticket->new( RT->SystemUser );
17 my $req = 'root' . ($n % 2) . '@localhost';
18 my ( $ret, $msg ) = $ticket->Create(
19 Subject => "base ticket $_",
23 MIMEObj => MIME::Entity->build(
26 Subject => "base ticket $_",
30 ok( $ret, "ticket $n created: $msg" );
33 my ($url, $m) = RT::Test->started_ok;
34 ok( $m->login, "Logged in" );
36 # Test that defaults work
37 $m->get_ok( "/Search/Chart.html?Query=id>0" );
38 $m->content_like(qr{<th[^>]*>Queue\s*</th>\s*<th[^>]*>Tickets\s*</th>}, "Grouped by queue");
39 $m->content_like(qr{General</a>\s*</td>\s*<td[^>]*>\s*<a[^>]*>7</a>}, "Found results in table");
40 $m->content_like(qr{<img src="/Search/Chart\?}, "Found image");
42 $m->get_ok( "/Search/Chart?Query=id>0" );
43 is( $m->content_type, "image/png" );
44 ok( length($m->content), "Has content" );
48 $m->get_ok( "/Search/Chart.html?Query=id>0&PrimaryGroupBy=Queue" );
49 $m->content_like(qr{<th[^>]*>Queue\s*</th>\s*<th[^>]*>Tickets\s*</th>}, "Grouped by queue");
50 $m->content_like(qr{General</a>\s*</td>\s*<td[^>]*>\s*<a[^>]*>7</a>}, "Found results in table");
51 $m->content_like(qr{<img src="/Search/Chart\?}, "Found image");
53 $m->get_ok( "/Search/Chart?Query=id>0&PrimaryGroupBy=Queue" );
54 is( $m->content_type, "image/png" );
55 ok( length($m->content), "Has content" );
58 # Group by Requestor email
59 $m->get_ok( "/Search/Chart.html?Query=id>0&PrimaryGroupBy=Requestor.EmailAddress" );
60 $m->content_like(qr{<th[^>]*>Requestor\.EmailAddress\s*</th>\s*<th[^>]*>Tickets\s*</th>},
61 "Grouped by requestor");
62 $m->content_like(qr{root0\@localhost</a>\s*</td>\s*<td[^>]*>\s*<a[^>]*>3</a>}, "Found results in table");
63 $m->content_like(qr{<img src="/Search/Chart\?}, "Found image");
65 $m->get_ok( "/Search/Chart?Query=id>0&PrimaryGroupBy=Requestor.Email" );
66 is( $m->content_type, "image/png" );
67 ok( length($m->content), "Has content" );
70 # Group by Requestor phone -- which is bogus, and falls back to queue
71 $m->get_ok( "/Search/Chart.html?Query=id>0&PrimaryGroupBy=Requestor.Phone" );
72 $m->content_like(qr{General</a>\s*</td>\s*<td[^>]*>\s*<a[^>]*>7</a>},
73 "Found queue results in table, as a default");
74 $m->content_like(qr{<img src="/Search/Chart\?}, "Found image");
76 $m->get_ok( "/Search/Chart?Query=id>0&PrimaryGroupBy=Requestor.Phone" );
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'