Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue #87. Test for MozTrap 5930

  • Loading branch information...
commit 515de214f6a5ae969b5480a1e651e8c5064b1cbb 1 parent 2bdb4e2
@sashakruglov authored
View
15 pages/manage_cases_page.py
@@ -8,6 +8,7 @@
from pages.base_page import MozTrapBasePage
from pages.regions.filter import Filter
+from pages.page import PageRegion
class MozTrapManageCasesPage(MozTrapBasePage):
@@ -16,6 +17,7 @@ class MozTrapManageCasesPage(MozTrapBasePage):
_delete_case_locator = (By.CSS_SELECTOR, '#managecases .itemlist .listitem[data-title="%(case_name)s"] .action-delete')
_case_status_locator = (By.CSS_SELECTOR, '#managecases .itemlist .listitem[data-title="%(case_name)s"] .status-action')
+ _test_case_item_locator = (By.CSS_SELECTOR, '.listitem.active')
@property
def filter_form(self):
@@ -36,3 +38,16 @@ def activate_case(self, name='Test Case'):
self.selenium.find_element(*_case_status_locator).click()
self.wait_for_ajax()
+
+ @property
+ def test_cases(self):
+ return [self.TestCaseItem(self.testsetup, web_element)
+ for web_element in self.find_elements(*self._test_case_item_locator)]
+
+ class TestCaseItem(PageRegion):
+
+ _case_title_locator = (By.CSS_SELECTOR, '.title')
+
+ @property
+ def name(self):
+ return self.find_element(*self._case_title_locator).text
View
15 pages/manage_suites_page.py
@@ -8,6 +8,7 @@
from pages.base_page import MozTrapBasePage
from pages.regions.filter import Filter
+from pages.page import PageRegion
class MozTrapManageSuitesPage(MozTrapBasePage):
@@ -17,6 +18,7 @@ class MozTrapManageSuitesPage(MozTrapBasePage):
_delete_suite_locator = (By.CSS_SELECTOR, '#managesuites .itemlist .listitem[data-title="%(suite_name)s"] .action-delete')
_suite_status_locator = (By.CSS_SELECTOR, '#managesuites .itemlist .listitem[data-title="%(suite_name)s"] .status-action')
_view_cases_locator = ((By.CSS_SELECTOR, '#managesuites .itemlist .listitem[data-title="%(suite_name)s"] .casecount .drill-link'))
+ _test_suite_item_locator = (By.CSS_SELECTOR, '#manage-suites-form .listitem')
@property
def filter_form(self):
@@ -43,3 +45,16 @@ def view_cases(self, name='Test Suite'):
self.selenium.find_element(*_view_cases_locator).click()
from pages.manage_cases_page import MozTrapManageCasesPage
return MozTrapManageCasesPage(self.testsetup)
+
+ @property
+ def test_suites(self):
+ return [self.TestSuiteItem(self.testsetup, web_element)
+ for web_element in self.find_elements(*self._test_suite_item_locator)]
+
+ class TestSuiteItem(PageRegion):
+
+ _suite_title_locator = (By.CSS_SELECTOR, '.title')
+
+ @property
+ def name(self):
+ return self.find_element(*self._suite_title_locator).text
View
21 pages/regions/filter.py
@@ -18,9 +18,10 @@ class Filter(Page):
_filter_suggestion_locator = (
By.CSS_SELECTOR,
'.textual .suggest .suggestion[data-type="%(filter_type)s"][data-name="%(filter_name)s"]')
- _filter_item_locator = (
+ _detailed_filter_item_locator = (
By.CSS_SELECTOR,
'input[data-name="%(filter_type)s"][value="%(filter_name)s"]:checked + .onoff')
+ _filter_item_locator = (By.CSS_SELECTOR, 'input:checked + .onoff')
def filter_by(self, lookup, value):
_suggestion_locator = (
@@ -36,8 +37,8 @@ def filter_by(self, lookup, value):
suggestion.click()
_filter_item_locator = (
- self._filter_item_locator[0],
- self._filter_item_locator[1] % {'filter_type': lookup, 'filter_name': data_id.lower()})
+ self._detailed_filter_item_locator[0],
+ self._detailed_filter_item_locator[1] % {'filter_type': lookup, 'filter_name': data_id.lower()})
self.wait_for_element_to_be_visible(*_filter_item_locator)
self.wait_for_ajax()
@@ -58,8 +59,8 @@ def filter_without_mouse_by(self, lookup, value):
suggestion.click()
_filter_item_locator = (
- self._filter_item_locator[0],
- self._filter_item_locator[1] % {'filter_type': lookup, 'filter_name': data_id.lower()})
+ self._detailed_filter_item_locator[0],
+ self._detailed_filter_item_locator[1] % {'filter_type': lookup, 'filter_name': data_id.lower()})
filter_input.send_keys(Keys.RETURN)
self.wait_for_element_to_be_visible(*_filter_item_locator)
@@ -69,11 +70,17 @@ def filter_without_mouse_by(self, lookup, value):
filter_item = self.find_element(*_filter_item_locator)
return FilterItem(self.testsetup, filter_item)
+ @property
+ def filter_items(self):
+ return [FilterItem(self.testsetup, web_element)
+ for web_element in self.find_elements(*self._filter_item_locator)]
+
class FilterItem(PageRegion):
_remove_button_locator = (By.CSS_SELECTOR, '.onoffswitch')
_pin_button_locator = (By.CSS_SELECTOR, '.pinswitch')
+ _filter_content_locator = (By.CSS_SELECTOR, '.content')
def pin_filter(self):
self.find_element(*self._pin_button_locator).click()
@@ -89,3 +96,7 @@ def get_filter_color(self, coding='hex'):
@property
def is_pinned(self):
return u'pinned' in self._selenium_root.get_attribute('className')
+
+ @property
+ def content_text(self):
+ return self.find_element(*self._filter_content_locator).text
View
77 tests/test_pinning_filters.py
@@ -12,12 +12,14 @@
from pages.manage_runs_page import MozTrapManageRunsPage
+PINNED_FILTER_COLOR = u'#DFB081'
+
+
class TestPinningFilters(BaseTest):
@pytest.mark.moztrap(5935)
@pytest.mark.nondestructive
def test_that_pinning_filter_on_product_version_set_defaults_in_new_run(self, mozwebqa_logged_in):
- pinned_filter_color = u'#DFB081'
product = self.create_product(mozwebqa_logged_in)
product_version_name = u'%s %s' % (product['name'], product['version']['name'])
@@ -29,17 +31,86 @@ def test_that_pinning_filter_on_product_version_set_defaults_in_new_run(self, mo
#check that filter is not orange before it's pinned
Assert.not_equal(
filter_item.get_filter_color(),
- pinned_filter_color)
+ PINNED_FILTER_COLOR)
filter_item.pin_filter()
#check that filter is orange after it's been pinned
Assert.equal(
filter_item.get_filter_color(),
- pinned_filter_color)
+ PINNED_FILTER_COLOR)
create_run_pg = manage_runs_pg.click_create_run_button()
Assert.equal(
create_run_pg.product_version,
product_version_name)
+
+ @pytest.mark.moztrap(5930)
+ @pytest.mark.nondestructive
+ def test_that_pinning_name_field_filter_only_works_for_current_page(self, mozwebqa_logged_in):
+ good_case_name = u'MOZILLA'
+ good_suite_name = u'MozTrap'
+
+ product = self.create_product(mozwebqa_logged_in)
+ first_cases_set = self.create_bulk_cases(mozwebqa_logged_in, name=good_case_name, product=product, cases_amount=3)
+ second_cases_set = self.create_bulk_cases(mozwebqa_logged_in, name=u'ALLIZOM', product=product, cases_amount=2)
+ first_suite = self.create_suite(mozwebqa_logged_in, name=good_suite_name, product=product)
+ second_suite = self.create_suite(mozwebqa_logged_in, name=u'PartZom', product=product)
+
+ from pages.manage_cases_page import MozTrapManageCasesPage
+ manage_cases_pg = MozTrapManageCasesPage(mozwebqa_logged_in)
+ manage_cases_pg.go_to_manage_cases_page()
+
+ #filter cases by name and assert that only cases with mozilla in their name are found
+ cases_filter = manage_cases_pg.filter_form.filter_by(lookup='name', value=good_case_name)
+ Assert.equal(cases_filter.content_text, good_case_name.lower())
+ Assert.not_equal(cases_filter.get_filter_color(), PINNED_FILTER_COLOR)
+ for case in manage_cases_pg.test_cases:
+ Assert.contains(good_case_name, case.name)
+
+ #pin filter and assert that it turns orange
+ cases_filter.pin_filter()
+ Assert.equal(cases_filter.get_filter_color(), PINNED_FILTER_COLOR)
+
+ from pages.manage_suites_page import MozTrapManageSuitesPage
+ manage_suites_pg = MozTrapManageSuitesPage(mozwebqa_logged_in)
+ manage_suites_pg.go_to_manage_suites_page()
+
+ #check that there is no filters applied
+ Assert.equal(manage_suites_pg.filter_form.filter_items, [])
+
+ #filter suites by name and assert that only suites with moztrap in their name are found
+ suites_filter = manage_suites_pg.filter_form.filter_by(lookup='name', value=good_suite_name)
+ Assert.equal(suites_filter.content_text, good_suite_name.lower())
+ Assert.not_equal(suites_filter.get_filter_color(), PINNED_FILTER_COLOR)
+ for suite in manage_suites_pg.test_suites:
+ Assert.contains(good_suite_name, suite.name)
+
+ #pin filter and assert that it turns orange
+ suites_filter.pin_filter()
+ Assert.equal(suites_filter.get_filter_color(), PINNED_FILTER_COLOR)
+
+ #and check everything again on manage cases page
+ manage_cases_pg.go_to_manage_cases_page()
+ applied_filter = manage_cases_pg.filter_form.filter_items
+ Assert.equal(len(applied_filter), 1)
+ Assert.equal(applied_filter[0].content_text, good_case_name.lower())
+ for case in manage_cases_pg.test_cases:
+ Assert.contains(good_case_name, case.name)
+
+ #and check everything one more time on manage suites page
+ manage_suites_pg.go_to_manage_suites_page()
+ applied_filter = manage_suites_pg.filter_form.filter_items
+ Assert.equal(len(applied_filter), 1)
+ Assert.equal(applied_filter[0].content_text, good_suite_name.lower())
+ for suite in manage_suites_pg.test_suites:
+ Assert.contains(good_suite_name, suite.name)
+
+ #and go to manage runs page and see no filters there
+ from pages.manage_runs_page import MozTrapManageRunsPage
+ manage_runs_pg = MozTrapManageRunsPage(mozwebqa_logged_in)
+ manage_runs_pg.go_to_manage_runs_page()
+
+ #check that there is no filters applied
+ Assert.equal(manage_runs_pg.filter_form.filter_items, [])
Please sign in to comment.
Something went wrong with that request. Please try again.