Permalink
Browse files

Merge pull request #111 from sashakruglov/moztrap_2742

Moztrap 2742
  • Loading branch information...
2 parents ae4d5fa + 5e5d74f commit a4d2e6009b7a218c465a18cab41c8e49f126e760 @stephendonner stephendonner committed Apr 7, 2013
Showing with 68 additions and 6 deletions.
  1. +0 −3 pages/base_test.py
  2. +14 −0 pages/edit_suite_page.py
  3. +54 −3 tests/test_manage_suites_page.py
View
@@ -5,7 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from pages.home_page import MozTrapHomePage
-from pages.run_tests_page import MozTrapRunTestsPage
from pages.create_case_page import MozTrapCreateCasePage
from pages.manage_cases_page import MozTrapManageCasesPage
from pages.create_suite_page import MozTrapCreateSuitePage
@@ -164,8 +163,6 @@ def delete_profile(self, mozwebqa, profile):
def create_and_run_test(self, mozwebqa, profile=None):
home_pg = MozTrapHomePage(mozwebqa)
- manage_suites_pg = MozTrapManageSuitesPage(mozwebqa)
- run_tests_pg = MozTrapRunTestsPage(mozwebqa)
if profile is None:
profile = self.create_profile(mozwebqa)
View
@@ -6,6 +6,7 @@
from selenium.webdriver.common.by import By
+from selenium.webdriver.common.action_chains import ActionChains
from pages.base_page import MozTrapBasePage
from pages.page import PageRegion
@@ -69,6 +70,19 @@ def include_cases_to_suite(self, case_name_list, save=True):
if save:
self.save_suite()
+ def reorder_included_cases(self, case_name_list):
+ """ reorder cases via drag and drop """
+ self.wait_for_element_not_present(*self._loading_included_cases_locator)
+
+ for i in xrange(1, len(case_name_list)):
+ case_names = [case.name for case in self.included_cases]
+ j = i - 1
+ while j >= 0 and case_name_list.index(case_names[i]) < case_name_list.index(case_names[j]):
+ ActionChains(self.selenium).drag_and_drop(
+ self.included_cases[j]._selenium_root,
+ self.included_cases[j + 1]._selenium_root).perform()
+ j -= 1
+
class TestCaseItem(PageRegion):
_select_item_locator = (By.CSS_SELECTOR, '.bulk-type')
@@ -4,6 +4,8 @@
# 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/.
+import random
+
import pytest
from unittestzero import Assert
@@ -46,21 +48,22 @@ def test_that_user_can_create_suite_and_add_some_cases_to_it(self, mozwebqa_logg
Assert.true(manage_test_cases_pg.is_element_present(*case['locator']))
@pytest.mark.moztrap(2743)
+ @pytest.mark.nondestructive
def test_editing_of_existing_suite_that_has_no_included_cases(self, mozwebqa_logged_in):
- #create product, suite and cases
+ # create product, suite and cases
product = self.create_product(mozwebqa_logged_in)
suite = self.create_suite(mozwebqa_logged_in, product=product)
cases = self.create_bulk_cases(mozwebqa_logged_in, cases_amount=3, product=product)
- #simulate random order of cases
+ # simulate random order of cases
case_list = [cases[i]['name'] for i in (2, 0, 1)]
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa_logged_in)
manage_suites_pg.go_to_manage_suites_page()
manage_suites_pg.filter_form.filter_by(lookup='name', value=suite['name'])
edit_suite_pg = manage_suites_pg.edit_suite(name=suite['name'])
- #product field should not be read-only.
+ # product field should not be read-only.
Assert.false(
edit_suite_pg.is_product_field_readonly,
u'product version field should be editable')
@@ -76,3 +79,51 @@ def test_editing_of_existing_suite_that_has_no_included_cases(self, mozwebqa_log
Assert.equal(
[item.name for item in edit_suite_pg.included_cases], case_list,
u'items are listed in wrong order')
+
+ @pytest.mark.native
+ @pytest.mark.moztrap(2742)
+ @pytest.mark.nondestructive
+ def test_editing_of_existing_suite_that_includes_cases(self, mozwebqa_logged_in):
+ # create product, suite, cases (both included and not included into suite)
+ product = self.create_product(mozwebqa_logged_in)
+ suite = self.create_suite(mozwebqa_logged_in, product=product)
+ included_cases = self.create_bulk_cases(mozwebqa_logged_in, suite_name=suite['name'], cases_amount=2, product=product)
+ not_included_cases = self.create_bulk_cases(mozwebqa_logged_in, cases_amount=3, product=product)
+
+ # filter by suite name and go to edit suite page
+ manage_suites_pg = MozTrapManageSuitesPage(mozwebqa_logged_in)
+ manage_suites_pg.go_to_manage_suites_page()
+ manage_suites_pg.filter_form.filter_by(lookup='name', value=suite['name'])
+ edit_suite_pg = manage_suites_pg.edit_suite(name=suite['name'])
+
+ Assert.true(
+ edit_suite_pg.is_product_field_readonly,
+ u'product version field should be read only')
+
+ # check list of available cases
+ actual_available_cases = [item.name for item in edit_suite_pg.available_cases]
+ expected_available_cases = [item['name'] for item in not_included_cases]
+ Assert.equal(actual_available_cases, expected_available_cases)
+
+ # check list of included cases
+ actual_included_cases = [item.name for item in edit_suite_pg.included_cases]
+ expected_included_cases = [item['name'] for item in included_cases]
+ Assert.equal(actual_included_cases, expected_included_cases)
+
+ # get all cases names and make random order via random.shuffle
+ all_cases = expected_available_cases + expected_included_cases
+ random.shuffle(all_cases)
+
+ # include new cases to suite and reorder them in accordance with all_cases list
+ edit_suite_pg.include_cases_to_suite(actual_available_cases, save=False)
+ edit_suite_pg.reorder_included_cases(all_cases)
+ edit_suite_pg.save_suite()
+
+ # re-edit the same suite
+ manage_suites_pg.filter_form.filter_by(lookup='name', value=suite['name'])
+ edit_suite_pg = manage_suites_pg.edit_suite(name=suite['name'])
+
+ # and ensure that included cases are listed in right order
+ Assert.equal(
+ [item.name for item in edit_suite_pg.included_cases], all_cases,
+ u'items are listed in wrong order')

0 comments on commit a4d2e60

Please sign in to comment.