html_template.t 2.12 KB
Newer Older
sunnavy's avatar
sunnavy committed
1
2
3
4

use strict;
use warnings;

sunnavy's avatar
sunnavy committed
5
use RT::Test tests => 19;
sunnavy's avatar
sunnavy committed
6
7
8
9
10
11
12
13
14
15
use Encode;
my ( $baseurl, $m ) = RT::Test->started_ok;
ok $m->login, 'logged in as root';

use utf8;

diag('make Autoreply template a html one and add utf8 chars')
  if $ENV{TEST_VERBOSE};

{
Alex Vandiver's avatar
Alex Vandiver committed
16
17
    $m->follow_link_ok( { id => 'admin-global-templates' }, '-> Templates' );
    $m->follow_link_ok( { text => 'Autoreply in HTML' },    '-> Autoreply in HTML' );
sunnavy's avatar
sunnavy committed
18
19

    $m->submit_form(
20
        form_name => 'ModifyTemplate',
sunnavy's avatar
sunnavy committed
21
22
23
        fields => {
            Content => <<'EOF',
Subject: AutoReply: {$Ticket->Subject}
24
Content-Type: text/html
sunnavy's avatar
sunnavy committed
25
26
27
28
29
30
31
32
33

你好 éèà€
{$Ticket->Subject}
-------------------------------------------------------------------------
{$Transaction->Content()}

EOF
        },
    );
34
    $m->content_like( qr/Content updated/, 'content is changed' );
sunnavy's avatar
sunnavy committed
35
36
37
38
39
40
41
42
43
    $m->content_contains( '你好', 'content is really updated' );
}

diag('create a ticket to see the autoreply mail') if $ENV{TEST_VERBOSE};

{
    $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );

    $m->submit_form(
44
        form_name => 'TicketCreate',
sunnavy's avatar
sunnavy committed
45
46
        fields      => { Subject => '标题', Content => '<h1>测试</h1>',
        ContentType => 'text/html' },
sunnavy's avatar
sunnavy committed
47
48
49
50
51
52
53
    );
    $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
    $m->follow_link( text => 'Show' );
    $m->content_contains( '你好',    'html has 你好' );
    $m->content_contains( 'éèà€', 'html has éèà€' );
    $m->content_contains( '标题',
        'html has ticket subject 标题' );
sunnavy's avatar
sunnavy committed
54
55
    $m->content_contains( '&lt;h1&gt;测试&lt;/h1&gt;',
        'html has ticket html content 测试' );
sunnavy's avatar
sunnavy committed
56
57
58
59
60
61
62
63
}

diag('test real mail outgoing') if $ENV{TEST_VERBOSE};

{

    # $mail is utf8 encoded
    my ($mail) = RT::Test->fetch_caught_mails;
64
    $mail = Encode::decode("UTF-8", $mail );
65
66
67
68
    like( $mail, qr/你好.*你好/s,    'mail has éèà€' );
    like( $mail, qr/éèà€.*éèà€/s, 'mail has éèà€' );
    like( $mail, qr/标题.*标题/s,    'mail has ticket subject 标题' );
    like( $mail, qr/测试.*测试/s,    'mail has ticket content 测试' );
sunnavy's avatar
sunnavy committed
69
    like( $mail, qr!<h1>测试</h1>!,    'mail has ticket html content 测试' );
sunnavy's avatar
sunnavy committed
70
71
}