Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Issue #87. Test for MozTrap #5935 #94

Merged
merged 6 commits into from

5 participants

@AndreiH
Collaborator

Lgtm :+1:

@sashakruglov sashakruglov commented on the diff
pages/manage_runs_page.py
@@ -5,6 +5,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from selenium.webdriver.common.by import By
+from selenium.webdriver.support.color import Color
@sashakruglov Collaborator

warning! that is relatively new feature in webdriver, so it will cause ImportError with obsolete versions of selenium

@AlinT
AlinT added a note

I don't think we are going to have this problem, due to the fact that we are using latest selenium version(2.28.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@AlinT

Looks good to me!

tests/test_pinning_filters.py
((19 lines not shown))
+ @pytest.mark.nondestructive
+ def test_that_pinned_product_version_is_defaulted_on_test_run_creation(self, mozwebqa_logged_in):
+ product = self.create_product(mozwebqa_logged_in)
+ product_version = u'%s %s' % (product['name'], product['version']['name'])
+
+ manage_runs_pg = MozTrapManageRunsPage(mozwebqa_logged_in)
+ manage_runs_pg.go_to_manage_runs_page()
+ manage_runs_pg.filter_runs_by_product_version(product_version)
+ manage_runs_pg.pin_product_version()
+
+ Assert.equal(
+ manage_runs_pg.pinned_filter_color.upper(),
+ u'#DFB081')
+
+ create_run_pg = MozTrapCreateRunPage(mozwebqa_logged_in)
+ create_run_pg.go_to_create_run_page()
@sashakruglov Collaborator

will change this part to make test closer to steps in test case.
click create run button and go_to_create_run_page() doesn't click button, but opens page by direct URL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sashakruglov
Collaborator

so, would you merge it into master? i would like to write some more tests for pinning filters and i need to know to what branch commit.

@sashakruglov
Collaborator

@AlinT , @AndreiH what do you think about moving filters into separate module?
I think I managed to migrate without braking any tests - https://github.com/sashakruglov/moztrap-tests/tree/filter_refactoring.

@AndreiH
Collaborator

Looked over the code. It should be more organized that way, but are you sure the tests weren't altered because "test_that_user_can_filter_product_by_name_without_mouse" is failing for me. What do you think @AlinT ?

@sashakruglov
Collaborator

@AndreiH will look into it.

@AlinT

@sashakruglov the reorganization is the best practice here.
However in branch filter_refactoring you have some remaining code from pull #93 , in several files:
https://github.com/sashakruglov/moztrap-tests/blob/filter_refactoring/pages/base_test.py#L21
My suggestion is wait until we merge pull #93 (this won't take much longer) and then submit a new pull for code review with filter_refactoring.

@sashakruglov
Collaborator

@AlinT it's true, i checked out this branch from the other one, not from master. it would be better to merge two my previous pull requests, so i can resolve all conflicts and update this pull request. apart from that, do you have any other suggestions?

@AlinT

@sashakruglov I don't have any suggestions for now, I'll wait until you have a pull request up for this :)

@sashakruglov
Collaborator

@AndreiH could you please provide traceback and in what browser this test fails? I guess that is not firefox?

@sashakruglov
Collaborator

@AndreiH bunch of tests are failing for me in chomium (on ubuntu).
so problem existed before, will try to fix at least issue with filters in chromium.

well, to be honest, there are so issues introduced by me into filters, and i think i've resolved them.

@AndreiH
Collaborator

We should investigate further after we merge this one and you request a pull for that. Please fix merge conflicts.

@sashakruglov
Collaborator

@AndreiH fixed merge conflict

@AlinT

LGTM

@teodosia
Collaborator

Lgtm too.

@m8ttyB
Owner

thx @sashakruglov looks good to me. @AlinT and @teodosia thanks for your excellent reviews.

One nit for future pulls please run a pep8 checker against the code. pep8 flaged a few issues in this pull request but I'll let them slip through so we can get this coverage.

Merged
pew_pew_pew

@m8ttyB m8ttyB merged commit d91483b into from
@sashakruglov sashakruglov deleted the branch
@sashakruglov
Collaborator

@m8ttyB thanks. Could you recommend some pep8 checker?

@m8ttyB
Owner

@sashakruglov more than happy to -- it depends on which env you're using and which setup feels best to you.
One option is to install pep8 with pip and then run the checker directly from the command-line:
pip install pep8
pep8 name_of_file_or_directory

A second option is to setup a pre-commit hook for pep8:
https://wiki.mozilla.org/QA/Execution/Web_Testing/Automation/PEP8_Pre_Commit_Hook

If you have any questions stop into our #mozwebqa irc channel and we'll help you sort it out.

@sashakruglov
Collaborator

@m8ttyB great! I'll try pep8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 13, 2013
  1. @sashakruglov
Commits on Jan 15, 2013
  1. @sashakruglov

    Fixed class name

    sashakruglov authored
  2. @sashakruglov
  3. @sashakruglov

    removed unused import

    sashakruglov authored
  4. @sashakruglov

    changed name of test

    sashakruglov authored
Commits on Jan 17, 2013
  1. @sashakruglov

    merge with master

    sashakruglov authored
This page is out of date. Refresh to see the latest.
View
5 pages/create_run_page.py
@@ -71,3 +71,8 @@ def create_run(self, name='Test Run', product_version='Test Product Test Version
self.selenium.find_element(*self._submit_locator).click()
return run
+
+ @property
+ def product_version(self):
+ product_version_select = Select(self.selenium.find_element(*self._product_version_select_locator))
+ return product_version_select.first_selected_option.text
View
40 pages/manage_runs_page.py
@@ -5,6 +5,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from selenium.webdriver.common.by import By
+from selenium.webdriver.support.color import Color
@sashakruglov Collaborator

warning! that is relatively new feature in webdriver, so it will cause ImportError with obsolete versions of selenium

@AlinT
AlinT added a note

I don't think we are going to have this problem, due to the fact that we are using latest selenium version(2.28.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
from pages.base_page import MozTrapBasePage
@@ -13,19 +14,32 @@ class MozTrapManageRunsPage(MozTrapBasePage):
_page_title = 'Manage-Runs'
+ _create_run_locator = (By.CSS_SELECTOR, '#manageruns .create.single')
_delete_run_locator = (By.CSS_SELECTOR, '#manageruns .itemlist .listitem[data-title="%(run_name)s"] .action-delete')
_run_activate_locator = (By.CSS_SELECTOR, '#manageruns .itemlist .listitem[data-title="%(run_name)s"] .status-action.active')
_run_draft_locator = (By.CSS_SELECTOR, '#manageruns .itemlist .listitem[data-title="%(run_name)s"] .status-action.draft')
_run_status_locator = (By.CSS_SELECTOR, '#manageruns .itemlist .listitem[data-title="%(run_name)s"] .status-title')
_edit_run_locator = (By.CSS_SELECTOR, '#manageruns .itemlist .listitem[data-title="%(run_name)s"] .edit-link')
_filter_input_locator = (By.ID, 'text-filter')
- _filter_suggestion_locator = (By.CSS_SELECTOR, '#filter .textual .suggest .suggestion[data-type="name"][data-name="%(filter_name)s"]')
- _filter_locator = (By.CSS_SELECTOR, '#filterform .filter-group input[data-name="name"][value="%(filter_name)s"]:checked')
+ _filter_suggestion_by_name_locator = (By.CSS_SELECTOR,
+ '#filter .textual .suggest .suggestion[data-type="name"][data-name="%(filter_name)s"]')
+ _filter_suggestion_by_product_version_locator = (By.CSS_SELECTOR,
+ '#filter .textual .suggest .suggestion[data-type="productversion"][data-name="%(filter_name)s"]')
+ _filter_locator = (By.CSS_SELECTOR,
+ '#filterform .filter-group input[data-name="name"][value="%(filter_name)s"]:checked')
+ _pin_filter_button_locator = (By.CSS_SELECTOR,
+ '#filterform input[data-name="productversion"]:checked + .onoff .pinswitch')
+ _pinned_filter_locator = (By.CSS_SELECTOR, '#filterform .onoff.pinned')
def go_to_manage_runs_page(self):
self.selenium.get(self.base_url + '/manage/runs/')
self.is_the_current_page
+ def click_create_run_button(self):
+ self.selenium.find_element(*self._create_run_locator).click()
+ from pages.create_run_page import MozTrapCreateRunPage
+ return MozTrapCreateRunPage(self.testsetup)
+
def delete_run(self, name='Test Run'):
_delete_locator = (self._delete_run_locator[0], self._delete_run_locator[1] % {'run_name': name})
@@ -33,12 +47,23 @@ def delete_run(self, name='Test Run'):
self.wait_for_ajax()
def filter_runs_by_name(self, name):
- _filter_suggestion_locator = (self._filter_suggestion_locator[0], self._filter_suggestion_locator[1] % {'filter_name': name})
+ _filter_suggestion_locator = (
+ self._filter_suggestion_by_name_locator[0],
+ self._filter_suggestion_by_name_locator[1] % {'filter_name': name})
self.selenium.find_element(*self._filter_input_locator).send_keys(name)
self.selenium.find_element(*_filter_suggestion_locator).click()
self.wait_for_ajax()
+ def filter_runs_by_product_version(self, product_version):
+ _filter_suggestion_locator = (
+ self._filter_suggestion_by_product_version_locator[0],
+ self._filter_suggestion_by_product_version_locator[1] % {'filter_name': product_version})
+
+ self.selenium.find_element(*self._filter_input_locator).send_keys(product_version)
+ self.selenium.find_element(*_filter_suggestion_locator).click()
+ self.wait_for_ajax()
+
def remove_name_filter(self, name):
_filter_locator = (self._filter_locator[0], self._filter_locator[1] % {'filter_name': name.lower()})
@@ -69,3 +94,12 @@ def go_to_edit_run_page(self, name='Test Run'):
self.selenium.find_element(*_edit_run_locator).click()
from pages.edit_run_page import MozTrapEditRunPage
return MozTrapEditRunPage(self.testsetup)
+
+ def pin_product_version(self):
+ self.selenium.find_element(*self._pin_filter_button_locator).click()
+
+ @property
+ def pinned_filter_color(self, coding='hex'):
+ pinned_filter = self.selenium.find_element(*self._pinned_filter_locator)
+ color = pinned_filter.value_of_css_property('background-color')
+ return getattr(Color.from_string(color), coding)
View
36 tests/test_pinning_filters.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+
+# 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/.
+
+import pytest
+
+from unittestzero import Assert
+
+from pages.base_test import BaseTest
+from pages.manage_runs_page import MozTrapManageRunsPage
+
+
+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):
+ product = self.create_product(mozwebqa_logged_in)
+ product_version = u'%s %s' % (product['name'], product['version']['name'])
+
+ manage_runs_pg = MozTrapManageRunsPage(mozwebqa_logged_in)
+ manage_runs_pg.go_to_manage_runs_page()
+ manage_runs_pg.filter_runs_by_product_version(product_version)
+ manage_runs_pg.pin_product_version()
+
+ Assert.equal(
+ manage_runs_pg.pinned_filter_color.upper(),
+ u'#DFB081')
+
+ create_run_pg = manage_runs_pg.click_create_run_button()
+
+ Assert.equal(
+ create_run_pg.product_version,
+ product_version)
Something went wrong with that request. Please try again.