[Rt-commit] r8103 - rtir/branches/2.3-EXPERIMENTAL/t
thayes at bestpractical.com
thayes at bestpractical.com
Wed Jul 11 10:46:28 EDT 2007
Author: thayes
Date: Wed Jul 11 10:46:28 2007
New Revision: 8103
Added:
rtir/branches/2.3-EXPERIMENTAL/t/019-watchers-on-create.t
Removed:
rtir/branches/2.3-EXPERIMENTAL/t/020-admincc-denied.t
Modified:
rtir/branches/2.3-EXPERIMENTAL/t/rtir-test.pl
Log:
* changed rtir-test according to feedback from ruz, addedd LinkChildToIncident subroutine from 001-basic-rtir.t
* replaced 020-admincc-denied.t with a more general test for adding watchers to a ticket
Added: rtir/branches/2.3-EXPERIMENTAL/t/019-watchers-on-create.t
==============================================================================
--- (empty file)
+++ rtir/branches/2.3-EXPERIMENTAL/t/019-watchers-on-create.t Wed Jul 11 10:46:28 2007
@@ -0,0 +1,142 @@
+use strict;
+use warnings;
+
+use Test::WWW::Mechanize;
+use Test::More tests => 52;
+
+require "t/rtir-test.pl";
+
+my $agent = default_agent();
+
+my $ir = create_ir($agent, {Subject => 'IR to test watcher add bug',
+ Requestors => 'requestor at example.com', Cc => 'foo at example.com', AdminCc => 'bar at example.com'});
+
+
+SKIP: {
+ skip "No IR created", 19 if(!$ir);
+
+ $agent->content_unlike(qr/permission denied/i, "No permissions problems");
+
+ diag("Testing if incident report has all watchers") if($ENV{'TEST_VERBOSE'});
+ has_watchers($agent, $ir);
+ has_watchers($agent, $ir, 'Cc');
+ has_watchers($agent, $ir, 'AdminCc');
+
+
+ # Testing creating an incident and investigation from an Incident Report
+ my ($ir_inc, $ir_inv) = create_incident_and_investigation($agent,
+ {Subject => "Incident linked with IR $ir to test adding watchers",
+ InvestigationSubject => "Investigation linked with Incident to test adding watchers",
+ InvestigationRequestors => 'requestor at example.com',
+ InvestigationCc => 'foo at example.com',
+ InvestigationAdminCc => 'bar at example.com'}, "", $ir);
+
+
+
+ SKIP: {
+ skip "No investigation created", 7 if(!$ir_inv);
+
+ $agent->content_unlike(qr/permission denied/i, "No permissions problems");
+
+ diag("Testing if investigation from IR has all watchers") if($ENV{'TEST_VERBOSE'});
+ has_watchers($agent, $ir_inv);
+ has_watchers($agent, $ir_inv, 'Cc');
+ has_watchers($agent, $ir_inv, 'AdminCc');
+ }
+}
+
+
+
+# Testing creating an incident and investigation not from an incident report
+my ($inc, $inv) = create_incident_and_investigation($agent,
+ {Subject => "Incident to test adding watchers",
+ InvestigationSubject => "Investigation linked to Incident to test adding watchers",
+ InvestigationRequestors => 'requestor at example.com',
+ InvestigationCc => 'foo at example.com',
+ InvestigationAdminCc => 'bar at example.com'});
+
+SKIP: {
+ skip "No Investigation created with the Incident", 7 if (!$inv);
+
+ $agent->content_unlike(qr/permission denied/i, "No permissions problems");
+
+ diag("Testing if investigation has all watchers") if($ENV{'TEST_VERBOSE'});
+ has_watchers($agent, $inv);
+ has_watchers($agent, $inv, 'Cc');
+ has_watchers($agent, $inv, 'AdminCc');
+
+}
+
+
+# Testing creating an investigation by itself
+my $solo_inv = create_investigation($agent,
+ {Subject => 'Investigation created on its own to test adding watchers',
+ Requestors => 'requestor at example.com',
+ Cc => 'foo at example.com',
+ AdminCc => 'bar at example.com'});
+
+SKIP: {
+ skip "No investigation created", 7 if(!$solo_inv);
+
+ $agent->content_unlike(qr/permission denied/i, "No permissions problems");
+
+ diag("Testing if solo investigation has all watchers") if($ENV{'TEST_VERBOSE'});
+ has_watchers($agent, $solo_inv);
+ has_watchers($agent, $solo_inv, 'Cc');
+ has_watchers($agent, $solo_inv, 'AdminCc');
+}
+
+
+
+sub create_incident_and_investigation {
+ my $agent = shift;
+ my $fields = shift || {};
+ my $cfs = shift || {};
+ my $ir_id = shift;
+
+ $ir_id ? display_ticket($agent, $ir_id) : go_home($agent);
+
+ if($ir_id) {
+ # Select the "New" link from the Display page
+ $agent->follow_link_ok({text => "[New]"}, "Followed 'New (Incident)' link");
+ }
+ else
+ {
+ $agent->follow_link_ok({text => "Incidents"}, "Followed 'Incidents' link");
+ $agent->follow_link_ok({text => "New Incident", n => '1'}, "Followed 'New Incident' link");
+ }
+
+ # Fill out forms
+ $agent->form_number(3);
+
+ while (my ($f, $v) = each %$fields) {
+ $agent->field($f, $v);
+ }
+
+ while (my ($f, $v) = each %$cfs) {
+ set_custom_field($agent, $f, $v);
+ }
+
+ $agent->click("CreateWithInvestigation");
+ my $msg = $ir_id ? "Attempting to create new incident and investigation linked to child $ir_id" : "Attempting to create new incident and investigation";
+ is ($agent->status, 200, $msg);
+ $msg = $ir_id ? "Incident created from child $ir_id." : "Incident created.";
+ ok ($agent->content =~ /.*Ticket (\d+) created in queue 'Incidents'/g, $msg);
+ my $incident_id = $1;
+
+ ok ($agent->content =~ /.*Ticket (\d+) created in queue 'Investigations'/g, "Investigation created for Incident $incident_id.");
+ my $investigation_id = $1;
+
+ return ($incident_id, $investigation_id);
+}
+
+
+sub has_watchers {
+ my $agent = shift;
+ my $id = shift;
+ my $type = shift || 'Correspondents';
+
+ display_ticket($agent, $id);
+
+ $agent->content_like(qr{<td class="labeltop">Correspondents:</td>\s*<td class="value">\s*([@\w\.]+)<br />}ms, "Found $type");
+}
Modified: rtir/branches/2.3-EXPERIMENTAL/t/rtir-test.pl
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/t/rtir-test.pl (original)
+++ rtir/branches/2.3-EXPERIMENTAL/t/rtir-test.pl Wed Jul 11 10:46:28 2007
@@ -67,8 +67,16 @@
my $agent = shift;
my $id = shift;
- #$agent->get_ok("$RT::WebURL/RTIR/Display.html?id=$id", "Loaded Display page");
- $agent->get_ok(RT->Config->Get('WebURL') . "/RTIR/Display.html?id=$id", "Loaded Display page");
+ $agent->get_ok(RT->Config->Get('WebURL') . "/RTIR/Display.html?id=$id", "Loaded Display page for Ticket #$id");
+}
+
+sub ticket_state {
+ my $agent = shift;
+ my $id = shift;
+
+ display_ticket($agent, $id);
+ $agent->content =~ qr{State:\s*</td>\s*<td[^>]*?>\s*<span class="cf-value">([\w ]+)</span>}ism;
+ return $1;
}
sub ticket_state_is {
@@ -168,7 +176,7 @@
'Incident Reports' => 'Report',
'Investigations' => 'Investigation',
'Blocks' => 'Block',
- 'Incidents' => 'Incident',
+ 'Incidents' => 'Incident'
);
go_home($agent);
@@ -193,7 +201,7 @@
'Incident Reports' => 'Create',
'Investigations' => 'Create',
'Blocks' => 'Create',
- 'Incidents' => 'CreateIncident',
+ 'Incidents' => 'CreateIncident'
);
# Create it!
$agent->click( $create{ $queue } );
@@ -214,8 +222,8 @@
if ($content =~ /.*Ticket (\d+) created.*/g) {
$id = $1;
}
- elsif ($content =~ /.*No permission to view newly created ticket #\d+.*/g) {
- print "\nNo permissions to view the ticket.\n";
+ elsif ($content =~ /.*No permission to view newly created ticket #(\d+).*/g) {
+ diag("\nNo permissions to view the ticket.\n") if($ENV{'TEST_VERBOSE'});
}
return $id;
}
@@ -262,4 +270,31 @@
like($agent->content, $re, $desc);
}
+
+sub LinkChildToIncident {
+ my %args = ( @_ );
+
+ my $id = $args{'id'};
+ my $incident = $args{'incident'};
+ my $agent = $args{'agent'};
+
+ display_ticket($agent, $id);
+
+ # Select the "Link" link from the Display page
+ $agent->follow_link_ok({text => "[Link]", n => "1"}, "Followed 'Link(to Incident)' link");
+
+ # TODO: Make sure desired incident appears on page
+
+ # Choose the incident and submit
+ $agent->form_number(3);
+ $agent->field("SelectedTicket", $incident);
+ $agent->click("LinkChild");
+
+ is ($agent->status, 200, "Attempting to link child $id to Incident $incident");
+
+ ok ($agent->content =~ /Ticket $id: Link created/g, "Incident $incident linked successfully.");
+
+ return;
+}
+
1;
More information about the Rt-commit
mailing list