5 use RT::Test tests => undef;
6 my ( $baseurl, $m ) = RT::Test->started_ok;
7 ok $m->login, 'logged in as root';
9 diag('make Autoreply template a html one and add utf8 chars')
10 if $ENV{TEST_VERBOSE};
12 my $template = Encode::decode("UTF-8", "你好 éèà€");
13 my $subject = Encode::decode("UTF-8", "标题");
14 my $content = Encode::decode("UTF-8", "测试");
16 $m->follow_link_ok( { id => 'tools-config-global-templates' }, '-> Templates' );
17 $m->follow_link_ok( { text => 'Autoreply' }, '-> Autoreply' );
20 form_name => 'ModifyTemplate',
23 Subject: AutoReply: {\$Ticket->Subject}
24 Content-Type: text/html
28 -------------------------------------------------------------------------
29 {\$Transaction->Content()}
34 $m->content_like( qr/Content updated/, 'content is changed' );
35 $m->content_contains( $template, 'content is really updated' );
38 diag('create a ticket to see the autoreply mail') if $ENV{TEST_VERBOSE};
41 $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
44 form_name => 'TicketCreate',
45 fields => { Subject => $subject, Content => "<h1>$content</h1>",
46 ContentType => 'text/html' },
48 $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
49 $m->follow_link( text => 'Show' );
50 $m->content_contains( $template, "html has $template" );
51 $m->content_contains( $subject,
52 "html has ticket subject $subject" );
53 $m->content_contains( "<h1>$content</h1>",
54 "html has ticket html content $content" );
57 diag('test real mail outgoing') if $ENV{TEST_VERBOSE};
61 # $mail is utf8 encoded
62 my ($mail) = RT::Test->fetch_caught_mails;
63 $mail = Encode::decode("UTF-8", $mail );
64 like( $mail, qr/$template.*$template/s, 'mail has template content $template twice' );
65 like( $mail, qr/$subject.*$subject/s, 'mail has ticket subject $sujbect twice' );
66 like( $mail, qr/$content.*$content/s, 'mail has ticket content $content twice' );
67 like( $mail, qr!<h1>$content</h1>!, 'mail has ticket html content <h1>$content</h1>' );