Browse Source

tests(acceptance): Add tests for resolving issues in Issues Li… (#14069)

Also refactor slightly to use page object
Billy Vong 5 years ago
parent
commit
dbda6e49b2

+ 1 - 4
src/sentry/static/sentry/app/components/checkbox.jsx

@@ -1,5 +1,4 @@
 import React from 'react';
-import classNames from 'classnames';
 
 class Checkbox extends React.Component {
   static defaultProps = {
@@ -7,9 +6,7 @@ class Checkbox extends React.Component {
   };
 
   render() {
-    const {className, ...otherProps} = this.props;
-    const cx = classNames('chk-select', className);
-    return <input type="checkbox" className={cx} {...otherProps} />;
+    return <input type="checkbox" {...this.props} />;
   }
 }
 

+ 1 - 0
src/sentry/static/sentry/app/components/eventOrGroupHeader.jsx

@@ -59,6 +59,7 @@ class EventOrGroupHeader extends React.Component {
     return (
       <Wrapper
         {...props}
+        data-test-id={data.status === 'resolved' ? 'resolved-issue' : null}
         style={data.status === 'resolved' ? {textDecoration: 'line-through'} : null}
       >
         {!hideLevel && level && (

+ 5 - 3
src/sentry/static/sentry/app/components/stream/groupCheckBox.jsx

@@ -1,10 +1,11 @@
 import PropTypes from 'prop-types';
 import React from 'react';
-import createReactClass from 'create-react-class';
 import Reflux from 'reflux';
+import createReactClass from 'create-react-class';
 
-import SelectedGroupStore from 'app/stores/selectedGroupStore';
+import {t} from 'app/locale';
 import Checkbox from 'app/components/checkbox';
+import SelectedGroupStore from 'app/stores/selectedGroupStore';
 
 const GroupCheckBox = createReactClass({
   displayName: 'GroupCheckBox',
@@ -29,7 +30,7 @@ const GroupCheckBox = createReactClass({
     }
   },
 
-  shouldComponentUpdate(nextProps, nextState) {
+  shouldComponentUpdate(_nextProps, nextState) {
     return nextState.isSelected !== this.state.isSelected;
   },
 
@@ -50,6 +51,7 @@ const GroupCheckBox = createReactClass({
   render() {
     return (
       <Checkbox
+        aria-label={t('Select Issue')}
         value={this.props.id}
         checked={this.state.isSelected}
         onChange={this.onSelect}

+ 3 - 0
tests/acceptance/page_objects/base.py

@@ -11,6 +11,9 @@ class BasePage(object):
     def driver(self):
         return self.browser.driver
 
+    def wait_until_loaded(self):
+        self.browser.wait_until_not('.loading-indicator')
+
 
 class BaseElement(object):
     def __init__(self, element):

+ 30 - 0
tests/acceptance/page_objects/issue_list.py

@@ -0,0 +1,30 @@
+from __future__ import absolute_import
+
+from .base import BasePage
+
+
+class IssueListPage(BasePage):
+    def __init__(self, browser, client):
+        super(IssueListPage, self).__init__(browser)
+        self.client = client
+
+    def visit_issue_list(self, org):
+        self.browser.get(u'/organizations/{}/issues/'.format(org))
+        self.wait_until_loaded()
+
+    def wait_for_stream(self):
+        self.browser.wait_until('.event-issue-header', timeout=20)
+
+    def select_issue(self, position):
+        self.browser.click(u'[data-test-id="group"]:nth-child({})'.format(position))
+
+    def resolve_issues(self):
+        self.browser.click('[aria-label="Resolve"]')
+        self.browser.click('[data-test-id="confirm-modal"]')
+
+    def wait_for_resolved_issue(self):
+        self.browser.wait_until('[data-test-id="resolved-issue"]')
+
+    def find_resolved_issues(self):
+        return self.browser.find_elements_by_css_selector(
+            '[data-test-id="resolved-issue"]')

+ 54 - 23
tests/acceptance/test_organization_group_index.py

@@ -6,6 +6,8 @@ from datetime import datetime, timedelta
 from django.utils import timezone
 
 from sentry.testutils import AcceptanceTestCase, SnubaTestCase
+from tests.acceptance.page_objects.issue_list import IssueListPage
+
 from mock import patch
 
 
@@ -32,25 +34,9 @@ class OrganizationGroupIndexTest(AcceptanceTestCase, SnubaTestCase):
             name='Sumatra',
         )
         self.login_as(self.user)
-        self.path = u'/organizations/{}/issues/'.format(self.org.slug)
-
-    def test_with_onboarding(self):
-        self.project.update(first_event=None)
-        self.browser.get(self.path)
-        self.wait_until_loaded()
-        self.browser.wait_until_test_id('awaiting-events')
-        self.browser.snapshot('organization issues onboarding')
+        self.page = IssueListPage(self.browser, self.client)
 
-    def test_with_no_results(self):
-        self.project.update(first_event=timezone.now())
-        self.browser.get(self.path)
-        self.wait_until_loaded()
-        self.browser.wait_until_test_id('empty-state')
-        self.browser.snapshot('organization issues no results')
-
-    @patch('django.utils.timezone.now')
-    def test_with_results(self, mock_now):
-        mock_now.return_value = datetime.utcnow().replace(tzinfo=pytz.utc)
+    def create_issues(self):
         self.store_event(
             data={
                 'event_id': 'a' * 32,
@@ -69,9 +55,25 @@ class OrganizationGroupIndexTest(AcceptanceTestCase, SnubaTestCase):
             },
             project_id=self.project.id
         )
-        self.browser.get(self.path)
-        self.wait_until_loaded()
-        self.browser.wait_until('.event-issue-header')
+
+    def test_with_onboarding(self):
+        self.project.update(first_event=None)
+        self.page.visit_issue_list(self.org.slug)
+        self.browser.wait_until_test_id('awaiting-events')
+        self.browser.snapshot('organization issues onboarding')
+
+    def test_with_no_results(self):
+        self.project.update(first_event=timezone.now())
+        self.page.visit_issue_list(self.org.slug)
+        self.browser.wait_until_test_id('empty-state')
+        self.browser.snapshot('organization issues no results')
+
+    @patch('django.utils.timezone.now')
+    def test_with_results(self, mock_now):
+        mock_now.return_value = datetime.utcnow().replace(tzinfo=pytz.utc)
+        self.create_issues()
+        self.page.visit_issue_list(self.org.slug)
+        self.page.wait_for_stream()
         self.browser.snapshot('organization issues with issues')
 
         groups = self.browser.find_elements_by_class_name('event-issue-header')
@@ -79,5 +81,34 @@ class OrganizationGroupIndexTest(AcceptanceTestCase, SnubaTestCase):
         assert 'oh snap' in groups[0].text
         assert 'oh no' in groups[1].text
 
-    def wait_until_loaded(self):
-        self.browser.wait_until_not('.loading')
+    @patch('django.utils.timezone.now')
+    def test_resolve_issues(self, mock_now):
+        mock_now.return_value = datetime.utcnow().replace(tzinfo=pytz.utc)
+        self.create_issues()
+        self.page.visit_issue_list(self.org.slug)
+        self.page.wait_for_stream()
+
+        self.page.select_issue(1)
+        self.page.select_issue(2)
+        self.page.resolve_issues()
+        self.page.wait_for_resolved_issue()
+        resolved_groups = self.page.find_resolved_issues()
+
+        assert len(resolved_groups) == 2
+
+    @patch('django.utils.timezone.now')
+    def test_resolve_issues_multi_projects(self, mock_now):
+        mock_now.return_value = datetime.utcnow().replace(tzinfo=pytz.utc)
+        self.create_issues()
+
+        with self.feature('organizations:global-views'):
+            self.page.visit_issue_list(self.org.slug)
+            self.page.wait_for_stream()
+
+            self.page.select_issue(1)
+            self.page.select_issue(2)
+            self.page.resolve_issues()
+            self.page.wait_for_resolved_issue()
+            resolved_groups = self.page.find_resolved_issues()
+
+            assert len(resolved_groups) == 2

+ 0 - 1
tests/js/spec/components/__snapshots__/checkbox.spec.jsx.snap

@@ -3,7 +3,6 @@
 exports[`Checkbox renders 1`] = `
 <input
   checked={false}
-  className="chk-select"
   type="checkbox"
 />
 `;

+ 2 - 1
tests/js/spec/views/organizationGroupDetails/__snapshots__/groupSimilar.spec.jsx.snap

@@ -658,7 +658,6 @@ exports[`Issues Similar View renders with mocked data 1`] = `
                           >
                             <input
                               checked={false}
-                              className="chk-select"
                               id="271"
                               onChange={[Function]}
                               type="checkbox"
@@ -845,6 +844,7 @@ exports[`Issues Similar View renders with mocked data 1`] = `
                                     size="normal"
                                   >
                                     <Link
+                                      data-test-id="resolved-issue"
                                       onlyActiveOnIndex={false}
                                       style={
                                         Object {
@@ -859,6 +859,7 @@ exports[`Issues Similar View renders with mocked data 1`] = `
                                       }
                                     >
                                       <a
+                                        data-test-id="resolved-issue"
                                         onClick={[Function]}
                                         style={
                                           Object {

+ 0 - 1
tests/js/spec/views/settings/organizationDeveloperSettings/__snapshots__/subscriptionBox.spec.jsx.snap

@@ -89,7 +89,6 @@ exports[`SubscriptionBox renders resource checkbox 1`] = `
             >
               <input
                 checked={false}
-                className="chk-select"
                 disabled={false}
                 id="issue"
                 onChange={[Function]}