[Rt-commit] r3051 - in rt/branches/3.4-RELEASE: . lib/t/regression
glasser at bestpractical.com
glasser at bestpractical.com
Wed Jun 1 18:37:30 EDT 2005
Author: glasser
Date: Wed Jun 1 18:37:29 2005
New Revision: 3051
Modified:
rt/branches/3.4-RELEASE/ (props changed)
rt/branches/3.4-RELEASE/lib/t/regression/02basic_web.t
rt/branches/3.4-RELEASE/lib/t/regression/08web_cf_access.t
rt/branches/3.4-RELEASE/lib/t/regression/09record_cf_api.t
rt/branches/3.4-RELEASE/lib/t/regression/10merge.t
rt/branches/3.4-RELEASE/lib/t/regression/11-template-insert.t
rt/branches/3.4-RELEASE/lib/t/regression/12-search.t
rt/branches/3.4-RELEASE/lib/t/regression/13-attribute-tests.t
rt/branches/3.4-RELEASE/lib/t/regression/15cf_single_values_are_single.t
rt/branches/3.4-RELEASE/lib/t/regression/21query-builder.t
Log:
r33242 at tin-foil: glasser | 2005-05-27 14:08:19 -0400
* Improved Query builder Tests
* add plans to a bunch of other tests
Modified: rt/branches/3.4-RELEASE/lib/t/regression/02basic_web.t
==============================================================================
--- rt/branches/3.4-RELEASE/lib/t/regression/02basic_web.t (original)
+++ rt/branches/3.4-RELEASE/lib/t/regression/02basic_web.t Wed Jun 1 18:37:29 2005
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
-use Test::More qw/no_plan/;
+use Test::More tests => 17;
use WWW::Mechanize;
use HTTP::Request::Common;
use HTTP::Cookies;
Modified: rt/branches/3.4-RELEASE/lib/t/regression/08web_cf_access.t
==============================================================================
--- rt/branches/3.4-RELEASE/lib/t/regression/08web_cf_access.t (original)
+++ rt/branches/3.4-RELEASE/lib/t/regression/08web_cf_access.t Wed Jun 1 18:37:29 2005
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use Test::More qw/no_plan/;
+use Test::More tests => 15;
use RT;
RT::LoadConfig;
RT::Init;
Modified: rt/branches/3.4-RELEASE/lib/t/regression/09record_cf_api.t
==============================================================================
--- rt/branches/3.4-RELEASE/lib/t/regression/09record_cf_api.t (original)
+++ rt/branches/3.4-RELEASE/lib/t/regression/09record_cf_api.t Wed Jun 1 18:37:29 2005
@@ -2,7 +2,7 @@
use strict;
#use warnings FATAL => 'all';
-use Test::More qw/no_plan/;
+use Test::More tests => 130;
use RT;
RT::LoadConfig();
Modified: rt/branches/3.4-RELEASE/lib/t/regression/10merge.t
==============================================================================
--- rt/branches/3.4-RELEASE/lib/t/regression/10merge.t (original)
+++ rt/branches/3.4-RELEASE/lib/t/regression/10merge.t Wed Jun 1 18:37:29 2005
@@ -8,7 +8,7 @@
# This test script validates that when merging two tickets, the comments from both tickets
# are integrated into the new ticket
-use Test::More qw/no_plan/;
+use Test::More tests => 13;
use RT;
RT::LoadConfig;
RT::Init;
Modified: rt/branches/3.4-RELEASE/lib/t/regression/11-template-insert.t
==============================================================================
--- rt/branches/3.4-RELEASE/lib/t/regression/11-template-insert.t (original)
+++ rt/branches/3.4-RELEASE/lib/t/regression/11-template-insert.t Wed Jun 1 18:37:29 2005
@@ -3,7 +3,7 @@
use warnings;
use strict;
-use Test::More qw/no_plan/;
+use Test::More tests => 7;
use RT;
RT::LoadConfig();
Modified: rt/branches/3.4-RELEASE/lib/t/regression/12-search.t
==============================================================================
--- rt/branches/3.4-RELEASE/lib/t/regression/12-search.t (original)
+++ rt/branches/3.4-RELEASE/lib/t/regression/12-search.t Wed Jun 1 18:37:29 2005
@@ -6,7 +6,7 @@
use strict;
use warnings;
-use Test::More qw/no_plan/;
+use Test::More tests => 35;
use_ok('RT');
RT::LoadConfig();
RT::Init();
Modified: rt/branches/3.4-RELEASE/lib/t/regression/13-attribute-tests.t
==============================================================================
--- rt/branches/3.4-RELEASE/lib/t/regression/13-attribute-tests.t (original)
+++ rt/branches/3.4-RELEASE/lib/t/regression/13-attribute-tests.t Wed Jun 1 18:37:29 2005
@@ -1,5 +1,5 @@
-use Test::More qw/no_plan/;
+use Test::More tests => 24;
use RT;
RT::LoadConfig();
RT::Init();
Modified: rt/branches/3.4-RELEASE/lib/t/regression/15cf_single_values_are_single.t
==============================================================================
--- rt/branches/3.4-RELEASE/lib/t/regression/15cf_single_values_are_single.t (original)
+++ rt/branches/3.4-RELEASE/lib/t/regression/15cf_single_values_are_single.t Wed Jun 1 18:37:29 2005
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use warnings;
use strict;
-use Test::More qw/no_plan/;
+use Test::More tests => 8;
use RT;
RT::LoadConfig();
Modified: rt/branches/3.4-RELEASE/lib/t/regression/21query-builder.t
==============================================================================
--- rt/branches/3.4-RELEASE/lib/t/regression/21query-builder.t (original)
+++ rt/branches/3.4-RELEASE/lib/t/regression/21query-builder.t Wed Jun 1 18:37:29 2005
@@ -1,15 +1,15 @@
#!/usr/bin/perl
use strict;
-use Test::More tests => 13;
-use WWW::Mechanize;
+use Test::More tests => 31;
+use Test::WWW::Mechanize;
use HTTP::Request::Common;
use HTTP::Cookies;
use LWP;
use Encode;
my $cookie_jar = HTTP::Cookies->new;
-my $agent = WWW::Mechanize->new();
+my $agent = Test::WWW::Mechanize->new();
# give the agent a place to stash the cookies
@@ -50,7 +50,7 @@
# Adding items
# set the first value
-ok($agent->form_name('BuildQuery'), "foud the form once");
+ok($agent->form_name('BuildQuery'), "found the form once");
$agent->field("ActorField", "Owner");
$agent->field("ActorOp", "=");
$agent->field("ValueOfActor", "Nobody");
@@ -64,16 +64,16 @@
ok($agent->form_name('BuildQuery'), "found the form a third time");
-# get the query
-my $query = $agent->current_form->find_input("Query")->value;
-# strip whitespace from ends
-$query =~ s/^\s*//g;
-$query =~ s/\s*$//g;
+sub getQueryFromForm {
+ # This pulls out the "hidden input" query from the page
+ my $q = $agent->current_form->find_input("Query")->value;
+ $q =~ s/^\s+//g;
+ $q =~ s/\s+$//g;
+ $q =~ s/\s+/ /g;
+ return $q;
+}
-# collapse other whitespace
-$query =~ s/\s+/ /g;
-
-is ($query, "Owner = 'Nobody' AND Queue != 'Regression'");
+is (getQueryFromForm, "Owner = 'Nobody' AND Queue != 'Regression'");
# We're going to delete the owner
@@ -83,16 +83,71 @@
ok($agent->form_name('BuildQuery'), "found the form a fourth time");
-# get the query
-$query = $agent->current_form->find_input("Query")->value;
-# strip whitespace from ends
-$query =~ s/^\s*//g;
-$query =~ s/\s*$//g;
+is (getQueryFromForm, "Queue != 'Regression'");
+
+$agent->field("AndOr", "OR");
+
+$agent->select("idOp", ">");
+
+$agent->field("ValueOfid" => "1234");
+
+$agent->click("AddClause");
+
+ok($agent->form_name('BuildQuery'), "found the form again");
+is(getQueryFromForm, "Queue != 'Regression' OR id > 1234", "added something as OR, and number not quoted");
+
+sub selectedClauses {
+ my @clauses = grep { defined } map { $_->value } $agent->current_form->find_input("clauses");
+ return [ @clauses ];
+}
+
+
+is_deeply(selectedClauses, ["1"], 'the id that we just entered is still selected');
+
+# Move the second one up a level
+$agent->click("Up");
+
+ok($agent->form_name('BuildQuery'), "found the form again");
+is(getQueryFromForm, "id > 1234 OR Queue != 'Regression'", "moved up one");
+
+is_deeply(selectedClauses, ["0"], 'the one we moved up is selected');
+
+$agent->click("Right");
+
+ok($agent->form_name('BuildQuery'), "found the form again");
+is(getQueryFromForm, "Queue != 'Regression' OR ( id > 1234 )", "moved over to the right (and down)");
+is_deeply(selectedClauses, ["2"], 'the one we moved right is selected');
+
+$agent->select("clauses", ["1"]);
+
+$agent->click("Up");
+
+ok($agent->form_name('BuildQuery'), "found the form again");
+is(getQueryFromForm, "( id > 1234 ) OR Queue != 'Regression'", "moved up");
+
+$agent->select("clauses", ["0"]); # this is a null clause
+
+$agent->click("Up");
+
+ok($agent->form_name('BuildQuery'), "found the form again");
+
+$agent->content_like(qr/error: can\S+t move up/, "i shouldn't have been able to hit up");
+
+$agent->click("Left");
+
+ok($agent->form_name('BuildQuery'), "found the form again");
+
+$agent->content_like(qr/error: can\S+t move left/, "i shouldn't have been able to hit left");
+
+$agent->select("clauses", ["1"]);
+$agent->select("ValueOfStatus" => "stalled");
+
+$agent->submit;
+ok($agent->form_name('BuildQuery'), "found the form again");
+is_deeply(selectedClauses, ["2"], 'the one we added is selected');
+is(getQueryFromForm, "( id > 1234 AND Status = 'stalled' ) OR Queue != 'Regression'", "added new one");
-# collapse other whitespace
-$query =~ s/\s+/ /g;
-is ($query, "Queue != 'Regression'");
# - new items go one level down
# - add items at currently selected level
More information about the Rt-commit
mailing list