File: render_multipart_related.t

package info (click to toggle)
ciderwebmail 1.05%2B20240702-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,392 kB
  • sloc: perl: 3,201; xml: 782; javascript: 675; sh: 42; makefile: 29
file content (50 lines) | stat: -rw-r--r-- 1,463 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use strict;
use warnings;
use Test::More;
use CiderWebmail::Test {login => 1};
use English qw(-no_match_vars);
use FindBin qw($Bin);

$ENV{CIDERWEBMAIL_NODISCONNECT} = 1;

use Catalyst::Test 'CiderWebmail';
use HTTP::Request::Common;

my ($response, $c) = ctx_request POST '/', [
    username => $ENV{TEST_USER},
    password => $ENV{TEST_PASSWORD},
];

my $unix_time = time();

open my $testmail, '<', "$Bin/testmessages/MULTIPART_RELATED.mbox";
my $message_text = join '', <$testmail>;
$message_text =~ s/TIME/$unix_time/gm;

$c->model('IMAPClient')->append_message({ mailbox => 'INBOX', message_text => $message_text });


$mech->get_ok( 'http://localhost/mailbox/INBOX?length=99999' );
$mech->follow_link_ok({ text => 'multipart-related-TestMail-'.$unix_time });

xpath_test {
    my ($tx) = @_;

    $tx->is( "//div[\@class='renderable monospace']", 'TestMail-PLAIN-'.$unix_time, 'p/span ok plain part' );
};

xpath_test {
    my ($tx) = @_;
    $tx->ok("//div[\@class='html_message renderable']/iframe", sub { #check for iframe itself
        $_->ok( './@src', qr{\d+/part/render/\d+}, sub { #check for render url
            my $iframe_src = $_->node->textContent;
            $mech->get($iframe_src);

            $mech->content_contains("TestMail-HTML-$unix_time", 'verify HTML in iframe');
        }, 'found iframe render url');
    }, 'found iframe for html content' );
};

cleanup_messages(["multipart-related-TestMail-$unix_time"]);

done_testing();