|
@@ -1,15 +1,17 @@
|
|
|
import React from 'react';
|
|
|
+import {browserHistory} from 'react-router';
|
|
|
|
|
|
import {initializeOrg} from 'sentry-test/initializeOrg';
|
|
|
import {mountWithTheme} from 'sentry-test/enzyme';
|
|
|
|
|
|
import ProjectsStore from 'app/stores/projectsStore';
|
|
|
-import PerformanceLanding from 'app/views/performance/landing';
|
|
|
+import PerformanceLanding, {FilterViews} from 'app/views/performance/landing';
|
|
|
+
|
|
|
+const FEATURES = ['transaction-event', 'performance-view'];
|
|
|
|
|
|
function initializeData(projects, query) {
|
|
|
- const features = ['transaction-event', 'performance-view'];
|
|
|
const organization = TestStubs.Organization({
|
|
|
- features,
|
|
|
+ features: FEATURES,
|
|
|
projects,
|
|
|
});
|
|
|
const initialData = initializeOrg({
|
|
@@ -24,8 +26,30 @@ function initializeData(projects, query) {
|
|
|
return initialData;
|
|
|
}
|
|
|
|
|
|
+function initializeTrendsData(query) {
|
|
|
+ const features = [...FEATURES, 'trends'];
|
|
|
+ const projects = [
|
|
|
+ TestStubs.Project({id: '1', firstTransactionEvent: false}),
|
|
|
+ TestStubs.Project({id: '2', firstTransactionEvent: true}),
|
|
|
+ ];
|
|
|
+ const organization = TestStubs.Organization({
|
|
|
+ features,
|
|
|
+ projects,
|
|
|
+ });
|
|
|
+
|
|
|
+ const initialData = initializeOrg({
|
|
|
+ organization,
|
|
|
+ router: {
|
|
|
+ location: {query},
|
|
|
+ },
|
|
|
+ });
|
|
|
+ ProjectsStore.loadInitialData(initialData.organization.projects);
|
|
|
+ return initialData;
|
|
|
+}
|
|
|
+
|
|
|
describe('Performance > Landing', function() {
|
|
|
beforeEach(function() {
|
|
|
+ browserHistory.push.mockReset();
|
|
|
MockApiClient.addMockResponse({
|
|
|
url: '/organizations/org-slug/projects/',
|
|
|
body: [],
|
|
@@ -88,6 +112,13 @@ describe('Performance > Landing', function() {
|
|
|
count: 2,
|
|
|
},
|
|
|
});
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
+ url: '/organizations/org-slug/events-trends/',
|
|
|
+ body: {
|
|
|
+ stats: {},
|
|
|
+ events: {meta: {}, data: []},
|
|
|
+ },
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
afterEach(function() {
|
|
@@ -191,4 +222,89 @@ describe('Performance > Landing', function() {
|
|
|
})
|
|
|
);
|
|
|
});
|
|
|
+
|
|
|
+ it('Sets default period when navigating to trends when stats period is not set', async function() {
|
|
|
+ const data = initializeTrendsData({query: 'tag:value'});
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
+ <PerformanceLanding
|
|
|
+ organization={data.organization}
|
|
|
+ location={data.router.location}
|
|
|
+ />,
|
|
|
+ data.routerContext
|
|
|
+ );
|
|
|
+ await tick();
|
|
|
+ wrapper.update();
|
|
|
+
|
|
|
+ const trendsLink = wrapper.find('[data-test-id="landing-header-trends"]').at(0);
|
|
|
+ trendsLink.simulate('click');
|
|
|
+
|
|
|
+ expect(browserHistory.push).toHaveBeenCalledWith(
|
|
|
+ expect.objectContaining({
|
|
|
+ query: {
|
|
|
+ query: 'tag:value count():>1000 transaction.duration:>0',
|
|
|
+ statsPeriod: '14d',
|
|
|
+ view: 'TRENDS',
|
|
|
+ },
|
|
|
+ })
|
|
|
+ );
|
|
|
+ });
|
|
|
+
|
|
|
+ it('Navigating to trends does not modify statsPeriod when already set', async function() {
|
|
|
+ const data = initializeTrendsData({
|
|
|
+ query: 'count():>500 transaction.duration:>10',
|
|
|
+ statsPeriod: '24h',
|
|
|
+ });
|
|
|
+
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
+ <PerformanceLanding
|
|
|
+ organization={data.organization}
|
|
|
+ location={data.router.location}
|
|
|
+ />,
|
|
|
+ data.routerContext
|
|
|
+ );
|
|
|
+ await tick();
|
|
|
+ wrapper.update();
|
|
|
+
|
|
|
+ const trendsLink = wrapper.find('[data-test-id="landing-header-trends"]').at(0);
|
|
|
+ trendsLink.simulate('click');
|
|
|
+
|
|
|
+ expect(browserHistory.push).toHaveBeenCalledWith(
|
|
|
+ expect.objectContaining({
|
|
|
+ query: {
|
|
|
+ query: 'count():>500 transaction.duration:>10',
|
|
|
+ statsPeriod: '24h',
|
|
|
+ view: 'TRENDS',
|
|
|
+ },
|
|
|
+ })
|
|
|
+ );
|
|
|
+ });
|
|
|
+
|
|
|
+ it('Navigating away from trends will reset query', async function() {
|
|
|
+ const data = initializeTrendsData({view: FilterViews.TRENDS});
|
|
|
+
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
+ <PerformanceLanding
|
|
|
+ organization={data.organization}
|
|
|
+ location={data.router.location}
|
|
|
+ />,
|
|
|
+ data.routerContext
|
|
|
+ );
|
|
|
+ await tick();
|
|
|
+ wrapper.update();
|
|
|
+
|
|
|
+ const byTransactionLink = wrapper
|
|
|
+ .find('[data-test-id="landing-header-all_transactions"]')
|
|
|
+ .at(0);
|
|
|
+ byTransactionLink.simulate('click');
|
|
|
+
|
|
|
+ expect(browserHistory.push).toHaveBeenNthCalledWith(
|
|
|
+ 1,
|
|
|
+ expect.objectContaining({
|
|
|
+ query: {
|
|
|
+ query: '',
|
|
|
+ view: 'ALL_TRANSACTIONS',
|
|
|
+ },
|
|
|
+ })
|
|
|
+ );
|
|
|
+ });
|
|
|
});
|