From: Perl Tidy Date: Wed, 5 Dec 2018 15:48:51 +0000 (-0500) Subject: no bug - reformat tests too X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0654918e48047c9283ac8921302b3f5a8d41b683;p=thirdparty%2Fbugzilla.git no bug - reformat tests too --- diff --git a/extensions/BMO/t/bounty_attachment.t b/extensions/BMO/t/bounty_attachment.t index 6e596eeba..61552c074 100644 --- a/extensions/BMO/t/bounty_attachment.t +++ b/extensions/BMO/t/bounty_attachment.t @@ -13,46 +13,69 @@ use Test::More; use Bugzilla; BEGIN { Bugzilla->extensions } -my $class = 'Bugzilla::Extension::BMO'; +my $class = 'Bugzilla::Extension::BMO'; my $parse = $class->can('parse_bounty_attachment_description'); my $format = $class->can('format_bounty_attachment_description'); ok($parse, "got the function"); my $bughunter = $parse->('bughunter@hacker.org, , 2014-06-25, , ,false'); -is_deeply({ reporter_email => 'bughunter@hacker.org', - amount_paid => '', - reported_date => '2014-06-25', - fixed_date => '', - awarded_date => '', - publish => 0, - credit => []}, $bughunter); - -my $hfli = $parse->('hfli@fortinet.com, 1000, 2010-07-16, 2010-08-04, 2011-06-15, true, Fortiguard Labs'); -is_deeply({ reporter_email => 'hfli@fortinet.com', - amount_paid => '1000', - reported_date => '2010-07-16', - fixed_date => '2010-08-04', - awarded_date => '2011-06-15', - publish => 1, - credit => ['Fortiguard Labs']}, $hfli); - -is('batman@justiceleague.america,1000,2015-01-01,2015-02-02,2015-03-03,true,JLA,Wayne Industries,Test', - $format->({ reporter_email => 'batman@justiceleague.america', - amount_paid => 1000, - reported_date => '2015-01-01', - fixed_date => '2015-02-02', - awarded_date => '2015-03-03', - publish => 1, - credit => ['JLA', 'Wayne Industries', 'Test'] })); - -my $dylan = $parse->('dylan@hardison.net,2,2014-09-23,2014-09-24,2014-09-25,true,Foo bar,Bork,'); -is_deeply({ reporter_email => 'dylan@hardison.net', - amount_paid => 2, - reported_date => '2014-09-23', - fixed_date => '2014-09-24', - awarded_date => '2014-09-25', - publish => 1, - credit => ['Foo bar', 'Bork']}, $dylan); +is_deeply( + { + reporter_email => 'bughunter@hacker.org', + amount_paid => '', + reported_date => '2014-06-25', + fixed_date => '', + awarded_date => '', + publish => 0, + credit => [] + }, + $bughunter +); + +my $hfli + = $parse->( + 'hfli@fortinet.com, 1000, 2010-07-16, 2010-08-04, 2011-06-15, true, Fortiguard Labs' + ); +is_deeply( + { + reporter_email => 'hfli@fortinet.com', + amount_paid => '1000', + reported_date => '2010-07-16', + fixed_date => '2010-08-04', + awarded_date => '2011-06-15', + publish => 1, + credit => ['Fortiguard Labs'] + }, + $hfli +); + +is( + 'batman@justiceleague.america,1000,2015-01-01,2015-02-02,2015-03-03,true,JLA,Wayne Industries,Test', + $format->({ + reporter_email => 'batman@justiceleague.america', + amount_paid => 1000, + reported_date => '2015-01-01', + fixed_date => '2015-02-02', + awarded_date => '2015-03-03', + publish => 1, + credit => ['JLA', 'Wayne Industries', 'Test'] + }) +); + +my $dylan = $parse->( + 'dylan@hardison.net,2,2014-09-23,2014-09-24,2014-09-25,true,Foo bar,Bork,'); +is_deeply( + { + reporter_email => 'dylan@hardison.net', + amount_paid => 2, + reported_date => '2014-09-23', + fixed_date => '2014-09-24', + awarded_date => '2014-09-25', + publish => 1, + credit => ['Foo bar', 'Bork'] + }, + $dylan +); done_testing; diff --git a/extensions/PhabBugz/t/basic.t b/extensions/PhabBugz/t/basic.t index 2f05496cd..161c58637 100644 --- a/extensions/PhabBugz/t/basic.t +++ b/extensions/PhabBugz/t/basic.t @@ -11,7 +11,7 @@ use 5.10.1; use lib qw( . lib local/lib/perl5 ); use Bugzilla; -BEGIN { Bugzilla->extensions }; +BEGIN { Bugzilla->extensions } use Test::More; use Test2::Tools::Mock; @@ -30,68 +30,65 @@ our @project_members; my $User = mock 'Bugzilla::Extension::PhabBugz::User' => ( - add_constructor => [ - 'fake_new' => 'hash', - ], - override => [ - 'match' => sub { [ mock() ] }, - ], + add_constructor => ['fake_new' => 'hash',], + override => ['match' => sub { [mock()] },], ); my $Feed = mock 'Bugzilla::Extension::PhabBugz::Feed' => ( - override => [ - get_group_members => sub { - return [ map { Bugzilla::Extension::PhabBugz::User->fake_new(%$_) } @group_members ]; - } - ] + override => [ + get_group_members => sub { + return [map { Bugzilla::Extension::PhabBugz::User->fake_new(%$_) } + @group_members]; + } + ] ); my $Project = mock 'Bugzilla::Extension::PhabBugz::Project' => ( - override_constructor => [ - new_from_query => 'ref_copy', - ], - override => [ - 'members' => sub { - return [ map { Bugzilla::Extension::PhabBugz::User->fake_new(%$_) } @project_members ]; - } - ] + override_constructor => [new_from_query => 'ref_copy',], + override => [ + 'members' => sub { + return [map { Bugzilla::Extension::PhabBugz::User->fake_new(%$_) } + @project_members]; + } + ] ); -local Bugzilla->params->{phabricator_enabled} = 1; -local Bugzilla->params->{phabricator_api_key} = 'FAKE-API-KEY'; +local Bugzilla->params->{phabricator_enabled} = 1; +local Bugzilla->params->{phabricator_api_key} = 'FAKE-API-KEY'; local Bugzilla->params->{phabricator_base_uri} = 'http://fake.fabricator.tld'; my $Bugzilla = mock 'Bugzilla' => ( - override => [ - 'dbh' => sub { mock() }, - 'user' => sub { Bugzilla::User->new({ name => 'phab-bot@bmo.tld' }) }, - ], + override => [ + 'dbh' => sub { mock() }, + 'user' => sub { Bugzilla::User->new({name => 'phab-bot@bmo.tld'}) }, + ], ); my $BugzillaGroup = mock 'Bugzilla::Group' => ( - add_constructor => [ - 'fake_new' => 'hash', - ], - override => [ - 'match' => sub { [ Bugzilla::Group->fake_new(id => 1, name => 'firefox-security' ) ] }, - ], + add_constructor => ['fake_new' => 'hash',], + override => [ + 'match' => + sub { [Bugzilla::Group->fake_new(id => 1, name => 'firefox-security')] }, + ], ); my $BugzillaUser = mock 'Bugzilla::User' => ( - add_constructor => [ - 'fake_new' => 'hash', - ], - override => [ - 'new' => sub { - my ($class, $hash) = @_; - if ($hash->{name} eq 'phab-bot@bmo.tld') { - return $class->fake_new( id => 8_675_309, login_name => 'phab-bot@bmo.tld', realname => 'Fake PhabBot' ); - } - else { - } - }, - 'match' => sub { [ mock() ] }, - ], + add_constructor => ['fake_new' => 'hash',], + override => [ + 'new' => sub { + my ($class, $hash) = @_; + if ($hash->{name} eq 'phab-bot@bmo.tld') { + return $class->fake_new( + id => 8_675_309, + login_name => 'phab-bot@bmo.tld', + realname => 'Fake PhabBot' + ); + } + else { + } + }, + 'match' => sub { [mock()] }, + ], ); @@ -99,78 +96,66 @@ my $feed = Bugzilla::Extension::PhabBugz::Feed->new; # Same members in both do { - my $UserAgent = mock 'Mojo::UserAgent' => ( - override => [ - 'post' => sub { - my ($self, $url, undef, $params) = @_; - my $data = decode_json($params->{params}); - is_deeply($data->{transactions}, [], 'no-op'); - return mock_useragent_tx('{}'); - }, - ], - ); - local @group_members = ( - { phid => 'foo' }, - ); - local @project_members = ( - { phid => 'foo' }, - ); - $feed->group_query; + my $UserAgent = mock 'Mojo::UserAgent' => ( + override => [ + 'post' => sub { + my ($self, $url, undef, $params) = @_; + my $data = decode_json($params->{params}); + is_deeply($data->{transactions}, [], 'no-op'); + return mock_useragent_tx('{}'); + }, + ], + ); + local @group_members = ({phid => 'foo'},); + local @project_members = ({phid => 'foo'},); + $feed->group_query; }; # Project has members not in group do { - my $UserAgent = mock 'Mojo::UserAgent' => ( - override => [ - 'post' => sub { - my ($self, $url, undef, $params) = @_; - my $data = decode_json($params->{params}); - my $expected = [ { type => 'members.remove', value => ['foo'] } ]; - is_deeply($data->{transactions}, $expected, 'remove foo'); - return mock_useragent_tx('{}'); - }, - ] - ); - local @group_members = (); - local @project_members = ( - { phid => 'foo' }, - ); - $feed->group_query; + my $UserAgent = mock 'Mojo::UserAgent' => ( + override => [ + 'post' => sub { + my ($self, $url, undef, $params) = @_; + my $data = decode_json($params->{params}); + my $expected = [{type => 'members.remove', value => ['foo']}]; + is_deeply($data->{transactions}, $expected, 'remove foo'); + return mock_useragent_tx('{}'); + }, + ] + ); + local @group_members = (); + local @project_members = ({phid => 'foo'},); + $feed->group_query; }; # Group has members not in project do { - my $UserAgent = mock 'Mojo::UserAgent' => ( - override => [ - 'post' => sub { - my ($self, $url, undef, $params) = @_; - my $data = decode_json($params->{params}); - my $expected = [ { type => 'members.add', value => ['foo'] } ]; - is_deeply($data->{transactions}, $expected, 'add foo'); - return mock_useragent_tx('{}'); - }, - ] - ); - local @group_members = ( - { phid => 'foo' }, - ); - local @project_members = ( - ); - $feed->group_query; + my $UserAgent = mock 'Mojo::UserAgent' => ( + override => [ + 'post' => sub { + my ($self, $url, undef, $params) = @_; + my $data = decode_json($params->{params}); + my $expected = [{type => 'members.add', value => ['foo']}]; + is_deeply($data->{transactions}, $expected, 'add foo'); + return mock_useragent_tx('{}'); + }, + ] + ); + local @group_members = ({phid => 'foo'},); + local @project_members = (); + $feed->group_query; }; do { - my $Revision = mock 'Bugzilla::Extension::PhabBugz::Revision' => ( - override => [ - 'update' => sub { 1 }, - ], - ); - my $UserAgent = mock 'Mojo::UserAgent' => ( - override => [ - 'post' => sub { - my ($self, $url, undef, $params) = @_; - if ($url =~ /differential\.revision\.search/) { - my $content = < + (override => ['update' => sub {1},],); + my $UserAgent = mock 'Mojo::UserAgent' => ( + override => [ + 'post' => sub { + my ($self, $url, undef, $params) = @_; + if ($url =~ /differential\.revision\.search/) { + my $content = < ( - add_constructor => [ fake_new => 'hash' ], - ); - my $Bug = mock 'Bugzilla::Bug' => ( - add_constructor => [ fake_new => 'hash' ], - ); - my $bug = Bugzilla::Bug->fake_new( - bug_id => 23, - attachments => [ - Bugzilla::Attachment->fake_new( - mimetype => 'text/x-phabricator-request', - filename => 'phabricator-D9999-url.txt', - ), - ] - ); + return mock_useragent_tx($content); + } + else { + return mock_useragent_tx("bad request"); + } + }, + ], + ); + my $Attachment + = mock 'Bugzilla::Attachment' => (add_constructor => [fake_new => 'hash'],); + my $Bug = mock 'Bugzilla::Bug' => (add_constructor => [fake_new => 'hash'],); + my $bug = Bugzilla::Bug->fake_new( + bug_id => 23, + attachments => [ + Bugzilla::Attachment->fake_new( + mimetype => 'text/x-phabricator-request', + filename => 'phabricator-D9999-url.txt', + ), + ] + ); - my $revisions = get_attachment_revisions($bug); - is(ref($revisions), 'ARRAY', 'it is an array ref'); - isa_ok($revisions->[0], 'Bugzilla::Extension::PhabBugz::Revision'); - is($revisions->[0]->bug_id, 23, 'Bugzila ID is 23'); - ok( try { $revisions->[0]->update }, 'update revision'); + my $revisions = get_attachment_revisions($bug); + is(ref($revisions), 'ARRAY', 'it is an array ref'); + isa_ok($revisions->[0], 'Bugzilla::Extension::PhabBugz::Revision'); + is($revisions->[0]->bug_id, 23, 'Bugzila ID is 23'); + ok(try { $revisions->[0]->update }, 'update revision'); }; diff --git a/extensions/PhabBugz/t/feed-daemon-guts.t b/extensions/PhabBugz/t/feed-daemon-guts.t index 0c508be98..44d65eab4 100644 --- a/extensions/PhabBugz/t/feed-daemon-guts.t +++ b/extensions/PhabBugz/t/feed-daemon-guts.t @@ -24,8 +24,11 @@ use Digest::SHA qw(sha1_hex); use ok 'Bugzilla::Extension::PhabBugz::Feed'; use ok 'Bugzilla::Extension::PhabBugz::Constants', 'PHAB_AUTOMATION_USER'; -use ok 'Bugzilla::Config', 'SetParam'; -can_ok('Bugzilla::Extension::PhabBugz::Feed', qw( group_query feed_query user_query )); +use ok 'Bugzilla::Config', 'SetParam'; +can_ok( + 'Bugzilla::Extension::PhabBugz::Feed', + qw( group_query feed_query user_query ) +); Bugzilla->error_mode(ERROR_MODE_TEST); @@ -34,127 +37,117 @@ my $phab_bot = create_user(PHAB_AUTOMATION_USER, '*'); my $UserAgent = mock 'Mojo::UserAgent' => (); { - SetParam('phabricator_enabled', 0); - my $feed = Bugzilla::Extension::PhabBugz::Feed->new; - my $Feed = mock 'Bugzilla::Extension::PhabBugz::Feed' => ( - override => [ - get_last_id => sub { die "get_last_id" }, - ], - ); - - foreach my $method (qw( feed_query user_query group_query )) { - try { - $feed->$method; - pass "disabling the phabricator sync: $method"; - } - catch { - fail "disabling the phabricator sync: $method"; - } + SetParam('phabricator_enabled', 0); + my $feed = Bugzilla::Extension::PhabBugz::Feed->new; + my $Feed = mock 'Bugzilla::Extension::PhabBugz::Feed' => + (override => [get_last_id => sub { die "get_last_id" },],); + + foreach my $method (qw( feed_query user_query group_query )) { + try { + $feed->$method; + pass "disabling the phabricator sync: $method"; + } + catch { + fail "disabling the phabricator sync: $method"; } + } } my @bad_response = ( - ['http error', mock_useragent_tx("doesn't matter", sub { $_->code(500) }) ], - ['invalid json', mock_useragent_tx('foo') ], - ['json containing error code', mock_useragent_tx(encode_json({error_code => 1234 }))], + ['http error', mock_useragent_tx("doesn't matter", sub { $_->code(500) })], + ['invalid json', mock_useragent_tx('foo')], + [ + 'json containing error code', + mock_useragent_tx(encode_json({error_code => 1234})) + ], ); -SetParam(phabricator_enabled => 1); -SetParam(phabricator_api_key => 'FAKE-API-KEY'); +SetParam(phabricator_enabled => 1); +SetParam(phabricator_api_key => 'FAKE-API-KEY'); SetParam(phabricator_base_uri => 'http://fake.fabricator.tld/'); foreach my $bad_response (@bad_response) { - my $feed = Bugzilla::Extension::PhabBugz::Feed->new; - $UserAgent->override( - post => sub { - my ( $self, $url, undef, $params ) = @_; - return $bad_response->[1]; - } - ); - - foreach my $method (qw( feed_query user_query group_query )) { - try { - # This is a hack to get reasonable exception objects. - local $Bugzilla::Template::is_processing = 1; - $feed->$method; - fail "$method - $bad_response->[0]"; - } - catch { - is( $_->type, 'bugzilla.code.phabricator_api_error', "$method - $bad_response->[0]" ); - }; + my $feed = Bugzilla::Extension::PhabBugz::Feed->new; + $UserAgent->override( + post => sub { + my ($self, $url, undef, $params) = @_; + return $bad_response->[1]; } - $UserAgent->reset('post'); + ); + + foreach my $method (qw( feed_query user_query group_query )) { + try { + # This is a hack to get reasonable exception objects. + local $Bugzilla::Template::is_processing = 1; + $feed->$method; + fail "$method - $bad_response->[0]"; + } + catch { + is( + $_->type, + 'bugzilla.code.phabricator_api_error', + "$method - $bad_response->[0]" + ); + }; + } + $UserAgent->reset('post'); } -my $feed = Bugzilla::Extension::PhabBugz::Feed->new; -my $json = JSON::MaybeXS->new( canonical => 1, pretty => 1 ); -my $dylan = create_user( 'dylan@mozilla.com', '*', realname => 'Dylan Hardison :dylan' ); -my $evildylan = create_user( 'dylan@gmail.com', '*', realname => 'Evil Dylan :dylan' ); -my $myk = create_user( 'myk@mozilla.com', '*', realname => 'Myk Melez :myk' ); +my $feed = Bugzilla::Extension::PhabBugz::Feed->new; +my $json = JSON::MaybeXS->new(canonical => 1, pretty => 1); +my $dylan + = create_user('dylan@mozilla.com', '*', realname => 'Dylan Hardison :dylan'); +my $evildylan + = create_user('dylan@gmail.com', '*', realname => 'Evil Dylan :dylan'); +my $myk = create_user('myk@mozilla.com', '*', realname => 'Myk Melez :myk'); my $phab_bot_phid = next_phid('PHID-USER'); done_testing; sub user_search { - my (%conf) = @_; - - return { - error_info => undef, - error_code => undef, - result => { - cursor => { - after => $conf{after}, - order => undef, - limit => 100, - before => undef + my (%conf) = @_; + + return { + error_info => undef, + error_code => undef, + result => { + cursor => + {after => $conf{after}, order => undef, limit => 100, before => undef}, + query => {queryKey => undef}, + maps => {}, + data => [ + map { + +{ + attachments => { + $_->{bmo_id} + ? ("external-accounts" => + {"external-accounts" => [{type => 'bmo', id => $_->{bmo_id},}]}) + : (), }, - query => { - queryKey => undef + fields => { + roles => ["verified", "approved", "activated"], + realName => $_->{realname}, + dateModified => time, + policy => {view => "public", edit => "no-one"}, + dateCreated => time, + username => $_->{username}, }, - maps => {}, - data => [ - map { - +{ - attachments => { - $_->{bmo_id} - ? ( "external-accounts" => { - "external-accounts" => [ - { - type => 'bmo', - id => $_->{bmo_id}, - } - ] - } - ) - : (), - }, - fields => { - roles => [ "verified", "approved", "activated" ], - realName => $_->{realname}, - dateModified => time, - policy => { - view => "public", - edit => "no-one" - }, - dateCreated => time, - username => $_->{username}, - }, - phid => next_phid("PHID-USER"), - type => "USER", - id => $_->{phab_id}, - }, - } @{ $conf{users} }, - ] - } - }; + phid => next_phid("PHID-USER"), + type => "USER", + id => $_->{phab_id}, + }, + } @{$conf{users}}, + ] + } + }; } sub next_phid { - my ($prefix) = @_; - state $number = 'a' x 20; - return $prefix . '-' . ($number++); + my ($prefix) = @_; + state $number = 'a' x 20; + return $prefix . '-' . ($number++); } diff --git a/qa/t/archived/test_email_preferences.t b/qa/t/archived/test_email_preferences.t index cc314ea2c..fe51ee140 100644 --- a/qa/t/archived/test_email_preferences.t +++ b/qa/t/archived/test_email_preferences.t @@ -59,76 +59,86 @@ $sel->click_ok("link=Email Preferences"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok("Email Preferences"); $sel->click_ok("//input[\@value='Disable All Bugmail']"); -$sel->click_ok("email-0-1", undef, 'Set "I\'m added to or removed from this capacity" for Assignee role'); -$sel->click_ok("email-0-5", undef, 'Set "The priority, status, severity, or milestone changes" for Assignee role'); -$sel->click_ok("email-0-2", undef, 'Set "New comments are added" for Assignee role'); -$sel->click_ok("email-0-0", undef, 'Set "Any field not mentioned above changes" for Assignee role'); +$sel->click_ok("email-0-1", undef, + 'Set "I\'m added to or removed from this capacity" for Assignee role'); +$sel->click_ok("email-0-5", undef, + 'Set "The priority, status, severity, or milestone changes" for Assignee role'); +$sel->click_ok("email-0-2", undef, + 'Set "New comments are added" for Assignee role'); +$sel->click_ok("email-0-0", undef, + 'Set "Any field not mentioned above changes" for Assignee role'); $sel->click_ok("email-3-8", undef, 'Set "The CC field changes" for CCed role'); -$sel->click_ok("email-1-10", undef, 'Set "A new bug is created" for QA Contact role'); -$sel->click_ok("email-100-101", undef, 'Set "Email me when someone sets a flag I asked for" global option'); +$sel->click_ok("email-1-10", undef, + 'Set "A new bug is created" for QA Contact role'); +$sel->click_ok("email-100-101", undef, + 'Set "Email me when someone sets a flag I asked for" global option'); + # Restore the old 4.2 behavior for 'Disable All Mail'. -foreach my $col (0..3) { - foreach my $row (50..51) { - $sel->click_ok("neg-email-$col-$row"); - } +foreach my $col (0 .. 3) { + foreach my $row (50 .. 51) { + $sel->click_ok("neg-email-$col-$row"); + } } -$sel->value_is("email-0-1", "on"); -$sel->value_is("email-0-10", "off"); -$sel->value_is("email-0-6", "off"); -$sel->value_is("email-0-5", "on"); -$sel->value_is("email-0-2", "on"); -$sel->value_is("email-0-3", "off"); -$sel->value_is("email-0-4", "off"); -$sel->value_is("email-0-7", "off"); -$sel->value_is("email-0-8", "off"); -$sel->value_is("email-0-9", "off"); -$sel->value_is("email-0-0", "on"); +$sel->value_is("email-0-1", "on"); +$sel->value_is("email-0-10", "off"); +$sel->value_is("email-0-6", "off"); +$sel->value_is("email-0-5", "on"); +$sel->value_is("email-0-2", "on"); +$sel->value_is("email-0-3", "off"); +$sel->value_is("email-0-4", "off"); +$sel->value_is("email-0-7", "off"); +$sel->value_is("email-0-8", "off"); +$sel->value_is("email-0-9", "off"); +$sel->value_is("email-0-0", "on"); $sel->value_is("neg-email-0-50", "off"); $sel->value_is("neg-email-0-51", "off"); -$sel->value_is("email-1-1", "off"); -$sel->value_is("email-1-10", "on"); -$sel->value_is("email-1-6", "off"); -$sel->value_is("email-1-5", "off"); -$sel->value_is("email-1-2", "off"); -$sel->value_is("email-1-3", "off"); -$sel->value_is("email-1-4", "off"); -$sel->value_is("email-1-7", "off"); -$sel->value_is("email-1-8", "off"); -$sel->value_is("email-1-9", "off"); -$sel->value_is("email-1-0", "off"); +$sel->value_is("email-1-1", "off"); +$sel->value_is("email-1-10", "on"); +$sel->value_is("email-1-6", "off"); +$sel->value_is("email-1-5", "off"); +$sel->value_is("email-1-2", "off"); +$sel->value_is("email-1-3", "off"); +$sel->value_is("email-1-4", "off"); +$sel->value_is("email-1-7", "off"); +$sel->value_is("email-1-8", "off"); +$sel->value_is("email-1-9", "off"); +$sel->value_is("email-1-0", "off"); $sel->value_is("neg-email-1-50", "off"); $sel->value_is("neg-email-1-51", "off"); -ok(!$sel->is_editable("email-2-1"), 'The "I\'m added to or removed from this capacity" for Reporter role is disabled'); -$sel->value_is("email-2-10", "off"); -$sel->value_is("email-2-6", "off"); -$sel->value_is("email-2-5", "off"); -$sel->value_is("email-2-2", "off"); -$sel->value_is("email-2-3", "off"); -$sel->value_is("email-2-4", "off"); -$sel->value_is("email-2-7", "off"); -$sel->value_is("email-2-8", "off"); -$sel->value_is("email-2-9", "off"); -$sel->value_is("email-2-0", "off"); +ok(!$sel->is_editable("email-2-1"), + 'The "I\'m added to or removed from this capacity" for Reporter role is disabled' +); +$sel->value_is("email-2-10", "off"); +$sel->value_is("email-2-6", "off"); +$sel->value_is("email-2-5", "off"); +$sel->value_is("email-2-2", "off"); +$sel->value_is("email-2-3", "off"); +$sel->value_is("email-2-4", "off"); +$sel->value_is("email-2-7", "off"); +$sel->value_is("email-2-8", "off"); +$sel->value_is("email-2-9", "off"); +$sel->value_is("email-2-0", "off"); $sel->value_is("neg-email-2-50", "off"); $sel->value_is("neg-email-2-51", "off"); -$sel->value_is("email-3-1", "off"); -$sel->value_is("email-3-10", "off"); -$sel->value_is("email-3-6", "off"); -$sel->value_is("email-3-5", "off"); -$sel->value_is("email-3-2", "off"); -$sel->value_is("email-3-3", "off"); -$sel->value_is("email-3-4", "off"); -$sel->value_is("email-3-7", "off"); -$sel->value_is("email-3-8", "on"); -$sel->value_is("email-3-9", "off"); -$sel->value_is("email-3-0", "off"); +$sel->value_is("email-3-1", "off"); +$sel->value_is("email-3-10", "off"); +$sel->value_is("email-3-6", "off"); +$sel->value_is("email-3-5", "off"); +$sel->value_is("email-3-2", "off"); +$sel->value_is("email-3-3", "off"); +$sel->value_is("email-3-4", "off"); +$sel->value_is("email-3-7", "off"); +$sel->value_is("email-3-8", "on"); +$sel->value_is("email-3-9", "off"); +$sel->value_is("email-3-0", "off"); $sel->value_is("neg-email-3-50", "off"); $sel->value_is("neg-email-3-51", "off"); -$sel->value_is("email-100-100", "off"); -$sel->value_is("email-100-101", "on"); +$sel->value_is("email-100-100", "off"); +$sel->value_is("email-100-101", "on"); $sel->click_ok("update", undef, "Submit modified admin email preferences"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->is_text_present_ok("The changes to your email preferences have been saved."); +$sel->is_text_present_ok( + "The changes to your email preferences have been saved."); # Set "After changing a bug" default preference to "Show the updated bug" # This simplifies bug changes below @@ -148,95 +158,120 @@ log_in($sel, $config, 'editbugs'); $sel->open_ok("$config->{bugzilla_installation}/userprefs.cgi?tab=email"); $sel->is_text_present_ok("Email Preferences"); $sel->click_ok("//input[\@value='Enable All Bugmail']"); -$sel->click_ok("email-3-1", undef, 'Clear "I\'m added to or removed from this capacity" for CCed role'); -$sel->click_ok("email-3-5", undef, 'Clear "The priority, status, severity, or milestone changes" for CCed role'); -$sel->click_ok("email-2-2", undef, 'Clear "New comments are added" for Reporter role'); -$sel->click_ok("email-3-2", undef, 'Clear "New comments are added" for CCed role'); -$sel->click_ok("email-2-8", undef, 'Clear "The CC field changes" for Reporter role'); -$sel->click_ok("email-3-8", undef, 'Clear "The CC field changes" for CCed role'); -$sel->click_ok("email-2-0", undef, 'Clear "Any field not mentioned above changes" for Reporter role'); -$sel->click_ok("email-3-0", undef, 'Clear "Any field not mentioned above changes" for CCed role'); -$sel->click_ok("neg-email-0-51", undef, 'Set "Change was made by me" override for Assignee role'); -$sel->click_ok("email-100-101", undef, 'Clear "Email me when someone sets a flag I asked for" global option'); -$sel->value_is("email-0-1", "on"); -$sel->value_is("email-0-10", "on"); -$sel->value_is("email-0-6", "on"); -$sel->value_is("email-0-5", "on"); -$sel->value_is("email-0-2", "on"); -$sel->value_is("email-0-3", "on"); -$sel->value_is("email-0-4", "on"); -$sel->value_is("email-0-7", "on"); -$sel->value_is("email-0-8", "on"); -$sel->value_is("email-0-9", "on"); -$sel->value_is("email-0-0", "on"); +$sel->click_ok("email-3-1", undef, + 'Clear "I\'m added to or removed from this capacity" for CCed role'); +$sel->click_ok("email-3-5", undef, + 'Clear "The priority, status, severity, or milestone changes" for CCed role'); +$sel->click_ok("email-2-2", undef, + 'Clear "New comments are added" for Reporter role'); +$sel->click_ok("email-3-2", undef, + 'Clear "New comments are added" for CCed role'); +$sel->click_ok("email-2-8", undef, + 'Clear "The CC field changes" for Reporter role'); +$sel->click_ok("email-3-8", undef, + 'Clear "The CC field changes" for CCed role'); +$sel->click_ok("email-2-0", undef, + 'Clear "Any field not mentioned above changes" for Reporter role'); +$sel->click_ok("email-3-0", undef, + 'Clear "Any field not mentioned above changes" for CCed role'); +$sel->click_ok("neg-email-0-51", undef, + 'Set "Change was made by me" override for Assignee role'); +$sel->click_ok("email-100-101", undef, + 'Clear "Email me when someone sets a flag I asked for" global option'); +$sel->value_is("email-0-1", "on"); +$sel->value_is("email-0-10", "on"); +$sel->value_is("email-0-6", "on"); +$sel->value_is("email-0-5", "on"); +$sel->value_is("email-0-2", "on"); +$sel->value_is("email-0-3", "on"); +$sel->value_is("email-0-4", "on"); +$sel->value_is("email-0-7", "on"); +$sel->value_is("email-0-8", "on"); +$sel->value_is("email-0-9", "on"); +$sel->value_is("email-0-0", "on"); $sel->value_is("neg-email-0-50", "off"); $sel->value_is("neg-email-0-51", "on"); -$sel->value_is("email-1-1", "on"); -$sel->value_is("email-1-10", "on"); -$sel->value_is("email-1-6", "on"); -$sel->value_is("email-1-5", "on"); -$sel->value_is("email-1-2", "on"); -$sel->value_is("email-1-3", "on"); -$sel->value_is("email-1-4", "on"); -$sel->value_is("email-1-7", "on"); -$sel->value_is("email-1-8", "on"); -$sel->value_is("email-1-9", "on"); -$sel->value_is("email-1-0", "on"); +$sel->value_is("email-1-1", "on"); +$sel->value_is("email-1-10", "on"); +$sel->value_is("email-1-6", "on"); +$sel->value_is("email-1-5", "on"); +$sel->value_is("email-1-2", "on"); +$sel->value_is("email-1-3", "on"); +$sel->value_is("email-1-4", "on"); +$sel->value_is("email-1-7", "on"); +$sel->value_is("email-1-8", "on"); +$sel->value_is("email-1-9", "on"); +$sel->value_is("email-1-0", "on"); $sel->value_is("neg-email-1-50", "off"); $sel->value_is("neg-email-1-51", "off"); -ok(!$sel->is_editable("email-2-1"), 'The "I\'m added to or removed from this capacity" for Reporter role is disabled'); -$sel->value_is("email-2-10", "on"); -$sel->value_is("email-2-6", "on"); -$sel->value_is("email-2-5", "on"); -$sel->value_is("email-2-2", "off"); -$sel->value_is("email-2-3", "on"); -$sel->value_is("email-2-4", "on"); -$sel->value_is("email-2-7", "on"); -$sel->value_is("email-2-8", "off"); -$sel->value_is("email-2-9", "on"); -$sel->value_is("email-2-0", "off"); +ok(!$sel->is_editable("email-2-1"), + 'The "I\'m added to or removed from this capacity" for Reporter role is disabled' +); +$sel->value_is("email-2-10", "on"); +$sel->value_is("email-2-6", "on"); +$sel->value_is("email-2-5", "on"); +$sel->value_is("email-2-2", "off"); +$sel->value_is("email-2-3", "on"); +$sel->value_is("email-2-4", "on"); +$sel->value_is("email-2-7", "on"); +$sel->value_is("email-2-8", "off"); +$sel->value_is("email-2-9", "on"); +$sel->value_is("email-2-0", "off"); $sel->value_is("neg-email-2-50", "off"); $sel->value_is("neg-email-2-51", "off"); -$sel->value_is("email-3-1", "off"); -$sel->value_is("email-3-10", "on"); -$sel->value_is("email-3-6", "on"); -$sel->value_is("email-3-5", "off"); -$sel->value_is("email-3-2", "off"); -$sel->value_is("email-3-3", "on"); -$sel->value_is("email-3-4", "on"); -$sel->value_is("email-3-7", "on"); -$sel->value_is("email-3-8", "off"); -$sel->value_is("email-3-9", "on"); -$sel->value_is("email-3-0", "off"); +$sel->value_is("email-3-1", "off"); +$sel->value_is("email-3-10", "on"); +$sel->value_is("email-3-6", "on"); +$sel->value_is("email-3-5", "off"); +$sel->value_is("email-3-2", "off"); +$sel->value_is("email-3-3", "on"); +$sel->value_is("email-3-4", "on"); +$sel->value_is("email-3-7", "on"); +$sel->value_is("email-3-8", "off"); +$sel->value_is("email-3-9", "on"); +$sel->value_is("email-3-0", "off"); $sel->value_is("neg-email-3-50", "off"); $sel->value_is("neg-email-3-51", "off"); -$sel->value_is("email-100-100", "on"); -$sel->value_is("email-100-101", "off"); -$sel->click_ok("update", undef, "Submit modified normal user email preferences"); +$sel->value_is("email-100-100", "on"); +$sel->value_is("email-100-101", "off"); +$sel->click_ok("update", undef, + "Submit modified normal user email preferences"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->is_text_present_ok("The changes to your email preferences have been saved."); +$sel->is_text_present_ok( + "The changes to your email preferences have been saved."); # Always show email recipients -ok($sel->create_cookie('show_bugmail_recipients=1'), 'Always show recipient list'); +ok($sel->create_cookie('show_bugmail_recipients=1'), + 'Always show recipient list'); # Create a test bug (bugmail to both normal user and admin) file_bug_in_product($sel, "Another Product"); $sel->select_ok("component", "label=c1"); -$sel->type_ok("short_desc", "Selenium Email Preference test bug", "Enter bug summary"); -$sel->type_ok("comment", "Created by Selenium to test Email Preferences", "Enter bug description"); +$sel->type_ok( + "short_desc", + "Selenium Email Preference test bug", + "Enter bug summary" +); +$sel->type_ok( + "comment", + "Created by Selenium to test Email Preferences", + "Enter bug description" +); $sel->type_ok("assigned_to", $config->{editbugs_user_login}); -$sel->type_ok("qa_contact", $config->{admin_user_login}); -$sel->type_ok("cc", $config->{admin_user_login}); +$sel->type_ok("qa_contact", $config->{admin_user_login}); +$sel->type_ok("cc", $config->{admin_user_login}); $sel->click_ok("commit"); $sel->wait_for_page_to_load(WAIT_TIME); my $bug1_id = $sel->get_value("//input[\@name='id' and \@type='hidden']"); -$sel->is_text_present_ok('has been added to the database', "Bug $bug1_id created"); +$sel->is_text_present_ok('has been added to the database', + "Bug $bug1_id created"); my @email_sentto = get_email_sentto($sel); is_deeply(\@email_sentto, \@email_both, "Admin and normal user got bugmail"); # Make normal user changes (first pass) # go_to_bug($sel, $bug1_id); + # Severity change (bugmail to normal user but not admin) $sel->select_ok("bug_severity", "label=blocker"); $sel->selected_label_is("bug_severity", "blocker"); @@ -245,14 +280,20 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); @email_sentto = get_email_sentto($sel); is_deeply(\@email_sentto, \@email_normal, "Normal user got bugmail"); + # Add a comment (bugmail to no one) -$sel->type_ok("comment", "This is a Selenium generated normal user test comment 1 of 2. (No bugmail should be generated for this.)"); -$sel->value_is("comment", "This is a Selenium generated normal user test comment 1 of 2. (No bugmail should be generated for this.)"); +$sel->type_ok("comment", + "This is a Selenium generated normal user test comment 1 of 2. (No bugmail should be generated for this.)" +); +$sel->value_is("comment", + "This is a Selenium generated normal user test comment 1 of 2. (No bugmail should be generated for this.)" +); $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); @email_sentto = get_email_sentto($sel); ok($email_sentto[0] eq "no one", "No bugmail sent"); + # Add normal user to CC list (bugmail to admin but not normal user) $sel->type_ok("newcc", $config->{editbugs_user_login}); $sel->value_is("newcc", $config->{editbugs_user_login}); @@ -261,6 +302,7 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); @email_sentto = get_email_sentto($sel); is_deeply(\@email_sentto, \@email_admin, "Admin got bugmail"); + # Request a flag from admin (bugmail to no one, request mail to no one) $sel->select_ok("flag_type-4", "label=?"); $sel->type_ok("requestee_type-4", $config->{admin_user_login}); @@ -276,6 +318,7 @@ ok($email_sentto[0] eq "no one", "No bugmail sent"); logout($sel); log_in($sel, $config, 'admin'); go_to_bug($sel, $bug1_id); + # Severity change (bugmail to normal user but not admin) $sel->select_ok("bug_severity", "label=trivial"); $sel->selected_label_is("bug_severity", "trivial"); @@ -284,14 +327,20 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); @email_sentto = get_email_sentto($sel); is_deeply(\@email_sentto, \@email_normal, "Normal user got bugmail"); + # Add a comment (bugmail to normal user but not admin) -$sel->type_ok("comment", "This is a Selenium generated admin user test comment. (Only normal user should get bugmail for this.)"); -$sel->value_is("comment", "This is a Selenium generated admin user test comment. (Only normal user should get bugmail for this.)"); +$sel->type_ok("comment", + "This is a Selenium generated admin user test comment. (Only normal user should get bugmail for this.)" +); +$sel->value_is("comment", + "This is a Selenium generated admin user test comment. (Only normal user should get bugmail for this.)" +); $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); @email_sentto = get_email_sentto($sel); is_deeply(\@email_sentto, \@email_normal, "Normal user got bugmail"); + # Remove normal user from CC list (bugmail to both normal user and admin) $sel->click_ok("removecc"); $sel->add_selection_ok("cc", "label=$config->{editbugs_user_login}"); @@ -302,6 +351,7 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); @email_sentto = get_email_sentto($sel); is_deeply(\@email_sentto, \@email_both, "Admin and normal user got bugmail"); + # Reassign bug to admin user (bugmail to both normal user and admin) $sel->type_ok("assigned_to", $config->{admin_user_login}); $sel->value_is("assigned_to", $config->{admin_user_login}); @@ -310,6 +360,7 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); @email_sentto = get_email_sentto($sel); is_deeply(\@email_sentto, \@email_both, "Admin and normal user got bugmail"); + # Request a flag from normal user (bugmail to admin but not normal user and request mail to admin) $sel->select_ok("flag_type-4", "label=?"); $sel->type_ok("requestee_type-4", $config->{editbugs_user_login}); @@ -318,6 +369,7 @@ $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); @email_sentto = get_email_sentto($sel); is_deeply(\@email_sentto, \@email_admin, "Admin got bugmail"); + # Grant a normal user flag request (bugmail to admin but not normal user and request mail to no one) my $flag1_id = set_flag($sel, $config->{admin_user_login}, "?", "+"); $sel->click_ok("commit"); @@ -330,6 +382,7 @@ is_deeply(\@email_sentto, \@email_admin, "Admin got bugmail"); logout($sel); log_in($sel, $config, 'editbugs'); go_to_bug($sel, $bug1_id); + # Severity change (bugmail to both admin and normal user) $sel->select_ok("bug_severity", "label=normal"); $sel->selected_label_is("bug_severity", "normal"); @@ -338,14 +391,20 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); @email_sentto = get_email_sentto($sel); is_deeply(\@email_sentto, \@email_both, "Admin and normal user got bugmail"); + # Add a comment (bugmail to admin but not normal user) -$sel->type_ok("comment", "This is a Selenium generated normal user test comment 2 of 2. (Only admin should get bugmail for this.)"); -$sel->value_is("comment", "This is a Selenium generated normal user test comment 2 of 2. (Only admin should get bugmail for this.)"); +$sel->type_ok("comment", + "This is a Selenium generated normal user test comment 2 of 2. (Only admin should get bugmail for this.)" +); +$sel->value_is("comment", + "This is a Selenium generated normal user test comment 2 of 2. (Only admin should get bugmail for this.)" +); $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); @email_sentto = get_email_sentto($sel); is_deeply(\@email_sentto, \@email_admin, "Admin got bugmail"); + # Reassign to normal user (bugmail to admin but not normal user) $sel->type_ok("assigned_to", $config->{editbugs_user_login}); $sel->value_is("assigned_to", $config->{editbugs_user_login}); @@ -353,12 +412,14 @@ $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); @email_sentto = get_email_sentto($sel); is_deeply(\@email_sentto, \@email_admin, "Admin got bugmail"); + # Deny a flag requested by admin (bugmail to no one and request mail to admin) my $flag2_id = set_flag($sel, $config->{editbugs_user_login}, "?", "-"); $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); @email_sentto = get_email_sentto($sel); ok($email_sentto[0] eq "no one", "No bugmail sent"); + # Cancel both flags (bugmail and request mail to no one) set_flag($sel, undef, "+", "X", $flag1_id); set_flag($sel, undef, "-", "X", $flag2_id); @@ -370,31 +431,41 @@ logout($sel); # Help functions sub get_email_sentto { - my ($sel) = @_; - my @email_sentto; - my $index = 1; - while ($sel->is_element_present("//dt[text()='Email sent to:']/following-sibling::dd/code[$index]")) { - push(@email_sentto, - $sel->get_text("//dt[text()='Email sent to:']/following-sibling::dd/code[$index]")); - $index++; - } - return ("no one") if !@email_sentto; - return sort @email_sentto; + my ($sel) = @_; + my @email_sentto; + my $index = 1; + while ($sel->is_element_present( + "//dt[text()='Email sent to:']/following-sibling::dd/code[$index]")) + { + push( + @email_sentto, + $sel->get_text( + "//dt[text()='Email sent to:']/following-sibling::dd/code[$index]") + ); + $index++; + } + return ("no one") if !@email_sentto; + return sort @email_sentto; } sub set_flag { - my ($sel, $login, $curval, $newval, $prev_id) = @_; + my ($sel, $login, $curval, $newval, $prev_id) = @_; - # Retrieve flag id for the flag to be set - my $flag_id = $prev_id; - if (defined $login) { - my $flag_name = $sel->get_attribute("//table[\@id='flags']//input[\@value='$login']\@name"); - $flag_name =~ /^requestee-(\d+)$/; - $flag_id = $1; - } + # Retrieve flag id for the flag to be set + my $flag_id = $prev_id; + if (defined $login) { + my $flag_name + = $sel->get_attribute("//table[\@id='flags']//input[\@value='$login']\@name"); + $flag_name =~ /^requestee-(\d+)$/; + $flag_id = $1; + } - # Set new value for the flag (verifies current value) - $sel->select_ok("//select[\@id=\"flag-$flag_id\"]/option[\@value=\"$curval\" and \@selected]/..", "value=$newval", "Set flag ID $flag_id to $newval from $curval"); + # Set new value for the flag (verifies current value) + $sel->select_ok( + "//select[\@id=\"flag-$flag_id\"]/option[\@value=\"$curval\" and \@selected]/..", + "value=$newval", + "Set flag ID $flag_id to $newval from $curval" + ); - return $flag_id; + return $flag_id; } diff --git a/qa/t/rest_bugzilla.t b/qa/t/rest_bugzilla.t index 01ee6af65..b4185d000 100644 --- a/qa/t/rest_bugzilla.t +++ b/qa/t/rest_bugzilla.t @@ -17,7 +17,7 @@ use lib qw(lib ../../lib ../../local/lib/perl5); use Test::More tests => 11; use QA::REST; -my $rest = get_rest_client(); +my $rest = get_rest_client(); my $config = $rest->bz_config; my $version = $rest->call('version')->{version}; @@ -26,31 +26,42 @@ ok($version, "GET /rest/version returns $version"); my $extensions = $rest->call('extensions')->{extensions}; isa_ok($extensions, 'HASH', 'GET /rest/extensions'); my @ext_names = sort keys %$extensions; + # There is always at least the QA extension enabled. -ok(scalar(@ext_names), scalar(@ext_names) . ' extension(s) found: ' . join(', ', @ext_names)); -ok($extensions->{QA}, 'The QA extension is enabled, with version ' . $extensions->{QA}->{version}); +ok(scalar(@ext_names), + scalar(@ext_names) . ' extension(s) found: ' . join(', ', @ext_names)); +ok($extensions->{QA}, + 'The QA extension is enabled, with version ' . $extensions->{QA}->{version}); my $timezone = $rest->call('timezone')->{timezone}; ok($timezone, "GET /rest/timezone retuns $timezone"); my $time = $rest->call('time'); foreach my $type (qw(db_time web_time)) { - ok($time->{$type}, "GET /rest/time returns $type = " . $time->{$type}); + ok($time->{$type}, "GET /rest/time returns $type = " . $time->{$type}); } # Logged-out users can only access the maintainer and requirelogin parameters. -my $params = $rest->call('parameters')->{parameters}; +my $params = $rest->call('parameters')->{parameters}; my @param_names = sort keys %$params; -ok(@param_names == 2 && defined $params->{maintainer} && defined $params->{requirelogin}, - 'Only 2 parameters accessible to logged-out users: ' . join(', ', @param_names)); +ok( + @param_names == 2 + && defined $params->{maintainer} + && defined $params->{requirelogin}, + 'Only 2 parameters accessible to logged-out users: ' . join(', ', @param_names) +); # Powerless users can access much more parameters. -$params = $rest->call('parameters', { api_key => $config->{unprivileged_user_api_key} })->{parameters}; +$params + = $rest->call('parameters', {api_key => $config->{unprivileged_user_api_key}}) + ->{parameters}; @param_names = sort keys %$params; -ok(@param_names > 2, scalar(@param_names) . ' parameters accessible to powerless users'); +ok(@param_names > 2, + scalar(@param_names) . ' parameters accessible to powerless users'); # Admins can access all parameters. -$params = $rest->call('parameters', { api_key => $config->{admin_user_api_key} })->{parameters}; +$params = $rest->call('parameters', {api_key => $config->{admin_user_api_key}}) + ->{parameters}; @param_names = sort keys %$params; ok(@param_names > 2, scalar(@param_names) . ' parameters accessible to admins'); diff --git a/qa/t/rest_classification.t b/qa/t/rest_classification.t index f5485de2b..e1083e98a 100644 --- a/qa/t/rest_classification.t +++ b/qa/t/rest_classification.t @@ -17,43 +17,67 @@ use lib qw(lib ../../lib ../../local/lib/perl5); use Test::More tests => 7; use QA::REST; -my $rest = get_rest_client(); +my $rest = get_rest_client(); my $config = $rest->bz_config; -my $args = { api_key => $config->{admin_user_api_key} }; +my $args = {api_key => $config->{admin_user_api_key}}; my $params = $rest->call('parameters', $args)->{parameters}; my $use_class = $params->{useclassification}; -ok(defined($use_class), 'Classifications are ' . ($use_class ? 'enabled' : 'disabled')); +ok(defined($use_class), + 'Classifications are ' . ($use_class ? 'enabled' : 'disabled')); # Admins can always access classifications, even when they are disabled. my $class = $rest->call('classification/1', $args)->{classifications}->[0]; -ok($class->{id}, "Admin found classification '" . $class->{name} . "' with the description '" . $class->{description} . "'"); -my @products = sort map { $_->{name} } @{ $class->{products} }; -ok(scalar(@products), scalar(@products) . ' product(s) found: ' . join(', ', @products)); +ok($class->{id}, + "Admin found classification '" + . $class->{name} + . "' with the description '" + . $class->{description} + . "'"); +my @products = sort map { $_->{name} } @{$class->{products}}; +ok(scalar(@products), + scalar(@products) . ' product(s) found: ' . join(', ', @products)); $class = $rest->call('classification/Class2_QA', $args)->{classifications}->[0]; -ok($class->{id}, "Admin found classification '" . $class->{name} . "' with the description '" . $class->{description} . "'"); -@products = sort map { $_->{name} } @{ $class->{products} }; -ok(scalar(@products), scalar(@products) . ' product(s) found: ' . join(', ', @products)); +ok($class->{id}, + "Admin found classification '" + . $class->{name} + . "' with the description '" + . $class->{description} + . "'"); +@products = sort map { $_->{name} } @{$class->{products}}; +ok(scalar(@products), + scalar(@products) . ' product(s) found: ' . join(', ', @products)); if ($use_class) { - # When classifications are enabled, everybody can query classifications... - # ... including logged-out users. - $class = $rest->call('classification/1')->{classifications}->[0]; - ok($class->{id}, 'Logged-out users can access classification ' . $class->{name}); - # ... and non-admins. - $class = $rest->call('classification/1', { api_key => $config->{editbugs_user_api_key} })->{classifications}->[0]; - ok($class->{id}, 'Non-admins can access classification ' . $class->{name}); + + # When classifications are enabled, everybody can query classifications... + # ... including logged-out users. + $class = $rest->call('classification/1')->{classifications}->[0]; + ok($class->{id}, + 'Logged-out users can access classification ' . $class->{name}); + + # ... and non-admins. + $class = $rest->call('classification/1', + {api_key => $config->{editbugs_user_api_key}})->{classifications}->[0]; + ok($class->{id}, 'Non-admins can access classification ' . $class->{name}); } else { - # When classifications are disabled, only users in the 'editclassifications' - # group can access this method... - # ... logged-out users get an error. - my $error = $rest->call('classification/1', undef, undef, MUST_FAIL); - ok($error->{error} && $error->{code} == 900, - 'Logged-out users cannot query classifications when disabled: ' . $error->{message}); - # ... as well as non-admins. - $error = $rest->call('classification/1', { api_key => $config->{editbugs_user_api_key} }, undef, MUST_FAIL); - ok($error->{error} && $error->{code} == 900, - 'Non-admins cannot query classifications when disabled: ' . $error->{message}); + # When classifications are disabled, only users in the 'editclassifications' + # group can access this method... + # ... logged-out users get an error. + my $error = $rest->call('classification/1', undef, undef, MUST_FAIL); + ok( + $error->{error} && $error->{code} == 900, + 'Logged-out users cannot query classifications when disabled: ' + . $error->{message} + ); + + # ... as well as non-admins. + $error + = $rest->call('classification/1', + {api_key => $config->{editbugs_user_api_key}}, + undef, MUST_FAIL); + ok($error->{error} && $error->{code} == 900, + 'Non-admins cannot query classifications when disabled: ' . $error->{message}); } diff --git a/qa/t/selenium_server_start.t b/qa/t/selenium_server_start.t index c08db293c..e70216433 100644 --- a/qa/t/selenium_server_start.t +++ b/qa/t/selenium_server_start.t @@ -9,9 +9,11 @@ use strict; use warnings; use constant DISPLAY => 99; + #use constant DISPLAY => 0; use Test::More tests => 12; + #use Test::More tests => 4; my $pid; @@ -21,63 +23,63 @@ $pid = xserver_start(); ok($pid, "X Server started with PID $pid on display " . DISPLAY); ok(open(XPID, ">testing.x.pid"), "Opening testing.x.pid"); ok((print XPID $pid), "Writing testing.x.pid"); -ok(close(XPID), "Closing testing.x.pid"); +ok(close(XPID), "Closing testing.x.pid"); # Start the VNC service second ok($pid = vnc_start(), "VNC desktop started with PID $pid"); ok(open(VNCPID, ">testing.vnc.pid"), "Opening testing.vnc.pid"); ok((print VNCPID $pid), "Writing testing.vnc.pid"); -ok(close(VNCPID), "Closing testing.vnc.pid"); +ok(close(VNCPID), "Closing testing.vnc.pid"); # Start the selenium server third ok($pid = selenium_start(), "Selenium RC server started with PID $pid"); ok(open(SPID, ">testing.selenium.pid"), "Opening testing.selenium.pid"); ok((print SPID $pid), "Writing testing.selenium.pid"); -ok(close(SPID), "Closing testing.selenium.pid"); +ok(close(SPID), "Closing testing.selenium.pid"); sleep(10); # Subroutines sub xserver_start { - my $pid; - my @x_cmd = qw(Xvfb -ac -screen 0 1600x1200x24 -fbdir /tmp); - push(@x_cmd, ":" . DISPLAY); - $pid = fork(); - if (!$pid) { - open(STDOUT, ">/dev/null"); - open(STDERR, ">/dev/null"); - exec(@x_cmd) || die "unable to execute: $!"; - } - else { - return $pid; - } - return 0; + my $pid; + my @x_cmd = qw(Xvfb -ac -screen 0 1600x1200x24 -fbdir /tmp); + push(@x_cmd, ":" . DISPLAY); + $pid = fork(); + if (!$pid) { + open(STDOUT, ">/dev/null"); + open(STDERR, ">/dev/null"); + exec(@x_cmd) || die "unable to execute: $!"; + } + else { + return $pid; + } + return 0; } sub vnc_start { - my @vnc_cmd = qw(x11vnc -viewonly -forever -nopw -quiet -display); - push(@vnc_cmd, ":" . DISPLAY); - my $pid = fork(); - if (!$pid) { - open(STDOUT, ">/dev/null"); - open(STDERR, ">/dev/null"); - exec(@vnc_cmd) || die "unabled to execute: $!"; - } - return $pid; + my @vnc_cmd = qw(x11vnc -viewonly -forever -nopw -quiet -display); + push(@vnc_cmd, ":" . DISPLAY); + my $pid = fork(); + if (!$pid) { + open(STDOUT, ">/dev/null"); + open(STDERR, ">/dev/null"); + exec(@vnc_cmd) || die "unabled to execute: $!"; + } + return $pid; } sub selenium_start { - my @selenium_cmd = qw(java -jar ../config/selenium-server-standalone.jar - -firefoxProfileTemplate ../config/firefox - -log ../config/selenium.log - -singlewindow); - unshift(@selenium_cmd, "env", "DISPLAY=:" . DISPLAY); - my $pid = fork(); - if (!$pid) { - open(STDOUT, ">/dev/null"); - open(STDERR, ">/dev/null"); - exec(@selenium_cmd) || die "unable to execute: $!"; - } - return $pid; + my @selenium_cmd = qw(java -jar ../config/selenium-server-standalone.jar + -firefoxProfileTemplate ../config/firefox + -log ../config/selenium.log + -singlewindow); + unshift(@selenium_cmd, "env", "DISPLAY=:" . DISPLAY); + my $pid = fork(); + if (!$pid) { + open(STDOUT, ">/dev/null"); + open(STDERR, ">/dev/null"); + exec(@selenium_cmd) || die "unable to execute: $!"; + } + return $pid; } diff --git a/qa/t/selenium_server_stop.t b/qa/t/selenium_server_stop.t index 62a29f38c..7633e57d7 100644 --- a/qa/t/selenium_server_stop.t +++ b/qa/t/selenium_server_stop.t @@ -29,6 +29,6 @@ ok(unlink("testing.vnc.pid"), "Removing testing.vnc.pid"); # Stop the Xvfb server third ok(open(XPID, "), "Reading testing.x.pid"); -ok(close(XPID), "Closing testing.x.pid"); +ok(close(XPID), "Closing testing.x.pid"); ok(kill(9, $pid), "Killing process $pid"); ok(unlink("testing.x.pid"), "Removing testing.x.pid"); diff --git a/qa/t/test_bmo_autolinkification.t b/qa/t/test_bmo_autolinkification.t index af61f09a4..a8bce05cd 100644 --- a/qa/t/test_bmo_autolinkification.t +++ b/qa/t/test_bmo_autolinkification.t @@ -19,7 +19,7 @@ log_in($sel, $config, 'unprivileged'); file_bug_in_product($sel, 'TestProduct'); my $bug_summary = "linkification test bug"; $sel->type_ok("short_desc", $bug_summary); -$sel->type_ok("comment", "linkification test"); +$sel->type_ok("comment", "linkification test"); $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_like(qr/\d+ \S $bug_summary/, "Bug created"); @@ -31,7 +31,9 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_like(qr/\d+ \S $bug_summary/, "crash report added"); $sel->click_ok("link=bug $bug_id"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->attribute_is('link=bp-63f096f7-253b-4ee2-ae3d-8bb782090824@href', 'https://crash-stats.mozilla.com/report/index/63f096f7-253b-4ee2-ae3d-8bb782090824'); +$sel->attribute_is('link=bp-63f096f7-253b-4ee2-ae3d-8bb782090824@href', + 'https://crash-stats.mozilla.com/report/index/63f096f7-253b-4ee2-ae3d-8bb782090824' +); $sel->type_ok("comment", "CVE-2010-2884"); $sel->click_ok("commit"); @@ -39,7 +41,8 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_like(qr/\d+ \S $bug_summary/, "cve added"); $sel->click_ok("link=bug $bug_id"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->attribute_is('link=CVE-2010-2884@href', 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-2884'); +$sel->attribute_is('link=CVE-2010-2884@href', + 'https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-2884'); $sel->type_ok("comment", "r12345"); $sel->click_ok("commit"); @@ -47,7 +50,8 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_like(qr/\d+ \S $bug_summary/, "svn revision added"); $sel->click_ok("link=bug $bug_id"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->attribute_is('link=r12345@href', 'https://viewvc.svn.mozilla.org/vc?view=rev&revision=12345'); +$sel->attribute_is('link=r12345@href', + 'https://viewvc.svn.mozilla.org/vc?view=rev&revision=12345'); logout($sel); diff --git a/qa/t/test_bmo_enter_new_bug.t b/qa/t/test_bmo_enter_new_bug.t index 021e25f06..b499a7fc9 100644 --- a/qa/t/test_bmo_enter_new_bug.t +++ b/qa/t/test_bmo_enter_new_bug.t @@ -23,7 +23,7 @@ use QA::Util; my ($sel, $config) = get_selenium(); log_in($sel, $config, 'admin'); -set_parameters($sel, { "Bug Fields" => {"useclassification-off" => undef} }); +set_parameters($sel, {"Bug Fields" => {"useclassification-off" => undef}}); # mktgevent and swag are dependent so we create the mktgevent bug first so # we can provide the bug id to swag @@ -90,15 +90,23 @@ _check_product('Marketing'); _check_component('Marketing', 'Trademark Permissions'); _check_group('marketing-private'); -$sel->open_ok("/$config->{bugzilla_installation}/enter_bug.cgi?product=Marketing&format=trademark"); +$sel->open_ok( + "/$config->{bugzilla_installation}/enter_bug.cgi?product=Marketing&format=trademark" +); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->title_is("Trademark Usage Requests", "Open custom bug entry form - trademark"); +$sel->title_is("Trademark Usage Requests", + "Open custom bug entry form - trademark"); $sel->type_ok("short_desc", "Bug created by Selenium", "Enter bug summary"); -$sel->type_ok("comment", "--- Bug created by Selenium ---", "Enter bug description"); +$sel->type_ok( + "comment", + "--- Bug created by Selenium ---", + "Enter bug description" +); $sel->click_ok("commit", undef, "Submit bug data to post_bug.cgi"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok('has been added to the database', 'Bug created'); -my $trademark_bug_id = $sel->get_value('//input[@name="id" and @type="hidden"]'); +my $trademark_bug_id + = $sel->get_value('//input[@name="id" and @type="hidden"]'); # itrequest @@ -173,14 +181,25 @@ _check_component('mozilla.org', 'Discussion Forums'); _check_version('mozilla.org', 'other'); _check_component('mozilla.org', 'Discussion Forums'); -$sel->open_ok("/$config->{bugzilla_installation}/enter_bug.cgi?product=mozilla.org&format=mozlist"); +$sel->open_ok( + "/$config->{bugzilla_installation}/enter_bug.cgi?product=mozilla.org&format=mozlist" +); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->title_is("Mozilla Discussion Forum", "Open custom bug entry form - mozlist"); +$sel->title_is("Mozilla Discussion Forum", + "Open custom bug entry form - mozlist"); $sel->type_ok("listName", "test-list", "Enter name for mailing list"); -$sel->type_ok("listAdmin", $config->{'admin_user_login'}, "Enter list administator"); +$sel->type_ok( + "listAdmin", + $config->{'admin_user_login'}, + "Enter list administator" +); $sel->type_ok("cc", $config->{'unprivileged_user_login'}, "Enter cc address"); $sel->check_ok("name=groups", "value=infra", "Select private group"); -$sel->type_ok("comment", "--- Bug created by Selenium ---", "Enter bug description"); +$sel->type_ok( + "comment", + "--- Bug created by Selenium ---", + "Enter bug description" +); $sel->click_ok("commit", undef, "Submit bug data to post_bug.cgi"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok('has been added to the database', 'Bug created'); @@ -214,193 +233,216 @@ _check_product('Legal'); _check_component('Legal', 'Contract Request'); _check_group('mozilla-employee-confidential'); -$sel->open_ok("/$config->{bugzilla_installation}/enter_bug.cgi?product=Legal&format=legal"); +$sel->open_ok( + "/$config->{bugzilla_installation}/enter_bug.cgi?product=Legal&format=legal"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->title_is("Mozilla Corporation Legal Requests", "Open custom bug entry form - legal"); +$sel->title_is("Mozilla Corporation Legal Requests", + "Open custom bug entry form - legal"); $sel->select_ok("component", "value=Contract Request", "Select request type"); -$sel->select_ok("business_unit", "value=Connected Devices", "Select business unit"); +$sel->select_ok( + "business_unit", + "value=Connected Devices", + "Select business unit" +); $sel->type_ok("short_desc", "Bug created by Selenium", "Enter request summary"); $sel->type_ok("cc", $config->{'unprivileged_user_login'}, "Enter cc address"); $sel->type_ok("important_dates", "Important dates", "Enter important dates"); -$sel->type_ok("comment", "--- Bug created by Selenium ---", "Enter request description"); +$sel->type_ok( + "comment", + "--- Bug created by Selenium ---", + "Enter request description" +); $sel->click_ok("commit", undef, "Submit bug data to post_bug.cgi"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok('has been added to the database', 'Bug created'); my $legal_bug_id = $sel->get_value('//input[@name="id" and @type="hidden"]'); -set_parameters($sel, { "Bug Fields" => {"useclassification-on" => undef} }); +set_parameters($sel, {"Bug Fields" => {"useclassification-on" => undef}}); logout($sel); sub _check_product { - my ($product, $version) = @_; - - go_to_admin($sel); - $sel->click_ok("link=Products"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Select product"); - - my $product_description = "$product Description"; - - my $text = trim($sel->get_text("bugzilla-body")); - if ($text =~ /$product_description/) { - # Product exists already - return 1; - } - - $sel->click_ok("link=Add"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Add Product"); - $sel->type_ok("product", $product); - $sel->type_ok("description", $product_description); - $sel->type_ok("version", $version) if $version; - $sel->select_ok("security_group_id", "label=core-security"); - $sel->select_ok("default_op_sys_id", "Unspecified"); - $sel->select_ok("default_platform_id", "Unspecified"); - $sel->click_ok('//input[@type="submit" and @value="Add"]'); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $text = trim($sel->get_text("message")); - ok($text =~ /You will need to add at least one component before anyone can enter bugs against this product/, - "Display a reminder about missing components"); + my ($product, $version) = @_; + go_to_admin($sel); + $sel->click_ok("link=Products"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Select product"); + + my $product_description = "$product Description"; + + my $text = trim($sel->get_text("bugzilla-body")); + if ($text =~ /$product_description/) { + + # Product exists already return 1; + } + + $sel->click_ok("link=Add"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Add Product"); + $sel->type_ok("product", $product); + $sel->type_ok("description", $product_description); + $sel->type_ok("version", $version) if $version; + $sel->select_ok("security_group_id", "label=core-security"); + $sel->select_ok("default_op_sys_id", "Unspecified"); + $sel->select_ok("default_platform_id", "Unspecified"); + $sel->click_ok('//input[@type="submit" and @value="Add"]'); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $text = trim($sel->get_text("message")); + ok( + $text + =~ /You will need to add at least one component before anyone can enter bugs against this product/, + "Display a reminder about missing components" + ); + + return 1; } sub _check_component { - my ($product, $component) = @_; - - go_to_admin($sel); - $sel->click_ok("link=components"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Edit components for which product?"); - - $sel->click_ok("//*[\@id='bugzilla-body']//a[normalize-space(text())='$product']"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Select component of product '$product'"); - - my $component_description = "$component Description"; - - my $text = trim($sel->get_text("bugzilla-body")); - if ($text =~ /$component_description/) { - # Component exists already - return 1; - } - - # Add the watch user for component watching - my $watch_user = lc $component . "@" . lc $product . ".bugs"; - $watch_user =~ s/ & /-/; - $watch_user =~ s/\s+/\-/g; - $watch_user =~ s/://g; - - go_to_admin($sel); - $sel->click_ok("link=components"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Edit components for which product?"); - $sel->click_ok("//*[\@id='bugzilla-body']//a[normalize-space(text())='$product']"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Select component of product '$product'"); - $sel->click_ok("link=Add"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Add component to the $product product"); - $sel->type_ok("component", $component); - $sel->type_ok("description", $component_description); - $sel->type_ok("initialowner", $config->{'admin_user_login'}); - $sel->uncheck_ok("watch_user_auto"); - $sel->type_ok("watch_user", $watch_user); - $sel->check_ok("watch_user_auto"); - $sel->click_ok('//input[@type="submit" and @value="Add"]'); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Component Created"); - $text = trim($sel->get_text("message")); - ok($text eq "The component $component has been created.", "Component successfully created"); + my ($product, $component) = @_; + + go_to_admin($sel); + $sel->click_ok("link=components"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Edit components for which product?"); + $sel->click_ok( + "//*[\@id='bugzilla-body']//a[normalize-space(text())='$product']"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Select component of product '$product'"); + + my $component_description = "$component Description"; + + my $text = trim($sel->get_text("bugzilla-body")); + if ($text =~ /$component_description/) { + + # Component exists already return 1; + } + + # Add the watch user for component watching + my $watch_user = lc $component . "@" . lc $product . ".bugs"; + $watch_user =~ s/ & /-/; + $watch_user =~ s/\s+/\-/g; + $watch_user =~ s/://g; + + go_to_admin($sel); + $sel->click_ok("link=components"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Edit components for which product?"); + $sel->click_ok( + "//*[\@id='bugzilla-body']//a[normalize-space(text())='$product']"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Select component of product '$product'"); + $sel->click_ok("link=Add"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Add component to the $product product"); + $sel->type_ok("component", $component); + $sel->type_ok("description", $component_description); + $sel->type_ok("initialowner", $config->{'admin_user_login'}); + $sel->uncheck_ok("watch_user_auto"); + $sel->type_ok("watch_user", $watch_user); + $sel->check_ok("watch_user_auto"); + $sel->click_ok('//input[@type="submit" and @value="Add"]'); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Component Created"); + $text = trim($sel->get_text("message")); + ok($text eq "The component $component has been created.", + "Component successfully created"); + + return 1; } sub _check_group { - my ($group) = @_; - - go_to_admin($sel); - $sel->click_ok("link=Groups"); - $sel->wait_for_page_to_load(WAIT_TIME); - $sel->title_is("Edit Groups"); - - my $group_description = "$group Description"; - - my $text = trim($sel->get_text("bugzilla-body")); - if ($text =~ /$group_description/) { - # Group exists already - return 1; - } - - $sel->title_is("Edit Groups"); - $sel->click_ok("link=Add Group"); - $sel->wait_for_page_to_load(WAIT_TIME); - $sel->title_is("Add group"); - $sel->type_ok("name", $group); - $sel->type_ok("desc", $group_description); - $sel->type_ok("owner", $config->{'admin_user_login'}); - $sel->check_ok("isactive"); - $sel->check_ok("insertnew"); - $sel->click_ok("create"); - $sel->wait_for_page_to_load(WAIT_TIME); - $sel->title_is("New Group Created"); - my $group_id = $sel->get_value("group_id"); + my ($group) = @_; + + go_to_admin($sel); + $sel->click_ok("link=Groups"); + $sel->wait_for_page_to_load(WAIT_TIME); + $sel->title_is("Edit Groups"); + my $group_description = "$group Description"; + + my $text = trim($sel->get_text("bugzilla-body")); + if ($text =~ /$group_description/) { + + # Group exists already return 1; + } + + $sel->title_is("Edit Groups"); + $sel->click_ok("link=Add Group"); + $sel->wait_for_page_to_load(WAIT_TIME); + $sel->title_is("Add group"); + $sel->type_ok("name", $group); + $sel->type_ok("desc", $group_description); + $sel->type_ok("owner", $config->{'admin_user_login'}); + $sel->check_ok("isactive"); + $sel->check_ok("insertnew"); + $sel->click_ok("create"); + $sel->wait_for_page_to_load(WAIT_TIME); + $sel->title_is("New Group Created"); + my $group_id = $sel->get_value("group_id"); + + return 1; } sub _check_version { - my ($product, $version) = @_; - - go_to_admin($sel); - $sel->click_ok("link=versions"); - $sel->wait_for_page_to_load(WAIT_TIME); - $sel->title_is("Edit versions for which product?"); - $sel->click_ok("//*[\@id='bugzilla-body']//a[normalize-space(text())='$product']"); - $sel->wait_for_page_to_load(WAIT_TIME); - - my $text = trim($sel->get_text("bugzilla-body")); - if ($text =~ /$version/) { - # Version exists already - return 1; - } - - $sel->click_ok("link=Add"); - $sel->wait_for_page_to_load(WAIT_TIME); - $sel->title_like(qr/^Add Version to Product/); - $sel->type_ok("version", $version); - $sel->click_ok("create"); - $sel->wait_for_page_to_load(WAIT_TIME); - $sel->title_is("Version Created"); + my ($product, $version) = @_; + + go_to_admin($sel); + $sel->click_ok("link=versions"); + $sel->wait_for_page_to_load(WAIT_TIME); + $sel->title_is("Edit versions for which product?"); + $sel->click_ok( + "//*[\@id='bugzilla-body']//a[normalize-space(text())='$product']"); + $sel->wait_for_page_to_load(WAIT_TIME); + + my $text = trim($sel->get_text("bugzilla-body")); + if ($text =~ /$version/) { + # Version exists already return 1; + } + + $sel->click_ok("link=Add"); + $sel->wait_for_page_to_load(WAIT_TIME); + $sel->title_like(qr/^Add Version to Product/); + $sel->type_ok("version", $version); + $sel->click_ok("create"); + $sel->wait_for_page_to_load(WAIT_TIME); + $sel->title_is("Version Created"); + + return 1; } sub _check_user { - my ($user) = @_; - - go_to_admin($sel); - $sel->click_ok("link=Users"); - $sel->wait_for_page_to_load(WAIT_TIME); - $sel->title_is("Search users"); - $sel->type_ok("matchstr", $user); - $sel->click_ok("search"); - $sel->wait_for_page_to_load(WAIT_TIME); - - my $text = trim($sel->get_text("bugzilla-body")); - if ($text =~ /$user/) { - # User exists already - return 1; - } - - $sel->click_ok("link=add a new user"); - $sel->wait_for_page_to_load(WAIT_TIME); - $sel->title_is('Add user'); - $sel->type_ok('login', $user); - $sel->type_ok('password', 'icohF1io2ohw'); - $sel->click_ok("add"); - $sel->wait_for_page_to_load(WAIT_TIME); - $sel->is_text_present('regexp:The user account .* has been created successfully'); + my ($user) = @_; + + go_to_admin($sel); + $sel->click_ok("link=Users"); + $sel->wait_for_page_to_load(WAIT_TIME); + $sel->title_is("Search users"); + $sel->type_ok("matchstr", $user); + $sel->click_ok("search"); + $sel->wait_for_page_to_load(WAIT_TIME); + + my $text = trim($sel->get_text("bugzilla-body")); + if ($text =~ /$user/) { + # User exists already return 1; + } + + $sel->click_ok("link=add a new user"); + $sel->wait_for_page_to_load(WAIT_TIME); + $sel->title_is('Add user'); + $sel->type_ok('login', $user); + $sel->type_ok('password', 'icohF1io2ohw'); + $sel->click_ok("add"); + $sel->wait_for_page_to_load(WAIT_TIME); + $sel->is_text_present( + 'regexp:The user account .* has been created successfully'); + + return 1; } diff --git a/qa/t/test_bmo_retire_values.t b/qa/t/test_bmo_retire_values.t index 5fbcb045a..14a5f5646 100644 --- a/qa/t/test_bmo_retire_values.t +++ b/qa/t/test_bmo_retire_values.t @@ -19,21 +19,26 @@ my ($text, $bug_id); my $admin_user_login = $config->{admin_user_login}; log_in($sel, $config, 'admin'); -set_parameters($sel, { "Bug Fields" => {"useclassification-off" => undef, - "usetargetmilestone-on" => undef}, - "Administrative Policies" => {"allowbugdeletion-on" => undef}, - }); +set_parameters( + $sel, + { + "Bug Fields" => + {"useclassification-off" => undef, "usetargetmilestone-on" => undef}, + "Administrative Policies" => {"allowbugdeletion-on" => undef}, + } +); # create a clean bug file_bug_in_product($sel, "TestProduct"); $sel->select_ok("component", "label=TestComponent"); $sel->type_ok("short_desc", "testing testComponent"); -$sel->type_ok("comment", "testing"); +$sel->type_ok("comment", "testing"); $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); my $clean_bug_id = $sel->get_value("//input[\@name='id' and \@type='hidden']"); -$sel->is_text_present_ok('has been added to the database', "Bug $clean_bug_id created"); +$sel->is_text_present_ok('has been added to the database', + "Bug $clean_bug_id created"); # # component @@ -51,19 +56,22 @@ $sel->click_ok("link=Edit components:"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Select component of product 'TestProduct'"); $text = trim($sel->get_text("bugzilla-body")); + if ($text =~ /TempComponent/) { - $sel->click_ok("//a[contains(\@href, '/editcomponents.cgi?action=del&product=TestProduct&component=TempComponent')]"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Delete component 'TempComponent' from 'TestProduct' product"); - $sel->click_ok("delete"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Component Deleted"); + $sel->click_ok( + "//a[contains(\@href, '/editcomponents.cgi?action=del&product=TestProduct&component=TempComponent')]" + ); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Delete component 'TempComponent' from 'TestProduct' product"); + $sel->click_ok("delete"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Component Deleted"); } $sel->click_ok("link=Add"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Add component to the TestProduct product"); -$sel->type_ok("component", "TempComponent"); -$sel->type_ok("description", "Temp component"); +$sel->type_ok("component", "TempComponent"); +$sel->type_ok("description", "Temp component"); $sel->type_ok("initialowner", $admin_user_login); $sel->uncheck_ok("watch_user_auto"); $sel->type_ok("watch_user", 'tempcomponent@testproduct.bugs'); @@ -77,11 +85,12 @@ $sel->title_is("Component Created"); file_bug_in_product($sel, "TestProduct"); $sel->select_ok("component", "label=TempComponent"); $sel->type_ok("short_desc", "testing tempComponent"); -$sel->type_ok("comment", "testing"); +$sel->type_ok("comment", "testing"); $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $bug_id = $sel->get_value("//input[\@name='id' and \@type='hidden']"); -$sel->is_text_present_ok('has been added to the database', "Bug $bug_id created"); +$sel->is_text_present_ok('has been added to the database', + "Bug $bug_id created"); # disable TestProduct:TestComponent for bug entry @@ -108,30 +117,37 @@ ok($text =~ /Disabled for bugs/, "Component deactivation confirmed"); # update bug TempComponent bug go_to_bug($sel, $bug_id); + # make sure the component is still tempcomponent $sel->selected_label_is("component", 'TempComponent'); + # update $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok("Changes submitted for bug $bug_id"); $sel->click_ok("link=bug $bug_id"); $sel->wait_for_page_to_load_ok(WAIT_TIME); + # make sure the component is still tempcomponent ok($sel->get_selected_labels("component"), 'TempComponent'); # try creating new bug with TempComponent file_bug_in_product($sel, "TestProduct"); -ok(!$sel->is_element_present( +ok( + !$sel->is_element_present( q#//select[@id='component']/option[@value='TempComponent']#), - 'TempComponent is missing from create'); + 'TempComponent is missing from create' +); # try changing compoent of existing bug to TempComponent go_to_bug($sel, $clean_bug_id); -ok(!$sel->is_element_present( +ok( + !$sel->is_element_present( q#//select[@id='component']/option[@value='TempComponent']#), - 'TempComponent is missing from update'); + 'TempComponent is missing from update' +); # delete TempComponent @@ -144,7 +160,9 @@ $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Edit Product 'TestProduct'"); $sel->click_ok("link=Edit components:"); $sel->wait_for_page_to_load_ok(WAIT_TIME); -$sel->click_ok("//a[contains(\@href, '/editcomponents.cgi?action=del&product=TestProduct&component=TempComponent')]"); +$sel->click_ok( + "//a[contains(\@href, '/editcomponents.cgi?action=del&product=TestProduct&component=TempComponent')]" +); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Delete component 'TempComponent' from 'TestProduct' product"); $sel->click_ok("delete"); @@ -168,13 +186,16 @@ $sel->click_ok("link=Edit versions:"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Select version of product 'TestProduct'"); $text = trim($sel->get_text("bugzilla-body")); + if ($text =~ /TempVersion/) { - $sel->click_ok("//a[contains(\@href, '/editversions.cgi?action=del&product=TestProduct&version=TempVersion')]"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Delete Version of Product 'TestProduct'"); - $sel->click_ok("delete"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Version Deleted"); + $sel->click_ok( + "//a[contains(\@href, '/editversions.cgi?action=del&product=TestProduct&version=TempVersion')]" + ); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Delete Version of Product 'TestProduct'"); + $sel->click_ok("delete"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Version Deleted"); } $sel->click_ok("link=Add"); $sel->wait_for_page_to_load_ok(WAIT_TIME); @@ -189,11 +210,12 @@ $sel->title_is("Version Created"); file_bug_in_product($sel, "TestProduct"); $sel->select_ok("version", "label=TempVersion"); $sel->type_ok("short_desc", "testing tempVersion"); -$sel->type_ok("comment", "testing"); +$sel->type_ok("comment", "testing"); $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $bug_id = $sel->get_value("//input[\@name='id' and \@type='hidden']"); -$sel->is_text_present_ok('has been added to the database', "Bug $bug_id created"); +$sel->is_text_present_ok('has been added to the database', + "Bug $bug_id created"); # disable new version for bug entry @@ -220,16 +242,20 @@ ok($text =~ /Disabled for bugs/, "Version deactivation confirmed"); # update new version bug go_to_bug($sel, $bug_id); + # make sure the version is still tempversion $sel->selected_label_is("version", 'TempVersion'); + # update $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok("Changes submitted for bug $bug_id"); $sel->click_ok("link=bug $bug_id"); $sel->wait_for_page_to_load_ok(WAIT_TIME); + # make sure the version is still tempversion $sel->selected_label_is("version", 'TempVersion'); + # change the version so it can be deleted $sel->select_ok("version", "label=unspecified"); $sel->click_ok("commit"); @@ -239,16 +265,20 @@ $sel->is_text_present_ok("Changes submitted for bug $bug_id"); # try creating new bug with new version file_bug_in_product($sel, "TestProduct"); -ok(!$sel->is_element_present( +ok( + !$sel->is_element_present( q#//select[@id='version']/option[@value='TempVersion']#), - 'TempVersion is missing from create'); + 'TempVersion is missing from create' +); # try changing existing bug to new version go_to_bug($sel, $clean_bug_id); -ok(!$sel->is_element_present( +ok( + !$sel->is_element_present( q#//select[@id='version']/option[@value='TempVersion']#), - 'TempVersion is missing from update'); + 'TempVersion is missing from update' +); # delete new version @@ -263,7 +293,9 @@ $sel->click_ok("link=Edit versions:"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Select version of product 'TestProduct'"); $text = trim($sel->get_text("bugzilla-body")); -$sel->click_ok("//a[contains(\@href, '/editversions.cgi?action=del&product=TestProduct&version=TempVersion')]"); +$sel->click_ok( + "//a[contains(\@href, '/editversions.cgi?action=del&product=TestProduct&version=TempVersion')]" +); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Delete Version of Product 'TestProduct'"); $sel->click_ok("delete"); @@ -287,19 +319,22 @@ $sel->click_ok("link=Edit milestones:"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Select milestone of product 'TestProduct'"); $text = trim($sel->get_text("bugzilla-body")); + if ($text =~ /TempMilestone/) { - $sel->click_ok("//a[contains(\@href, '/editmilestones.cgi?action=del&product=TestProduct&milestone=TempMilestone')]"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Delete Milestone of Product 'TestProduct'"); - $sel->click_ok("delete"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Milestone Deleted"); + $sel->click_ok( + "//a[contains(\@href, '/editmilestones.cgi?action=del&product=TestProduct&milestone=TempMilestone')]" + ); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Delete Milestone of Product 'TestProduct'"); + $sel->click_ok("delete"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Milestone Deleted"); } $sel->click_ok("link=Add"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Add Milestone to Product 'TestProduct'"); $sel->type_ok("milestone", "TempMilestone"); -$sel->type_ok("sortkey", "999"); +$sel->type_ok("sortkey", "999"); $sel->click_ok("create"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Milestone Created"); @@ -309,11 +344,12 @@ $sel->title_is("Milestone Created"); file_bug_in_product($sel, "TestProduct"); $sel->select_ok("target_milestone", "label=TempMilestone"); $sel->type_ok("short_desc", "testing tempMilestone"); -$sel->type_ok("comment", "testing"); +$sel->type_ok("comment", "testing"); $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $bug_id = $sel->get_value("//input[\@name='id' and \@type='hidden']"); -$sel->is_text_present_ok('has been added to the database', "Bug $bug_id created"); +$sel->is_text_present_ok('has been added to the database', + "Bug $bug_id created"); # disable milestone for bug entry @@ -340,30 +376,37 @@ ok($text =~ /Disabled for bugs/, "Milestone deactivation confirmed"); # update milestone bug go_to_bug($sel, $bug_id); + # make sure the milestone is still tempmilestone $sel->selected_label_is("target_milestone", 'TempMilestone'); + # update $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->is_text_present_ok("Changes submitted for bug $bug_id"); $sel->click_ok("link=bug $bug_id"); $sel->wait_for_page_to_load_ok(WAIT_TIME); + # make sure the milestone is still tempmilestone $sel->selected_label_is("target_milestone", 'TempMilestone'); # try creating new bug with milestone file_bug_in_product($sel, "TestProduct"); -ok(!$sel->is_element_present( +ok( + !$sel->is_element_present( q#//select[@id='target_milestone']/option[@value='TempMilestone']#), - 'TempMilestone is missing from create'); + 'TempMilestone is missing from create' +); # try changing existing bug to milestone go_to_bug($sel, $clean_bug_id); -ok(!$sel->is_element_present( +ok( + !$sel->is_element_present( q#//select[@id='target_milestone']/option[@value='TempMilestone']#), - 'TempMilestone is missing from update'); + 'TempMilestone is missing from update' +); # delete milestone @@ -378,7 +421,9 @@ $sel->click_ok("link=Edit milestones:"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Select milestone of product 'TestProduct'"); $text = trim($sel->get_text("bugzilla-body")); -$sel->click_ok("//a[contains(\@href, '/editmilestones.cgi?action=del&product=TestProduct&milestone=TempMilestone')]"); +$sel->click_ok( + "//a[contains(\@href, '/editmilestones.cgi?action=del&product=TestProduct&milestone=TempMilestone')]" +); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Delete Milestone of Product 'TestProduct'"); $sel->click_ok("delete"); diff --git a/qa/t/test_bug_edit.t b/qa/t/test_bug_edit.t index 3eccd5d04..bb78dcce7 100644 --- a/qa/t/test_bug_edit.t +++ b/qa/t/test_bug_edit.t @@ -16,17 +16,17 @@ use QA::Util; my ($sel, $config) = get_selenium(); log_in($sel, $config, 'admin'); -set_parameters($sel, { "Bug Fields" => {"usestatuswhiteboard-on" => undef} }); +set_parameters($sel, {"Bug Fields" => {"usestatuswhiteboard-on" => undef}}); # Clear the saved search, in case this test didn't complete previously. if ($sel->is_text_present("My bugs from QA_Selenium")) { - $sel->click_ok("link=My bugs from QA_Selenium"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Bug List: My bugs from QA_Selenium"); - $sel->click_ok("link=Forget Search 'My bugs from QA_Selenium'"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Search is gone"); - $sel->is_text_present_ok("OK, the My bugs from QA_Selenium search is gone"); + $sel->click_ok("link=My bugs from QA_Selenium"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Bug List: My bugs from QA_Selenium"); + $sel->click_ok("link=Forget Search 'My bugs from QA_Selenium'"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Search is gone"); + $sel->is_text_present_ok("OK, the My bugs from QA_Selenium search is gone"); } # Just in case the test failed before completion previously, reset the CANEDIT bit. @@ -35,7 +35,8 @@ $sel->click_ok("link=Groups"); check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/editgroups.cgi}); $sel->title_is("Edit Groups"); $sel->click_ok("link=Master"); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/editgroups.cgi?action=changeform&group=25}); +check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/editgroups.cgi?action=changeform&group=25}); $sel->title_is("Change Group: Master"); my $group_url = $sel->get_location(); $group_url =~ /group=(\d+)$/; @@ -50,30 +51,34 @@ log_in($sel, $config, 'QA_Selenium_TEST'); file_bug_in_product($sel, 'TestProduct'); $sel->select_ok("bug_severity", "label=critical"); $sel->type_ok("short_desc", "Test bug editing"); -$sel->type_ok("comment", "ploc"); +$sel->type_ok("comment", "ploc"); $sel->click_ok("commit"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=__BUG_ID__}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=__BUG_ID__}); my $bug1_id = $sel->get_value('//input[@name="id" and @type="hidden"]'); -$sel->is_text_present_ok('has been added to the database', "Bug $bug1_id created"); +$sel->is_text_present_ok('has been added to the database', + "Bug $bug1_id created"); # Now edit field values of the bug you just filed. $sel->select_ok("rep_platform", "label=Other"); -$sel->select_ok("op_sys", "label=Other"); -$sel->select_ok("priority", "label=Highest"); +$sel->select_ok("op_sys", "label=Other"); +$sel->select_ok("priority", "label=Highest"); $sel->select_ok("bug_severity", "label=blocker"); -$sel->type_ok("bug_file_loc", "foo.cgi?action=bar"); +$sel->type_ok("bug_file_loc", "foo.cgi?action=bar"); $sel->type_ok("status_whiteboard", "[Selenium was here]"); -$sel->type_ok("comment", "new comment from me :)"); +$sel->type_ok("comment", "new comment from me :)"); $sel->select_ok("bug_status", "label=RESOLVED"); $sel->click_ok("commit"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); # Now move the bug into another product, which has a mandatory group. $sel->click_ok("link=bug $bug1_id"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->title_like(qr/^$bug1_id /); $sel->select_ok("product", "label=QA-Selenium-TEST"); $sel->type_ok("comment", "moving to QA-Selenium-TEST"); @@ -81,34 +86,49 @@ $sel->click_ok("commit"); check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi}); $sel->title_is("Verify New Product Details..."); $sel->select_ok("component", "label=QA-Selenium-TEST"); -$sel->is_element_present_ok('//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'); -ok(!$sel->is_editable('//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'), "QA-Selenium-TEST group not editable"); -$sel->is_checked_ok('//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]', "QA-Selenium-TEST group is selected"); +$sel->is_element_present_ok( + '//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'); +ok( + !$sel->is_editable( + '//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'), + "QA-Selenium-TEST group not editable" +); +$sel->is_checked_ok( + '//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]', + "QA-Selenium-TEST group is selected"); $sel->click_ok("change_product"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); $sel->click_ok("link=bug $bug1_id"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->title_like(qr/^$bug1_id /); $sel->select_ok("bug_severity", "label=normal"); -$sel->select_ok("priority", "label=High"); +$sel->select_ok("priority", "label=High"); $sel->select_ok("rep_platform", "label=All"); -$sel->select_ok("op_sys", "label=All"); +$sel->select_ok("op_sys", "label=All"); $sel->click_ok("cc_edit_area_showhide"); -$sel->type_ok("newcc", $config->{admin_user_login}); +$sel->type_ok("newcc", $config->{admin_user_login}); $sel->type_ok("comment", "Unchecking the reporter_accessible checkbox"); + # This checkbox is checked by default. $sel->click_ok("reporter_accessible"); $sel->select_ok("bug_status", "label=VERIFIED"); $sel->click_ok("commit"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); $sel->click_ok("link=bug $bug1_id"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->title_like(qr/^$bug1_id /); -$sel->type_ok("comment", "I am the reporter, but I can see the bug anyway as I belong to the mandatory group"); +$sel->type_ok("comment", + "I am the reporter, but I can see the bug anyway as I belong to the mandatory group" +); $sel->click_ok("commit"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); logout($sel); @@ -118,23 +138,26 @@ logout($sel); log_in($sel, $config, 'admin'); go_to_bug($sel, $bug1_id); $sel->select_ok("bug_severity", "label=blocker"); -$sel->select_ok("priority", "label=Highest"); +$sel->select_ok("priority", "label=Highest"); $sel->type_ok("status_whiteboard", "[Selenium was here][admin too]"); $sel->select_ok("bug_status", "label=CONFIRMED"); $sel->click_ok("bz_assignee_edit_action"); $sel->type_ok("assigned_to", $config->{admin_user_login}); -$sel->type_ok("comment", "I have editbugs privs. Taking!"); +$sel->type_ok("comment", "I have editbugs privs. Taking!"); $sel->click_ok("commit"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); $sel->click_ok("link=bug $bug1_id"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->title_like(qr/^$bug1_id /); $sel->click_ok("cc_edit_area_showhide"); $sel->type_ok("newcc", $config->{unprivileged_user_login}); $sel->click_ok("commit"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); logout($sel); @@ -151,9 +174,12 @@ logout($sel); log_in($sel, $config, 'admin'); go_to_bug($sel, $bug1_id); $sel->click_ok("cclist_accessible"); -$sel->type_ok("comment", "I am allowed to turn off cclist_accessible despite not being in the mandatory group"); +$sel->type_ok("comment", + "I am allowed to turn off cclist_accessible despite not being in the mandatory group" +); $sel->click_ok("commit"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); logout($sel); @@ -162,7 +188,8 @@ logout($sel); log_in($sel, $config, 'unprivileged'); $sel->type_ok("quicksearch_top", $bug1_id); $sel->submit("header-search"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->title_is("Access Denied"); $sel->is_text_present_ok("You are not authorized to access bug $bug1_id"); logout($sel); @@ -172,6 +199,7 @@ logout($sel); log_in($sel, $config, 'admin'); go_to_bug($sel, $bug1_id); $sel->select_ok("product", "label=TestProduct"); + # When selecting a new product, Bugzilla tries to reassign the bug by default, # so we have to uncheck it. $sel->click_ok("set_default_assignee"); @@ -181,23 +209,46 @@ $sel->click_ok("commit"); check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi}); $sel->title_is("Verify New Product Details..."); $sel->select_ok("component", "label=TestComponent"); -$sel->is_text_present_ok("These groups are not legal for the 'TestProduct' product or you are not allowed to restrict bugs to these groups"); -$sel->is_element_present_ok('//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'); -ok(!$sel->is_editable('//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'), "QA-Selenium-TEST group not editable"); -ok(!$sel->is_checked('//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'), "QA-Selenium-TEST group not selected"); -$sel->is_element_present_ok('//input[@type="checkbox" and @name="groups" and @value="Master"]'); -$sel->is_editable_ok('//input[@type="checkbox" and @name="groups" and @value="Master"]', "Master group is editable"); -ok(!$sel->is_checked('//input[@type="checkbox" and @name="groups" and @value="Master"]'), "Master group not selected by default"); +$sel->is_text_present_ok( + "These groups are not legal for the 'TestProduct' product or you are not allowed to restrict bugs to these groups" +); +$sel->is_element_present_ok( + '//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'); +ok( + !$sel->is_editable( + '//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'), + "QA-Selenium-TEST group not editable" +); +ok( + !$sel->is_checked( + '//input[@type="checkbox" and @name="groups" and @value="QA-Selenium-TEST"]'), + "QA-Selenium-TEST group not selected" +); +$sel->is_element_present_ok( + '//input[@type="checkbox" and @name="groups" and @value="Master"]'); +$sel->is_editable_ok( + '//input[@type="checkbox" and @name="groups" and @value="Master"]', + "Master group is editable"); +ok( + !$sel->is_checked( + '//input[@type="checkbox" and @name="groups" and @value="Master"]'), + "Master group not selected by default" +); $sel->click_ok("change_product"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); $sel->click_ok("link=bug $bug1_id"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->title_like(qr/^$bug1_id /); $sel->click_ok("cclist_accessible"); -$sel->type_ok("comment", "I am allowed to turn off cclist_accessible despite not being in the mandatory group"); +$sel->type_ok("comment", + "I am allowed to turn off cclist_accessible despite not being in the mandatory group" +); $sel->click_ok("commit"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); logout($sel); @@ -206,17 +257,24 @@ logout($sel); log_in($sel, $config, 'unprivileged'); go_to_bug($sel, $bug1_id); -$sel->type_ok("comment", "I have no privs, I can only comment (and remove people from the CC list)"); -ok(!$sel->is_element_present('//select[@name="product"]'), "Product field not editable"); -ok(!$sel->is_element_present('//select[@name="bug_severity"]'), "Severity field not editable"); -ok(!$sel->is_element_present('//select[@name="priority"]'), "Priority field not editable"); -ok(!$sel->is_element_present('//select[@name="op_sys"]'), "OS field not editable"); -ok(!$sel->is_element_present('//select[@name="rep_platform"]'), "Hardware field not editable"); +$sel->type_ok("comment", + "I have no privs, I can only comment (and remove people from the CC list)"); +ok(!$sel->is_element_present('//select[@name="product"]'), + "Product field not editable"); +ok(!$sel->is_element_present('//select[@name="bug_severity"]'), + "Severity field not editable"); +ok(!$sel->is_element_present('//select[@name="priority"]'), + "Priority field not editable"); +ok(!$sel->is_element_present('//select[@name="op_sys"]'), + "OS field not editable"); +ok(!$sel->is_element_present('//select[@name="rep_platform"]'), + "Hardware field not editable"); $sel->click_ok("cc_edit_area_showhide"); $sel->add_selection_ok("cc", "label=" . $config->{admin_user_login}); $sel->click_ok("removecc"); $sel->click_ok("commit"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); logout($sel); @@ -225,7 +283,9 @@ logout($sel); log_in($sel, $config, 'admin'); edit_product($sel, "TestProduct"); $sel->click_ok("link=Edit Group Access Controls:"); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/editproducts.cgi?action=editgroupcontrols&product=TestProduct}); +check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/editproducts.cgi?action=editgroupcontrols&product=TestProduct} +); $sel->title_is("Edit Group Controls for TestProduct"); $sel->check_ok("canedit_$master_gid"); $sel->click_ok("submit"); @@ -237,7 +297,8 @@ $sel->title_is("Update group access controls for TestProduct"); go_to_bug($sel, $bug1_id); $sel->type_ok("comment", "Do nothing except adding a comment..."); $sel->click_ok("commit"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); logout($sel); @@ -249,7 +310,8 @@ $sel->type_ok("comment", "Just a comment too..."); $sel->click_ok("commit"); check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi}); $sel->title_is("Product Edit Access Denied"); -$sel->is_text_present_ok("You are not permitted to edit bugs in product TestProduct."); +$sel->is_text_present_ok( + "You are not permitted to edit bugs in product TestProduct."); logout($sel); # Test searches and "format for printing". @@ -272,24 +334,32 @@ $sel->select_ok("emailtype2", "label=is"); $sel->type_ok("email2", $config->{QA_Selenium_TEST_user_login}); screenshot_page($sel, '/app/artifacts/line271.png'); $sel->click_ok("Search"); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?emailreporter2=1&emailtype2=exact&order=Importance&list_id=15&emailtype1=exact&emailcc2=1&query_format=advanced&emailassigned_to1=1&emailqa_contact2=1&email2=QA-Selenium-TEST%40mozilla.test&email1=admin%40mozilla.test&emailassigned_to2=1&product=TestProduct}); +check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/buglist.cgi?emailreporter2=1&emailtype2=exact&order=Importance&list_id=15&emailtype1=exact&emailcc2=1&query_format=advanced&emailassigned_to1=1&emailqa_contact2=1&email2=QA-Selenium-TEST%40mozilla.test&email1=admin%40mozilla.test&emailassigned_to2=1&product=TestProduct} +); $sel->title_is("Bug List"); screenshot_page($sel, '/app/artifacts/line275.png'); $sel->is_text_present_ok("One bug found."); $sel->type_ok("save_newqueryname", "My bugs from QA_Selenium"); $sel->click_ok("remember"); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?newquery=email1%3Dadmin%2540mozilla.test%26email2%3DQA-Selenium-TEST%2540mozilla.test%26emailassigned_to1%3D1%26emailassigned_to2%3D1%26emailcc2%3D1%26emailqa_contact2%3D1%26emailreporter2%3D1%26emailtype1%3Dexact%26emailtype2%3Dexact%26list_id%3D15%26product%3DTestProduct%26query_format%3Dadvanced%26order%3Dpriority%252Cbug_severity&cmdtype=doit&remtype=asnamed&token=1531926552-dc69995d79c786af046436ec6717000b&newqueryname=My%20bugs%20from%20QA_Selenium&list_id=16}); +check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/buglist.cgi?newquery=email1%3Dadmin%2540mozilla.test%26email2%3DQA-Selenium-TEST%2540mozilla.test%26emailassigned_to1%3D1%26emailassigned_to2%3D1%26emailcc2%3D1%26emailqa_contact2%3D1%26emailreporter2%3D1%26emailtype1%3Dexact%26emailtype2%3Dexact%26list_id%3D15%26product%3DTestProduct%26query_format%3Dadvanced%26order%3Dpriority%252Cbug_severity&cmdtype=doit&remtype=asnamed&token=1531926552-dc69995d79c786af046436ec6717000b&newqueryname=My%20bugs%20from%20QA_Selenium&list_id=16} +); $sel->title_is("Search created"); -$sel->is_text_present_ok("OK, you have a new search named My bugs from QA_Selenium."); +$sel->is_text_present_ok( + "OK, you have a new search named My bugs from QA_Selenium."); $sel->click_ok("link=My bugs from QA_Selenium"); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=17}); +check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=17} +); $sel->title_is("Bug List: My bugs from QA_Selenium"); $sel->click_ok("long_format"); check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/show_bug.cgi}); $sel->title_is("Full Text Bug Listing"); $sel->is_text_present_ok("Bug $bug1_id"); $sel->is_text_present_ok("Status: CONFIRMED"); -$sel->is_text_present_ok("Reporter: QA-Selenium-TEST <$config->{QA_Selenium_TEST_user_login}>"); +$sel->is_text_present_ok( + "Reporter: QA-Selenium-TEST <$config->{QA_Selenium_TEST_user_login}>"); $sel->is_text_present_ok("Assignee: QA Admin <$config->{admin_user_login}>"); $sel->is_text_present_ok("Severity: blocker"); $sel->is_text_present_ok("Priority: Highest"); @@ -303,30 +373,37 @@ log_in($sel, $config, 'QA_Selenium_TEST'); file_bug_in_product($sel, 'TestProduct'); $sel->select_ok("bug_severity", "label=blocker"); $sel->type_ok("short_desc", "New bug from me"); + # We turned on the CANEDIT bit for TestProduct. $sel->type_ok("comment", "I can enter a new bug, but not edit it, right?"); $sel->click_ok("commit"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=__BUG_ID__}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=__BUG_ID__}); my $bug2_id = $sel->get_value('//input[@name="id" and @type="hidden"]'); -$sel->is_text_present_ok('has been added to the database', "Bug $bug2_id created"); +$sel->is_text_present_ok('has been added to the database', + "Bug $bug2_id created"); # Clicking the "Back" button and resubmitting the form again should trigger a suspicous action error. $sel->go_back_ok(); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/enter_bug.cgi?product=TestProduct&format=__default__}); +check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/enter_bug.cgi?product=TestProduct&format=__default__} +); $sel->title_is("Enter Bug: TestProduct"); $sel->click_ok("commit"); check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/post_bug.cgi}); $sel->title_is("Suspicious Action"); $sel->is_text_present_ok("you have no valid token for the create_bug action"); $sel->click_ok('//input[@value="Confirm Changes"]'); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/show_bug.cgi?id=14}); +check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/show_bug.cgi?id=14}); $sel->is_text_present_ok('has been added to the database', 'Bug created'); $sel->type_ok("comment", "New comment not allowed"); $sel->click_ok("commit"); check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi}); $sel->title_is("Product Edit Access Denied"); -$sel->is_text_present_ok("You are not permitted to edit bugs in product TestProduct."); +$sel->is_text_present_ok( + "You are not permitted to edit bugs in product TestProduct."); logout($sel); # Reassign the newly created bug to the admin. @@ -335,23 +412,28 @@ log_in($sel, $config, 'admin'); go_to_bug($sel, $bug2_id); $sel->click_ok("bz_assignee_edit_action"); $sel->type_ok("assigned_to", $config->{admin_user_login}); -$sel->type_ok("comment", "Taking!"); +$sel->type_ok("comment", "Taking!"); $sel->click_ok("commit"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug2_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug2_id}); $sel->is_text_present_ok("Changes submitted for bug $bug2_id"); # Test mass-change. $sel->click_ok("link=My bugs from QA_Selenium"); screenshot_page($sel, '/app/artifacts/line344.png'); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=19}); +check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=19} +); screenshot_page($sel, '/app/artifacts/line346.png'); $sel->title_is("Bug List: My bugs from QA_Selenium"); screenshot_page($sel, '/app/artifacts/line348.png'); $sel->is_text_present_ok("2 bugs found"); screenshot_page($sel, '/app/artifacts/line350.png'); $sel->click_ok("link=Change Several Bugs at Once"); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?email1=admin%40mozilla.test&email2=QA-Selenium-TEST%40mozilla.test&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailqa_contact2=1&emailreporter2=1&emailtype1=exact&emailtype2=exact&product=TestProduct&query_format=advanced&order=priority%2Cbug_severity&tweak=1&list_id=20}); +check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/buglist.cgi?email1=admin%40mozilla.test&email2=QA-Selenium-TEST%40mozilla.test&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailqa_contact2=1&emailreporter2=1&emailtype1=exact&emailtype2=exact&product=TestProduct&query_format=advanced&order=priority%2Cbug_severity&tweak=1&list_id=20} +); $sel->title_is("Bug List"); $sel->click_ok("check_all"); $sel->type_ok("comment", 'Mass change"'); @@ -362,25 +444,30 @@ check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi}); $sel->title_is("Bugs processed"); $sel->click_ok("link=bug $bug1_id"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->title_like(qr/$bug1_id /); $sel->selected_label_is("resolution", "WORKSFORME"); $sel->select_ok("resolution", "label=INVALID"); $sel->click_ok("commit"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); $sel->click_ok("link=bug $bug1_id"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); $sel->title_like(qr/$bug1_id /); $sel->selected_label_is("resolution", "INVALID"); $sel->click_ok("link=History"); -check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_activity.cgi?id=$bug1_id}); +check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_activity.cgi?id=$bug1_id}); $sel->title_is("Changes made to bug $bug1_id"); $sel->is_text_present_ok("URL foo.cgi?action=bar"); $sel->is_text_present_ok("Severity critical blocker"); -$sel->is_text_present_ok("Whiteboard [Selenium was here] [Selenium was here][admin too]"); +$sel->is_text_present_ok( + "Whiteboard [Selenium was here] [Selenium was here][admin too]"); $sel->is_text_present_ok("Product QA-Selenium-TEST TestProduct"); $sel->is_text_present_ok("Status CONFIRMED RESOLVED"); @@ -431,53 +518,68 @@ $sel->is_text_present_ok("Status CONFIRMED RESOLVED"); # Make sure token checks are working correctly for single bug editing and mass change, # first with no token, then with an invalid token. -foreach my $params (["no_token_single_bug", ""], ["invalid_token_single_bug", "&token=1"]) { - my ($comment, $token) = @$params; - $sel->open_ok("/$config->{bugzilla_installation}/process_bug.cgi?id=$bug1_id&comment=$comment$token", - undef, "Edit a single bug with " . ($token ? "an invalid" : "no") . " token"); - $sel->title_is("Suspicious Action"); - $sel->is_text_present_ok($token ? "an invalid token" : "web browser directly"); - $sel->click_ok("confirm"); - check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); - $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); - $sel->click_ok("link=bug $bug1_id"); - check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); - $sel->title_like(qr/^$bug1_id /); - $sel->is_text_present_ok($comment); +foreach my $params (["no_token_single_bug", ""], + ["invalid_token_single_bug", "&token=1"]) +{ + my ($comment, $token) = @$params; + $sel->open_ok( + "/$config->{bugzilla_installation}/process_bug.cgi?id=$bug1_id&comment=$comment$token", + undef, "Edit a single bug with " . ($token ? "an invalid" : "no") . " token" + ); + $sel->title_is("Suspicious Action"); + $sel->is_text_present_ok($token ? "an invalid token" : "web browser directly"); + $sel->click_ok("confirm"); + check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); + $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); + $sel->click_ok("link=bug $bug1_id"); + check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug1_id}); + $sel->title_like(qr/^$bug1_id /); + $sel->is_text_present_ok($comment); } -foreach my $params (["no_token_mass_change", ""], ["invalid_token_mass_change", "&token=1"]) { - my ($comment, $token) = @$params; - $sel->open_ok("/$config->{bugzilla_installation}/process_bug.cgi?id_$bug1_id=1&id_$bug2_id=1&comment=$comment$token", - undef, "Mass change with " . ($token ? "an invalid" : "no") . " token"); - $sel->title_is("Suspicious Action"); - $sel->is_text_present_ok("no valid token for the buglist_mass_change action"); - $sel->click_ok("confirm"); +foreach my $params (["no_token_mass_change", ""], + ["invalid_token_mass_change", "&token=1"]) +{ + my ($comment, $token) = @$params; + $sel->open_ok( + "/$config->{bugzilla_installation}/process_bug.cgi?id_$bug1_id=1&id_$bug2_id=1&comment=$comment$token", + undef, "Mass change with " . ($token ? "an invalid" : "no") . " token" + ); + $sel->title_is("Suspicious Action"); + $sel->is_text_present_ok("no valid token for the buglist_mass_change action"); + $sel->click_ok("confirm"); + check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi}); + $sel->title_is("Bugs processed"); + foreach my $bug_id ($bug1_id, $bug2_id) { + $sel->click_ok("link=bug $bug_id"); + check_page_load($sel, WAIT_TIME, + qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug_id}); + $sel->title_like(qr/^$bug_id /); + $sel->is_text_present_ok($comment); + next if $bug_id == $bug2_id; + $sel->go_back_ok(); check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi}); $sel->title_is("Bugs processed"); - foreach my $bug_id ($bug1_id, $bug2_id) { - $sel->click_ok("link=bug $bug_id"); - check_page_load($sel, WAIT_TIME, qq{http://HOSTNAME:8000/bmo/show_bug.cgi?id=$bug_id}); - $sel->title_like(qr/^$bug_id /); - $sel->is_text_present_ok($comment); - next if $bug_id == $bug2_id; - $sel->go_back_ok(); - check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi}); - $sel->title_is("Bugs processed"); - } + } } # Now move these bugs out of our radar. $sel->click_ok("link=My bugs from QA_Selenium"); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=21}); +check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=21} +); $sel->title_is("Bug List: My bugs from QA_Selenium"); $sel->is_text_present_ok("2 bugs found"); $sel->click_ok("link=Change Several Bugs at Once"); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?email1=admin%40mozilla.test&email2=QA-Selenium-TEST%40mozilla.test&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailqa_contact2=1&emailreporter2=1&emailtype1=exact&emailtype2=exact&product=TestProduct&query_format=advanced&order=priority%2Cbug_severity&tweak=1&list_id=22}); +check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/buglist.cgi?email1=admin%40mozilla.test&email2=QA-Selenium-TEST%40mozilla.test&emailassigned_to1=1&emailassigned_to2=1&emailcc2=1&emailqa_contact2=1&emailreporter2=1&emailtype1=exact&emailtype2=exact&product=TestProduct&query_format=advanced&order=priority%2Cbug_severity&tweak=1&list_id=22} +); $sel->title_is("Bug List"); $sel->click_ok("check_all"); -$sel->type_ok("comment", "Reassigning to the reporter"); +$sel->type_ok("comment", "Reassigning to the reporter"); $sel->type_ok("assigned_to", $config->{QA_Selenium_TEST_user_login}); $sel->click_ok("commit"); check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/process_bug.cgi}); @@ -486,10 +588,14 @@ $sel->title_is("Bugs processed"); # Now delete the saved search. $sel->click_ok("link=My bugs from QA_Selenium"); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=23}); +check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=runnamed&namedcmd=My%20bugs%20from%20QA_Selenium&list_id=23} +); $sel->title_is("Bug List: My bugs from QA_Selenium"); $sel->click_ok("link=Forget Search 'My bugs from QA_Selenium'"); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=My%20bugs%20from%20QA_Selenium&token=1531926582-f228fa8ebc2f2b3970f2a791e54534ec&list_id=24}); +check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/buglist.cgi?cmdtype=dorem&remaction=forget&namedcmd=My%20bugs%20from%20QA_Selenium&token=1531926582-f228fa8ebc2f2b3970f2a791e54534ec&list_id=24} +); $sel->title_is("Search is gone"); $sel->is_text_present_ok("OK, the My bugs from QA_Selenium search is gone"); @@ -498,14 +604,16 @@ clear_canedit_on_testproduct($sel, $master_gid); logout($sel); sub clear_canedit_on_testproduct { - my ($sel, $master_gid) = @_; - - edit_product($sel, "TestProduct"); - $sel->click_ok("link=Edit Group Access Controls:"); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/editproducts.cgi?action=editgroupcontrols&product=TestProduct}); - $sel->title_is("Edit Group Controls for TestProduct"); - $sel->uncheck_ok("canedit_$master_gid"); - $sel->click_ok("submit"); -check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/editproducts.cgi}); - $sel->title_is("Update group access controls for TestProduct"); + my ($sel, $master_gid) = @_; + + edit_product($sel, "TestProduct"); + $sel->click_ok("link=Edit Group Access Controls:"); + check_page_load($sel, WAIT_TIME, + q{http://HOSTNAME:8000/bmo/editproducts.cgi?action=editgroupcontrols&product=TestProduct} + ); + $sel->title_is("Edit Group Controls for TestProduct"); + $sel->uncheck_ok("canedit_$master_gid"); + $sel->click_ok("submit"); + check_page_load($sel, WAIT_TIME, q{http://HOSTNAME:8000/bmo/editproducts.cgi}); + $sel->title_is("Update group access controls for TestProduct"); } diff --git a/qa/t/test_choose_priority.t b/qa/t/test_choose_priority.t index 95f401e66..6320df652 100644 --- a/qa/t/test_choose_priority.t +++ b/qa/t/test_choose_priority.t @@ -16,11 +16,14 @@ use QA::Util; my ($sel, $config) = get_selenium(); log_in($sel, $config, 'admin'); -set_parameters($sel, { "Bug Change Policies" => {"letsubmitterchoosepriority-off" => undef} }); +set_parameters($sel, + {"Bug Change Policies" => {"letsubmitterchoosepriority-off" => undef}}); file_bug_in_product($sel, "TestProduct"); ok(!$sel->is_text_present("Priority"), "The Priority label is not present"); -ok(!$sel->is_element_present("//select[\@name='priority']"), "The Priority drop-down menu is not present"); -set_parameters($sel, { "Bug Change Policies" => {"letsubmitterchoosepriority-on" => undef} }); +ok(!$sel->is_element_present("//select[\@name='priority']"), + "The Priority drop-down menu is not present"); +set_parameters($sel, + {"Bug Change Policies" => {"letsubmitterchoosepriority-on" => undef}}); file_bug_in_product($sel, "TestProduct"); $sel->is_text_present_ok("Priority"); $sel->is_element_present_ok("//select[\@name='priority']"); diff --git a/qa/t/test_classifications.t b/qa/t/test_classifications.t index e9ea18ab9..a9ac8f5a7 100644 --- a/qa/t/test_classifications.t +++ b/qa/t/test_classifications.t @@ -18,7 +18,7 @@ my ($sel, $config) = get_selenium(); # Enable classifications log_in($sel, $config, 'admin'); -set_parameters($sel, { "Bug Fields" => {"useclassification-on" => undef} }); +set_parameters($sel, {"Bug Fields" => {"useclassification-on" => undef}}); # Create a new classification. @@ -31,25 +31,29 @@ $sel->title_is("Select classification"); # Accessing action=delete directly must 1) trigger the security check page, # and 2) automatically reclassify products in this classification. if ($sel->is_text_present("cone")) { - $sel->open_ok("/$config->{bugzilla_installation}/editclassifications.cgi?action=delete&classification=cone"); - $sel->title_is("Suspicious Action"); - $sel->click_ok("confirm"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Classification Deleted"); + $sel->open_ok( + "/$config->{bugzilla_installation}/editclassifications.cgi?action=delete&classification=cone" + ); + $sel->title_is("Suspicious Action"); + $sel->click_ok("confirm"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Classification Deleted"); } if ($sel->is_text_present("ctwo")) { - $sel->open_ok("/$config->{bugzilla_installation}/editclassifications.cgi?action=delete&classification=ctwo"); - $sel->title_is("Suspicious Action"); - $sel->click_ok("confirm"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Classification Deleted"); + $sel->open_ok( + "/$config->{bugzilla_installation}/editclassifications.cgi?action=delete&classification=ctwo" + ); + $sel->title_is("Suspicious Action"); + $sel->click_ok("confirm"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Classification Deleted"); } $sel->click_ok("link=Add"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Add new classification"); $sel->type_ok("classification", "cone"); -$sel->type_ok("description", "Classification number 1"); +$sel->type_ok("description", "Classification number 1"); $sel->click_ok('//input[@type="submit" and @value="Add"]'); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("New Classification Created"); @@ -62,7 +66,8 @@ $sel->click_ok("add_products"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Reclassify products"); my @products = $sel->get_select_options("myprodlist"); -ok(scalar @products == 1 && $products[0] eq 'TestProduct', "TestProduct successfully added to 'cone'"); +ok(scalar @products == 1 && $products[0] eq 'TestProduct', + "TestProduct successfully added to 'cone'"); # Create a new bug in this product/classification. @@ -72,7 +77,8 @@ $sel->type_ok("comment", "Created by Selenium with classifications turned on"); $sel->click_ok("commit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); my $bug1_id = $sel->get_value('//input[@name="id" and @type="hidden"]'); -$sel->is_text_present_ok('has been added to the database', "Bug $bug1_id created"); +$sel->is_text_present_ok('has been added to the database', + "Bug $bug1_id created"); # Rename 'cone' to 'Unclassified', which must be rejected as it already exists, # then to 'ctwo', which is not yet in use. Should work fine, even with products @@ -109,18 +115,23 @@ go_to_admin($sel); $sel->click_ok("link=Classifications"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Select classification"); -$sel->click_ok('//a[contains(@href,"/editclassifications.cgi?action=del&classification=ctwo")]'); +$sel->click_ok( + '//a[contains(@href,"/editclassifications.cgi?action=del&classification=ctwo")]' +); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Error"); my $error = trim($sel->get_text("error_msg")); -ok($error =~ /there are products for this classification/, "Reject classification deletion"); +ok($error =~ /there are products for this classification/, + "Reject classification deletion"); # Reclassify the product before deleting the classification. $sel->go_back_ok(); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Select classification"); -$sel->click_ok('//a[contains(@href,"/editclassifications.cgi?action=reclassify&classification=ctwo")]'); +$sel->click_ok( + '//a[contains(@href,"/editclassifications.cgi?action=reclassify&classification=ctwo")]' +); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Reclassify products"); $sel->add_selection_ok("myprodlist", "label=TestProduct"); @@ -130,7 +141,9 @@ $sel->title_is("Reclassify products"); $sel->click_ok("link=edit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Select classification"); -$sel->click_ok('//a[contains(@href,"/editclassifications.cgi?action=del&classification=ctwo")]'); +$sel->click_ok( + '//a[contains(@href,"/editclassifications.cgi?action=del&classification=ctwo")]' +); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Delete classification"); $sel->is_text_present_ok("Do you really want to delete this classification?"); @@ -140,7 +153,7 @@ $sel->title_is("Classification Deleted"); # Disable classifications and make sure you cannot edit them anymore. -set_parameters($sel, { "Bug Fields" => {"useclassification-off" => undef} }); +set_parameters($sel, {"Bug Fields" => {"useclassification-off" => undef}}); $sel->open_ok("/$config->{bugzilla_installation}/editclassifications.cgi"); $sel->title_is("Classification Not Enabled"); logout($sel); diff --git a/qa/t/test_config.t b/qa/t/test_config.t index ef1d8d898..7ad97190a 100644 --- a/qa/t/test_config.t +++ b/qa/t/test_config.t @@ -18,12 +18,13 @@ my ($sel, $config) = get_selenium(); # Turn on 'requirelogin' and log out. log_in($sel, $config, 'admin'); -set_parameters($sel, { "User Authentication" => {"requirelogin-on" => undef} }); +set_parameters($sel, {"User Authentication" => {"requirelogin-on" => undef}}); logout($sel); # Accessing config.cgi should display no sensitive data. -$sel->open_ok("/$config->{bugzilla_installation}/config.cgi", undef, "Go to config.cgi (JS format)"); +$sel->open_ok("/$config->{bugzilla_installation}/config.cgi", + undef, "Go to config.cgi (JS format)"); $sel->is_text_present_ok("var status = [ ];"); $sel->is_text_present_ok("var status_open = [ ];"); $sel->is_text_present_ok("var status_closed = [ ];"); @@ -33,13 +34,14 @@ $sel->is_text_present_ok("var platform = [ ];"); $sel->is_text_present_ok("var severity = [ ];"); $sel->is_text_present_ok("var field = [\n];"); -ok(!$sel->is_text_present("cf_"), "No custom field displayed"); +ok(!$sel->is_text_present("cf_"), "No custom field displayed"); ok(!$sel->is_text_present("component["), "No component displayed"); -ok(!$sel->is_text_present("version["), "No version displayed"); -ok(!$sel->is_text_present("target_milestone["), "No target milestone displayed"); +ok(!$sel->is_text_present("version["), "No version displayed"); +ok(!$sel->is_text_present("target_milestone["), + "No target milestone displayed"); # Turn on 'requirelogin' and log out. log_in($sel, $config, 'admin'); -set_parameters($sel, { "User Authentication" => {"requirelogin-off" => undef} }); +set_parameters($sel, {"User Authentication" => {"requirelogin-off" => undef}}); logout($sel); diff --git a/qa/t/test_create_user_accounts.t b/qa/t/test_create_user_accounts.t index ba0f39671..25f93ba65 100644 --- a/qa/t/test_create_user_accounts.t +++ b/qa/t/test_create_user_accounts.t @@ -18,7 +18,13 @@ my ($sel, $config) = get_selenium(); # Set the email regexp for new bugzilla accounts to end with @bugzilla.test. log_in($sel, $config, 'admin'); -set_parameters($sel, { "User Authentication" => {"createemailregexp" => {type => "text", value => '[^@]+@bugzilla\.test$'}} }); +set_parameters( + $sel, + { + "User Authentication" => + {"createemailregexp" => {type => "text", value => '[^@]+@bugzilla\.test$'}} + } +); logout($sel); # Create a valid account. We need to randomize the login address, because a request @@ -50,58 +56,69 @@ $sel->click_ok('//input[@value="Create Account"]'); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Too Soon For New Token"); my $error_msg = trim($sel->get_text("error_msg")); -ok($error_msg =~ /Please wait a while and try again/, "Too soon for this account"); +ok($error_msg =~ /Please wait a while and try again/, + "Too soon for this account"); # These accounts do not pass the regexp. -my @accounts = ('test@yahoo.com', 'test@bugzilla.net', 'test@bugzilla.test.com'); +my @accounts + = ('test@yahoo.com', 'test@bugzilla.net', 'test@bugzilla.test.com'); foreach my $account (@accounts) { - $sel->click_ok("link=New Account"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Create a new Bugzilla account"); - $sel->type_ok("login", $account); - $sel->check_ok("etiquette", "Agree to abide by code of conduct"); - $sel->click_ok('//input[@value="Create Account"]'); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Account Creation Restricted"); - $sel->is_text_present_ok("User account creation has been restricted."); + $sel->click_ok("link=New Account"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Create a new Bugzilla account"); + $sel->type_ok("login", $account); + $sel->check_ok("etiquette", "Agree to abide by code of conduct"); + $sel->click_ok('//input[@value="Create Account"]'); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Account Creation Restricted"); + $sel->is_text_present_ok("User account creation has been restricted."); } # These accounts are illegal and should cause a javascript alert. @accounts = qw( - test\bugzilla@bugzilla.test - testbugzilla.test - test@bugzilla - test@bugzilla. - 'test'@bugzilla.test - test&test@bugzilla.test - [test]@bugzilla.test + test\bugzilla@bugzilla.test + testbugzilla.test + test@bugzilla + test@bugzilla. + 'test'@bugzilla.test + test&test@bugzilla.test + [test]@bugzilla.test ); + foreach my $account (@accounts) { - $sel->click_ok("link=New Account"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Create a new Bugzilla account"); - $sel->type_ok("login", $account); - $sel->check_ok("etiquette", "Agree to abide by code of conduct"); - $sel->click_ok('//input[@value="Create Account"]'); - ok($sel->get_alert() =~ /The e-mail address doesn't pass our syntax checking for a legal email address/, - 'Invalid email address detected'); + $sel->click_ok("link=New Account"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Create a new Bugzilla account"); + $sel->type_ok("login", $account); + $sel->check_ok("etiquette", "Agree to abide by code of conduct"); + $sel->click_ok('//input[@value="Create Account"]'); + ok( + $sel->get_alert() + =~ /The e-mail address doesn't pass our syntax checking for a legal email address/, + 'Invalid email address detected' + ); } # These accounts are illegal but do not cause a javascript alert @accounts = ('test@bugzilla.org@bugzilla.test', 'test@bugzilla..test'); + # Logins larger than 127 characters must be rejected, for security reasons. push @accounts, 'selenium-' . random_string(110) . '@bugzilla.test'; foreach my $account (@accounts) { - $sel->click_ok("link=New Account"); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Create a new Bugzilla account"); - $sel->type_ok("login", $account); - $sel->check_ok("etiquette", "Agree to abide by code of conduct"); - $sel->click_ok('//input[@value="Create Account"]'); - $sel->wait_for_page_to_load_ok(WAIT_TIME); - $sel->title_is("Invalid Email Address"); - my $error_msg = trim($sel->get_text("error_msg")); - ok($error_msg =~ /^The e-mail address you entered (\S+) didn't pass our syntax checking/, "Invalid email address detected"); + $sel->click_ok("link=New Account"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Create a new Bugzilla account"); + $sel->type_ok("login", $account); + $sel->check_ok("etiquette", "Agree to abide by code of conduct"); + $sel->click_ok('//input[@value="Create Account"]'); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Invalid Email Address"); + my $error_msg = trim($sel->get_text("error_msg")); + ok( + $error_msg + =~ /^The e-mail address you entered (\S+) didn't pass our syntax checking/, + "Invalid email address detected" + ); } # This account already exists. @@ -114,11 +131,20 @@ $sel->click_ok('//input[@value="Create Account"]'); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Account Already Exists"); $error_msg = trim($sel->get_text("error_msg")); -ok($error_msg eq "There is already an account with the login name $config->{admin_user_login}.", "Account already exists"); +ok( + $error_msg eq + "There is already an account with the login name $config->{admin_user_login}.", + "Account already exists" +); # Turn off user account creation. log_in($sel, $config, 'admin'); -set_parameters($sel, { "User Authentication" => {"createemailregexp" => {type => "text", value => ''}} }); +set_parameters( + $sel, + { + "User Authentication" => {"createemailregexp" => {type => "text", value => ''}} + } +); logout($sel); # Make sure that links pointing to createaccount.cgi are all deactivated. @@ -132,13 +158,22 @@ ok(!$sel->is_text_present("New Account"), "No link named 'New Account'"); $sel->open_ok("/$config->{bugzilla_installation}/createaccount.cgi"); $sel->title_is("Account Creation Disabled"); $error_msg = trim($sel->get_text("error_msg")); -ok($error_msg =~ /^User account creation has been disabled. New accounts must be created by an administrator/, - "User account creation disabled"); +ok( + $error_msg + =~ /^User account creation has been disabled. New accounts must be created by an administrator/, + "User account creation disabled" +); # Re-enable user account creation. log_in($sel, $config, 'admin'); -set_parameters($sel, { "User Authentication" => {"createemailregexp" => {type => "text", value => '.*'}} }); +set_parameters( + $sel, + { + "User Authentication" => + {"createemailregexp" => {type => "text", value => '.*'}} + } +); # Make sure selenium-@bugzilla.test has not be added to the DB yet. go_to_admin($sel); diff --git a/qa/t/test_custom_fields.t b/qa/t/test_custom_fields.t index d08e23eb0..85f2fe3a2 100644 --- a/qa/t/test_custom_fields.t +++ b/qa/t/test_custom_fields.t @@ -21,7 +21,8 @@ log_in($sel, $config, 'admin'); file_bug_in_product($sel, 'TestProduct'); my $bug_summary = "What's your ID?"; $sel->type_ok("short_desc", $bug_summary); -$sel->type_ok("comment", "Use the ID of this bug to generate a unique custom field name."); +$sel->type_ok("comment", + "Use the ID of this bug to generate a unique custom field name."); $sel->type_ok("bug_severity", "label=normal"); my $bug1_id = create_bug($sel, $bug_summary); @@ -38,13 +39,16 @@ $sel->type_ok("name", "cf_qa_freetext_$bug1_id"); $sel->type_ok("desc", "Freetext$bug1_id"); $sel->select_ok("type", "label=Free Text"); $sel->type_ok("sortkey", $bug1_id); + # These values are off by default. $sel->value_is("enter_bug", "off"); -$sel->value_is("obsolete", "off"); +$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); @@ -58,11 +62,12 @@ $sel->value_is("enter_bug", "on"); $sel->click_ok("new_bugmail"); sleep 10; $sel->value_is("new_bugmail", "on"); -$sel->value_is("obsolete", "off"); +$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."); $sel->click_ok("link=Add a new custom field"); $sel->wait_for_page_to_load_ok(WAIT_TIME); @@ -70,15 +75,16 @@ $sel->title_is("Add a new Custom Field"); $sel->type_ok("name", "cf_qa_bugid_$bug1_id"); $sel->type_ok("desc", "Reference$bug1_id"); $sel->select_ok("type", "label=Bug ID"); -$sel->type_ok("sortkey", $bug1_id); +$sel->type_ok("sortkey", $bug1_id); $sel->type_ok("reverse_desc", "IsRef$bug1_id"); $sel->click_ok("enter_bug"); $sel->value_is("enter_bug", "on"); -$sel->value_is("obsolete", "off"); +$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_bugid_$bug1_id' has been successfully created."); +$sel->is_text_present_ok( + "The new custom field 'cf_qa_bugid_$bug1_id' has been successfully created."); # Add values to the custom fields. @@ -87,27 +93,32 @@ $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->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->type_ok("value", "have fun?"); +$sel->type_ok("value", "have fun?"); $sel->type_ok("sortkey", "805"); $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->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"); -$sel->type_ok("value", "storage"); +$sel->type_ok("value", "storage"); $sel->type_ok("sortkey", "49"); $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 storage has been added as a valid choice for the List$bug1_id (cf_qa_list_$bug1_id) field."); +$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. @@ -121,7 +132,7 @@ $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("value", "UPSTREAM"); $sel->type_ok("sortkey", 450); $sel->click_ok("create"); $sel->wait_for_page_to_load_ok(WAIT_TIME); @@ -137,7 +148,7 @@ $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("value", "SUSPENDED"); $sel->type_ok("sortkey", 250); $sel->click_ok("open_status"); $sel->click_ok("create"); @@ -147,7 +158,7 @@ $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("value", "IN_QA"); $sel->type_ok("sortkey", 550); $sel->click_ok("closed_status"); $sel->click_ok("create"); @@ -157,13 +168,20 @@ $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 CONFIRMED to SUSPENDED"]//input[@type="checkbox"]'); -$sel->click_ok('//td[@title="From SUSPENDED to CONFIRMED"]//input[@type="checkbox"]'); -$sel->click_ok('//td[@title="From SUSPENDED to IN_PROGRESS"]//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 CONFIRMED"]//input[@type="checkbox"]'); +$sel->click_ok( + '//td[@title="From UNCONFIRMED to SUSPENDED"]//input[@type="checkbox"]'); +$sel->click_ok( + '//td[@title="From CONFIRMED to SUSPENDED"]//input[@type="checkbox"]'); +$sel->click_ok( + '//td[@title="From SUSPENDED to CONFIRMED"]//input[@type="checkbox"]'); +$sel->click_ok( + '//td[@title="From SUSPENDED to IN_PROGRESS"]//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 CONFIRMED"]//input[@type="checkbox"]'); $sel->click_ok('//input[@value="Commit Changes"]'); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Edit Workflow"); @@ -175,13 +193,19 @@ $sel->is_text_present_ok("List$bug1_id:"); $sel->is_element_present_ok("cf_qa_list_$bug1_id"); $sel->is_text_present_ok("Reference$bug1_id:"); $sel->is_element_present_ok("cf_qa_bugid_$bug1_id"); -ok(!$sel->is_text_present("Freetext$bug1_id:"), "Freetext$bug1_id is not displayed"); -ok(!$sel->is_element_present("cf_qa_freetext_$bug1_id"), "cf_qa_freetext_$bug1_id is not available"); +ok( + !$sel->is_text_present("Freetext$bug1_id:"), + "Freetext$bug1_id is not displayed" +); +ok( + !$sel->is_element_present("cf_qa_freetext_$bug1_id"), + "cf_qa_freetext_$bug1_id is not available" +); my $bug_summary2 = "Et de un"; $sel->type_ok("short_desc", $bug_summary2); $sel->select_ok("bug_severity", "critical"); $sel->type_ok("cf_qa_bugid_$bug1_id", $bug1_id); -$sel->type_ok("comment", "hops!"); +$sel->type_ok("comment", "hops!"); my $bug2_id = create_bug($sel, $bug_summary2); # Both fields are editable. @@ -257,27 +281,32 @@ $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->select_ok("visibility_field_id", "label=Severity (bug_severity)"); -$sel->select_ok("visibility_values", "label=critical"); +$sel->select_ok("visibility_values", "label=critical"); $sel->click_ok("edit"); $sel->wait_for_page_to_load_ok(WAIT_TIME); $sel->title_is("Custom Field Updated"); go_to_bug($sel, $bug1_id); -$sel->is_element_present_ok("cf_qa_list_$bug1_id", "List$bug1_id is in the DOM of the page..."); -ok(!$sel->is_visible("cf_qa_list_$bug1_id"), "... but is not displayed with severity = 'normal'"); +$sel->is_element_present_ok("cf_qa_list_$bug1_id", + "List$bug1_id is in the DOM of the page..."); +ok(!$sel->is_visible("cf_qa_list_$bug1_id"), + "... but is not displayed with severity = 'normal'"); $sel->select_ok("bug_severity", "major"); ok(!$sel->is_visible("cf_qa_list_$bug1_id"), "... nor with severity = 'major'"); $sel->select_ok("bug_severity", "critical"); -$sel->is_visible_ok("cf_qa_list_$bug1_id", "... but is visible with severity = 'critical'"); +$sel->is_visible_ok("cf_qa_list_$bug1_id", + "... but is visible with severity = 'critical'"); edit_bug_and_return($sel, $bug1_id, $bug_summary); $sel->is_visible_ok("cf_qa_list_$bug1_id"); go_to_bug($sel, $bug2_id); $sel->is_visible_ok("cf_qa_list_$bug1_id"); $sel->select_ok("bug_severity", "minor"); -ok(!$sel->is_visible("cf_qa_list_$bug1_id"), "List$bug1_id is not displayed with severity = 'minor'"); +ok(!$sel->is_visible("cf_qa_list_$bug1_id"), + "List$bug1_id is not displayed with severity = 'minor'"); edit_bug_and_return($sel, $bug2_id, $bug_summary2); -ok(!$sel->is_visible("cf_qa_list_$bug1_id"), "List$bug1_id is not displayed with severity = 'minor'"); +ok(!$sel->is_visible("cf_qa_list_$bug1_id"), + "List$bug1_id is not displayed with severity = 'minor'"); # Add a new value which is only listed under some condition. @@ -297,11 +326,12 @@ $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->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->type_ok("value", "ghost"); +$sel->type_ok("value", "ghost"); $sel->type_ok("sortkey", "500"); $sel->select_ok("visibility_value_id", "label=FIXED"); $sel->click_ok("id=create"); @@ -313,8 +343,8 @@ my @labels = $sel->get_select_options("cf_qa_list_$bug1_id"); ok(grep(/^ghost$/, @labels), "ghost is in the DOM of the page..."); my $disabled = $sel->get_attribute("v4_cf_qa_list_$bug1_id\@disabled"); ok($disabled, "... but is not available for selection by default"); -$sel->select_ok("bug_status", "label=RESOLVED"); -$sel->select_ok("resolution", "label=FIXED"); +$sel->select_ok("bug_status", "label=RESOLVED"); +$sel->select_ok("resolution", "label=FIXED"); $sel->select_ok("cf_qa_list_$bug1_id", "label=ghost"); edit_bug_and_return($sel, $bug1_id, $bug_summary); $sel->selected_label_is("cf_qa_list_$bug1_id", "ghost"); @@ -327,10 +357,14 @@ $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->click_ok("//a[contains(\@href, '/editvalues.cgi?action=del&field=cf_qa_list_$bug1_id&value=have%20fun%3F')]"); +$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); @@ -338,9 +372,12 @@ $sel->title_is("Field Value Deleted"); # This value cannot be deleted as it's in use. -$sel->click_ok("//a[contains(\@href, '/editvalues.cgi?action=del&field=cf_qa_list_$bug1_id&value=storage')]"); +$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 fields. Bugzilla->dbh->bz_populate_enum_tables(); -}); + } +); -$lives_ok->('update_fielddefs_definition' => sub { +$lives_ok->( + 'update_fielddefs_definition' => sub { Bugzilla::Install::DB::update_fielddefs_definition(); -}); + } +); -$lives_ok->('populate_field_definitions' => sub { +$lives_ok->( + 'populate_field_definitions' => sub { Bugzilla::Field::populate_field_definitions(); -}); + } +); -$lives_ok->('init_workflow' => sub { +$lives_ok->( + 'init_workflow' => sub { Bugzilla::Install::init_workflow(); -}); + } +); -$lives_ok->('update_table_definitions' => sub { +$lives_ok->( + 'update_table_definitions' => sub { Bugzilla::Install::DB->update_table_definitions({}); -}); + } +); -$lives_ok->('update_system_groups' => sub { +$lives_ok->( + 'update_system_groups' => sub { Bugzilla::Install::update_system_groups(); -}); + } +); # "Log In" as the fake superuser who can do everything. Bugzilla->set_user(Bugzilla::User->super_user); -$lives_ok->('update_settings' => sub { +$lives_ok->( + 'update_settings' => sub { Bugzilla::Install::update_settings(); -}); + } +); SKIP: { - skip 'default product cannot be created without default assignee', 1; - $lives_ok->('create_default_product' => sub { - Bugzilla::Install::create_default_product(); - }); + skip 'default product cannot be created without default assignee', 1; + $lives_ok->( + 'create_default_product' => sub { + Bugzilla::Install::create_default_product(); + } + ); } done_testing; diff --git a/xt/search.t b/xt/search.t index bd77f5b20..5ae1a606a 100644 --- a/xt/search.t +++ b/xt/search.t @@ -36,7 +36,8 @@ use Test::More; my %switches; GetOptions(\%switches, 'operators=s', 'top-operators=s', 'long', - 'add-custom-fields', 'help|h') || die $@; + 'add-custom-fields', 'help|h') + || die $@; pod2usage(verbose => 1) if $switches{'help'};