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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
use strict;
use warnings;
use RT::Test tests => undef;
my $content = join ' ', ('<h3>The quick brown fox jumps over the lazy dog.</h3>') x 5;
$content = join '<br>', $content, $content, $content;
my $escaped_content = $content;
RT::Interface::Web::EscapeHTML( \$escaped_content );
my $cf = RT::CustomField->new( RT->SystemUser );
$cf->Load('Content');
ok( $cf->Id, 'Found custom field' );
my $article = RT::Article->new( RT->SystemUser );
my ( $ret, $msg ) = $article->Create( Class => 'General', Name => 'Test html content' );
ok( $ret, 'Created article' );
my ( $base, $m ) = RT::Test->started_ok;
$m->login;
my $cf_input = RT::Interface::Web::GetCustomFieldInputName(
Object => $article,
CustomField => $cf,
);
$m->get_ok( '/Articles/Article/Edit.html?id=' . $article->Id );
$m->submit_form_ok(
{
with_fields => {
$cf_input => $content,
},
},
'Set content'
);
$m->content_contains( "<li>Content $escaped_content added</li>", 'content found' );
$m->save_content('/tmp/x.html');
my $new_content = '<h3>The quick brown fox jumps over the lazy dog.</h3>';
my $escaped_new_content = $new_content;
RT::Interface::Web::EscapeHTML( \$escaped_new_content );
$m->submit_form_ok(
{
with_fields => {
$cf_input => $new_content,
},
},
'Update content'
);
$m->content_contains( "<li>Content $escaped_content changed to $escaped_new_content</li>", 'Content was updated' );
my $newer_content = '<h3>The quick yellow fox jumps over the lazy dog.</h3>';
my $escaped_newer_content = $newer_content;
RT::Interface::Web::EscapeHTML( \$escaped_newer_content );
$m->submit_form_ok(
{
with_fields => {
$cf_input => $newer_content,
},
},
'Update content again'
);
$m->content_contains( "<li>Content $escaped_new_content changed to $escaped_newer_content</li>",
'Content was updated' );
my $txn = $article->Transactions->Last;
$m->get_ok( '/Helpers/TextDiff?TransactionId=' . $txn->id );
$m->content_like( qr{<del>brown\s*</del><ins>yellow\s*</ins>}, 'text diff has the brown => yellow change' );
$m->back;
$m->follow_link_ok( { text => 'Display' } );
$m->content_contains( $newer_content, 'Content on display page' );
$m->back;
$m->submit_form_ok(
{
with_fields => {
$cf_input => '',
},
},
'Delete content'
);
$m->content_contains( "<li>$escaped_newer_content is no longer a value for custom field Content</li>",
'Content was deleted' );
$m->follow_link_ok( { text => 'History' } );
$m->content_like(
qr/Content\sadded.+\Q$content\E.+
Content\schanged.+From:.+\Q$content\E.+To:.+\Q$new_content\E.+
Content\schanged.+From:.+\Q$new_content\E.+To:.+\Q$newer_content\E.+
Content\sdeleted.+\Q$newer_content\E/xs,
'Content change details'
);
done_testing;
|