4 use RT::Test tests => undef;
6 plan skip_all => 'GD required'
9 my $root = RT::Test->load_or_create_user( Name => 'root' );
11 my ( $baseurl, $m ) = RT::Test->started_ok;
12 ok( $m->login, 'logged in' );
13 my $ticket = RT::Ticket->new( $RT::SystemUser );
16 Subject => Encode::decode("UTF-8",'test äöü'),
18 ok( $ticket->id, 'created ticket' );
20 $m->get_ok(Encode::decode("UTF-8", q{/Search/Chart.html?Query=Subject LIKE 'test äöü'}));
22 form_name => 'SaveSearch',
24 SavedSearchDescription => 'chart foo',
25 SavedSearchOwner => 'RT::User-' . $root->id,
28 button => 'SavedSearchSave',
31 # first, create and populate a dashboard
32 $m->get_ok('/Dashboards/Modify.html?Create=1');
33 $m->form_name('ModifyDashboard');
34 $m->field( 'Name' => 'dashboard foo' );
35 $m->click_button( value => 'Create' );
37 $m->follow_link_ok( { text => 'Content' } );
38 my $form = $m->form_name('Dashboard-Searches-body');
39 my @input = $form->find_input('Searches-body-Available');
40 my ($dashboards_component) =
41 map { ( $_->possible_values )[1] }
42 grep { ( $_->value_names )[1] =~ /^Chart/ } @input;
43 $form->value( 'Searches-body-Available' => $dashboards_component );
44 $m->click_button( name => 'add' );
45 $m->content_contains('Dashboard updated');
47 $m->follow_link_ok( { text => 'Subscription' } );
48 $m->form_name('SubscribeDashboard');
49 $m->field( 'Frequency' => 'daily' );
50 $m->field( 'Hour' => '06:00' );
51 $m->click_button( name => 'Save' );
52 $m->content_contains('Subscribed to dashboard dashboard foo');
54 my $c = $m->get(Encode::decode("UTF-8",q{/Search/Chart?Query=Subject LIKE 'test äöü'}));
55 my $image = $c->content;
56 RT::Test->run_and_capture(
57 command => $RT::SbinPath . '/rt-email-dashboards', all => 1
60 my @mails = RT::Test->fetch_caught_mails;
61 is @mails, 1, "got a dashboard mail";
63 # can't use parse_mail here is because it deletes all attachments
64 # before we can call bodyhandle :/
66 my $parser = RT::EmailParser->new;
67 my $mail = $parser->ParseMIMEEntityFromScalar( $mails[0] );
69 $mail->head->get('Subject'),
70 qr/Daily Dashboard: dashboard foo/,
74 my ($mail_image) = grep { $_->mime_type eq 'image/png' } $mail->parts;
75 ok( $mail_image, 'mail contains image attachment' );
77 my $handle = $mail_image->bodyhandle;
79 my $mail_image_data = '';
80 if ( my $io = $handle->open('r') ) {
81 while ( defined( $_ = $io->getline ) ) { $mail_image_data .= $_ }
84 is( $mail_image_data, $image, 'image in mail is the same one in web' );