78b95a3b2f84d10b2909ca78c8dd60942dd0465b
[freeside.git] / rt / t / web / html_template.t
1
2 use strict;
3 use warnings;
4
5 use RT::Test tests => 19;
6 use Encode;
7 my ( $baseurl, $m ) = RT::Test->started_ok;
8 ok $m->login, 'logged in as root';
9
10 use utf8;
11
12 diag('make Autoreply template a html one and add utf8 chars')
13   if $ENV{TEST_VERBOSE};
14
15 {
16     $m->follow_link_ok( { id => 'tools-config-global-templates' },     '-> Templates' );
17     $m->follow_link_ok( { text => 'Autoreply' },     '-> Autoreply' );
18
19     $m->submit_form(
20         form_name => 'ModifyTemplate',
21         fields => {
22             Content => <<'EOF',
23 Subject: AutoReply: {$Ticket->Subject}
24 Content-Type: text/html
25
26 你好 éèà€
27 {$Ticket->Subject}
28 -------------------------------------------------------------------------
29 {$Transaction->Content()}
30
31 EOF
32         },
33     );
34     $m->content_like( qr/Content updated/, 'content is changed' );
35     $m->content_contains( '你好', 'content is really updated' );
36 }
37
38 diag('create a ticket to see the autoreply mail') if $ENV{TEST_VERBOSE};
39
40 {
41     $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
42
43     $m->submit_form(
44         form_name => 'TicketCreate',
45         fields      => { Subject => '标题', Content => '<h1>测试</h1>',
46         ContentType => 'text/html' },
47     );
48     $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
49     $m->follow_link( text => 'Show' );
50     $m->content_contains( '你好',    'html has 你好' );
51     $m->content_contains( 'éèà€', 'html has éèà€' );
52     $m->content_contains( '标题',
53         'html has ticket subject 标题' );
54     $m->content_contains( '&lt;h1&gt;测试&lt;/h1&gt;',
55         'html has ticket html content 测试' );
56 }
57
58 diag('test real mail outgoing') if $ENV{TEST_VERBOSE};
59
60 {
61
62     # $mail is utf8 encoded
63     my ($mail) = RT::Test->fetch_caught_mails;
64     $mail = decode_utf8 $mail;
65     like( $mail, qr/你好.*你好/s,    'mail has éèà€' );
66     like( $mail, qr/éèà€.*éèà€/s, 'mail has éèà€' );
67     like( $mail, qr/标题.*标题/s,    'mail has ticket subject 标题' );
68     like( $mail, qr/测试.*测试/s,    'mail has ticket content 测试' );
69     like( $mail, qr!<h1>测试</h1>!,    'mail has ticket html content 测试' );
70 }
71