From 9b6ec1f545da1cc4088ddf9cc117747954e58e65 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Fri, 26 Feb 2016 17:57:55 +0000 Subject: Bug 1069799 - move the QA repository into the main repository r=LpSolit --- xt/selenium/bug_edit.t | 441 +++++++++++++++++++++++++++++++ xt/selenium/choose_priority.t | 30 +++ xt/selenium/classifications.t | 142 ++++++++++ xt/selenium/config.t | 48 ++++ xt/selenium/create_user_accounts.t | 139 ++++++++++ xt/selenium/custom_fields.t | 462 +++++++++++++++++++++++++++++++++ xt/selenium/custom_fields_admin.t | 56 ++++ xt/selenium/dependencies.t | 56 ++++ xt/selenium/edit_products_properties.t | 338 ++++++++++++++++++++++++ xt/selenium/email_preferences.t | 405 +++++++++++++++++++++++++++++ xt/selenium/enter_new_bug.t | 35 +++ xt/selenium/flags.t | 441 +++++++++++++++++++++++++++++++ xt/selenium/flags2.t | 308 ++++++++++++++++++++++ xt/selenium/groups.t | 378 +++++++++++++++++++++++++++ xt/selenium/keywords.t | 181 +++++++++++++ xt/selenium/login.t | 37 +++ xt/selenium/milestones.t | 149 +++++++++++ xt/selenium/password_complexity.t | 123 +++++++++ xt/selenium/private_attachments.t | 173 ++++++++++++ xt/selenium/qa_contact.t | 164 ++++++++++++ xt/selenium/require_login.t | 83 ++++++ xt/selenium/sanity_check.t | 49 ++++ xt/selenium/saved_searches.t | 117 +++++++++ xt/selenium/search.t | 71 +++++ xt/selenium/security.t | 198 ++++++++++++++ xt/selenium/shared_searches.t | 199 ++++++++++++++ xt/selenium/show_all_products.t | 56 ++++ xt/selenium/shutdown.t | 77 ++++++ xt/selenium/status_whiteboard.t | 118 +++++++++ xt/selenium/strict_isolation.t | 145 +++++++++++ xt/selenium/sudo_sessions.t | 158 +++++++++++ xt/selenium/target_milestones.t | 111 ++++++++ xt/selenium/time_summary.t | 101 +++++++ xt/selenium/user_groups.t | 249 ++++++++++++++++++ xt/selenium/user_matching.t | 188 ++++++++++++++ xt/selenium/user_preferences.t | 225 ++++++++++++++++ xt/selenium/user_privs.t | 60 +++++ xt/selenium/votes.t | 233 +++++++++++++++++ 38 files changed, 6544 insertions(+) create mode 100644 xt/selenium/bug_edit.t create mode 100644 xt/selenium/choose_priority.t create mode 100644 xt/selenium/classifications.t create mode 100644 xt/selenium/config.t create mode 100644 xt/selenium/create_user_accounts.t create mode 100644 xt/selenium/custom_fields.t create mode 100644 xt/selenium/custom_fields_admin.t create mode 100644 xt/selenium/dependencies.t create mode 100644 xt/selenium/edit_products_properties.t create mode 100644 xt/selenium/email_preferences.t create mode 100644 xt/selenium/enter_new_bug.t create mode 100644 xt/selenium/flags.t create mode 100644 xt/selenium/flags2.t create mode 100644 xt/selenium/groups.t create mode 100644 xt/selenium/keywords.t create mode 100644 xt/selenium/login.t create mode 100644 xt/selenium/milestones.t create mode 100644 xt/selenium/password_complexity.t create mode 100644 xt/selenium/private_attachments.t create mode 100644 xt/selenium/qa_contact.t create mode 100644 xt/selenium/require_login.t create mode 100644 xt/selenium/sanity_check.t create mode 100644 xt/selenium/saved_searches.t create mode 100644 xt/selenium/search.t create mode 100644 xt/selenium/security.t create mode 100644 xt/selenium/shared_searches.t create mode 100644 xt/selenium/show_all_products.t create mode 100644 xt/selenium/shutdown.t create mode 100644 xt/selenium/status_whiteboard.t create mode 100644 xt/selenium/strict_isolation.t create mode 100644 xt/selenium/sudo_sessions.t create mode 100644 xt/selenium/target_milestones.t create mode 100644 xt/selenium/time_summary.t create mode 100644 xt/selenium/user_groups.t create mode 100644 xt/selenium/user_matching.t create mode 100644 xt/selenium/user_preferences.t create mode 100644 xt/selenium/user_privs.t create mode 100644 xt/selenium/votes.t (limited to 'xt/selenium') diff --git a/xt/selenium/bug_edit.t b/xt/selenium/bug_edit.t new file mode 100644 index 000000000..46e7e6cb3 --- /dev/null +++ b/xt/selenium/bug_edit.t @@ -0,0 +1,441 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +use 5.10.1; +use strict; +use warnings; + +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; + +use Test::More "no_plan"; + +use QA::Util; + +my ($sel, $config) = get_selenium(); + +log_in($sel, $config, 'admin'); +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("forget_search"); + $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. +go_to_admin($sel); +$sel->click_ok("link=Groups"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit Groups"); +$sel->click_ok("link=Master"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Change Group: Master"); +my $group_url = $sel->get_location(); +$group_url =~ /group=(\d+)$/; +my $master_gid = $1; + +clear_canedit_on_testproduct($sel, $master_gid); +logout($sel); + +# First create a bug. + +log_in($sel, $config, 'QA_Selenium_TEST'); +file_bug_in_product($sel, 'TestProduct'); +my $bug_summary = "Test bug editing"; +$sel->select_ok("bug_severity", "label=critical"); +$sel->type_ok("short_desc", $bug_summary); +$sel->type_ok("comment", "ploc"); +my $bug1_id = create_bug($sel, $bug_summary); + +# 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("bug_severity", "label=blocker"); +$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->select_ok("bug_status", "label=RESOLVED"); +edit_bug($sel, $bug1_id, $bug_summary); + +# Now move the bug into another product, which has a mandatory group. + +$sel->click_ok("link=$bug1_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^$bug1_id /); +$sel->select_ok("product", "label=QA-Selenium-TEST"); +$sel->type_ok("comment", "moving to QA-Selenium-TEST"); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Verify New Product Details..."); +$sel->select_ok("component", "label=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"]'); +edit_bug_and_return($sel, $bug1_id, $bug_summary, {id => "change_product"}); +$sel->select_ok("bug_severity", "label=normal"); +$sel->select_ok("priority", "label=High"); +$sel->select_ok("rep_platform", "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("comment", "Unchecking the reporter_accessible checkbox"); +# This checkbox is checked by default. +$sel->click_ok("reporter_accessible"); +$sel->select_ok("bug_status", "label=VERIFIED"); +edit_bug_and_return($sel, $bug1_id, $bug_summary); +$sel->type_ok("comment", "I am the reporter, but I can see the bug anyway as I belong to the mandatory group"); +edit_bug($sel, $bug1_id, $bug_summary); +logout($sel); + +# The admin is not in the mandatory group, but he has been CC'ed, +# so he can view and edit the bug (as he has editbugs privs by inheritance). + +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->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!"); +edit_bug_and_return($sel, $bug1_id, $bug_summary); +$sel->click_ok("cc_edit_area_showhide"); +$sel->type_ok("newcc", $config->{unprivileged_user_login}); +edit_bug($sel, $bug1_id, $bug_summary); +logout($sel); + +# The powerless user can see the restricted bug, as he has been CC'ed. + +log_in($sel, $config, 'unprivileged'); +go_to_bug($sel, $bug1_id); +$sel->is_text_present_ok("I have editbugs privs. Taking!"); +logout($sel); + +# Now turn off cclist_accessible, which will prevent +# the powerless user to see the bug again. + +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"); +edit_bug($sel, $bug1_id, $bug_summary); +logout($sel); + +# The powerless user cannot see the restricted bug anymore. + +log_in($sel, $config, 'unprivileged'); +$sel->type_ok("quicksearch_top", $bug1_id); +$sel->click_ok("find_top"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug Access Denied"); +$sel->is_text_present_ok("You are not authorized to access bug #$bug1_id"); +logout($sel); + +# Move the bug back to TestProduct, which has no group restrictions. + +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"); +$sel->uncheck_ok("set_default_assignee"); +$sel->type_ok("comment", "-> Moving back to Testproduct."); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Verify New Product Details..."); +$sel->select_ok("component", "label=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"]'); +ok(!$sel->is_checked('//input[@type="checkbox" and @name="groups" and @value="Master"]'), "Master group not selected by default"); +edit_bug($sel, $bug1_id, $bug_summary, {id => "change_product"}); +logout($sel); + +# The unprivileged user can view the bug again, but cannot +# edit it, except adding comments. + +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->click_ok("cc_edit_area_showhide"); +$sel->add_selection_ok("cc", "label=" . $config->{admin_user_login}); +$sel->click_ok("removecc"); +edit_bug($sel, $bug1_id, $bug_summary); +logout($sel); + +# Now let's test the CANEDIT bit. + +log_in($sel, $config, 'admin'); +edit_product($sel, "TestProduct"); +$sel->click_ok("link=Edit Group Access Controls:"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit Group Controls for TestProduct"); +$sel->check_ok("canedit_$master_gid"); +$sel->click_ok("submit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Update group access controls for TestProduct"); + +# The user is in the master group, so he can comment. + +go_to_bug($sel, $bug1_id); +$sel->type_ok("comment", "Do nothing except adding a comment..."); +edit_bug($sel, $bug1_id, $bug_summary); +logout($sel); + +# This user is not in the master group, so he cannot comment. + +log_in($sel, $config, 'QA_Selenium_TEST'); +go_to_bug($sel, $bug1_id); +$sel->type_ok("comment", "Just a comment too..."); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Product Edit Access Denied"); +$sel->is_text_present_ok("You are not permitted to edit bugs in product TestProduct."); +logout($sel); + +# Test searches and "format for printing". + +log_in($sel, $config, 'admin'); +open_advanced_search_page($sel); +$sel->remove_all_selections_ok("product"); +$sel->add_selection_ok("product", "TestProduct"); +$sel->remove_all_selections_ok("bug_status"); +$sel->remove_all_selections_ok("resolution"); +$sel->check_ok("emailassigned_to1"); +$sel->select_ok("emailtype1", "label=is"); +$sel->type_ok("email1", $config->{admin_user_login}); +$sel->check_ok("emailassigned_to2"); +$sel->check_ok("emailqa_contact2"); +$sel->check_ok("emailcc2"); +$sel->select_ok("emailtype2", "label=is"); +$sel->type_ok("email2", $config->{QA_Selenium_TEST_user_login}); +$sel->click_ok("Search"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug List"); + +$sel->is_text_present_ok("One bug found."); +$sel->type_ok("save_newqueryname", "My bugs from QA_Selenium"); +$sel->click_ok("remember"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Search created"); +$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"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug List: My bugs from QA_Selenium"); +$sel->click_ok("long_format"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$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("Assignee: admin <$config->{admin_user_login}>"); +$sel->is_text_present_ok("Severity: blocker"); +$sel->is_text_present_ok("Priority: Highest"); +$sel->is_text_present_ok("I have no privs, I can only comment"); +logout($sel); + +# Let's create a 2nd bug by this user so that we can test mass-change +# using the saved search the admin just created. + +log_in($sel, $config, 'QA_Selenium_TEST'); +file_bug_in_product($sel, 'TestProduct'); +my $bug_summary2 = "New bug from me"; +$sel->select_ok("bug_severity", "label=blocker"); +$sel->type_ok("short_desc", $bug_summary2); +# We turned on the CANEDIT bit for TestProduct. +$sel->type_ok("comment", "I can enter a new bug, but not edit it, right?"); +my $bug2_id = create_bug($sel, $bug_summary2); + +# Clicking the "Back" button and resubmitting the form again should trigger a warning. + +$sel->go_back_ok(); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Enter Bug: TestProduct"); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Suspicious Action"); +$sel->is_text_present_ok("no valid token for the create_bug action while processing the 'post_bug.cgi' script"); +$sel->click_ok("confirm"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/\d+ \S $bug_summary2/, "Bug created"); +$sel->type_ok("comment", "New comment not allowed"); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Product Edit Access Denied"); +$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. + +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!"); +edit_bug($sel, $bug2_id, $bug_summary2); + +# Test mass-change. + +$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->is_text_present_ok("2 bugs found"); +$sel->click_ok("mass_change"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug List"); +$sel->click_ok("check_all"); +$sel->type_ok("comment", 'Mass change"'); +$sel->select_ok("bug_status", "label=RESOLVED"); +$sel->select_ok("resolution", "label=WORKSFORME"); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bugs processed"); + +$sel->click_ok("link=$bug1_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/$bug1_id /); +$sel->selected_label_is("resolution", "WORKSFORME"); +$sel->select_ok("resolution", "label=INVALID"); +edit_bug_and_return($sel, $bug1_id, $bug_summary); +$sel->selected_label_is("resolution", "INVALID"); + +$sel->click_ok("link=History"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$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("Product QA-Selenium-TEST TestProduct"); +$sel->is_text_present_ok("Status CONFIRMED RESOLVED"); + +# Last step: move bugs to another DB, if the extension is enabled. + +if ($config->{test_extensions}) { + set_parameters($sel, { "Bug Moving" => {"move-to-url" => {type => "text", value => 'http://www.foo.com/'}, + "move-to-address" => {type => "text", value => 'import@foo.com'}, + "movers" => {type => "text", value => $config->{admin_user_login}} + } + }); + + $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->is_text_present_ok("2 bugs found"); + $sel->click_ok("mass_change"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Bug List"); + $sel->click_ok("check_all"); + $sel->type_ok("comment", "-> moved"); + $sel->click_ok('oldbugmove'); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Bugs processed"); + $sel->is_text_present_ok("Changes submitted for bug $bug1_id"); + $sel->is_text_present_ok("Changes submitted for bug $bug2_id"); + $sel->click_ok("link=$bug2_id"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_like(qr/^$bug2_id/); + $sel->selected_label_is("resolution", "MOVED"); + $sel->is_text_present_ok("Bug moved to http://www.foo.com/."); + + # Disable bug moving again. + set_parameters($sel, { "Bug Moving" => {"movers" => {type => "text", value => ""}} }); +} + +# 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"); + edit_bug_and_return($sel, $bug1_id, $bug_summary, {id => "confirm"}); + $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"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Bugs processed"); + foreach my $bug_id ($bug1_id, $bug2_id) { + $sel->click_ok("link=$bug_id"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_like(qr/^$bug_id /); + $sel->is_text_present_ok($comment); + next if $bug_id == $bug2_id; + $sel->go_back_ok(); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Bugs processed"); + } +} + +# Now move these bugs out of our radar. + +$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->is_text_present_ok("2 bugs found"); +$sel->click_ok("mass_change"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug List"); +$sel->click_ok("check_all"); +$sel->type_ok("comment", "Reassigning to the reporter"); +$sel->type_ok("assigned_to", $config->{QA_Selenium_TEST_user_login}); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bugs processed"); + +# Now delete the saved search. + +$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("forget_search"); +$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"); + +# Reset the CANEDIT bit. We want it to be turned off by default. +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:"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Edit Group Controls for TestProduct"); + $sel->uncheck_ok("canedit_$master_gid"); + $sel->click_ok("submit"); + $sel->wait_for_page_to_load_ok(WAIT_TIME); + $sel->title_is("Update group access controls for TestProduct"); +} diff --git a/xt/selenium/choose_priority.t b/xt/selenium/choose_priority.t new file mode 100644 index 000000000..1089d2003 --- /dev/null +++ b/xt/selenium/choose_priority.t @@ -0,0 +1,30 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +use 5.10.1; +use strict; +use warnings; + +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; + +use Test::More "no_plan"; + +use QA::Util; + +my ($sel, $config) = get_selenium(); + +log_in($sel, $config, 'admin'); +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} }); +file_bug_in_product($sel, "TestProduct"); +$sel->is_text_present_ok("Priority"); +$sel->is_element_present_ok("//select[\@name='priority']"); +logout($sel); diff --git a/xt/selenium/classifications.t b/xt/selenium/classifications.t new file mode 100644 index 000000000..4d5d012f0 --- /dev/null +++ b/xt/selenium/classifications.t @@ -0,0 +1,142 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +use 5.10.1; +use strict; +use warnings; + +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; + +use Test::More "no_plan"; + +use QA::Util; + +my ($sel, $config) = get_selenium(); + +# Enable classifications + +log_in($sel, $config, 'admin'); +set_parameters($sel, { "Bug Fields" => {"useclassification-on" => undef} }); + +# Create a new classification. + +go_to_admin($sel); +$sel->click_ok("link=Classifications"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Select classification"); + +# Delete old classifications if this script failed. +# 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"); +} +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->click_ok("link=Add a new classification"); +$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->click_ok('//input[@type="submit" and @value="Add"]'); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("New Classification Created"); + +# Add TestProduct to the new classification. There should be no other +# products in this classification. + +$sel->select_ok("prodlist", "value=TestProduct"); +$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'"); + +# Create a new bug in this product/classification. + +file_bug_in_product($sel, 'TestProduct', 'cone'); +my $bug_summary = "Bug in classification cone"; +$sel->type_ok("short_desc", $bug_summary); +$sel->type_ok("comment", "Created by Selenium with classifications turned on"); +create_bug($sel, $bug_summary); + +# 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 +# already in it. + +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("link=cone"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit classification"); +$sel->type_ok("classification", "Unclassified"); +$sel->click_ok("//input[\@value='Update']"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Classification Already Exists"); +$sel->go_back_ok(); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit classification"); +$sel->type_ok("classification", "ctwo"); +$sel->click_ok("//input[\@value='Update']"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Classification Updated"); + +# Now try to delete the 'ctwo' classification. It should fail as there are +# products in it. + +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[@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"); + +# 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[@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"); +$sel->click_ok("remove_products"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$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[@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?"); +$sel->click_ok("//input[\@value='Yes, delete']"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Classification Deleted"); + +# Disable classifications and make sure you cannot edit them anymore. + +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/xt/selenium/config.t b/xt/selenium/config.t new file mode 100644 index 000000000..b99927321 --- /dev/null +++ b/xt/selenium/config.t @@ -0,0 +1,48 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +use 5.10.1; +use strict; +use warnings; + +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; + +use Test::More "no_plan"; + +use QA::Util; + +my ($sel, $config) = get_selenium(); + +# Turn on 'requirelogin' and log out. + +log_in($sel, $config, 'admin'); +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->is_text_present_ok("var status = [ ];"); +$sel->is_text_present_ok("var status_open = [ ];"); +$sel->is_text_present_ok("var status_closed = [ ];"); +$sel->is_text_present_ok("var resolution = [ ];"); +$sel->is_text_present_ok("var keyword = [ ];"); +$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("component["), "No component 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} }); +logout($sel); diff --git a/xt/selenium/create_user_accounts.t b/xt/selenium/create_user_accounts.t new file mode 100644 index 000000000..7c71273a6 --- /dev/null +++ b/xt/selenium/create_user_accounts.t @@ -0,0 +1,139 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +use 5.10.1; +use strict; +use warnings; + +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; + +use Test::More "no_plan"; + +use QA::Util; + +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$'}} }); +logout($sel); + +# Create a valid account. We need to randomize the login address, because a request +# expires after 3 days only and this test can be executed several times per day. +my $valid_account = 'selenium-' . random_string(10) . '@bugzilla.test'; + +$sel->click_ok("link=Home"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bugzilla Main Page"); +$sel->is_text_present_ok("Open a New Account"); +$sel->click_ok("link=Open a New Account"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Create a new Bugzilla account"); +$sel->type_ok("login", $valid_account); +$sel->click_ok("send"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Request for new user account '$valid_account' submitted"); +$sel->is_text_present_ok("A confirmation email has been sent"); + +# Try creating the same account again. It's too soon. +$sel->click_ok("link=Home"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bugzilla Main Page"); +$sel->is_text_present_ok("Open a New Account"); +$sel->click_ok("link=Open a New Account"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Create a new Bugzilla account"); +$sel->type_ok("login", $valid_account); +$sel->click_ok("send"); +$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 10 minutes/, "Too soon for this account"); + +# These accounts do not pass the regexp. +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->click_ok("send"); + $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. +@accounts = ('test\bugzilla@bugzilla.test', '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"); + # Starting with 5.0, the login field is a type=email and is marked "required" + # This means that we need to add the novalidate attribute to the enclosing form + # so that the illegal login can still be checked by the backend code. + my $script = q{ + document.getElementById('account_creation_form').setAttribute('novalidate', 1); + }; + $sel->run_script($script); + $sel->type_ok("login", $account); + $sel->click_ok("send"); + $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. +$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", $config->{admin_user_login}); +$sel->click_ok("send"); +$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"); + +# Turn off user account creation. +log_in($sel, $config, 'admin'); +set_parameters($sel, { "User Authentication" => {"createemailregexp" => {type => "text", value => ''}} }); +logout($sel); + +# Make sure that links pointing to createaccount.cgi are all deactivated. +ok(!$sel->is_text_present("New Account"), "No link named 'New Account'"); +$sel->click_ok("link=Home"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bugzilla Main Page"); +ok(!$sel->is_text_present("Open a New Account"), "No link named 'Open a 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"); + +# Re-enable user account creation. + +log_in($sel, $config, 'admin'); +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); +$sel->click_ok("link=Users"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Search users"); +$sel->type_ok("matchstr", $valid_account); +$sel->click_ok("search"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Select user"); +$sel->is_text_present_ok("0 users found"); +logout($sel); diff --git a/xt/selenium/custom_fields.t b/xt/selenium/custom_fields.t new file mode 100644 index 000000000..6c0c8fa5d --- /dev/null +++ b/xt/selenium/custom_fields.t @@ -0,0 +1,462 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +use 5.10.1; +use strict; +use warnings; + +use FindBin qw($RealBin); +use lib "$RealBin/../lib"; + +use Test::More "no_plan"; + +use QA::Util; + +my ($sel, $config) = get_selenium(); +log_in($sel, $config, 'admin'); + +# Create new bug to test custom fields + +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("bug_severity", "label=normal"); +my $bug1_id = create_bug($sel, $bug_summary); + +# Create custom fields + +go_to_admin($sel); +$sel->click_ok("link=Custom Fields"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Custom Fields"); +$sel->click_ok("link=Add a new custom field"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Add a new Custom Field"); +$sel->type_ok("name", "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->click_ok("create"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Custom Field Created"); +$sel->is_text_present_ok("The new custom field 'cf_qa_freetext_$bug1_id' has been successfully created."); + +$sel->click_ok("link=Add a new custom field"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Add a new Custom Field"); +$sel->type_ok("name", "cf_qa_list_$bug1_id"); +$sel->type_ok("desc", "List$bug1_id"); +$sel->select_ok("type", "label=Drop Down"); +$sel->type_ok("sortkey", $bug1_id); +$sel->click_ok("enter_bug"); +$sel->value_is("enter_bug", "on"); +$sel->click_ok("new_bugmail"); +$sel->value_is("new_bugmail", "on"); +$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->click_ok("link=Add a new custom field"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Add a new Custom Field"); +$sel->type_ok("name", "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("reverse_desc", "IsRef$bug1_id"); +$sel->click_ok("enter_bug"); +$sel->value_is("enter_bug", "on"); +$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."); + +# Add values to the custom fields. + +$sel->click_ok("link=cf_qa_list_$bug1_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit the Custom Field 'cf_qa_list_$bug1_id' (List$bug1_id)"); +$sel->click_ok("link=Edit legal values for this field"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Select value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field"); + +$sel->click_ok("link=Add"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Add Value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field"); +$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->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("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."); + +# Also create a new bug status and a new resolution. + +go_to_admin($sel); +$sel->click_ok("link=Field Values"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit values for which field?"); +$sel->click_ok("link=Resolution"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Select value for the 'Resolution' (resolution) field"); +$sel->click_ok("link=Add"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Add Value for the 'Resolution' (resolution) field"); +$sel->type_ok("value", "UPSTREAM"); +$sel->type_ok("sortkey", 450); +$sel->click_ok("create"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("New Field Value Created"); + +go_to_admin($sel); +$sel->click_ok("link=Field Values"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit values for which field?"); +$sel->click_ok("link=Status"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Select value for the 'Status' (bug_status) field"); +$sel->click_ok("link=Add"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Add Value for the 'Status' (bug_status) field"); +$sel->type_ok("value", "SUSPENDED"); +$sel->type_ok("sortkey", 250); +$sel->click_ok("open_status"); +$sel->click_ok("create"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("New Field Value Created"); + +$sel->click_ok("link=Add"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Add Value for the 'Status' (bug_status) field"); +$sel->type_ok("value", "IN_QA"); +$sel->type_ok("sortkey", 550); +$sel->click_ok("closed_status"); +$sel->click_ok("create"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("New Field Value Created"); + +$sel->click_ok("link=status workflow page"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit Workflow"); +$sel->click_ok('//td[@title="From UNCONFIRMED to SUSPENDED"]//input[@type="checkbox"]'); +$sel->click_ok('//td[@title="From 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"); + +# Create new bug to test custom fields in bug creation page + +file_bug_in_product($sel, 'TestProduct'); +$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"); +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); +my $bug2_id = create_bug($sel, $bug_summary2); + +# Both fields are editable. + +$sel->type_ok("cf_qa_freetext_$bug1_id", "bonsai"); +$sel->selected_label_is("cf_qa_list_$bug1_id", "---"); +$sel->select_ok("bug_status", "label=SUSPENDED"); +edit_bug($sel, $bug2_id, $bug_summary2); + +go_to_bug($sel, $bug1_id); +$sel->type_ok("cf_qa_freetext_$bug1_id", "dumbo"); +$sel->select_ok("cf_qa_list_$bug1_id", "label=storage"); +$sel->is_text_present_ok("IsRef$bug1_id: $bug2_id"); +$sel->select_ok("bug_status", "RESOLVED"); +$sel->select_ok("resolution", "UPSTREAM"); +edit_bug_and_return($sel, $bug1_id, $bug_summary); +$sel->select_ok("bug_status", "IN_QA"); +edit_bug_and_return($sel, $bug1_id, $bug_summary); + +$sel->click_ok("link=Format For Printing"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Full Text Bug Listing"); +$sel->is_text_present_ok("Freetext$bug1_id: dumbo"); +$sel->is_text_present_ok("List$bug1_id: storage"); +$sel->is_text_present_ok("Status: IN_QA UPSTREAM"); +go_to_bug($sel, $bug2_id); +$sel->select_ok("cf_qa_list_$bug1_id", "label=storage"); +edit_bug($sel, $bug2_id, $bug_summary2); + +# Test searching for bugs using the custom fields + +open_advanced_search_page($sel); +$sel->remove_all_selections_ok("product"); +$sel->add_selection_ok("product", "TestProduct"); +$sel->remove_all_selections("bug_status"); +$sel->remove_all_selections("resolution"); +$sel->select_ok("f1", "label=List$bug1_id"); +$sel->select_ok("o1", "label=is equal to"); +$sel->type_ok("v1", "storage"); +$sel->click_ok("Search"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug List"); +$sel->is_text_present_ok("2 bugs found"); +$sel->is_text_present_ok("What's your ID?"); +$sel->is_text_present_ok("Et de un"); + +# Now edit custom fields in mass changes. + +$sel->click_ok("mass_change"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bug List"); +$sel->click_ok("check_all"); +$sel->select_ok("cf_qa_list_$bug1_id", "label=---"); +$sel->type_ok("cf_qa_freetext_$bug1_id", "thanks"); +$sel->click_ok("commit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Bugs processed"); +$sel->click_ok("link=$bug2_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_like(qr/^$bug2_id/); +$sel->value_is("cf_qa_freetext_$bug1_id", "thanks"); +$sel->selected_label_is("cf_qa_list_$bug1_id", "---"); +$sel->select_ok("cf_qa_list_$bug1_id", "label=storage"); +edit_bug($sel, $bug2_id, $bug_summary2); + +# Let's now test custom field visibility. + +go_to_admin($sel); +$sel->click_ok("link=Custom Fields"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Custom Fields"); +$sel->click_ok("link=cf_qa_list_$bug1_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit the Custom Field 'cf_qa_list_$bug1_id' (List$bug1_id)"); +$sel->select_ok("visibility_field_id", "label=Severity (bug_severity)"); +$sel->add_selection_ok("visibility_values", "label=blocker"); +$sel->add_selection_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->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'"); +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'"); +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'"); + +# Add a new value which is only listed under some condition. + +go_to_admin($sel); +$sel->click_ok("link=Custom Fields"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Custom Fields"); +$sel->click_ok("link=cf_qa_list_$bug1_id"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit the Custom Field 'cf_qa_list_$bug1_id' (List$bug1_id)"); +$sel->select_ok("value_field_id", "label=Resolution (resolution)"); +$sel->click_ok("edit"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Custom Field Updated"); +$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->click_ok("link=Edit legal values for this field"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Select value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field"); +$sel->click_ok("link=Add"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Add Value for the 'List$bug1_id' (cf_qa_list_$bug1_id) field"); +$sel->type_ok("value", "ghost"); +$sel->type_ok("sortkey", "500"); +$sel->select_ok("visibility_value_id", "label=FIXED"); +$sel->click_ok("id=create"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("New Field Value Created"); + +go_to_bug($sel, $bug1_id); +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("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"); + +# Delete an unused field value. + +go_to_admin($sel); +$sel->click_ok("link=Field Values"); +$sel->wait_for_page_to_load_ok(WAIT_TIME); +$sel->title_is("Edit values for which field?"); +$sel->click_ok("link=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->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->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); +$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->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->is_text_present_ok("There is 1 bug with this field value"); + +# Mark the