[Rt-commit] r8059 - rtir/branches/2.3-EXPERIMENTAL/t
thayes at bestpractical.com
thayes at bestpractical.com
Thu Jul 5 13:09:16 EDT 2007
Author: thayes
Date: Thu Jul 5 13:09:15 2007
New Revision: 8059
Added:
rtir/branches/2.3-EXPERIMENTAL/t/018-bulk-abandon.t
rtir/branches/2.3-EXPERIMENTAL/t/019-webui-block-fields.t
rtir/branches/2.3-EXPERIMENTAL/t/020-admincc-denied.t
Modified:
rtir/branches/2.3-EXPERIMENTAL/t/001-basic-RTIR.t
rtir/branches/2.3-EXPERIMENTAL/t/010-bulk-reject.t
rtir/branches/2.3-EXPERIMENTAL/t/rtir-test.pl
Log:
* Edited rtir-test.pl to make some more informative output messages
* Created a test script to test the RTIR Bulk Abandon feature
* Created a test script to test the reported bug that includes an unwanted option in the State field when editing a Block
* Created a test script to test the reported bug that results in a "permission denied" message when adding AdminCc contacts when creating an Incident and Investigation from an IR
Modified: rtir/branches/2.3-EXPERIMENTAL/t/001-basic-RTIR.t
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/t/001-basic-RTIR.t (original)
+++ rtir/branches/2.3-EXPERIMENTAL/t/001-basic-RTIR.t Thu Jul 5 13:09:15 2007
@@ -4,7 +4,7 @@
use warnings;
use Test::More tests => 23;
-require "t/rtir-test.pl";
+require "rtir-test.pl";
my $agent = default_agent();
Modified: rtir/branches/2.3-EXPERIMENTAL/t/010-bulk-reject.t
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/t/010-bulk-reject.t (original)
+++ rtir/branches/2.3-EXPERIMENTAL/t/010-bulk-reject.t Thu Jul 5 13:09:15 2007
@@ -4,7 +4,7 @@
use warnings;
use Test::More tests => 45;
-require "t/rtir-test.pl";
+require "rtir-test.pl";
my $agent = default_agent();
Added: rtir/branches/2.3-EXPERIMENTAL/t/018-bulk-abandon.t
==============================================================================
--- (empty file)
+++ rtir/branches/2.3-EXPERIMENTAL/t/018-bulk-abandon.t Thu Jul 5 13:09:15 2007
@@ -0,0 +1,151 @@
+use strict;
+
+use Test::WWW::Mechanize;
+use Test::More tests => 99;
+
+require "rtir-test.pl";
+
+my $agent = default_agent();
+#create_user();
+
+my @ir_ids;
+
+for(my $i = 1; $i < 5; $i++) {
+ push @ir_ids, create_ir($agent, {Subject => "IR number $i for RTIR testing"});
+ my $ir_obj = RT::Ticket->new(RT::SystemUser());
+ my $ir_id = $ir_ids[-1];
+
+ $ir_obj->Load($ir_id);
+ is($ir_obj->Id, ($ir_id), "IR $i has the right ID");
+ is($ir_obj->Subject, "IR number $i for RTIR testing", "IR $i has the right subject")
+}
+
+my @incident_ids;
+
+push @incident_ids, create_incident_for_ir($agent, $ir_ids[0], {Subject => "Incident number 1"}, {Function => "IncidentCoord"});
+my $inc_obj = RT::Ticket->new(RT::SystemUser());
+
+$inc_obj->Load($incident_ids[0]);
+is($inc_obj->Id, $incident_ids[0], "Incident has the right ID");
+is($inc_obj->Subject, "Incident number 1", "Incident has the right subject");
+
+LinkChildToIncident(id => $ir_ids[1], incident => $incident_ids[0]);
+
+ticket_is_linked_to_inc($agent, $ir_ids[0], [$incident_ids[0]]);
+ticket_is_linked_to_inc($agent, $ir_ids[1], [$incident_ids[0]]);
+
+push @incident_ids, create_incident_for_ir($agent, $ir_ids[2], {Subject => 'Incident number 2'}, {Function => 'IncidentCoord'});
+
+$inc_obj->Load($incident_ids[0]);
+is($inc_obj->Id, $incident_ids[0], "Incident has the right ID");
+is($inc_obj->Subject, "Incident number 1", "Incident has the right subject");
+
+LinkChildToIncident(id => $ir_ids[3], incident => $incident_ids[1]);
+
+ticket_is_linked_to_inc($agent, $ir_ids[2], [$incident_ids[1]]);
+ticket_is_linked_to_inc($agent, $ir_ids[3], [$incident_ids[1]]);
+
+resolve_ir($agent, $ir_ids[0]);
+
+my @invests;
+
+push @invests, create_investigation($agent, {Incident => $incident_ids[0], Subject => 'Investigation 1 for incident ' . $incident_ids[0]});
+push @invests, create_investigation($agent, {Incident => $incident_ids[0], Subject => 'Investigation 2 for incident ' . $incident_ids[0]});
+
+push @invests, create_investigation($agent, {Incident => $incident_ids[1], Subject => 'Investigation 1 for incident ' . $incident_ids[1]});
+push @invests, create_investigation($agent, {Incident => $incident_ids[0], Subject => 'Investigation 2 for incident ' . $incident_ids[1]});
+
+resolve_inv($agent, $invests[0]);
+
+bulk_abandon($agent, @incident_ids);
+
+foreach(@incident_ids) {
+ ticket_state_is($agent, $_, 'abandoned', "Incident #$_ is abandoned");
+}
+
+foreach(@ir_ids ) {
+ $agent->get(RT->Config->Get('WebURL') . "/RTIR/Display.html?id=$_");
+ $agent->content =~ qr{State:\s*</td>\s*<td[^>]*?>\s*<span class="cf-value">([\w ]+)</span>}ism;
+ diag("IR #$_ state is " . $1);
+}
+foreach(@invests) {
+ $agent->get(RT->Config->Get('WebURL') . "/RTIR/Display.html?id=$_");
+ $agent->content =~ qr{State:\s*</td>\s*<td[^>]*?>\s*<span class="cf-value">([\w ]+)</span>}ism;
+ diag("Investigation #$_ state is " . $1);
+}
+
+
+sub bulk_abandon {
+ my $agent = shift;
+ my @toAbandon = @_;
+
+ go_home($agent);
+ $agent->follow_link_ok({text => "Incidents", n => '1'}, "Followed 'Incidents' link");
+ $agent->follow_link_ok({text => "Bulk Abandon", n => '1'}, "Followed 'Bulk Abandon' link");
+
+ $agent->form_number(3);
+ foreach my $id (@toAbandon) {
+ $agent->tick('SelectedTickets', $id);
+ }
+
+ $agent->click('BulkAbandon');
+
+ foreach my $id (@toAbandon) {
+ ok_and_content_like($agent, qr/Ticket $id: State changed from \w+ to abandoned/, "Incident $id abandoned");
+ }
+
+ $agent->form_number(3);
+ ok($agent->value('BulkAbandon'), "Still on Bulk Abandon page");
+}
+
+sub resolve_ir {
+ my $agent = shift;
+ my $id = shift;
+
+ display_ticket($agent, $id);
+ $agent->follow_link_ok({text => "Quick Resolve", n => "1"}, "Followed 'Quick Resolve' link");
+
+ is($agent->status, 200, "Attempting to resolve IR $id");
+
+ $agent->content_like(qr/.*State changed from \w+ to resolved.*/, "Successfully resolved IR $id")
+}
+
+
+sub resolve_inv {
+ my $agent = shift;
+ my $id = shift;
+
+ display_ticket($agent, $id);
+ $agent->follow_link_ok({text => "Quick Resolve", n => "1"}, "Followed 'Quick Resolve' link");
+
+ is($agent->status, 200, "Attempting to resolve Investigation $id");
+
+ $agent->content_like(qr/.*State changed from \w+ to resolved.*/, "Successfully resolved Investigation $id")
+}
+
+#Copied straight from t/001-basic-RTIR.t
+
+sub LinkChildToIncident {
+ my %args = ( @_ );
+
+ my $id = $args{'id'};
+ my $incident = $args{'incident'};
+
+ 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;
+}
Added: rtir/branches/2.3-EXPERIMENTAL/t/019-webui-block-fields.t
==============================================================================
--- (empty file)
+++ rtir/branches/2.3-EXPERIMENTAL/t/019-webui-block-fields.t Thu Jul 5 13:09:15 2007
@@ -0,0 +1,25 @@
+use strict;
+
+use Test::WWW::Mechanize;
+use Test::More tests => 16;
+
+require "rtir-test.pl";
+
+my $agent = default_agent();
+
+my $incident = create_incident($agent, {Subject => 'Incident to test Block editing'});
+my $block = create_block($agent, {Incident => $incident});
+
+goto_edit_block($agent, $block);
+
+$agent->content_unlike(qr{<option (?:value=.*)?>Use system default\(\)</option>}, "The option 'Use system default()' does not exist.");
+
+
+sub goto_edit_block {
+ my $agent = shift;
+ my $id = shift;
+
+ display_ticket($agent, $id);
+
+ $agent->follow_link_ok({text => 'Edit', n => '1'}, "Followed 'Edit' (block) link");
+}
Added: rtir/branches/2.3-EXPERIMENTAL/t/020-admincc-denied.t
==============================================================================
--- (empty file)
+++ rtir/branches/2.3-EXPERIMENTAL/t/020-admincc-denied.t Thu Jul 5 13:09:15 2007
@@ -0,0 +1,55 @@
+use strict;
+
+use Test::WWW::Mechanize;
+use Test::More tests => 14;
+
+require "rtir-test.pl";
+
+my $agent = default_agent();
+
+my $ir = create_ir($agent, {Subject => 'IR to test AdminCC Denied bug'});
+
+my ($inc, $inv) = create_incident_and_investigation_for_ir($agent, $ir,
+ {Subject => "Incident linked with IR $ir to test AdminCC Denied bug",
+ InvestigationSubject => "Investigation linked with Incident to test AdminCC Denied bug",
+ InvestigationAdminCc => 'foo at bar.tld'});
+
+$agent->content_unlike(qr/permission denied/i, "No permissions problems");
+
+
+
+
+sub create_incident_and_investigation_for_ir {
+ my $agent = shift;
+ my $ir_id = shift;
+ my $fields = shift || {};
+ my $cfs = shift || {};
+
+ display_ticket($agent, $ir_id);
+
+ # Select the "New" link from the Display page
+ $agent->follow_link_ok({text => "[New]"}, "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");
+
+ is ($agent->status, 200, "Attempting to create new incident and investigation linked to child $ir_id");
+ ok ($agent->content =~ /.*Ticket (\d+) created in queue 'Incidents'/g, "Incident created from child $ir_id.");
+ my $incident_id = $1;
+
+ ok ($agent->content =~ /.*Ticket (\d+) created in queue 'Investigations'/g, "Investigation created for Incident $incident_id.");
+ my $investigation_id = $1;
+
+# diag("incident ID is $incident_id");
+ return ($incident_id, $investigation_id);
+}
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 Thu Jul 5 13:09:15 2007
@@ -11,12 +11,13 @@
use Test::WWW::Mechanize;
use HTTP::Cookies;
+use Test::More;
### after: use lib qw(@RT_LIB_PATH@);
use lib qw(/opt/rt3/local/lib /opt/rt3/lib);
use RT;
-ok(RT::LoadConfig);
+ok(RT::LoadConfig, "Loaded configuration");
ok(RT::Init, "Basic initialization and DB connectivity");
require $RT::BasePath. '/lib/t/utils.pl';
@@ -66,7 +67,8 @@
my $agent = shift;
my $id = shift;
- $agent->get_ok("$RT::WebURL/RTIR/Display.html?id=$id", "Loaded Display page");
+ #$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");
}
sub ticket_state_is {
@@ -200,7 +202,7 @@
# Now see if we succeeded
my $id = get_ticket_id($agent);
- ok ($id, "Ticket $id created successfully.");
+ ok ($id, $type{$queue} . " $id created successfully.");
return $id;
}
@@ -212,6 +214,9 @@
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";
+ }
return $id;
}
@@ -241,7 +246,7 @@
is ($agent->status, 200, "Attempting to create new incident linked to child $ir_id");
- ok ($agent->content =~ /.*Ticket (\d+) created in queue*/g, "Incident created from child $ir_id.");
+ ok ($agent->content =~ /.*Ticket (\d+) created in queue.*/g, "Incident created from child $ir_id.");
my $incident_id = $1;
# diag("incident ID is $incident_id");
More information about the Rt-commit
mailing list