Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/sentry/static/sentry/app/components/checkbox.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import React from 'react';
import classNames from 'classnames';

class Checkbox extends React.Component {
static defaultProps = {
checked: false,
};

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} />;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 && (
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -29,7 +30,7 @@ const GroupCheckBox = createReactClass({
}
},

shouldComponentUpdate(nextProps, nextState) {
shouldComponentUpdate(_nextProps, nextState) {
return nextState.isSelected !== this.state.isSelected;
},

Expand All @@ -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}
Expand Down
3 changes: 3 additions & 0 deletions tests/acceptance/page_objects/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ def __init__(self, browser):
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):
Expand Down
30 changes: 30 additions & 0 deletions tests/acceptance/page_objects/issue_list.py
Original file line number Diff line number Diff line change
@@ -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"]')
77 changes: 54 additions & 23 deletions tests/acceptance/test_organization_group_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from django.utils import timezone

from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from tests.acceptance.page_objects.issue_list import IssueListPage

from mock import patch


Expand All @@ -32,25 +34,9 @@ def setUp(self):
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,
Expand All @@ -69,15 +55,60 @@ def test_with_results(self, mock_now):
},
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')
assert len(groups) == 2
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
exports[`Checkbox renders 1`] = `
<input
checked={false}
className="chk-select"
type="checkbox"
/>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand All @@ -859,6 +859,7 @@ exports[`Issues Similar View renders with mocked data 1`] = `
}
>
<a
data-test-id="resolved-issue"
onClick={[Function]}
style={
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ exports[`SubscriptionBox renders resource checkbox 1`] = `
>
<input
checked={false}
className="chk-select"
disabled={false}
id="issue"
onChange={[Function]}
Expand Down