~cldunlap1/ubuntu/quantal/ciderwebmail/typo-fix

« back to all changes in this revision

Viewing changes to t/render_html.t

  • Committer: Package Import Robot
  • Author(s): Jonas Smedegaard
  • Date: 2012-06-08 22:28:26 UTC
  • Revision ID: package-import@ubuntu.com-20120608222826-3umzx12hf4d0dcnc
Tags: upstream-1.04~20120607
ImportĀ upstreamĀ versionĀ 1.04~20120607

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use strict;
 
2
use warnings;
 
3
use Test::More;
 
4
use Test::XPath;
 
5
use English qw(-no_match_vars);
 
6
use FindBin qw($Bin);
 
7
 
 
8
return plan skip_all => 'Set TEST_USER and TEST_PASSWORD to access a mailbox for these tests' unless $ENV{TEST_USER} and $ENV{TEST_PASSWORD};
 
9
 
 
10
$ENV{CIDERWEBMAIL_NODISCONNECT} = 1;
 
11
 
 
12
use Catalyst::Test 'CiderWebmail';
 
13
use HTTP::Request::Common;
 
14
 
 
15
my ($response, $c) = ctx_request POST '/', [
 
16
    username => $ENV{TEST_USER},
 
17
    password => $ENV{TEST_PASSWORD},
 
18
];
 
19
 
 
20
my $unix_time = time();
 
21
 
 
22
open my $testmail, '<', "$Bin/testmessages/HTML.mbox";
 
23
my $message_text = join '', <$testmail>;
 
24
$message_text =~ s/htmltest-TIME/htmltest-$unix_time/gm;
 
25
 
 
26
$c->model('IMAPClient')->append_message($c, { mailbox => 'INBOX', message_text => $message_text });
 
27
 
 
28
eval "use Test::WWW::Mechanize::Catalyst 'CiderWebmail'";
 
29
if ($@) {
 
30
    plan skip_all => 'Test::WWW::Mechanize::Catalyst required';
 
31
    exit;
 
32
}
 
33
 
 
34
my $uname = getpwuid $UID;
 
35
 
 
36
ok( my $mech = Test::WWW::Mechanize::Catalyst->new, 'Created mech object' );
 
37
 
 
38
$mech->get_ok( 'http://localhost/' );
 
39
$mech->submit_form_ok({ with_fields => { username => $ENV{TEST_USER}, password => $ENV{TEST_PASSWORD} } });
 
40
 
 
41
$mech->get_ok( 'http://localhost/mailbox/INBOX?length=99999' );
 
42
$mech->follow_link_ok({ text => 'htmltest-'.$unix_time });
 
43
 
 
44
 
 
45
my $tx = Test::XPath->new(xml => $mech->content, is_html => 1);
 
46
$tx->ok( "//div[\@class='html_message renderable']", sub {
 
47
    $_->is( './p[1]/span', 'This is an HTML testmail.', 'p/span ok' );
 
48
}, 'check html' );
 
49
 
 
50
$mech->get_ok( 'http://localhost/mailbox/INBOX?length=99999' );
 
51
my @messages = $mech->find_all_links( text_regex => qr{\Ahtmltest-$unix_time\z});
 
52
ok((@messages == 1), 'messages found');
 
53
$mech->get_ok($messages[0]->url.'/delete', "Delete message");
 
54
 
 
55
done_testing();