Skip to content

Commit

Permalink
tests(acceptance): Add acceptance tests for global selection header (#…
Browse files Browse the repository at this point in the history
…18452)

This adds some acceptance tests for global selection header, some tests are commented out as they are bugs that need to be fixed.
  • Loading branch information
billyvg authored Apr 24, 2020
1 parent b458e8e commit a00a073
Show file tree
Hide file tree
Showing 6 changed files with 380 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ class GlobalSelectionHeader extends React.Component<Props, State> {
<BackButtonWrapper>
<Tooltip title={t('Back to Issues Stream')} position="bottom">
<BackToIssues
data-test-id="back-to-issues"
to={`/organizations/${organization.slug}/issues/${location.search}`}
>
<InlineSvg src="icon-arrow-left" />
Expand Down
31 changes: 26 additions & 5 deletions src/sentry/utils/pytest/selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,17 @@ def delete(self, path, *args, **kwargs):
self._has_initialized_cookie_store = True
return self

def element(self, selector):
def element(self, selector=None, xpath=None):
"""
Get an element from the page. This method will wait for the element to show up.
"""
self.wait_until(selector)
return self.driver.find_element_by_css_selector(selector)

if xpath is not None:
self.wait_until(xpath=xpath)
return self.driver.find_element_by_xpath(xpath)
else:
self.wait_until(selector)
return self.driver.find_element_by_css_selector(selector)

def element_exists(self, selector):
"""
Expand All @@ -100,8 +105,8 @@ def element_exists_by_aria_label(self, selector):
"""
return self.element_exists('[aria-label="%s"]' % (selector))

def click(self, selector):
self.element(selector).click()
def click(self, selector=None, xpath=None):
self.element(selector, xpath=xpath).click()

def click_when_visible(self, selector=None, timeout=3):
"""
Expand Down Expand Up @@ -217,6 +222,22 @@ def snapshot(self, name):
self.percy.snapshot(name=name)
return self

def get_local_storage_items(self):
"""
Retrieve all items in local storage
"""

return self.driver.execute_script(
"Object.fromEntries(Object.entries(window.localStorage));"
)

def get_local_storage_item(self, key):
"""
Retrieve key from local storage, this will fail if you use single quotes in your keys.
"""

return self.driver.execute_script(u"window.localStorage.getItem('{}')".format(key))

def save_cookie(
self,
name,
Expand Down
50 changes: 50 additions & 0 deletions tests/acceptance/page_objects/global_selection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from __future__ import absolute_import

from .base import BasePage


class GlobalSelectionPage(BasePage):
def __init__(self, browser, client):
super(GlobalSelectionPage, self).__init__(browser)
self.client = client

def get_selected_project_slug(self):
return self.browser.element('[data-test-id="global-header-project-selector"]').text

def get_selected_environment(self):
return self.browser.element('[data-test-id="global-header-environment-selector"]').text

def go_back_to_issues(self):
self.browser.click('[data-test-id="back-to-issues"]')

def open_project_selector(self):
self.browser.click('[data-test-id="global-header-project-selector"]')

def select_project_by_slug(self, slug):
project_item_selector = u'//*[@data-test-id="badge-display-name" and text()="{}"]'.format(
slug
)

self.open_project_selector()
self.browser.wait_until(xpath=project_item_selector)
self.browser.click(xpath=project_item_selector)

def open_environment_selector(self):
self.browser.click('[data-test-id="global-header-environment-selector"]')

def select_environment(self, environment):
environment_path = u'//*[text()="{}"]'.format(environment)

self.open_project_selector()
self.browser.wait_until(xpath=environment_path)
self.browser.click(xpath=environment_path)

def open_date_selector(self):
self.browser.click('[data-test-id="global-header-timerange-selector"]')

def select_date(self, date):
date_path = u'//*[text()="{}"]'.format(date)

self.open_project_selector()
self.browser.wait_until(xpath=date_path)
self.browser.click(xpath=date_path)
15 changes: 15 additions & 0 deletions tests/acceptance/page_objects/issue_details.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
from __future__ import absolute_import

from .base import BasePage
from .global_selection import GlobalSelectionPage


class IssueDetailsPage(BasePage):
def __init__(self, browser, client):
super(IssueDetailsPage, self).__init__(browser)
self.client = client
self.global_selection = GlobalSelectionPage(browser, client)

def visit_issue(self, org, groupid):
self.dismiss_assistant()
self.browser.get(u"/organizations/{}/issues/{}/".format(org, groupid))
self.wait_until_loaded()

def visit_issue_in_environment(self, org, groupid, environment):
self.dismiss_assistant()
self.browser.get(
u"/organizations/{}/issues/{}/?environment={}".format(org, groupid, environment)
)
self.browser.wait_until(".group-detail")

def visit_tag_values(self, org, groupid, tag):
self.dismiss_assistant()
self.browser.get(u"/organizations/{}/issues/{}/tags/{}".format(org, groupid, tag))
self.browser.wait_until_not(".loading-indicator")

def get_environment(self):
return self.browser.find_element_by_css_selector('[data-test-id="env-label"').text.lower()

def go_back_to_issues(self):
self.global_selection.go_back_to_issues()

def api_issue_get(self, groupid):
return self.client.get(u"/api/0/issues/{}/".format(groupid))

Expand Down
11 changes: 11 additions & 0 deletions tests/acceptance/page_objects/issue_list.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from __future__ import absolute_import

from .base import BasePage
from .global_selection import GlobalSelectionPage
from .issue_details import IssueDetailsPage


class IssueListPage(BasePage):
def __init__(self, browser, client):
super(IssueListPage, self).__init__(browser)
self.client = client
self.global_selection = GlobalSelectionPage(browser, client)

def visit_issue_list(self, org, query=""):
self.dismiss_assistant()
Expand All @@ -19,12 +22,20 @@ def wait_for_stream(self):
def select_issue(self, position):
self.browser.click(u'[data-test-id="group"]:nth-child({})'.format(position))

def navigate_to_issue(self, position):
self.browser.click(u'[data-test-id="group"]:nth-child({}) a'.format(position))
self.browser.wait_until(".group-detail")
self.issue_details = IssueDetailsPage(self.browser, self.client)

def resolve_issues(self):
self.browser.click('[aria-label="Resolve"]')
self.browser.click('[data-test-id="confirm-button"]')

def wait_for_resolved_issue(self):
self.browser.wait_until('[data-test-id="resolved-issue"]')

def wait_for_issue(self):
self.browser.wait_until('[data-test-id="group"]')

def find_resolved_issues(self):
return self.browser.find_elements_by_css_selector('[data-test-id="resolved-issue"]')
Loading

0 comments on commit a00a073

Please sign in to comment.