From c52d1a38b62c89792068cf31d66e50a2adfa6b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Mon, 8 Feb 2010 22:26:51 +0100 Subject: [PATCH 01/14] Bug 3163: Set useqacontact = 1 and mail_delivery_method = 'Test' when creating a new installation --- config/generate_test_data.pl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/config/generate_test_data.pl b/config/generate_test_data.pl index 1ad45c8..5a013ca 100644 --- a/config/generate_test_data.pl +++ b/config/generate_test_data.pl @@ -40,15 +40,24 @@ BEGIN # Set Parameters ########################################################################## -my $params_modified; -# 'usebugaliases' must be turned on to create bugs with an alias. -# It's also expected to be turned on by some webservice_*.t scripts. +my $params_modified = 0; +# Some parameters must be turned on to create bugs requiring them. +# They are also expected to be turned on by some webservice_*.t scripts. if (!Bugzilla->params->{usebugaliases}) { SetParam('usebugaliases', 1); - write_params(); + $params_modified = 1; +} +if (!Bugzilla->params->{useqacontact}) { + SetParam('useqacontact', 1); + $params_modified = 1; +} +# Do not try to send emails for real! +if (Bugzilla->params->{mail_delivery_method} ne 'Test') { + SetParam('mail_delivery_method', 'Test'); $params_modified = 1; } +write_params() if $params_modified; ########################################################################## # Create Users ########################################################################## @@ -484,11 +493,11 @@ BEGIN if (Bugzilla->params->{insidergroup} ne 'QA-Selenium-TEST') { SetParam('insidergroup', 'QA-Selenium-TEST'); - write_params(); $params_modified = 1; } if ($params_modified) { + write_params(); print < Date: Tue, 9 Feb 2010 01:57:47 +0100 Subject: [PATCH 02/14] Bug 3164: Wrong checks --- t/test_default_groups.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/test_default_groups.t b/t/test_default_groups.t index 31fcc6d..ac53712 100644 --- a/t/test_default_groups.t +++ b/t/test_default_groups.t @@ -149,8 +149,8 @@ $sel->value_is("canedit_$group1_id", "off"); $sel->value_is("canedit_$group2_id", "off"); $sel->selected_label_is("membercontrol_$group1_id", "NA"); $sel->selected_label_is("othercontrol_$group1_id", "NA"); -$sel->selected_label_is("membercontrol_$group1_id", "NA"); -$sel->selected_label_is("othercontrol_$group1_id", "NA"); +$sel->selected_label_is("membercontrol_$group2_id", "NA"); +$sel->selected_label_is("othercontrol_$group2_id", "NA"); # Delete all created groups and products. From 5f5891f6187dee74bebdc3367d9747c95840c541 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Mon, 22 Feb 2010 13:59:47 -0800 Subject: [PATCH 03/14] Bug 3159: Make webservice_bug_create.t use API field names instead of backend field names. r=LpSolit, a=LpSolit --- t/webservice_bug_create.t | 51 +++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/t/webservice_bug_create.t b/t/webservice_bug_create.t index e36e740..f165610 100644 --- a/t/webservice_bug_create.t +++ b/t/webservice_bug_create.t @@ -5,7 +5,7 @@ use strict; use warnings; use lib qw(lib); -use Test::More tests => 53; +use Test::More tests => 62; use QA::Util; my ($rpc, $config) = get_xmlrpc_client(); @@ -16,26 +16,26 @@ my ($rpc, $config) = get_xmlrpc_client(); my $bug_fields = { 'priority' => 'P1', - 'bug_status' => 'NEW', + 'status' => 'NEW', 'version' => 'unspecified', 'reporter' => $config->{editbugs_user_login}, 'bug_file_loc' => '', - 'comment' => '-- Comment Created By Bugzilla XML-RPC Tests --', + 'description' => '-- Comment Created By Bugzilla XML-RPC Tests --', 'cc' => [$config->{unprivileged_user_login}], 'component' => 'TestComponent', - 'rep_platform' => 'All', + 'platform' => 'All', 'assigned_to' => $config->{editbugs_user_login}, - 'short_desc' => 'XML-RPC Test Bug', + 'summary' => 'XML-RPC Test Bug', 'product' => 'TestProduct', 'op_sys' => 'Linux', - 'bug_severity' => 'normal', + 'severity' => 'normal', 'qa_contact' => $config->{canconfirm_user_login}, }; # hash to contain all the possible $bug_fields values that # can be passed to createBug() my $fields = { - short_desc => { + summary => { undefined => { faultstring => 'You must enter a summary for this bug', value => undef @@ -67,7 +67,7 @@ my $fields = { value => 'does-not-exist' }, }, - rep_platform => { + platform => { undefined => { faultstring => 'A legal Platform was not set', value => undef }, invalid => { @@ -76,14 +76,14 @@ my $fields = { }, }, - bug_status => { + status => { invalid => { faultstring => "There is no status named 'does-not-exist'", value => 'does-not-exist' }, }, - bug_severity => { + severity => { undefined => { faultstring => 'A legal Severity was not set', value => undef }, invalid => { @@ -149,15 +149,12 @@ my $fields = { value => 'Bug 12345' }, - } - + }, }; # test calling Bug.create without logging into bugzilla -my $create_call = xmlrpc_call_fail($rpc, 'Bug.create', $bug_fields); -cmp_ok( $create_call->faultstring, '=~', 'Login Required', - 'calling the function without loggin in first returns error "Login Required"' -); +my $create_call = xmlrpc_call_fail($rpc, 'Bug.create', $bug_fields, + 'Login Required', 'Cannot file bugs as logged-out user'); xmlrpc_log_in($rpc, $config, 'editbugs'); @@ -169,10 +166,8 @@ foreach my $f (sort keys %{$fields}) { $bug_fields_copy->{$f} = $fields->{$f}->{$val}->{value}; my $expected_faultstring = $fields->{$f}->{$val}->{faultstring}; - my $fail_call = xmlrpc_call_fail($rpc, 'Bug.create', $bug_fields_copy); - cmp_ok(trim($fail_call->faultstring), '=~', $expected_faultstring, - "attempt to set $f to $val value got faultstring '$expected_faultstring'" - ); + my $fail_call = xmlrpc_call_fail($rpc, 'Bug.create', $bug_fields_copy, + $expected_faultstring, "Specifying $val $f fails"); } } @@ -180,6 +175,20 @@ foreach my $f (sort keys %{$fields}) { # this is done by the sort so call create bug with the valid $bug_fields # to run the test for the successful creation of the bug my $success_create = xmlrpc_call_success($rpc, 'Bug.create', $bug_fields); -cmp_ok($success_create->result->{id}, 'gt', 0, +my $bug_id = $success_create->result->{id}; +cmp_ok($bug_id, 'gt', 0, "Created new bug with id " . $success_create->result->{id}); + +# Make sure that the bug that we created has the field values we specified. +my $bug_result = xmlrpc_call_success($rpc, 'Bug.get', { ids => [$bug_id] }); +my $bug = $bug_result->result->{bugs}->[0]; +isa_ok($bug, 'HASH', "Bug $bug_id"); +# We have to limit the fields checked because Bug.get only returns certain +# fields. +foreach my $field (qw(assigned_to component priority product severity + status summary)) +{ + is($bug->{$field}, $bug_fields->{$field}, "$field has the right value"); +}; + xmlrpc_call_success($rpc, 'User.logout'); From 6464c908a15dd34e18a57830c84ca34d6b5610ad Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Wed, 10 Mar 2010 13:29:10 -0800 Subject: [PATCH 04/14] Bug 3153: Add a test for Bug.search r=LpSolit, a=LpSolit --- t/lib/QA/Tests.pm | 31 +++++++ t/webservice_bug_create.t | 19 +---- t/webservice_bug_search.t | 165 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 198 insertions(+), 17 deletions(-) create mode 100644 t/webservice_bug_search.t diff --git a/t/lib/QA/Tests.pm b/t/lib/QA/Tests.pm index 495647e..bff962b 100644 --- a/t/lib/QA/Tests.pm +++ b/t/lib/QA/Tests.pm @@ -6,12 +6,43 @@ use base qw(Exporter); our @EXPORT_OK = qw( PRIVATE_BUG_USER STANDARD_BUG_TESTS + create_bug_fields ); use constant INVALID_BUG_ID => -1; use constant INVALID_BUG_ALIAS => 'aaaaaaa12345'; use constant PRIVATE_BUG_USER => 'QA_Selenium_TEST'; +use constant CREATE_BUG => { + 'priority' => 'P1', + 'status' => 'NEW', + 'version' => 'unspecified', + 'reporter' => 'editbugs', + 'bug_file_loc' => '', + 'description' => '-- Comment Created By Bugzilla XML-RPC Tests --', + 'cc' => ['unprivileged'], + 'component' => 'TestComponent', + 'platform' => 'All', + 'assigned_to' => 'editbugs', + 'summary' => 'XML-RPC Test Bug', + 'product' => 'TestProduct', + 'op_sys' => 'Linux', + 'severity' => 'normal', + 'qa_contact' => 'canconfirm', + url => 'http://www.bugzilla.org/', +}; + +sub create_bug_fields { + my ($config) = @_; + my %bug = %{ CREATE_BUG() }; + foreach my $field (qw(reporter assigned_to qa_contact)) { + my $value = $bug{$field}; + $bug{$field} = $config->{"${value}_user_login"}; + } + $bug{cc} = [map { $config->{$_ . "_user_login"} } @{ $bug{cc} }]; + return \%bug; +} + use constant STANDARD_BUG_TESTS => [ { args => { ids => ['private_bug'] }, error => "You are not authorized to access", diff --git a/t/webservice_bug_create.t b/t/webservice_bug_create.t index f165610..4965f93 100644 --- a/t/webservice_bug_create.t +++ b/t/webservice_bug_create.t @@ -7,6 +7,7 @@ use warnings; use lib qw(lib); use Test::More tests => 62; use QA::Util; +use QA::Tests qw(create_bug_fields); my ($rpc, $config) = get_xmlrpc_client(); @@ -14,23 +15,7 @@ my ($rpc, $config) = get_xmlrpc_client(); # Bug.create() testing # ######################## -my $bug_fields = { - 'priority' => 'P1', - 'status' => 'NEW', - 'version' => 'unspecified', - 'reporter' => $config->{editbugs_user_login}, - 'bug_file_loc' => '', - 'description' => '-- Comment Created By Bugzilla XML-RPC Tests --', - 'cc' => [$config->{unprivileged_user_login}], - 'component' => 'TestComponent', - 'platform' => 'All', - 'assigned_to' => $config->{editbugs_user_login}, - 'summary' => 'XML-RPC Test Bug', - 'product' => 'TestProduct', - 'op_sys' => 'Linux', - 'severity' => 'normal', - 'qa_contact' => $config->{canconfirm_user_login}, -}; +my $bug_fields = create_bug_fields($config); # hash to contain all the possible $bug_fields values that # can be passed to createBug() diff --git a/t/webservice_bug_search.t b/t/webservice_bug_search.t new file mode 100644 index 0000000..5617211 --- /dev/null +++ b/t/webservice_bug_search.t @@ -0,0 +1,165 @@ +######################################## +# Test for xmlrpc call to Bug.search() # +######################################## + +use strict; +use warnings; +use lib qw(lib); +use QA::Util; +use QA::Tests qw(PRIVATE_BUG_USER create_bug_fields); +use DateTime; +use Storable qw(dclone); +use Test::More tests => 109; +my ($rpc, $config) = get_xmlrpc_client(); + +sub string_array { map { random_string() } (1..$_[0]) } + +my @whiteboard_strings = string_array(3); +my @summary_strings = string_array(3); + +my $public_bug = create_bug_fields($config); +$public_bug->{alias} = random_string(20); +$public_bug->{whiteboard} = join(' ', @whiteboard_strings); +$public_bug->{summary} = join(' ', @summary_strings); + +my $private_bug = dclone($public_bug); +$private_bug->{alias} = random_string(20); +$private_bug->{product} = 'QA-Selenium-TEST'; +$private_bug->{component} = 'QA-Selenium-TEST'; + +my @create_bugs = ( + { user => 'editbugs', + args => $public_bug, + test => 'Create a public bug' }, + { user => PRIVATE_BUG_USER, + args => $private_bug, + test => 'Create a private bug' }, +); + +xmlrpc_run_tests(rpc => $rpc, config => $config, tests => \@create_bugs, + method => 'Bug.create'); + +my @tests; +foreach my $field (keys %$public_bug) { + next if ($field eq 'cc' or $field eq 'description'); + my $test = { args => { $field => $public_bug->{$field} }, + test => "Search by $field" }; + if ( grep($_ eq $field, qw(alias whiteboard summary)) ) { + $test->{exactly} = 1; + } + push(@tests, $test); +} + + +push(@tests, ( + { args => { offset => 1 }, + test => "Offset without limit fails", + error => 'requires a limit argument', + }, + + { args => { alias => $private_bug->{alias} }, + test => 'Logged-out cannot find a private_bug by alias', + bugs => 0, + }, + + { args => { creation_time => '19700101T00:00:00' }, + test => 'Get all bugs by creation time', + }, + { args => { creation_time => '20380101T00:00:00' }, + test => 'Get no bugs, by creation time', + bugs => 0, + }, + { args => { last_change_time => '19700101T00:00:00' }, + test => 'Get all bugs by last_change_time', + }, + { args => { last_change_time => '20380101T00:00:00' }, + test => 'Get no bugs by last_change_time', + bugs => 0, + }, + + { args => { reporter => $config->{editbugs_user_login} }, + test => 'Search by reporter', + }, + { args => { resolution => '' }, + test => 'Search for empty resolution', + }, + { args => { resolution => 'NO_SUCH_RESOLUTION' }, + test => 'Search for invalid resolution', + bugs => 0, + }, + { args => { summary => substr($public_bug->{summary}, 0, 50) }, + test => 'Search by partial summary', + bugs => 1, exactly => 1 + }, + { args => { summary => random_string() . ' ' . random_string() }, + test => 'Summary search that returns no results', + bugs => 0, + }, + { args => { summary => \@summary_strings }, + test => 'Summary search using multiple terms', + }, + { args => { votes => 1 }, + test => 'Search by votes', + bugs => -1, # We don't care how many it returns, for now. + }, + + { args => { whiteboard => substr($public_bug->{whiteboard}, 0, 50) }, + test => 'Search by partial whiteboard', + bugs => 1, exactly => 1, + }, + { args => { whiteboard => random_string(100) }, + test => 'Whiteboard search that returns no results', + bugs => 0, + }, + { args => { whiteboard => \@whiteboard_strings }, + test => 'Whiteboard search using multiple terms', + bugs => 1, exactly => 1, + }, + + { args => { product => $public_bug->{product}, + component => $public_bug->{component}, + last_change_time => '19700101T00:00:00' }, + test => 'Search by multiple arguments', + }, + + # Logged-in user who can see private bugs + { user => PRIVATE_BUG_USER, + args => { alias => [$public_bug->{alias}, $private_bug->{alias}] }, + test => 'Search using two aliases (including one private)', + bugs => 2, exactly => 1, + }, + { user => PRIVATE_BUG_USER, + args => { product => [$public_bug->{product}, $private_bug->{product}], + limit => 1 }, + test => 'Limit 1', + bugs => 1, exactly => 1, + }, + { user => PRIVATE_BUG_USER, + args => { product => [$public_bug->{product}, $private_bug->{product}], + limit => 1, offset => 1 }, + test => 'Limit 1 Offset 1', + bugs => 1, exactly => 1, + }, +)); + +sub post_success { + my ($call, $t) = @_; + my $bugs = $call->result->{bugs}; + my $expected_count = $t->{bugs}; + $expected_count = 1 if !defined $expected_count; + if ($expected_count) { + my $operator = $t->{exactly} ? '=' : '>='; + cmp_ok(scalar @$bugs, $operator, $expected_count, + 'The right number of bugs are returned'); + unless ($t->{user} and $t->{user} eq PRIVATE_BUG_USER) { + ok(!grep($_->{alias} eq $private_bug->{alias}, @$bugs), + 'Result does not contain the private bug'); + } + } + else { + is(scalar @$bugs, 0, 'No bugs returned'); + } +} + +xmlrpc_run_tests(rpc => $rpc, config => $config, tests => \@tests, + method => 'Bug.search', post_success => \&post_success); From 3979fd9edc669656fe33d3cede62842917e1c944 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Wed, 10 Mar 2010 13:29:59 -0800 Subject: [PATCH 05/14] Post-checkin fix for bug 3153. --- t/webservice_bug_search.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/webservice_bug_search.t b/t/webservice_bug_search.t index 5617211..ff821a2 100644 --- a/t/webservice_bug_search.t +++ b/t/webservice_bug_search.t @@ -45,7 +45,7 @@ foreach my $field (keys %$public_bug) { my $test = { args => { $field => $public_bug->{$field} }, test => "Search by $field" }; if ( grep($_ eq $field, qw(alias whiteboard summary)) ) { - $test->{exactly} = 1; + $test->{exactly} = 1; $test->{bugs} = 1; } push(@tests, $test); } From 2516ce663225ec810856c7e2a130636fb73f7f01 Mon Sep 17 00:00:00 2001 From: Noura Elhawary Date: Fri, 12 Mar 2010 01:10:46 +0100 Subject: [PATCH 06/14] Bug 3097: Add the "test_flags2" Perl selenium test script r/a=LpSolit --- t/test_flags2.t | 343 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 343 insertions(+) create mode 100644 t/test_flags2.t diff --git a/t/test_flags2.t b/t/test_flags2.t new file mode 100644 index 0000000..28dbcf8 --- /dev/null +++ b/t/test_flags2.t @@ -0,0 +1,343 @@ +use strict; +use warnings; +use lib qw(lib); + +use Test::More "no_plan"; + +use QA::Util; + +################################################################ +# 2nd script about flags. This one is focused on flag behavior # +# when moving a bug from one product/component to another one. # +################################################################ + +# We have to upload files from the local computer. This requires +# chrome privileges. +my ($sel, $config) = get_selenium(CHROME_MODE); + +# Start by creating a flag type for bugs. + +log_in($sel, $config, 'admin'); +go_to_admin($sel); +$sel->click_ok("link=Flags"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Administer Flag Types"); +$sel->click_ok("link=Create Flag Type for Bugs"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Create Flag Type for Bugs"); +$sel->type_ok("name", "selenium"); +$sel->type_ok("description", "Available in TestProduct and Another Product/c1"); +$sel->add_selection_ok("inclusion_to_remove", "label=__Any__:__Any__"); +$sel->click_ok("categoryAction-removeInclusion"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Create Flag Type for Bugs"); +$sel->select_ok("product", "label=TestProduct"); +$sel->selected_label_is("component", "__Any__"); +$sel->click_ok("categoryAction-include"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Create Flag Type for Bugs"); +$sel->select_ok("product", "label=Another Product"); +$sel->select_ok("component", "label=c1"); +$sel->click_ok("categoryAction-include"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Create Flag Type for Bugs"); + +# This flag type must have a higher sortkey than the one we will create later. +# The reason is that link=selenium will catch the first link with this name in +# the UI, so when the second flag type with this name is created, we have to +# catch it, not this one (which will be unique for now, so no worry to find it). + +$sel->type_ok("sortkey", 100); +$sel->value_is("is_active", "on"); +$sel->value_is("is_requestable", "on"); +$sel->click_ok("is_multiplicable"); +$sel->value_is("is_multiplicable", "off"); +$sel->select_ok("grant_group", "label=editbugs"); +$sel->select_ok("request_group", "label=canconfirm"); +$sel->click_ok("save"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Flag Type 'selenium' Created"); +$sel->is_text_present_ok("The flag type selenium has been created."); + +# Store the flag type ID. + +$sel->click_ok("link=selenium"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +my $flag_url = $sel->get_location(); +$flag_url =~ /id=(\d+)/; +my $flagtype1_id = $1; + +# Now create a flag type for attachments in 'Another Product'. + +$sel->go_back_ok(); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->click_ok("link=Create Flag Type For Attachments"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Create Flag Type for Attachments"); +$sel->type_ok("name", "selenium_review"); +$sel->type_ok("description", "Review flag used by Selenium"); +$sel->add_selection_ok("inclusion_to_remove", "label=__Any__:__Any__"); +$sel->click_ok("categoryAction-removeInclusion"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Create Flag Type for Attachments"); +$sel->select_ok("product", "label=Another Product"); +$sel->click_ok("categoryAction-include"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Create Flag Type for Attachments"); +$sel->type_ok("sortkey", 100); +$sel->value_is("is_active", "on"); +$sel->value_is("is_requestable", "on"); +$sel->click_ok("is_multiplicable"); +$sel->value_is("is_multiplicable", "off"); +$sel->selected_label_is("grant_group", "(no group)"); +$sel->selected_label_is("request_group", "(no group)"); +$sel->click_ok("save"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Flag Type 'selenium_review' Created"); +$sel->is_text_present_ok("The flag type selenium_review has been created."); + +# Store the flag type ID. + +$sel->click_ok("link=selenium_review"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$flag_url = $sel->get_location(); +$flag_url =~ /id=(\d+)/; +my $aflagtype1_id = $1; + +# Create a 2nd flag type for attachments, with the same name +# as the 1st one, but now *excluded* from 'Another Product'. + +$sel->go_back_ok(); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->click_ok("link=Create Flag Type For Attachments"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->type_ok("name", "selenium_review"); +$sel->type_ok("description", "Another review flag used by Selenium"); +$sel->select_ok("product", "label=Another Product"); +$sel->click_ok("categoryAction-include"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Create Flag Type for Attachments"); +$sel->type_ok("sortkey", 50); +$sel->value_is("is_active", "on"); +$sel->value_is("is_requestable", "on"); +$sel->value_is("is_multiplicable", "on"); +$sel->select_ok("grant_group", "label=editbugs"); +$sel->select_ok("request_group", "label=canconfirm"); +$sel->click_ok("save"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Flag Type 'selenium_review' Created"); + +# Store the flag type ID. + +$sel->click_ok("link=selenium_review"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$flag_url = $sel->get_location(); +$flag_url =~ /id=(\d+)/; +my $aflagtype2_id = $1; + +# We are done with the admin tasks. Now play with flags in bugs. + +file_bug_in_product($sel, 'TestProduct'); +$sel->select_ok("flag_type-$flagtype1_id", "label=+"); +$sel->type_ok("short_desc", "The selenium flag should be kept on product change"); +$sel->type_ok("comment", "pom"); +$sel->click_ok('//input[@value="Add an attachment"]'); +$sel->type_ok("data", "/var/www/html/selenium/bugzilla/patch.diff"); +$sel->type_ok("description", "small patch"); +$sel->click_ok("ispatch"); +$sel->value_is("ispatch", "on"); +ok(!$sel->is_element_present("flag_type-$aflagtype1_id"), "Flag type $aflagtype1_id not available in TestProduct"); +$sel->select_ok("flag_type-$aflagtype2_id", "label=-"); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/Bug \d+ Submitted/, "Bug created"); + +# Store the bug and flag IDs. + +my $bug1_id = $sel->get_value('//input[@name="id" and @type="hidden"]'); +$sel->click_ok("link=Bug $bug1_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug1_id /); +$sel->is_text_present_ok("$config->{admin_user_username}: selenium"); +my $flag1_id = $sel->get_attribute('//select[@title="Available in TestProduct and Another Product/c1"]@id'); +$flag1_id =~ s/flag-//; +$sel->selected_label_is("flag-$flag1_id", "+"); +$sel->is_text_present_ok("$config->{admin_user_username}: selenium_review-"); + +# Now move the bug into the 'Another Product' product. +# Both the bug and attachment flags should survive. + +$sel->select_ok("product", "label=Another Product"); +$sel->type_ok("comment", "Moving to Another Product / c1. The flag should be preserved."); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Verify New Product Details..."); +$sel->select_ok("component", "label=c1"); +$sel->click_ok("change_product"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug $bug1_id processed"); +$sel->click_ok("link=bug $bug1_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug1_id /); +$sel->selected_label_is("flag-$flag1_id", "+"); +$sel->is_text_present_ok("$config->{admin_user_username}: selenium_review-"); + +# Now moving the bug into the c2 component. The bug flag +# won't survive, but the attachment flag should. + +$sel->type_ok("comment", "Moving to c2. The selenium flag will be deleted."); +$sel->select_ok("component", "label=c2"); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug $bug1_id processed"); +$sel->click_ok("link=bug $bug1_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug1_id /); +ok(!$sel->is_element_present("flag-$flag1_id"), "The selenium bug flag didn't survive"); +ok(!$sel->is_element_present("flag_type-$flagtype1_id"), "The selenium flag type doesn't exist"); +$sel->is_text_present_ok("$config->{admin_user_username}: selenium_review-"); + +# File a bug in 'Another Product / c2' and assign it +# to a powerless user, so that he can move it later. + +file_bug_in_product($sel, 'Another Product'); +$sel->select_ok("component", "label=c2"); +$sel->type_ok("assigned_to", $config->{unprivileged_user_login}); +ok(!$sel->is_editable("flag_type-$flagtype1_id"), "The selenium bug flag type is displayed but not selectable"); +$sel->select_ok("component", "label=c1"); +$sel->is_editable_ok("flag_type-$flagtype1_id", "The selenium bug flag type is not selectable"); +$sel->select_ok("flag_type-$flagtype1_id", "label=?"); +$sel->type_ok("short_desc", "Create a new selenium flag for c2"); +$sel->type_ok("comment", "."); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/Bug \d+ Submitted/); + +# Store the bug and flag IDs. + +my $bug2_id = $sel->get_value('//input[@name="id" and @type="hidden"]'); +$sel->click_ok("link=Bug $bug2_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug2_id /); +$sel->is_text_present_ok("$config->{admin_user_username}: selenium"); +my $flag2_id = $sel->get_attribute('//select[@title="Available in TestProduct and Another Product/c1"]@id'); +$flag2_id =~ s/flag-//; +$sel->selected_label_is("flag-$flag2_id", '?'); + +# Create a 2nd bug flag type, again named 'selenium', but now +# for the 'Another Product / c2' component only. + +go_to_admin($sel); +$sel->click_ok("link=Flags"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Administer Flag Types"); +$sel->click_ok("link=Create Flag Type for Bugs"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Create Flag Type for Bugs"); +$sel->type_ok("name", "selenium"); +$sel->type_ok("description", "Another flag with the selenium name"); +$sel->add_selection_ok("inclusion_to_remove", "label=__Any__:__Any__"); +$sel->click_ok("categoryAction-removeInclusion"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Create Flag Type for Bugs"); +$sel->select_ok("product", "label=Another Product"); +$sel->select_ok("component", "label=c2"); +$sel->click_ok("categoryAction-include"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Create Flag Type for Bugs"); +$sel->type_ok("sortkey", 50); +$sel->value_is("is_active", "on"); +$sel->value_is("is_requestable", "on"); +$sel->value_is("is_multiplicable", "on"); +$sel->selected_label_is("grant_group", "(no group)"); +$sel->selected_label_is("request_group", "(no group)"); +$sel->click_ok("save"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Flag Type 'selenium' Created"); + +# Store the flag type ID. + +$sel->click_ok("link=selenium"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$flag_url = $sel->get_location(); +$flag_url =~ /id=(\d+)/; +my $flagtype2_id = $1; + +# Now move the bug from c1 into c2. The bug flag should survive. + +$sel->type_ok("quicksearch_top", $bug2_id); +$sel->click_ok("find_top"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug2_id /); +$sel->select_ok("component", "label=c2"); +$sel->click_ok("set_default_assignee"); +$sel->type_ok("comment", "The selenium flag should be preserved."); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug $bug2_id processed"); +$sel->click_ok("link=bug $bug2_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug2_id /); +$sel->selected_label_is("flag-$flag2_id", '?'); +ok(!$sel->is_element_present("flag_type-$flagtype1_id"), "Flag type not available in c2"); +$sel->is_element_present_ok("flag_type-$flagtype2_id"); +logout($sel); + +# Powerless users can edit the 'selenium' flag being in c2. + +log_in($sel, $config, 'unprivileged'); +$sel->type_ok("quicksearch_top", $bug2_id); +$sel->click_ok("find_top"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug2_id /); +$sel->select_ok("flag-$flag2_id", "label=+"); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug $bug2_id processed"); +$sel->click_ok("link=bug $bug2_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug2_id /); +$sel->selected_label_is("flag-$flag2_id", "+"); + +# But moving the bug into TestProduct will delete the flag +# as the flag setter is not in the editbugs group. + +$sel->select_ok("product", "label=TestProduct"); +$sel->type_ok("comment", "selenium flag will be lost. I don't have editbugs privs."); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Verify New Product Details..."); +$sel->click_ok("change_product"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug $bug2_id processed"); +$sel->click_ok("link=bug $bug2_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug2_id /); +ok(!$sel->is_element_present("flag-$flag2_id"), "Flag $flag2_id deleted"); +ok(!$sel->is_editable("flag_type-$flagtype1_id"), "Flag type 'selenium' not editable by powerless users"); +ok(!$sel->is_element_present("flag_type-$flagtype2_id"), "Flag type not available in c1"); +logout($sel); + +# Time to delete created flag types. + +log_in($sel, $config, 'admin'); +go_to_admin($sel); +$sel->click_ok("link=Flags"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Administer Flag Types"); + +foreach my $flagtype ([$flagtype1_id, "selenium"], [$flagtype2_id, "selenium"], + [$aflagtype1_id, "selenium_review"], [$aflagtype2_id, "selenium_review"]) +{ + my $flag_id = $flagtype->[0]; + my $flag_name = $flagtype->[1]; + $sel->click_ok("//a[\@href='editflagtypes.cgi?action=confirmdelete&id=$flag_id']"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Confirm Deletion of Flag Type '$flag_name'"); + $sel->click_ok("link=Yes, delete"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Flag Type '$flag_name' Deleted"); + my $msg = trim($sel->get_text("message")); + ok($msg eq "The flag type $flag_name has been deleted.", "Flag type $flag_name deleted"); +} +logout($sel); From 74fdf1e8cd7e305e109cc8bfa6d32cb9b6827175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Wed, 7 Apr 2010 01:52:30 +0200 Subject: [PATCH 07/14] New Selenium script to test custom field administration --- t/test_custom_fields_admin.t | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 t/test_custom_fields_admin.t diff --git a/t/test_custom_fields_admin.t b/t/test_custom_fields_admin.t new file mode 100644 index 0000000..14884ca --- /dev/null +++ b/t/test_custom_fields_admin.t @@ -0,0 +1,46 @@ +use strict; +use warnings; +use lib qw(lib); + +use Test::More "no_plan"; + +use QA::Util; + +my ($sel, $config) = get_selenium(); +log_in($sel, $config, 'admin'); + +# Create a custom field, going through each type available, +# mark it as obsolete and delete it immediately. + +go_to_admin($sel); +$sel->click_ok("link=Custom Fields"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Custom Fields"); + +my @types = ("Bug ID", "Large Text Box", "Free Text", "Multiple-Selection Box", + "Drop Down", "Date/Time"); +my $counter = int(rand(10000)); + +foreach my $type (@types) { + my $fname = "cf_field" . ++$counter; + my $fdesc = "Field" . $counter; + + $sel->click_ok("link=Add a new custom field"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Add a new Custom Field"); + $sel->type_ok("name", $fname); + $sel->type_ok("desc", $fdesc); + $sel->select_ok("type", "label=$type"); + $sel->click_ok("obsolete"); + $sel->click_ok("create"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Custom Field Created"); + $sel->click_ok("//a[\@href='editfields.cgi?action=del&name=$fname']"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Delete the Custom Field '$fname' ($fdesc)"); + $sel->click_ok("link=Delete field '$fdesc'"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Custom Field Deleted"); +} + +logout($sel); From 976b047b065d0e588c10fc3c3bdb19e903d5a6a8 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Wed, 7 Apr 2010 03:56:43 +0200 Subject: [PATCH 08/14] Bug 3173: Refactor the XML-RPC helpers into a QA::RPC object r/a=LpSolit --- t/lib/QA/RPC.pm | 107 +++++++++++++++++++++ t/lib/QA/Util.pm | 107 +-------------------- t/webservice_bug_add_comment.t | 3 +- t/webservice_bug_comments.t | 8 +- t/webservice_bug_create.t | 12 +-- t/webservice_bug_get_bugs.t | 2 +- t/webservice_bug_history.t | 2 +- t/webservice_bug_legal_values.t | 4 +- t/webservice_bug_search.t | 4 +- t/webservice_bug_update_see_also.t | 2 +- t/webservice_bugzilla.t | 8 +- t/webservice_product.t | 23 ++--- t/webservice_user_create.t | 2 +- t/webservice_user_get.t | 14 +-- t/webservice_user_login_logout.t | 7 +- t/webservice_user_offer_account_by_email.t | 2 +- 16 files changed, 153 insertions(+), 154 deletions(-) create mode 100644 t/lib/QA/RPC.pm diff --git a/t/lib/QA/RPC.pm b/t/lib/QA/RPC.pm new file mode 100644 index 0000000..8fc0cd7 --- /dev/null +++ b/t/lib/QA/RPC.pm @@ -0,0 +1,107 @@ +# -*- Mode: perl; indent-tabs-mode: nil -*- + +package QA::RPC; +use strict; +use base qw(XMLRPC::Lite); +use QA::Util; +use Test::More; + +sub bz_config { + my $self = shift; + $self->{bz_config} ||= QA::Util::get_config(); + return $self->{bz_config}; +} + +################################ +# Helpers for RPC test scripts # +################################ + +sub bz_log_in { + my ($self, $user) = @_; + my $username = $self->bz_config->{"${user}_user_login"}; + my $password = $self->bz_config->{"${user}_user_passwd"}; + + my $call = $self->bz_call_success( + 'User.login', { login => $username, password => $password }); + cmp_ok($call->result->{id}, 'gt', 0, "Logged in as $user"); + + # Save the cookies in the cookie file + $self->transport->cookie_jar->extract_cookies( + $self->transport->http_response); + $self->transport->cookie_jar->save; +} + +sub bz_call_success { + my ($self, $method, $args, $test_name) = @_; + my $call = $self->call($method, $args); + $test_name ||= "$method returned successfully"; + ok(!defined $call->fault, $test_name) or diag($call->faultstring); + return $call; +} + +sub bz_call_fail { + my ($self, $method, $args, $faultstring, $test_name) = @_; + my $call = $self->call($method, $args); + $test_name ||= "$method failed (as intended)"; + ok(defined $call->fault, $test_name) + or diag("Returned: " . Dumper($call->result)); + if (defined $faultstring) { + cmp_ok(trim($call->faultstring), '=~', $faultstring, + "Got correct fault for $method"); + } + return $call; +} + +sub bz_get_products { + my ($self) = @_; + $self->bz_log_in('QA_Selenium_TEST'); + + my $accessible = $self->bz_call_success('Product.get_accessible_products'); + my $prod_call = $self->bz_call_success('Product.get', $accessible->result); + my %products; + foreach my $prod (@{ $prod_call->result->{products} }) { + $products{$prod->{name}} = $prod->{id}; + } + + $self->bz_call_success('User.logout'); + return \%products; +} + +sub bz_run_tests { + my ($self, %params) = @_; + # Required params + my $config = $self->bz_config; + my $tests = $params{tests}; + my $method = $params{method}; + + # Optional params + my $post_success = $params{post_success}; + + my $former_user = ''; + foreach my $t (@$tests) { + # Only logout/login if the user has changed since the last test + # (this saves us LOTS of needless logins). + my $user = $t->{user} || ''; + if ($former_user ne $user) { + $self->bz_call_success('User.logout') if $former_user; + $self->bz_log_in($user) if $user; + $former_user = $user; + } + + if ($t->{error}) { + $self->bz_call_fail($method, $t->{args}, $t->{error}, $t->{test}); + } + else { + my $call = $self->bz_call_success($method, $t->{args}, $t->{test}); + if ($call->result && $post_success) { + $post_success->($call, $t); + } + } + } + + $self->bz_call_success('User.logout') if $former_user; +} + +1; + +__END__ diff --git a/t/lib/QA/Util.pm b/t/lib/QA/Util.pm index 3141507..3e81338 100644 --- a/t/lib/QA/Util.pm +++ b/t/lib/QA/Util.pm @@ -8,7 +8,6 @@ use HTTP::Cookies; use Test::More; use Test::WWW::Selenium; use WWW::Selenium::Util qw(server_is_running); -use XMLRPC::Lite; use base qw(Exporter); @QA::Util::EXPORT = qw( @@ -28,12 +27,6 @@ use base qw(Exporter); get_selenium get_xmlrpc_client - xmlrpc_log_in - xmlrpc_call_success - xmlrpc_call_fail - xmlrpc_get_product_ids - xmlrpc_run_tests - WAIT_TIME CHROME_MODE ); @@ -104,110 +97,14 @@ sub get_xmlrpc_client { my $xmlrpc_url = $config->{browser_url} . "/" . $config->{bugzilla_installation} . "/xmlrpc.cgi"; - + require QA::RPC; # A temporary cookie jar that isn't saved after the script closes. my $cookie_jar = new HTTP::Cookies(); - my $rpc = new XMLRPC::Lite(proxy => $xmlrpc_url); + my $rpc = new QA::RPC(proxy => $xmlrpc_url); $rpc->transport->cookie_jar($cookie_jar); return ($rpc, $config); } -############################### -# Helpers for XML-RPC scripts # -############################### - -sub xmlrpc_log_in { - my ($rpc, $config, $user) = @_; - my $username = $config->{"${user}_user_login"}; - my $password = $config->{"${user}_user_passwd"}; - - my $call = xmlrpc_call_success($rpc, 'User.login', - { login => $username, password => $password }); - cmp_ok($call->result->{id}, 'gt', 0, "Logged in as $user"); - - # Save the cookies in the cookie file - $rpc->transport->cookie_jar->extract_cookies( - $rpc->transport->http_response); - $rpc->transport->cookie_jar->save; -} - -sub xmlrpc_call_success { - my ($rpc, $method, $args, $test_name) = @_; - my $call = $rpc->call($method, $args); - $test_name ||= "$method returned successfully"; - ok(!defined $call->fault, $test_name) or diag($call->faultstring); - return $call; -} - -sub xmlrpc_call_fail { - my ($rpc, $method, $args, $faultstring, $test_name) = @_; - my $call = $rpc->call($method, $args); - $test_name ||= "$method failed (as intended)"; - ok(defined $call->fault, $test_name) - or diag("Returned: " . Dumper($call->result)); - if (defined $faultstring) { - cmp_ok(trim($call->faultstring), '=~', $faultstring, - "Got correct fault for $method"); - } - return $call; -} - -sub xmlrpc_get_product_ids { - my ($rpc, $config) = @_; - xmlrpc_log_in($rpc, $config, 'QA_Selenium_TEST'); - - my $accessible = xmlrpc_call_success($rpc, - 'Product.get_accessible_products'); - my $prod_call = xmlrpc_call_success($rpc, 'Product.get', - $accessible->result); - my %products; - foreach my $prod (@{ $prod_call->result->{products} }) { - $products{$prod->{name}} = $prod->{id}; - } - - xmlrpc_call_success($rpc, 'User.logout'); - - return \%products; -} - -sub xmlrpc_run_tests { - my %params = @_; - # Required params - my $rpc = $params{rpc}; - my $config = $params{config}; - my $tests = $params{tests}; - my $method = $params{method}; - - # Optional params - my $post_success = $params{post_success}; - - my $former_user = ''; - foreach my $t (@$tests) { - # Only logout/login if the user has changed since the last test - # (this saves us LOTS of needless logins). - my $user = $t->{user} || ''; - if ($former_user ne $user) { - xmlrpc_call_success($rpc, 'User.logout') if $former_user; - xmlrpc_log_in($rpc, $config, $user) if $user; - $former_user = $user; - } - - if ($t->{error}) { - xmlrpc_call_fail($rpc, $method, $t->{args}, $t->{error}, - $t->{test}); - } - else { - my $call = xmlrpc_call_success($rpc, $method, $t->{args}, - $t->{test}); - if ($call->result && $post_success) { - $post_success->($call, $t); - } - } - } - - xmlrpc_call_success($rpc, 'User.logout') if $former_user; -} - ################################ # Helpers for Selenium Scripts # ################################ diff --git a/t/webservice_bug_add_comment.t b/t/webservice_bug_add_comment.t index 6f012d8..8795ff8 100644 --- a/t/webservice_bug_add_comment.t +++ b/t/webservice_bug_add_comment.t @@ -134,5 +134,4 @@ my @tests = ( # XXX Need to verify that the comment added was actually private. ); -xmlrpc_run_tests(rpc => $rpc, config => $config, tests => \@tests, - method => 'Bug.add_comment'); +$rpc->bz_run_tests(tests => \@tests, method => 'Bug.add_comment'); diff --git a/t/webservice_bug_comments.t b/t/webservice_bug_comments.t index 3ab57a6..b5348c4 100644 --- a/t/webservice_bug_comments.t +++ b/t/webservice_bug_comments.t @@ -20,8 +20,8 @@ sub post_bug_success { is(scalar keys %{ $call->result->{bugs} }, 1, "Got exactly one bug"); } -xmlrpc_run_tests(rpc => $rpc, config => $config, tests => STANDARD_BUG_TESTS, - method => 'Bug.comments', post_success => \&post_bug_success); +$rpc->bz_run_tests(tests => STANDARD_BUG_TESTS, method => 'Bug.comments', + post_success => \&post_bug_success); #################### # Comment ID Tests # @@ -56,7 +56,7 @@ sub post_add { $comments{$key} = $call->result->{id}; } -xmlrpc_run_tests(rpc => $rpc, config => $config, tests => \@add_comment_tests, +$rpc->bz_run_tests(tests => \@add_comment_tests, method => 'Bug.add_comment', post_success => \&post_add); # Now check access on each private and public comment @@ -111,5 +111,5 @@ my @comment_tests = ( }, ); -xmlrpc_run_tests(rpc => $rpc, config => $config, tests => \@comment_tests, +$rpc->bz_run_tests(tests => \@comment_tests, method => 'Bug.comments'); diff --git a/t/webservice_bug_create.t b/t/webservice_bug_create.t index 4965f93..0d7a7f6 100644 --- a/t/webservice_bug_create.t +++ b/t/webservice_bug_create.t @@ -138,10 +138,10 @@ my $fields = { }; # test calling Bug.create without logging into bugzilla -my $create_call = xmlrpc_call_fail($rpc, 'Bug.create', $bug_fields, +my $create_call = $rpc->bz_call_fail('Bug.create', $bug_fields, 'Login Required', 'Cannot file bugs as logged-out user'); -xmlrpc_log_in($rpc, $config, 'editbugs'); +$rpc->bz_log_in('editbugs'); # run the tests for all the invalid values that can be passed to Bug.create() foreach my $f (sort keys %{$fields}) { @@ -151,7 +151,7 @@ foreach my $f (sort keys %{$fields}) { $bug_fields_copy->{$f} = $fields->{$f}->{$val}->{value}; my $expected_faultstring = $fields->{$f}->{$val}->{faultstring}; - my $fail_call = xmlrpc_call_fail($rpc, 'Bug.create', $bug_fields_copy, + my $fail_call = $rpc->bz_call_fail('Bug.create', $bug_fields_copy, $expected_faultstring, "Specifying $val $f fails"); } } @@ -159,13 +159,13 @@ foreach my $f (sort keys %{$fields}) { # after the loop ends all the $bug_fields value will be set to valid # this is done by the sort so call create bug with the valid $bug_fields # to run the test for the successful creation of the bug -my $success_create = xmlrpc_call_success($rpc, 'Bug.create', $bug_fields); +my $success_create = $rpc->bz_call_success('Bug.create', $bug_fields); my $bug_id = $success_create->result->{id}; cmp_ok($bug_id, 'gt', 0, "Created new bug with id " . $success_create->result->{id}); # Make sure that the bug that we created has the field values we specified. -my $bug_result = xmlrpc_call_success($rpc, 'Bug.get', { ids => [$bug_id] }); +my $bug_result = $rpc->bz_call_success('Bug.get', { ids => [$bug_id] }); my $bug = $bug_result->result->{bugs}->[0]; isa_ok($bug, 'HASH', "Bug $bug_id"); # We have to limit the fields checked because Bug.get only returns certain @@ -176,4 +176,4 @@ foreach my $field (qw(assigned_to component priority product severity is($bug->{$field}, $bug_fields->{$field}, "$field has the right value"); }; -xmlrpc_call_success($rpc, 'User.logout'); +$rpc->bz_call_success('User.logout'); diff --git a/t/webservice_bug_get_bugs.t b/t/webservice_bug_get_bugs.t index 198f95f..823fd34 100644 --- a/t/webservice_bug_get_bugs.t +++ b/t/webservice_bug_get_bugs.t @@ -28,5 +28,5 @@ sub post_success { } } -xmlrpc_run_tests(rpc => $rpc, config => $config, tests => STANDARD_BUG_TESTS, +$rpc->bz_run_tests(tests => STANDARD_BUG_TESTS, method => 'Bug.get', post_success => \&post_success); diff --git a/t/webservice_bug_history.t b/t/webservice_bug_history.t index 4dd068a..ebc3670 100644 --- a/t/webservice_bug_history.t +++ b/t/webservice_bug_history.t @@ -16,5 +16,5 @@ sub post_success { isa_ok($call->result->{bugs}->[0]->{history}, 'ARRAY', "Bug's history"); } -xmlrpc_run_tests(rpc => $rpc, config => $config, tests => STANDARD_BUG_TESTS, +$rpc->bz_run_tests(tests => STANDARD_BUG_TESTS, method => 'Bug.history', post_success => \&post_success); diff --git a/t/webservice_bug_legal_values.t b/t/webservice_bug_legal_values.t index fbd041a..711cc66 100644 --- a/t/webservice_bug_legal_values.t +++ b/t/webservice_bug_legal_values.t @@ -17,7 +17,7 @@ use constant GLOBAL_FIELDS => use constant PRODUCT_FIELDS => qw(version target_milestone component); -my $products = xmlrpc_get_product_ids($rpc, $config); +my $products = $rpc->bz_get_products(); my $public_product = $products->{'Another Product'}; my $private_product = $products->{'QA-Selenium-TEST'}; @@ -87,5 +87,5 @@ sub post_success { 'Got one or more values'); } -xmlrpc_run_tests(rpc => $rpc, config => $config, tests => \@all_tests, +$rpc->bz_run_tests(tests => \@all_tests, method => 'Bug.legal_values', post_success => \&post_success); diff --git a/t/webservice_bug_search.t b/t/webservice_bug_search.t index ff821a2..a3aada0 100644 --- a/t/webservice_bug_search.t +++ b/t/webservice_bug_search.t @@ -36,7 +36,7 @@ my @create_bugs = ( test => 'Create a private bug' }, ); -xmlrpc_run_tests(rpc => $rpc, config => $config, tests => \@create_bugs, +$rpc->bz_run_tests(tests => \@create_bugs, method => 'Bug.create'); my @tests; @@ -161,5 +161,5 @@ sub post_success { } } -xmlrpc_run_tests(rpc => $rpc, config => $config, tests => \@tests, +$rpc->bz_run_tests(tests => \@tests, method => 'Bug.search', post_success => \&post_success); diff --git a/t/webservice_bug_update_see_also.t b/t/webservice_bug_update_see_also.t index e509707..789d549 100644 --- a/t/webservice_bug_update_see_also.t +++ b/t/webservice_bug_update_see_also.t @@ -65,5 +65,5 @@ sub post_success { isa_ok($call->result->{changes}, 'HASH', "Changes"); } -xmlrpc_run_tests(rpc => $rpc, config => $config, tests => \@tests, +$rpc->bz_run_tests(tests => \@tests, method => 'Bug.update_see_also', post_success => \&post_success); diff --git a/t/webservice_bugzilla.t b/t/webservice_bugzilla.t index 7d626f4..ffeb68a 100644 --- a/t/webservice_bugzilla.t +++ b/t/webservice_bugzilla.t @@ -11,20 +11,20 @@ my ($rpc, $config) = get_xmlrpc_client(); use constant DATETIME_REGEX => qr/^\d{8}T\d\d:\d\d:\d\d$/; -my $vers_call = xmlrpc_call_success($rpc, 'Bugzilla.version'); +my $vers_call = $rpc->bz_call_success('Bugzilla.version'); my $version = $vers_call->result->{version}; ok($version, "Bugzilla.version returns $version"); -my $tz_call = xmlrpc_call_success($rpc, 'Bugzilla.timezone'); +my $tz_call = $rpc->bz_call_success('Bugzilla.timezone'); my $tz = $tz_call->result->{timezone}; ok($tz, "Bugzilla.timezone retuns $tz"); -my $ext_call = xmlrpc_call_success($rpc, 'Bugzilla.extensions'); +my $ext_call = $rpc->bz_call_success('Bugzilla.extensions'); my $extensions = $ext_call->result->{extensions}; isa_ok($extensions, 'HASH', 'extensions'); is(scalar keys %$extensions, 0, 'No extensions returned'); -my $time_call = xmlrpc_call_success($rpc, 'Bugzilla.time'); +my $time_call = $rpc->bz_call_success('Bugzilla.time'); my $time_result = $time_call->result; foreach my $type (qw(db_time web_time web_time_utc)) { cmp_ok($time_result->{$type}, '=~', DATETIME_REGEX, diff --git a/t/webservice_product.t b/t/webservice_product.t index 38e7597..6130ce5 100644 --- a/t/webservice_product.t +++ b/t/webservice_product.t @@ -13,7 +13,7 @@ use Test::More tests => 50; use QA::Util; my ($rpc, $config) = get_xmlrpc_client(); -my $products = xmlrpc_get_product_ids($rpc, $config); +my $products = $rpc->bz_get_products(); my $public = $products->{'Another Product'}; my $private = $products->{'QA-Selenium-TEST'}; my $no_entry = $products->{'QA Entry Only'}; @@ -53,11 +53,10 @@ foreach my $user (keys %$tests) { my $not_enterable = $tests->{$user}->{not_enterable}; my $not_accessible = $tests->{$user}->{not_accessible}; - xmlrpc_log_in($rpc, $config, $user) if $user; + $rpc->bz_log_in($user) if $user; $user ||= "Logged-out user"; - my $select_call = xmlrpc_call_success($rpc, - 'Product.get_selectable_products'); + my $select_call = $rpc->bz_call_success('Product.get_selectable_products'); my $select_ids = $select_call->result->{ids}; foreach my $id (@selectable) { ok(grep($_ == $id, @$select_ids), "$user can select " . $id_map{$id}); @@ -67,8 +66,7 @@ foreach my $user (keys %$tests) { "$user cannot select " . $id_map{$not_selectable}); } - my $enter_call = xmlrpc_call_success($rpc, - 'Product.get_enterable_products'); + my $enter_call = $rpc->bz_call_success('Product.get_enterable_products'); my $enter_ids = $enter_call->result->{ids}; foreach my $id (@enterable) { ok(grep($_ == $id, @$enter_ids), "$user can enter " . $id_map{$id}); @@ -78,20 +76,19 @@ foreach my $user (keys %$tests) { "$user cannot enter " . $id_map{$not_enterable}); } - my $access_call = xmlrpc_call_success($rpc, - 'Product.get_accessible_products'); - my $get_call = xmlrpc_call_success($rpc, 'Product.get', - { ids => \@accessible }); + my $access_call = $rpc->bz_call_success('Product.get_accessible_products'); + my $get_call = $rpc->bz_call_success('Product.get', + { ids => \@accessible }); my $products = $get_call->result->{products}; my $expected_count = scalar @accessible; cmp_ok(scalar @$products, '==', $expected_count, "Product.get gets all $expected_count accessible products for $user."); if ($not_accessible) { - my $not_accessible = xmlrpc_call_success($rpc, 'Product.get', - { ids => [$not_accessible] }); + my $not_accessible = $rpc->bz_call_success('Product.get', + { ids => [$not_accessible] }); ok(!scalar @{ $not_accessible->result->{products} }, "$user gets 0 products when asking for " . $id_map{$not_accessible}); } - xmlrpc_call_success($rpc, 'User.logout') if $user ne "Logged-out user"; + $rpc->bz_call_success('User.logout') if $user ne "Logged-out user"; } diff --git a/t/webservice_user_create.t b/t/webservice_user_create.t index 16a5b79..fbfe1d4 100644 --- a/t/webservice_user_create.t +++ b/t/webservice_user_create.t @@ -94,5 +94,5 @@ sub post_success { ok($call->result->{id}, "Got a non-zero user id"); } -xmlrpc_run_tests(rpc => $rpc, config => $config, tests => \@tests, +$rpc->bz_run_tests(tests => \@tests, method => 'User.create', post_success => \&post_success); diff --git a/t/webservice_user_get.t b/t/webservice_user_get.t index fd89a10..239bf44 100644 --- a/t/webservice_user_get.t +++ b/t/webservice_user_get.t @@ -72,40 +72,40 @@ sub post_success { } } -xmlrpc_run_tests(rpc => $rpc, config => $config, tests => \@tests, +$rpc->bz_run_tests(tests => \@tests, method => 'User.get', post_success => \&post_success); ############################# # Include and Exclude Tests # ############################# -xmlrpc_call_success($rpc, 'User.logout'); +$rpc->bz_call_success('User.logout'); -my $include_nothing = xmlrpc_call_success($rpc, 'User.get', { +my $include_nothing = $rpc->bz_call_success('User.get', { names => [$get_user], include_fields => ['asdfasdfsdf'], }, 'User.get including only invalid fields'); is(scalar keys %{ $include_nothing->result->{users}->[0] }, 0, 'No fields returned for user'); -my $include_one = xmlrpc_call_success($rpc, 'User.get', { +my $include_one = $rpc->bz_call_success('User.get', { names => [$get_user], include_fields => ['id'], }, 'User.get including only id'); is(scalar keys %{ $include_one->result->{users}->[0] }, 1, 'Only one field returned for user'); -my $exclude_none = xmlrpc_call_success($rpc, 'User.get', { +my $exclude_none = $rpc->bz_call_success('User.get', { names => [$get_user], exclude_fields => ['asdfasdfsdf'], }, 'User.get excluding only invalid fields'); is(scalar keys %{ $exclude_none->result->{users}->[0] }, 3, 'All fields returned for user'); -my $exclude_one = xmlrpc_call_success($rpc, 'User.get', { +my $exclude_one = $rpc->bz_call_success('User.get', { names => [$get_user], exclude_fields => ['id'], }, 'User.get excluding id'); is(scalar keys %{ $exclude_one->result->{users}->[0] }, 2, 'Only two fields returned for user'); -my $override = xmlrpc_call_success($rpc, 'User.get', { +my $override = $rpc->bz_call_success('User.get', { names => [$get_user], include_fields => ['id', 'name'], exclude_fields => ['id'] }, 'User.get with both include and exclude'); diff --git a/t/webservice_user_login_logout.t b/t/webservice_user_login_logout.t index ab635dc..890a784 100644 --- a/t/webservice_user_login_logout.t +++ b/t/webservice_user_login_logout.t @@ -51,11 +51,10 @@ my @tests = ( for my $t (@tests) { if ($t->{user}) { - xmlrpc_log_in($rpc, $config, $t->{user}); - xmlrpc_call_success($rpc, 'User.logout'); + $rpc->bz_log_in($t->{user}); + $rpc->bz_call_success('User.logout'); } else { - xmlrpc_call_fail($rpc, 'User.login', $t->{args}, $t->{error}, - $t->{test}); + $rpc->bz_call_fail('User.login', $t->{args}, $t->{error}, $t->{test}); } } diff --git a/t/webservice_user_offer_account_by_email.t b/t/webservice_user_offer_account_by_email.t index a304a27..268cfd9 100644 --- a/t/webservice_user_offer_account_by_email.t +++ b/t/webservice_user_offer_account_by_email.t @@ -40,5 +40,5 @@ my @tests = ( }, ); -xmlrpc_run_tests(rpc => $rpc, config => $config, tests => \@tests, +$rpc->bz_run_tests(tests => \@tests, method => 'User.offer_account_by_email'); From 7e53a6f4f93863c5140632c480c6b2f81c29a219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Wed, 20 Oct 2010 18:49:04 +0200 Subject: [PATCH 09/14] Bug 3200: webservice_bug_add_comment.t passes isprivate to Bug.add_comment() instead of private --- t/lib/QA/RPC.pm | 2 +- t/webservice_bug_add_comment.t | 32 ++++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/t/lib/QA/RPC.pm b/t/lib/QA/RPC.pm index 8fc0cd7..1247dd6 100644 --- a/t/lib/QA/RPC.pm +++ b/t/lib/QA/RPC.pm @@ -94,7 +94,7 @@ sub bz_run_tests { else { my $call = $self->bz_call_success($method, $t->{args}, $t->{test}); if ($call->result && $post_success) { - $post_success->($call, $t); + $post_success->($call, $t, $self); } } } diff --git a/t/webservice_bug_add_comment.t b/t/webservice_bug_add_comment.t index 8795ff8..b64224a 100644 --- a/t/webservice_bug_add_comment.t +++ b/t/webservice_bug_add_comment.t @@ -6,7 +6,7 @@ use strict; use warnings; use lib qw(lib); use QA::Util; -use Test::More tests => 50; +use Test::More tests => 54; my ($rpc, $config) = get_xmlrpc_client(); use constant INVALID_BUG_ID => -1; @@ -119,6 +119,13 @@ my @tests = ( { user => 'QA_Selenium_TEST', args => { id => 'private_bug', comment => TEST_COMMENT }, test => 'Privileged user can add a comment to a private bug', + check_privacy => 1, + }, + { user => 'QA_Selenium_TEST', + args => { id => 'public_bug', comment => TEST_COMMENT, + private => 1 }, + test => 'Insidergroup user can add a private comment', + check_privacy => 1, }, { user => 'admin', args => { id => 'public_bug', comment => TEST_COMMENT, @@ -126,12 +133,21 @@ my @tests = ( test => 'Timetracking user can add work_time to a bug', }, # XXX Need to verify that the comment added actually has work_time. - { user => 'admin', - args => { id => 'public_bug', comment => TEST_COMMENT, - isprivate => 1 }, - test => 'Insidergroup user can add a private comment', - }, - # XXX Need to verify that the comment added was actually private. ); -$rpc->bz_run_tests(tests => \@tests, method => 'Bug.add_comment'); +$rpc->bz_run_tests(tests => \@tests, method => 'Bug.add_comment', + post_success => \&post_success); + +sub post_success { + my ($call, $t, $rpc) = @_; + return unless $t->{check_privacy}; + + my $comment_id = $call->result->{id}; + my $result = $rpc->bz_call_success('Bug.comments', {comment_ids => [$comment_id]}); + if ($t->{args}->{private}) { + ok($result->result->{comments}->{$comment_id}->{is_private}, "Comment $comment_id is private"); + } + else { + ok(!$result->result->{comments}->{$comment_id}->{is_private}, "Comment $comment_id is NOT private"); + } +} From 636359a7fc7bc05b604fec178fe2ff7a61a30ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Sat, 5 Feb 2011 20:52:56 +0100 Subject: [PATCH 10/14] Test for bug 38922: Default (Initial) CC list for each component --- t/test_edit_products_properties.t | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/t/test_edit_products_properties.t b/t/test_edit_products_properties.t index 6f8f9d2..7184595 100644 --- a/t/test_edit_products_properties.t +++ b/t/test_edit_products_properties.t @@ -10,6 +10,7 @@ my ($sel, $config) = get_selenium(); my $admin_user_login = $config->{admin_user_login}; my $unprivileged_user_login = $config->{unprivileged_user_login}; +my $permanent_user = $config->{permanent_user}; log_in($sel, $config, 'admin'); set_parameters($sel, { "Bug Fields" => {"useclassification-off" => undef, @@ -73,6 +74,7 @@ $sel->title_is("Add component to the Kill me! product"); $sel->type_ok("component", "first comp"); $sel->type_ok("description", "comp 2"); $sel->type_ok("initialowner", $admin_user_login); +$sel->type_ok("initialcc", $permanent_user); $sel->click_ok("create"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Component Already Exists"); @@ -149,6 +151,21 @@ $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_like(qr/^Bug \d+ Submitted/); my $bug1_id = $sel->get_value("//input[\@name='id' and \@type='hidden']"); +my @cc_list = $sel->get_select_options("cc"); +ok(grep($_ eq $unprivileged_user_login, @cc_list), "$unprivileged_user_login correctly added to the CC list"); +ok(!grep($_ eq $permanent_user, @cc_list), "$permanent_user not in the CC list for 'first comp' by default"); + +# File a second bug, and make sure users in the default CC list are added. +file_bug_in_product($sel, "Kill me!"); +$sel->select_ok("version", "label=0.1a"); +$sel->select_ok("component", "label=second comp"); +$sel->type_ok("short_desc", "check default CC list"); +$sel->type_ok("comment", "is the CC list populated correctly?"); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug \d+ Submitted/); +@cc_list = $sel->get_select_options("cc"); +ok(grep($_ eq $permanent_user, @cc_list), "$permanent_user in the CC list for 'second comp' by default"); # Edit product properties and set votes_to_confirm to 0, which has # the side-effect to confirm the UNCONFIRMED bug above. @@ -185,6 +202,11 @@ $sel->select_ok("component", "label=second comp"); $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Bug $bug1_id processed"); +$sel->click_ok("link=bug $bug1_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/Bug $bug1_id /); +@cc_list = $sel->get_select_options("cc"); +ok(grep($_ eq $permanent_user, @cc_list), "User $permanent_user automatically added to the CC list"); # Delete the milestone the bug belongs to. This should retarget the bug # to the default milestone. @@ -217,7 +239,7 @@ $sel->click_ok("//a[contains(\@href, 'editversions.cgi?action=del&product=Kill%2 $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Delete Version of Product 'Kill me nicely'"); $text = trim($sel->get_text("bugzilla-body")); -ok($text =~ /Sorry, there is 1 bug outstanding for this version/, "Rejecting version deletion"); +ok($text =~ /Sorry, there are 2 bugs outstanding for this version/, "Rejecting version deletion"); $sel->go_back_ok(); $sel->wait_for_page_to_load_ok(WAIT_TIME); @@ -244,7 +266,7 @@ $sel->click_ok("//a[contains(\@href, 'editcomponents.cgi?action=del&product=Kill $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Delete component 'second comp' from 'Kill me nicely' product"); $text = trim($sel->get_text("bugzilla-body")); -ok($text =~ /There is 1 bug entered for this component/, "Warning displayed"); +ok($text =~ /There are 2 bugs entered for this component/, "Warning displayed"); ok($text =~ /Do you really want to delete this component\?/, "Requesting confirmation"); $sel->click_ok("delete"); $sel->wait_for_page_to_load_ok(WAIT_TIME); From 17127b96ae970ba0e9985ee44fa810627e9c1d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Sat, 5 Feb 2011 22:27:38 +0100 Subject: [PATCH 11/14] Test for bug 44595: interface for administrator to delete attachments --- t/test_private_attachments.t | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/t/test_private_attachments.t b/t/test_private_attachments.t index be9daf0..5015de3 100644 --- a/t/test_private_attachments.t +++ b/t/test_private_attachments.t @@ -11,11 +11,12 @@ use QA::Util; my ($sel, $config) = get_selenium(CHROME_MODE); # set the insidergroup parameter to the admin group, and make sure -# we can view attachments. +# we can view and delete attachments. log_in($sel, $config, 'admin'); set_parameters($sel, { "Group Security" => {"insidergroup" => {type => "select", value => "admin"}}, - "Attachments" => {"allow_attachment_display-on" => undef} + "Attachments" => {"allow_attachment_display-on" => undef, + "allow_attachment_deletion-on" => undef} }); # First create a new bug with a private attachment. @@ -140,7 +141,7 @@ $sel->title_like(qr/^Bug $bug1_id/); ok(!$sel->is_text_present("private attachment, v1"), "Private attachment not visible to logged out users"); ok(!$sel->is_text_present("My patch, which I should see, always ("), "Private attachment not visible to logged out users"); $sel->is_text_present_ok("This is my patch!"); -ok(!$sel->is_text_present("Making the powerless user's patch private"), "Private attachment not visible to logged out users"); +ok(!$sel->is_text_present("Making the powerless user's patch private"), "Private comment not visible to logged out users"); # A powerless user can only see private attachments he owns. @@ -157,7 +158,34 @@ $sel->title_is(""); $sel->go_back_ok(); $sel->wait_for_page_to_load_ok(WAIT_TIME); logout($sel); + +# Admins can delete attachments. + log_in($sel, $config, 'admin'); +$sel->type_ok("quicksearch_top", "$bug1_id"); +$sel->click_ok("find_top"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug1_id/); +$sel->click_ok('//a[@href="attachment.cgi?id=' . $attachment2_id . '&action=edit"]'); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Attachment $attachment2_id Details for Bug $bug1_id"); +$sel->click_ok("link=Delete"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Delete Attachment $attachment2_id of Bug $bug1_id"); +$sel->is_text_present_ok("Do you really want to delete this attachment?"); +$sel->type_ok("reason", "deleted by Selenium"); +$sel->click_ok("delete"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Changes Submitted to Attachment $attachment2_id of Bug $bug1_id"); +$sel->click_ok("link=bug $bug1_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug1_id/); +$sel->is_text_present_ok("deleted by Selenium"); +$sel->click_ok("link=attachment $attachment2_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Attachment Removed"); +$sel->is_text_present_ok("The attachment you are attempting to access has been removed"); + set_parameters($sel, { "Group Security" => {"insidergroup" => { type => "select", value => "QA-Selenium-TEST" }}, From d0545d3d650d400ab079a49c49a1f6e8a382b990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Sun, 6 Feb 2011 02:59:25 +0100 Subject: [PATCH 12/14] Test for bug 101179: Customised statuses and workflow and bug 94534: Customised resolutions --- t/test_custom_fields.t | 150 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) diff --git a/t/test_custom_fields.t b/t/test_custom_fields.t index c0bc424..affc002 100644 --- a/t/test_custom_fields.t +++ b/t/test_custom_fields.t @@ -39,6 +39,7 @@ $sel->click_ok("create"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Custom Field Created"); $sel->is_text_present_ok("The new custom field \'cf_qa_freetext_$bug1_id\' has been successfully created."); + $sel->click_ok("link=Add a new custom field"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Add a new Custom Field"); @@ -64,6 +65,7 @@ $sel->title_is("Edit the Custom Field \'cf_qa_list_$bug1_id\' (List$bug1_id)"); $sel->click_ok("link=Edit legal values for this field"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Select value for the \'List$bug1_id\' (cf_qa_list_$bug1_id) field"); + $sel->click_ok("link=Add"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Add Value for the \'List$bug1_id\' (cf_qa_list_$bug1_id) field"); @@ -73,6 +75,7 @@ $sel->click_ok("create"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("New Field Value Created"); $sel->is_text_present_ok("The value have fun? has been added as a valid choice for the List$bug1_id (cf_qa_list_$bug1_id) field."); + $sel->click_ok("link=Add"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Add Value for the \'List$bug1_id\' (cf_qa_list_$bug1_id) field"); @@ -83,6 +86,65 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("New Field Value Created"); $sel->is_text_present_ok("The value storage has been added as a valid choice for the List$bug1_id (cf_qa_list_$bug1_id) field."); +# Also create a new bug status and a new resolution. + +go_to_admin($sel); +$sel->click_ok("link=Field Values"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit values for which field?"); +$sel->click_ok("link=Resolution"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Select value for the 'Resolution' (resolution) field"); +$sel->click_ok("link=Add"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Add Value for the 'Resolution' (resolution) field"); +$sel->type_ok("value", "UPSTREAM"); +$sel->type_ok("sortkey", 450); +$sel->click_ok("create"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("New Field Value Created"); + +go_to_admin($sel); +$sel->click_ok("link=Field Values"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit values for which field?"); +$sel->click_ok("link=Status"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Select value for the 'Status' (bug_status) field"); +$sel->click_ok("link=Add"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Add Value for the 'Status' (bug_status) field"); +$sel->type_ok("value", "SUSPENDED"); +$sel->type_ok("sortkey", 250); +$sel->click_ok("open_status"); +$sel->click_ok("create"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("New Field Value Created"); + +$sel->click_ok("link=Add"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Add Value for the 'Status' (bug_status) field"); +$sel->type_ok("value", "IN_QA"); +$sel->type_ok("sortkey", 550); +$sel->click_ok("closed_status"); +$sel->click_ok("create"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("New Field Value Created"); + +$sel->click_ok("link=status workflow page"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit Workflow"); +$sel->click_ok('//td[@title="From UNCONFIRMED to SUSPENDED"]//input[@type="checkbox"]'); +$sel->click_ok('//td[@title="From NEW to SUSPENDED"]//input[@type="checkbox"]'); +$sel->click_ok('//td[@title="From SUSPENDED to NEW"]//input[@type="checkbox"]'); +$sel->click_ok('//td[@title="From SUSPENDED to ASSIGNED"]//input[@type="checkbox"]'); +$sel->click_ok('//td[@title="From RESOLVED to IN_QA"]//input[@type="checkbox"]'); +$sel->click_ok('//td[@title="From IN_QA to VERIFIED"]//input[@type="checkbox"]'); +$sel->click_ok('//td[@title="From IN_QA to NEW"]//input[@type="checkbox"]'); +$sel->click_ok('//input[@value="Commit Changes"]'); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit Workflow"); + # Create new bug to test custom fields in bug creation page file_bug_in_product($sel, 'TestProduct'); @@ -99,26 +161,39 @@ my $bug2_id = $sel->get_value('//input[@name="id" and @type="hidden"]'); $sel->type_ok("cf_qa_freetext_$bug1_id", "bonsai"); $sel->selected_label_is("cf_qa_list_$bug1_id", "---"); +$sel->select_ok("bug_status", "label=SUSPENDED"); $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Bug $bug2_id processed"); + $sel->type_ok("quicksearch_top", $bug1_id); $sel->click_ok("find_top"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_like(qr/^Bug $bug1_id/); $sel->type_ok("cf_qa_freetext_$bug1_id", "dumbo"); $sel->select_ok("cf_qa_list_$bug1_id", "label=storage"); +$sel->select_ok("bug_status", "RESOLVED"); +$sel->select_ok("resolution", "UPSTREAM"); $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Bug $bug1_id processed"); $sel->click_ok("link=bug $bug1_id"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_like(qr/^Bug $bug1_id/); +$sel->select_ok("bug_status", "IN_QA"); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug $bug1_id processed"); +$sel->click_ok("link=bug $bug1_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug1_id/); + $sel->click_ok("link=Format For Printing"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Full Text Bug Listing"); $sel->is_text_present_ok("Freetext$bug1_id: dumbo"); $sel->is_text_present_ok("List$bug1_id: storage"); +$sel->is_text_present_ok("Status: IN_QA UPSTREAM"); $sel->type_ok("quicksearch_top", $bug2_id); $sel->click_ok("find_top"); $sel->wait_for_page_to_load_ok(WAIT_TIME); @@ -134,6 +209,7 @@ open_advanced_search_page($sel); $sel->remove_all_selections_ok("product"); $sel->add_selection_ok("product", "TestProduct"); $sel->remove_all_selections("bug_status"); +$sel->remove_all_selections("resolution"); $sel->select_ok("field0-0-0", "label=List$bug1_id"); $sel->select_ok("type0-0-0", "label=is equal to"); $sel->type_ok("value0-0-0", "storage"); @@ -250,4 +326,78 @@ $sel->value_is("obsolete", "on"); $sel->click_ok("edit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Custom Field Updated"); + +# Trying to delete a bug status which is in use is forbidden. + +go_to_admin($sel); +$sel->click_ok("link=Field Values"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit values for which field?"); +$sel->click_ok("link=Status"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Select value for the 'Status' (bug_status) field"); +$sel->click_ok('//a[@href="editvalues.cgi?action=del&field=bug_status&value=SUSPENDED"]'); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Delete Value 'SUSPENDED' from the 'Status' (bug_status) field"); +$sel->is_text_present_ok("Sorry, but the 'SUSPENDED' value cannot be deleted"); + +$sel->type_ok("quicksearch_top", $bug2_id); +$sel->click_ok("find_top"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug2_id/); +$sel->select_ok("bug_status", "NEW"); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug $bug2_id processed"); + +$sel->type_ok("quicksearch_top", $bug1_id); +$sel->click_ok("find_top"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^Bug $bug1_id/); +$sel->select_ok("bug_status", "VERIFIED"); +$sel->select_ok("resolution", "INVALID"); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug $bug1_id processed"); + +# Unused values can be deleted. + +go_to_admin($sel); +$sel->click_ok("link=Field Values"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit values for which field?"); +$sel->click_ok("link=Status"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Select value for the 'Status' (bug_status) field"); +$sel->click_ok('//a[@href="editvalues.cgi?action=del&field=bug_status&value=SUSPENDED"]'); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Delete Value 'SUSPENDED' from the 'Status' (bug_status) field"); +$sel->click_ok("delete"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Field Value Deleted"); +$sel->is_text_present_ok("The value SUSPENDED of the Status (bug_status) field has been deleted"); + +$sel->click_ok('//a[@href="editvalues.cgi?action=del&field=bug_status&value=IN_QA"]'); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Delete Value 'IN_QA' from the 'Status' (bug_status) field"); +$sel->click_ok("delete"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Field Value Deleted"); +$sel->is_text_present_ok("The value IN_QA of the Status (bug_status) field has been deleted"); + +go_to_admin($sel); +$sel->click_ok("link=Field Values"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit values for which field?"); +$sel->click_ok("link=Resolution"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Select value for the 'Resolution' (resolution) field"); +$sel->click_ok('//a[@href="editvalues.cgi?action=del&field=resolution&value=UPSTREAM"]'); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Delete Value 'UPSTREAM' from the 'Resolution' (resolution) field"); +$sel->click_ok("delete"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Field Value Deleted"); +$sel->is_text_present_ok("The value UPSTREAM of the Resolution (resolution) field has been deleted"); + logout($sel); From 40b107c30d98a42d353487d96ea7ef06248a2ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Fri, 8 Jul 2011 14:21:17 +0200 Subject: [PATCH 13/14] Bug 670116: flagtypes.cc_list accepts NULL values, but the code doesn't handle it correctly --- config/generate_test_data.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/generate_test_data.pl b/config/generate_test_data.pl index 5a013ca..515e5bf 100644 --- a/config/generate_test_data.pl +++ b/config/generate_test_data.pl @@ -401,7 +401,7 @@ BEGIN my @flagtypes = ( {name => 'spec_multi_flag', desc => 'Specifically requestable and multiplicable bug flag', is_requestable => 1, is_requesteeble => 1, is_multiplicable => 1, grant_group => 'editbugs', - target_type => 'b', inclusions => ['Another Product:c1']}, + target_type => 'b', cc_list => '', inclusions => ['Another Product:c1']}, ); print "creating flag types...\n"; From ccf7b514122fb71fa7c115ad780924f00c2a5dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Sat, 3 Dec 2011 00:50:21 +0100 Subject: [PATCH 14/14] Remove useless escaping characters --- t/test_custom_fields.t | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/t/test_custom_fields.t b/t/test_custom_fields.t index affc002..19c2ad6 100644 --- a/t/test_custom_fields.t +++ b/t/test_custom_fields.t @@ -38,7 +38,7 @@ $sel->value_is("obsolete", "off"); $sel->click_ok("create"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Custom Field Created"); -$sel->is_text_present_ok("The new custom field \'cf_qa_freetext_$bug1_id\' has been successfully created."); +$sel->is_text_present_ok("The new custom field 'cf_qa_freetext_$bug1_id' has been successfully created."); $sel->click_ok("link=Add a new custom field"); $sel->wait_for_page_to_load_ok(WAIT_TIME); @@ -55,20 +55,20 @@ $sel->value_is("obsolete", "off"); $sel->click_ok("create"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Custom Field Created"); -$sel->is_text_present_ok("The new custom field \'cf_qa_list_$bug1_id\' has been successfully created."); +$sel->is_text_present_ok("The new custom field 'cf_qa_list_$bug1_id' has been successfully created."); # Add values to the custom fields. $sel->click_ok("link=cf_qa_list_$bug1_id"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->title_is("Edit the Custom Field \'cf_qa_list_$bug1_id\' (List$bug1_id)"); +$sel->title_is("Edit the Custom Field 'cf_qa_list_$bug1_id' (List$bug1_id)"); $sel->click_ok("link=Edit legal values for this field"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->title_is("Select value for the \'List$bug1_id\' (cf_qa_list_$bug1_id) field"); +$sel->title_is("Select value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field"); $sel->click_ok("link=Add"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->title_is("Add Value for the \'List$bug1_id\' (cf_qa_list_$bug1_id) field"); +$sel->title_is("Add Value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field"); $sel->type_ok("value", "have fun?"); $sel->type_ok("sortkey", "805"); $sel->click_ok("create"); @@ -78,7 +78,7 @@ $sel->is_text_present_ok("The value have fun? has been added as a valid choice f $sel->click_ok("link=Add"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->title_is("Add Value for the \'List$bug1_id\' (cf_qa_list_$bug1_id) field"); +$sel->title_is("Add Value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field"); $sel->type_ok("value", "storage"); $sel->type_ok("sortkey", "49"); $sel->click_ok("create"); @@ -249,10 +249,10 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Edit values for which field?"); $sel->click_ok("link=List$bug1_id"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->title_is("Select value for the \'List$bug1_id\' (cf_qa_list_$bug1_id) field"); +$sel->title_is("Select value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field"); $sel->click_ok("//a[contains(\@href, 'editvalues.cgi?action=del&field=cf_qa_list_$bug1_id&value=have%20fun%3F')]"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->title_is("Delete Value \'have fun?\' from the \'List$bug1_id\' (cf_qa_list_$bug1_id) field"); +$sel->title_is("Delete Value 'have fun?' from the 'List$bug1_id' (cf_qa_list_$bug1_id) field"); $sel->is_text_present_ok("Do you really want to delete this value?"); $sel->click_ok("delete"); $sel->wait_for_page_to_load_ok(WAIT_TIME); @@ -262,7 +262,7 @@ $sel->title_is("Field Value Deleted"); $sel->click_ok("//a[contains(\@href, 'editvalues.cgi?action=del&field=cf_qa_list_$bug1_id&value=storage')]"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->title_is("Delete Value \'storage\' from the \'List$bug1_id\' (cf_qa_list_$bug1_id) field"); +$sel->title_is("Delete Value 'storage' from the 'List$bug1_id' (cf_qa_list_$bug1_id) field"); $sel->is_text_present_ok("There is 1 bug with this field value"); # Mark the