From 8414d19404fc26a9219e4ec7d7a9f6e92debfb7b Mon Sep 17 00:00:00 2001 From: Tetiana Churikova Date: Wed, 24 Jan 2018 12:58:58 +0200 Subject: [PATCH] Config support and other little improvements (#231) * Configure work with remote config; add stepa to verify issue title; * transfer settings to global .gitignore * Change channel and repo path * Delete local env by default * change locator for BountyFooters --- .gitignore | 1 - doc/testing.md | 4 +-- test/end-to-end/pages/openbounty/bounties.py | 28 ++++++++++++++++++++ test/end-to-end/pages/openbounty/landing.py | 3 ++- test/end-to-end/pages/thirdparty/github.py | 6 ++++- test/end-to-end/tests/__init__.py | 11 +++++++- test/end-to-end/tests/basetestcase.py | 14 +++++++--- test/end-to-end/tests/config_example.ini | 13 +++++++++ test/end-to-end/tests/test_contracts.py | 24 +++++++++++++++-- 9 files changed, 92 insertions(+), 12 deletions(-) create mode 100644 test/end-to-end/tests/config_example.ini diff --git a/.gitignore b/.gitignore index 0e3eb68..4f4f73c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,3 @@ profiles.clj .idea resources/contracts node_modules -.DS_Store diff --git a/doc/testing.md b/doc/testing.md index a3e59d0..c0ad83f 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -10,7 +10,7 @@ For testing you will need: * a Github account with administrative access to one or more repositories * for approving bounty payouts you will additionally need access to an Ethereum wallet. So far, Mist and [MetaMask](https://metamask.io/) have been used, but anything that provides the web3 javascript interface should work. -The developers can be reached on the `#commiteth` channel in the [Status slack](http://slack.status.im/). +The developers can be reached on the `#openbounty` channel in the [Status slack](http://slack.status.im/). ### Signing up @@ -60,6 +60,6 @@ To remove issue from the Bounties list you can close it in GitHub. ### Reporting bugs -All bugs should be reported as issues in the [CommitETH Github repository](https://github.com/status-im/commiteth/issues). +All bugs should be reported as issues in the [OpenBounty Github repository](https://github.com/status-im/open-bounty/issues). Please first check that there is not already a duplicate issue. Issues should contain exact and minimal step-by-step instructions for reproducing the problem. diff --git a/test/end-to-end/pages/openbounty/bounties.py b/test/end-to-end/pages/openbounty/bounties.py index 91415fd..24a47bc 100644 --- a/test/end-to-end/pages/openbounty/bounties.py +++ b/test/end-to-end/pages/openbounty/bounties.py @@ -1,5 +1,6 @@ from pages.base_page import BasePageObject from pages.base_element import * +from tests import test_data class BountiesHeader(BaseText): @@ -15,11 +16,38 @@ class TopHuntersHeader(BaseText): super(TopHuntersHeader, self).__init__(driver) self.locator = self.Locator.css_selector('.top-hunters-header') +class BountyTitles(BaseText): + + def __init__(self, driver): + super(BountyTitles, self).__init__(driver) + self.locator = self.Locator.css_selector('.open-bounty-item-content .header') + + +class BountyItemRows(BaseText): + + def __init__(self, driver): + super(BountyItemRows, self).__init__(driver) + self.locator = self.Locator.css_selector('.open-bounty-item-content .bounty-item-row') + +class BountyFooters(BaseText): + + def __init__(self, driver): + super(BountyFooters, self).__init__(driver) + self.locator = self.Locator.css_selector('.open-bounty-item-content .footer-row') + class BountiesPage(BasePageObject): def __init__(self, driver): super(BountiesPage, self).__init__(driver) + self.driver = driver self.bounties_header = BountiesHeader(self.driver) self.top_hunters_header = TopHuntersHeader(self.driver) + self.bounty_titles = BountyTitles(self.driver) + self.bounty_item_rows = BountyItemRows(self.driver) + self.bounty_footers = BountyFooters(self.driver) + + def get_bounties_page(self): + self.driver.get(test_data.config['Common']['url'] + 'app') + diff --git a/test/end-to-end/pages/openbounty/landing.py b/test/end-to-end/pages/openbounty/landing.py index 7886f90..71f47f1 100644 --- a/test/end-to-end/pages/openbounty/landing.py +++ b/test/end-to-end/pages/openbounty/landing.py @@ -1,5 +1,6 @@ from pages.base_page import BasePageObject from pages.base_element import * +from tests import test_data class LoginButton(BaseButton): @@ -20,4 +21,4 @@ class LandingPage(BasePageObject): self.login_button = LoginButton(self.driver) def get_landing_page(self): - self.driver.get('https://openbounty.status.im:444/') + self.driver.get(test_data.config['Common']['url']) diff --git a/test/end-to-end/pages/thirdparty/github.py b/test/end-to-end/pages/thirdparty/github.py index eaf3c84..0d00335 100644 --- a/test/end-to-end/pages/thirdparty/github.py +++ b/test/end-to-end/pages/thirdparty/github.py @@ -1,6 +1,7 @@ import time, pytest from pages.base_element import * from pages.base_page import BasePageObject +from tests import test_data class EmailEditbox(BaseEditBox): @@ -156,11 +157,14 @@ class GithubPage(BasePageObject): def create_new_bounty(self): self.get_issues_page() self.new_issue_button.click() - self.issue_title_input.send_keys('auto_test_bounty_%s' % self.time_now) + test_data.issue = dict() + test_data.issue['title'] = 'auto_test_bounty_%s' % self.time_now + self.issue_title_input.send_keys(test_data.issue['title']) self.labels_button.click() self.bounty_label.click() self.cross_button.click() self.submit_new_issue_button.click() + return test_data.issue['title'] def get_deployed_contract(self, wait=120): for i in range(wait): diff --git a/test/end-to-end/tests/__init__.py b/test/end-to-end/tests/__init__.py index d9e141d..41ae6be 100644 --- a/test/end-to-end/tests/__init__.py +++ b/test/end-to-end/tests/__init__.py @@ -1,8 +1,17 @@ - +import configparser class TestData(object): def __init__(self): self.test_name = None + self.config = configparser.ConfigParser() + + # define here path to your config.ini file + #example - config_example.ini + + self.config.read('config.ini') + self.base_case_issue = dict() + self.base_case_issue['title'] = 'Very first auto_test_bounty' + test_data = TestData() diff --git a/test/end-to-end/tests/basetestcase.py b/test/end-to-end/tests/basetestcase.py index b658ed1..9ba9409 100644 --- a/test/end-to-end/tests/basetestcase.py +++ b/test/end-to-end/tests/basetestcase.py @@ -46,16 +46,22 @@ class BaseTestCase: def setup_method(self): self.errors = [] + self.cleanup = None if self.environment == 'local': options = webdriver.ChromeOptions() options.add_argument('--start-fullscreen') - self.driver = webdriver.Chrome(options=options) + options.add_extension( + path.abspath(test_data.config['Paths']['tests_absolute'] + 'resources/metamask3_12_0.crx')) + # for chromedriver 2.35 + self.driver = webdriver.Chrome(chrome_options=options) if self.environment == 'sauce': self.driver = webdriver.Remote(self.executor_sauce_lab, desired_capabilities=self.capabilities_sauce_lab) self.driver.implicitly_wait(5) + + def verify_no_errors(self): if self.errors: msg = '' @@ -64,9 +70,9 @@ class BaseTestCase: pytest.fail(msg, pytrace=False) def teardown_method(self): - - remove_application(self.driver) - remove_installation(self.driver) + if self.cleanup: + remove_application(self.driver) + remove_installation(self.driver) try: self.print_sauce_lab_info(self.driver) diff --git a/test/end-to-end/tests/config_example.ini b/test/end-to-end/tests/config_example.ini new file mode 100644 index 0000000..4b52a24 --- /dev/null +++ b/test/end-to-end/tests/config_example.ini @@ -0,0 +1,13 @@ +[Common] +;app URL +url = https://openbounty.status.im:444/ +[Paths] +;AbsolutePath to 'tests' folder +tests_absolute = /usr/dir/open-bounty/test/end-to-end/tests/ +[ORG] +;GitHub credentials for organization +gh_login = login +gh_password = password +;MetaMask password for organization +mm_password = password + diff --git a/test/end-to-end/tests/test_contracts.py b/test/end-to-end/tests/test_contracts.py index 6e617f3..5564b7b 100644 --- a/test/end-to-end/tests/test_contracts.py +++ b/test/end-to-end/tests/test_contracts.py @@ -1,22 +1,42 @@ import pytest from os import environ from pages.openbounty.landing import LandingPage +from pages.openbounty.bounties import BountiesPage from tests.basetestcase import BaseTestCase +from tests import test_data @pytest.mark.sanity class TestLogin(BaseTestCase): def test_deploy_new_contract(self): + self.cleanup = True landing = LandingPage(self.driver) landing.get_landing_page() + + # Sign Up to SOB github = landing.login_button.click() - github.sign_in('anna04test', - 'f@E23D3H15Rd') + github.sign_in(test_data.config['ORG']['gh_login'], + test_data.config['ORG']['gh_password']) assert github.permission_type.text == 'Personal user data' bounties_page = github.authorize_sob.click() + + # SOB Plugin installation and navigate to "Open bounties" github.install_sob_plugin() assert bounties_page.bounties_header.text == 'Bounties' assert bounties_page.top_hunters_header.text == 'Top 5 hunters' + + # Waiting for deployed contract; test_data.issue created here github.create_new_bounty() github.get_deployed_contract() + + # Navigate and check top bounty in "Open bounties" + bounties_page = BountiesPage(self.driver) + bounties_page.get_bounties_page() + titles = bounties_page.bounty_titles.find_elements() + assert titles[0].text == test_data.issue['title'] + + + + +