|
@@ -1,6 +1,7 @@
|
|
|
import {cleanup, mountWithTheme, screen} from 'sentry-test/reactTestingLibrary';
|
|
|
|
|
|
import ProjectsStore from 'sentry/stores/projectsStore';
|
|
|
+import {OrganizationContext} from 'sentry/views/organizationContext';
|
|
|
import EventDetails from 'sentry/views/performance/transactionDetails';
|
|
|
|
|
|
const alertText =
|
|
@@ -9,7 +10,7 @@ const alertText =
|
|
|
describe('EventDetails', () => {
|
|
|
afterEach(cleanup);
|
|
|
|
|
|
- it('renders alert for sample transaction', () => {
|
|
|
+ it('renders alert for sample transaction', async () => {
|
|
|
const project = TestStubs.Project();
|
|
|
ProjectsStore.loadInitialData([project]);
|
|
|
const organization = TestStubs.Organization({
|
|
@@ -17,20 +18,31 @@ describe('EventDetails', () => {
|
|
|
projects: [project],
|
|
|
});
|
|
|
const event = TestStubs.Event();
|
|
|
+ event.tags.push({key: 'sample_event', value: 'yes'});
|
|
|
const routerContext = TestStubs.routerContext([]);
|
|
|
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
+ url: `/organizations/${organization.slug}/events/latest/`,
|
|
|
+ statusCode: 200,
|
|
|
+ body: {
|
|
|
+ ...event,
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
mountWithTheme(
|
|
|
- <EventDetails
|
|
|
- organization={organization}
|
|
|
- params={{orgId: organization.slug, eventSlug: `${project.slug}:${event.id}`}}
|
|
|
- location={routerContext.context.location}
|
|
|
- />
|
|
|
+ <OrganizationContext.Provider value={organization}>
|
|
|
+ <EventDetails
|
|
|
+ organization={organization}
|
|
|
+ params={{orgId: organization.slug, eventSlug: 'latest'}}
|
|
|
+ location={routerContext.context.location}
|
|
|
+ />
|
|
|
+ </OrganizationContext.Provider>
|
|
|
);
|
|
|
expect(screen.getByText(alertText)).toBeInTheDocument();
|
|
|
});
|
|
|
|
|
|
it('does not reender alert if already received transaction', () => {
|
|
|
- const project = TestStubs.Project({firstTransactionEvent: true});
|
|
|
+ const project = TestStubs.Project();
|
|
|
ProjectsStore.loadInitialData([project]);
|
|
|
const organization = TestStubs.Organization({
|
|
|
features: ['performance-view'],
|
|
@@ -39,12 +51,22 @@ describe('EventDetails', () => {
|
|
|
const event = TestStubs.Event();
|
|
|
const routerContext = TestStubs.routerContext([]);
|
|
|
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
+ url: `/organizations/${organization.slug}/events/latest/`,
|
|
|
+ statusCode: 200,
|
|
|
+ body: {
|
|
|
+ ...event,
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
mountWithTheme(
|
|
|
- <EventDetails
|
|
|
- organization={organization}
|
|
|
- params={{orgId: organization.slug, eventSlug: `${project.slug}:${event.id}`}}
|
|
|
- location={routerContext.context.location}
|
|
|
- />
|
|
|
+ <OrganizationContext.Provider value={organization}>
|
|
|
+ <EventDetails
|
|
|
+ organization={organization}
|
|
|
+ params={{orgId: organization.slug, eventSlug: 'latest'}}
|
|
|
+ location={routerContext.context.location}
|
|
|
+ />
|
|
|
+ </OrganizationContext.Provider>
|
|
|
);
|
|
|
expect(screen.queryByText(alertText)).not.toBeInTheDocument();
|
|
|
});
|