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