diff options
Diffstat (limited to 'rt/t/web')
-rw-r--r-- | rt/t/web/case-sensitivity.t | 2 | ||||
-rw-r--r-- | rt/t/web/query_builder.t | 33 | ||||
-rw-r--r-- | rt/t/web/redirect-after-login.t | 6 | ||||
-rw-r--r-- | rt/t/web/rest.t | 83 | ||||
-rw-r--r-- | rt/t/web/scrub.t | 4 | ||||
-rw-r--r-- | rt/t/web/ticket_forward.t | 35 | ||||
-rw-r--r-- | rt/t/web/ticket_links.t | 65 |
7 files changed, 220 insertions, 8 deletions
diff --git a/rt/t/web/case-sensitivity.t b/rt/t/web/case-sensitivity.t index 276b7615a..f984bf3e4 100644 --- a/rt/t/web/case-sensitivity.t +++ b/rt/t/web/case-sensitivity.t @@ -75,7 +75,7 @@ my $cf; # test custom field values auto completer { - $m->get_ok('/Helpers/Autocomplete/CustomFieldValues?term=eNo&Object---CustomField-'. $cf->id .'-Value'); + $m->get_ok('/Helpers/Autocomplete/CustomFieldValues?term=eNo&Object---CustomField-'. $cf->id .'-Value&ContextId=1&ContextType=RT::Queue'); require JSON; is_deeply( JSON::from_json( $m->content ), diff --git a/rt/t/web/query_builder.t b/rt/t/web/query_builder.t index 0abbfaca8..5a64d4646 100644 --- a/rt/t/web/query_builder.t +++ b/rt/t/web/query_builder.t @@ -5,7 +5,7 @@ use HTTP::Request::Common; use HTTP::Cookies; use LWP; use Encode; -use RT::Test tests => 56; +use RT::Test tests => 70; my $cookie_jar = HTTP::Cookies->new; my ($baseurl, $agent) = RT::Test->started_ok; @@ -295,3 +295,34 @@ diag "click advanced, enter a valid SQL, but the field is lower cased"; ); } +diag "make sure skipped order by field doesn't break search"; +{ + my $t = RT::Test->create_ticket( Queue => 'General', Subject => 'test' ); + ok $t && $t->id, 'created a ticket'; + + $agent->get_ok($url."Search/Edit.html"); + ok($agent->form_name('BuildQueryAdvanced'), "found the form"); + $agent->field("Query", "id = ". $t->id); + $agent->submit; + + $agent->follow_link_ok({id => 'page-results'}); + ok( $agent->find_link( + text => $t->id, + url_regex => qr{/Ticket/Display\.html}, + ), "link to the ticket" ); + + $agent->follow_link_ok({id => 'page-edit_search'}); + $agent->form_name('BuildQuery'); + $agent->field("OrderBy", 'Requestor.EmailAddress', 3); + $agent->submit; + $agent->form_name('BuildQuery'); + is $agent->value('OrderBy', 1), 'id'; + is $agent->value('OrderBy', 2), ''; + is $agent->value('OrderBy', 3), 'Requestor.EmailAddress'; + + $agent->follow_link_ok({id => 'page-results'}); + ok( $agent->find_link( + text => $t->id, + url_regex => qr{/Ticket/Display\.html}, + ), "link to the ticket" ); +} diff --git a/rt/t/web/redirect-after-login.t b/rt/t/web/redirect-after-login.t index d429d30d1..835b24c37 100644 --- a/rt/t/web/redirect-after-login.t +++ b/rt/t/web/redirect-after-login.t @@ -196,16 +196,17 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) { # test REST login response { + $agent = RT::Test::Web->new; my $requested = $url."REST/1.0/?user=root;pass=password"; $agent->get($requested); is($agent->status, 200, "Loaded a page"); is($agent->uri, $requested, "didn't redirect to /NoAuth/Login.html for REST"); - $agent->get_ok($url); - $agent->logout(); + $agent->get_ok($url."REST/1.0"); } # test REST login response for wrong pass { + $agent = RT::Test::Web->new; my $requested = $url."REST/1.0/?user=root;pass=passwrong"; $agent->get_ok($requested); is($agent->status, 200, "Loaded a page"); @@ -217,6 +218,7 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) { # test REST login response for no creds { + $agent = RT::Test::Web->new; my $requested = $url."REST/1.0/"; $agent->get_ok($requested); is($agent->status, 200, "Loaded a page"); diff --git a/rt/t/web/rest.t b/rt/t/web/rest.t index 5e7194c95..e38f201fb 100644 --- a/rt/t/web/rest.t +++ b/rt/t/web/rest.t @@ -1,7 +1,9 @@ #!/usr/bin/env perl use strict; use warnings; -use RT::Test tests => 18; +use RT::Interface::REST; + +use RT::Test tests => 22; my ($baseurl, $m) = RT::Test->started_ok; @@ -69,3 +71,82 @@ for ("id: ticket/1", $m->content_contains($_); } +# Create ticket 2 for testing ticket links +for (2 .. 3) { + $m->post("$baseurl/REST/1.0/ticket/edit", [ + user => 'root', + pass => 'password', + content => $text, + ], Content_Type => 'form-data'); + + $m->post( + "$baseurl/REST/1.0/ticket/1/links", + [ + user => 'root', + pass => 'password', + ], + Content_Type => 'form-data', + ); + + my $link_data = form_parse($m->content); + + push @{$link_data->[0]->[1]}, 'DependsOn'; + vpush($link_data->[0]->[2], 'DependsOn', $_); + + $m->post( + "$baseurl/REST/1.0/ticket/1/links", + [ + user => 'root', + pass => 'password', + content => form_compose($link_data), + ], + Content_Type => 'form-data', + ); + +} + +# See what links get reported for ticket 1. +$m->post( + "$baseurl/REST/1.0/ticket/1/links/show", + [ + user => 'root', + pass => 'password', + ], + Content_Type => 'form-data', +); + +# Verify that the link was added correctly. +my $content = form_parse($m->content); +my $depends_on = vsplit($content->[0]->[2]->{DependsOn}); +@$depends_on = sort @$depends_on; +like( + $depends_on->[0], qr{/ticket/2$}, + "Check ticket link.", +) or diag("'content' obtained:\n", $m->content); + +like( + $depends_on->[1], qr{/ticket/3$}, + "Check ticket link.", +) or diag("'content' obtained:\n", $m->content); + +$m->post( + "$baseurl/REST/1.0/ticket/2/links/show", + [ + user => 'root', + pass => 'password', + ], + Content_Type => 'form-data', +); +my ($link) = $m->content =~ m|DependedOnBy:.*ticket/(\d+)|; +is($link, 1, "Check ticket link.") or diag("'content' obtained:\n", $m->content); + +$m->post( + "$baseurl/REST/1.0/ticket/3/links/show", + [ + user => 'root', + pass => 'password', + ], + Content_Type => 'form-data', +); +($link) = $m->content =~ m|DependedOnBy:.*ticket/(\d+)|; +is($link, 1, "Check ticket link.") or diag("'content' obtained:\n", $m->content); diff --git a/rt/t/web/scrub.t b/rt/t/web/scrub.t index 6483a7500..612c6e210 100644 --- a/rt/t/web/scrub.t +++ b/rt/t/web/scrub.t @@ -30,13 +30,13 @@ use Test::LongString; { my $html = q[<span lang=EN-US style='font-family:"Century Gothic","sans-serif";'>oh hai I'm some text</span>]; - my $expected = q[<span style="font-family:"Century Gothic","sans-serif";">oh hai I'm some text</span>]; + my $expected = q[<span lang="EN-US" style="font-family:"Century Gothic","sans-serif";">oh hai I'm some text</span>]; is_string(scrub_html($html), $expected, "font lists"); } { my $html = q[<span lang=EN-US style='font-size:7.5pt;font-family:"Century Gothic","sans-serif";color:#666666;mso-fareast-language:IT'>oh hai I'm some text</span>]; - my $expected = q[<span style="font-size:7.5pt;font-family:"Century Gothic","sans-serif";color:#666666;mso-fareast-language:IT">oh hai I'm some text</span>]; + my $expected = q[<span lang="EN-US" style="font-size:7.5pt;font-family:"Century Gothic","sans-serif";color:#666666;mso-fareast-language:IT">oh hai I'm some text</span>]; is_string(scrub_html($html), $expected, "outlook html"); } diff --git a/rt/t/web/ticket_forward.t b/rt/t/web/ticket_forward.t index be06ad976..1d74673de 100644 --- a/rt/t/web/ticket_forward.t +++ b/rt/t/web/ticket_forward.t @@ -227,6 +227,41 @@ diag "Forward Transaction with attachments but no 'content' part" if $ENV{TEST_V like( $mail, qr/image\/png/, 'att image content type' ); } } +RT::Test->clean_caught_mails; + +diag "Forward Ticket Template with a Subject: line" if $ENV{TEST_VERBOSE}; +{ + + require RT::Template; + my $template = RT::Template->new($RT::SystemUser); + $template->Load('Forward Ticket'); + + # prepend a Subject: line + $template->SetContent("Subject: OVERRIDING SUBJECT\n\n" . $template->Content); + + my $ticket = RT::Test->create_ticket( + Subject => 'test ticket', + Queue => 1, + ); + + $m->goto_ticket($ticket->Id); + + $m->follow_link_ok( + { id => 'page-actions-forward' }, + 'follow 1st Forward to forward ticket' + ); + + $m->submit_form( + form_name => 'ForwardMessage', + fields => { + To => 'rt-to@example.com', + }, + button => 'ForwardAndReturn' + ); + + my ($mail) = RT::Test->fetch_caught_mails; + like($mail, qr/Subject: OVERRIDING SUBJECT/); +} undef $m; done_testing; diff --git a/rt/t/web/ticket_links.t b/rt/t/web/ticket_links.t index cb30e92f9..efb615107 100644 --- a/rt/t/web/ticket_links.t +++ b/rt/t/web/ticket_links.t @@ -1,6 +1,6 @@ use strict; use warnings; -use RT::Test tests => 106; +use RT::Test tests => 146; my ( $baseurl, $m ) = RT::Test->started_ok; ok( $m->login, "Logged in" ); @@ -24,6 +24,16 @@ is( $deleted->Status, 'deleted', "deleted $deleted_id" ); $inactive->SetStatus('resolved'); is( $inactive->Status, 'resolved', 'resolved $inactive_id' ); +# Create an article for linking +require RT::Class; +my $class = RT::Class->new($RT::SystemUser); +$class->Create(Name => 'test class'); + +require RT::Article; +my $article = RT::Article->new($RT::SystemUser); + +$article->Create(Class => $class->Id, Name => 'test article'); + for my $type ( "DependsOn", "MemberOf", "RefersTo" ) { for my $c (qw/base target/) { my $id; @@ -105,6 +115,59 @@ for my $type ( "DependsOn", "MemberOf", "RefersTo" ) { ); $m->content_unlike( qr{$deleted_id.*?\[deleted\]}, "no deleted ticket", ); + + diag "[$type]: Testing that reminders don't get copied for $c tickets"; + { + my $ticket = RT::Test->create_ticket( + Subject => 'test ticket', + Queue => 1, + ); + + $m->goto_ticket($ticket->Id); + $m->form_name('UpdateReminders'); + $m->field('NewReminder-Subject' => 'hello test reminder subject'); + $m->click_button(value => 'Save'); + $m->text_contains('hello test reminder subject'); + + my $id = $ticket->Id; + my $type_value = my $link_field = $type; + if ($c eq 'base') { + $type_value = "new-$type_value"; + $link_field = "$link_field-$id"; + } + else { + $type_value = "$type_value-new"; + $link_field = "$id-$link_field"; + } + + if ($type eq 'RefersTo') { + $m->goto_ticket($ticket->Id); + $m->follow_link(id => 'page-links'); + + # add $baseurl as a link + $m->form_name('ModifyLinks'); + $m->field($link_field => "$baseurl/test_ticket_reference"); + $m->click('SubmitTicket'); + + # add an article as a link + $m->form_name('ModifyLinks'); + $m->field($link_field => 'a:' . $article->Id); + $m->click('SubmitTicket'); + } + + my $depends_on_url = sprintf( + '%s/Ticket/Create.html?Queue=%s&CloneTicket=%s&%s=%s', + $baseurl, '1', $id, $type_value, $id, + ); + $m->get_ok($depends_on_url); + $m->form_name('TicketCreate'); + $m->click_button(value => 'Create'); + $m->content_lacks('hello test reminder subject'); + if ($type eq 'RefersTo') { + $m->text_contains("$baseurl/test_ticket_reference"); + $m->text_contains("Article " . $article->Id . ': test article'); + } + } } } |