Skip to content

test(incidents): Add initial acceptance tests [SEN-734] #13623

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 1 commit into from
Jun 11, 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
1 change: 1 addition & 0 deletions src/sentry/incidents/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ def get_incident_suspects(incident, projects):
committers = get_event_file_committers(group.project, event)
except (Release.DoesNotExist, Commit.DoesNotExist):
continue

for committer in committers:
author = committer['author']
for commit in committer['commits']:
Expand Down
6 changes: 3 additions & 3 deletions src/sentry/static/sentry/app/actionCreators/modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ export function openCreateIncidentModal(options = {}) {
import(/* webpackChunkName: "CreateIncidentModal" */ 'app/components/modals/createIncidentModal')
.then(mod => mod.default)
.then(Modal => {
openModal(deps => <Modal {...deps} {...options} />, {
modalClassName: 'create-incident-modal',
});
openModal(deps => (
<Modal data-test-id="create-incident-modal" {...deps} {...options} />
));
});
}

Expand Down
8 changes: 7 additions & 1 deletion src/sentry/static/sentry/app/components/stream/group.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ const StreamGroup = createReactClass({
const {query, hasGuideAnchor, canSelect, memberList} = this.props;

return (
<Group onClick={this.toggleSelect} py={1} px={0} align="center">
<Group
data-test-id="group"
onClick={this.toggleSelect}
py={1}
px={0}
align="center"
>
{canSelect && (
<GroupCheckbox ml={2}>
{hasGuideAnchor && <GuideAnchor target="issues" type="text" />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class DetailsHeader extends React.Component {
</React.Fragment>
)}
</Breadcrumb>
<IncidentTitle loading={!isIncidentReady}>
<IncidentTitle data-test-id="incident-title" loading={!isIncidentReady}>
{isIncidentReady ? incident.title : 'Loading'}
</IncidentTitle>
</PageHeading>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import EmptyStateWarning from 'app/components/emptyStateWarning';
import Link from 'app/components/links/link';
import PageHeading from 'app/components/pageHeading';
import Pagination from 'app/components/pagination';
import getDynamicText from 'app/utils/getDynamicText';
import space from 'app/styles/space';

import Status from '../status';
Expand Down Expand Up @@ -53,7 +54,7 @@ class OrganizationIncidentsList extends AsyncComponent {
</Link>
<Status incident={incident} />
<div>
<Duration seconds={duration} />
<Duration seconds={getDynamicText({value: duration, fixed: 1200})} />
</div>
<div>
<Count value={incident.uniqueUsers} />
Expand Down
74 changes: 74 additions & 0 deletions tests/acceptance/test_incidents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
from __future__ import absolute_import

from datetime import datetime, timedelta
from django.utils import timezone
import pytz
from mock import patch

from sentry.testutils import AcceptanceTestCase, SnubaTestCase
from sentry.incidents.logic import create_incident
from sentry.incidents.models import IncidentType

FEATURE_NAME = 'organizations:incidents'

event_time = (datetime.utcnow() - timedelta(days=3)).replace(tzinfo=pytz.utc)


class OrganizationIncidentsListTest(AcceptanceTestCase, SnubaTestCase):
def setUp(self):
super(OrganizationIncidentsListTest, self).setUp()
self.login_as(self.user)
self.path = u'/organizations/{}/incidents/'.format(self.organization.slug)

def test_empty_incidents(self):
with self.feature(FEATURE_NAME):
self.browser.get(self.path)
self.browser.wait_until_not('.loading-indicator')
self.browser.snapshot('incidents - empty state')

def test_incidents_list(self):
incident = create_incident(
self.organization,
type=IncidentType.CREATED,
title="Incident #1",
query="",
date_started=timezone.now(),
projects=[self.project],
groups=[self.group],
)
with self.feature(FEATURE_NAME):
self.browser.get(self.path)
self.browser.wait_until_not('.loading-indicator')
self.browser.snapshot('incidents - list')

details_url = u'[href="/organizations/{}/incidents/{}/'.format(
self.organization.slug, incident.identifier)
self.browser.wait_until(details_url)
self.browser.click(details_url)
self.browser.wait_until_not('.loading-indicator')
self.browser.wait_until_test_id('incident-title')

# TODO: wait until sidebar loads
self.browser.snapshot('incidents - details')

@patch('django.utils.timezone.now')
def test_open_create_incident_modal(self, mock_now):
mock_now.return_value = datetime.utcnow().replace(tzinfo=pytz.utc)
self.store_event(
data={
'event_id': 'a' * 32,
'message': 'oh no',
'timestamp': event_time.isoformat()[:19],
'fingerprint': ['group-1']
},
project_id=self.project.id
)

with self.feature(FEATURE_NAME):
self.browser.get(u'/organizations/{}/issues/'.format(self.organization.slug))
self.browser.wait_until_not('.loading-indicator')
self.browser.wait_until_test_id('group')
self.browser.click('[data-test-id="group"]')
self.browser.click('[data-test-id="action-link-create-new-incident"]')
self.browser.wait_until_test_id('create-new-incident-form')
# TODO: Figure out how to deal with mocked dates
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
exports[`StreamGroup renders with anchors 1`] = `
<Group
align="center"
data-test-id="group"
onClick={[Function]}
p={2}
px={0}
Expand Down