Optimise test_filter_panel_reset_button by introducing locators for in-progress jobs

This commit is contained in:
Dave Hunt 2017-10-25 16:25:52 +01:00 коммит произвёл Ed Morley
Родитель 1c4ee76326
Коммит ace72dcd1e
2 изменённых файлов: 22 добавлений и 3 удалений

Просмотреть файл

@ -58,6 +58,11 @@ class TreeherderPage(Base):
def all_jobs(self):
return list(itertools.chain.from_iterable([r.jobs for r in self.result_sets]))
@property
def all_in_progress_jobs(self):
return list(itertools.chain.from_iterable(
r.in_progress_jobs for r in self.result_sets))
@property
def checkbox_busted_is_selected(self):
return self.find_element(*self._filter_panel_busted_failures_locator).is_selected()
@ -288,8 +293,10 @@ class TreeherderPage(Base):
_email_locator = (By.CSS_SELECTOR, '.result-set-title-left > th-author > span > a')
_job_groups_locator = (By.CSS_SELECTOR, '.job-group')
_jobs_locator = (By.CSS_SELECTOR, '.job-btn.filter-shown')
_pending_jobs_locator = (By.CSS_SELECTOR, '.job-btn.filter-shown.btn-ltgray')
_pin_all_jobs_locator = (By.CLASS_NAME, 'pin-all-jobs-btn')
_platform_locator = (By.CLASS_NAME, 'platform')
_running_jobs_locator = (By.CSS_SELECTOR, '.job-btn.filter-shown.btn-dkgray')
_set_bottom_of_range_locator = (By.CSS_SELECTOR, '.open ul > li:nth-child(9) > a')
_set_top_of_range_locator = (By.CSS_SELECTOR, '.open ul > li:nth-child(8) > a')
@ -309,6 +316,10 @@ class TreeherderPage(Base):
def email_name(self):
return self.find_element(*self._email_locator).text
@property
def in_progress_jobs(self):
return self.pending_jobs + self.running_jobs
@property
def job_groups(self):
return [self.JobGroup(self.page, root=el) for el in self.find_elements(*self._job_groups_locator)]
@ -317,9 +328,17 @@ class TreeherderPage(Base):
def jobs(self):
return [self.Job(self.page, root=el) for el in self.find_elements(*self._jobs_locator)]
@property
def pending_jobs(self):
return [self.Job(self.page, root=el) for el in self.find_elements(*self._pending_jobs_locator)]
def pin_all_jobs(self):
return self.find_element(*self._pin_all_jobs_locator).click()
@property
def running_jobs(self):
return [self.Job(self.page, root=el) for el in self.find_elements(*self._running_jobs_locator)]
def set_as_bottom_of_range(self):
# FIXME workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1411264
el = self.page.find_element(By.CSS_SELECTOR, 'body')

Просмотреть файл

@ -45,11 +45,11 @@ def test_filter_panel_reset_button(base_url, selenium):
"""Open Treeherder page, hide jobs in progress, reset filters button and
verify in progress jobs are displayed"""
page = TreeherderPage(selenium, base_url).open()
assert any(j for j in page.all_jobs if j.in_progress)
assert page.all_in_progress_jobs
page.filter_job_in_progress()
assert not page.nav_filter_in_progress_is_selected
assert not any(j for j in page.all_jobs if j.in_progress)
assert not page.all_in_progress_jobs
page.click_on_filters_panel()
page.reset_filters()
assert page.nav_filter_in_progress_is_selected
assert any(j for j in page.all_jobs if j.in_progress)
assert page.all_in_progress_jobs