[Rt-commit] r8178 - in rtir/branches/2.3-EXPERIMENTAL: .

thayes at bestpractical.com thayes at bestpractical.com
Mon Jul 16 17:44:41 EDT 2007


Author: thayes
Date: Mon Jul 16 17:44:41 2007
New Revision: 8178

Modified:
   rtir/branches/2.3-EXPERIMENTAL/   (props changed)
   rtir/branches/2.3-EXPERIMENTAL/t/001-basic-RTIR.t
   rtir/branches/2.3-EXPERIMENTAL/t/018-bulk-abandon.t
   rtir/branches/2.3-EXPERIMENTAL/t/019-watchers-on-create.t
   rtir/branches/2.3-EXPERIMENTAL/t/rtir-test.pl

Log:
 r8298 at toth:  toth | 2007-07-16 17:44:22 -0400
 * Added some utility functions to rtir-test.pl and adjusted the affected files
 


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	Mon Jul 16 17:44:41 2007
@@ -36,7 +36,7 @@
 my $second_incident_id = create_incident( $agent, { Subject => "foo Incident", Content => "bar baz quux" } );
 
 # link our report to that incident
-LinkChildToIncident(agent => $agent, id => $report, incident => $second_incident_id);
+LinkChildToIncident($agent, $report, $second_incident_id);
 
 # TODO: verify in DB that report has 1 parent, and the right parent
 

Modified: rtir/branches/2.3-EXPERIMENTAL/t/018-bulk-abandon.t
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/t/018-bulk-abandon.t	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/t/018-bulk-abandon.t	Mon Jul 16 17:44:41 2007
@@ -28,7 +28,7 @@
 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(agent => $agent, id => $ir_ids[1], incident => $incident_ids[0]);
+LinkChildToIncident($agent, $ir_ids[1], $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]]);
@@ -39,7 +39,7 @@
 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(agent => $agent, id => $ir_ids[3], incident => $incident_ids[1]);
+LinkChildToIncident($agent, $ir_ids[3], $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]]);

Modified: rtir/branches/2.3-EXPERIMENTAL/t/019-watchers-on-create.t
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/t/019-watchers-on-create.t	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/t/019-watchers-on-create.t	Mon Jul 16 17:44:41 2007
@@ -87,50 +87,6 @@
 }
 
 
-
-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;

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	Mon Jul 16 17:44:41 2007
@@ -39,7 +39,6 @@
     my $agent = shift;
     my $cf_name = shift;
     my $val = shift;
-
     my $field_name = $agent->value($cf_name) or return 0;
     $agent->field($field_name, $val);
     return 1;
@@ -272,22 +271,28 @@
 
 
 sub LinkChildToIncident {
-    my %args = ( @_ );
 
-    my $id = $args{'id'};
-    my $incident = $args{'incident'};
-    my $agent = $args{'agent'};
+	my $agent = shift;
+    my $id = shift;
+    my $incident = shift;
 
     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
+    
+	# Check that the desired incident occurs in the list of available incidents; if not, keep
+	# going to the next page until you find it (or get to the last page and don't find it,
+	# whichever comes first)
+    while($agent->content() !~ m|<a href="/Ticket/Display.html\?id=$incident">$incident</a>|) {
+    	last unless $agent->follow_link(text => 'Next Page');
+    }
+    
     $agent->form_number(3);
+    
     $agent->field("SelectedTicket", $incident);
+
     $agent->click("LinkChild");
 
     is ($agent->status, 200, "Attempting to link child $id to Incident $incident");
@@ -297,4 +302,72 @@
     return;
 }
 
+
+sub merge_ticket {
+	my $agent = shift;
+	my $id = shift;
+	my $id_to_merge_to = shift;
+	
+	display_ticket($agent, $id);
+	
+	$agent->follow_link_ok({text => 'Merge', n => '1'}, "Followed 'Merge' link");
+	
+	$agent->content() =~ /Merge ([\w ]+) #$id:/i;
+	my $type = $1 || 'Ticket';
+	
+	$agent->form_number(3);
+	
+	#print "Content:\n\n" . $agent->content() . "\n\n";
+	
+	$agent->field("SelectedTicket", $id_to_merge_to);
+    $agent->click_button(value => 'Merge');
+    
+    is ($agent->status, 200, "Attempting to merge $type #$id to ticket #$id_to_merge_to");
+	
+	$agent->content_like(qr{.*<ul class="action-results">\s*<li>Merge Successful</li>.*}i, 
+    	"Successfully merged $type #$id to ticket #$id_to_merge_to");
+}
+
+
+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.";
+    $agent->content_like(qr/.*Ticket (\d+) created in queue &#39;Incidents&#39;/, $msg);
+  	my $incident_id = $1;
+  	
+    $agent->content_like(qr/.*Ticket (\d+) created in queue &#39;Investigations&#39;/, "Investigation created for Incident $incident_id.");
+    my $investigation_id = $1;
+
+    return ($incident_id, $investigation_id);
+}
+
 1;


More information about the Rt-commit mailing list