123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- import {mountWithTheme} from 'sentry-test/enzyme';
- import {OrganizationContext} from 'sentry/views/organizationContext';
- import QuickTraceMeta from 'sentry/views/performance/transactionDetails/quickTraceMeta';
- const WrappedQuickTraceMeta = ({organization, ...rest}) => {
- return (
- <OrganizationContext.Provider value={organization}>
- <QuickTraceMeta {...rest} />
- </OrganizationContext.Provider>
- );
- };
- describe('QuickTraceMeta', function () {
- const routerContext = TestStubs.routerContext();
- const location = routerContext.context.location;
- const organization = TestStubs.Organization({features: ['performance-view']});
- const project = TestStubs.Project({platform: 'javascript'});
- const event = TestStubs.Event({contexts: {trace: {trace_id: 'a'.repeat(32)}}});
- const emptyQuickTrace = {
- isLoading: false,
- error: null,
- trace: [],
- type: 'empty',
- currentEvent: null,
- };
- const emptyTraceMeta = {
- projects: 0,
- transactions: 0,
- errors: 0,
- };
- it('renders basic UI', async function () {
- const wrapper = mountWithTheme(
- <WrappedQuickTraceMeta
- event={event}
- project={project}
- organization={organization}
- location={location}
- quickTrace={emptyQuickTrace}
- traceMeta={emptyTraceMeta}
- anchor="left"
- errorDest="issue"
- transactionDest="performance"
- />,
- routerContext
- );
- await tick();
- wrapper.update();
- expect(wrapper.find('MetaData').exists()).toBe(true);
- expect(wrapper.find('div[data-test-id="quick-trace-body"] QuickTrace').exists()).toBe(
- true
- );
- expect(wrapper.find('div[data-test-id="quick-trace-footer"]').text()).toEqual(
- `View Full Trace: ${'a'.repeat(8)} (0 events)`
- );
- });
- it('renders placeholder while loading', async function () {
- const wrapper = mountWithTheme(
- <WrappedQuickTraceMeta
- event={event}
- project={project}
- organization={organization}
- location={location}
- quickTrace={{
- ...emptyQuickTrace,
- isLoading: true,
- }}
- traceMeta={emptyTraceMeta}
- anchor="left"
- errorDest="issue"
- transactionDest="performance"
- />,
- routerContext
- );
- await tick();
- wrapper.update();
- expect(wrapper.find('MetaData').exists()).toBe(true);
- expect(
- wrapper.find('div[data-test-id="quick-trace-body"] Placeholder').exists()
- ).toBe(true);
- expect(wrapper.find('div[data-test-id="quick-trace-footer"]').text()).toEqual(
- `View Full Trace: ${'a'.repeat(8)} (0 events)`
- );
- });
- it('renders errors', async function () {
- const wrapper = mountWithTheme(
- <WrappedQuickTraceMeta
- event={event}
- project={project}
- organization={organization}
- location={location}
- quickTrace={{
- ...emptyQuickTrace,
- error: 'something bad',
- }}
- traceMeta={emptyTraceMeta}
- anchor="left"
- errorDest="issue"
- transactionDest="performance"
- />,
- routerContext
- );
- await tick();
- wrapper.update();
- expect(wrapper.find('MetaData').exists()).toBe(true);
- expect(wrapper.find('div[data-test-id="quick-trace-body"]').text()).toEqual('\u2014');
- expect(wrapper.find('div[data-test-id="quick-trace-footer"]').text()).toEqual(
- `View Full Trace: ${'a'.repeat(8)} (0 events)`
- );
- });
- it('renders missing trace when trace id is not present', async function () {
- const newEvent = TestStubs.Event();
- const wrapper = mountWithTheme(
- <WrappedQuickTraceMeta
- event={newEvent}
- project={project}
- organization={organization}
- location={location}
- quickTrace={emptyQuickTrace}
- traceMeta={emptyTraceMeta}
- anchor="left"
- errorDest="issue"
- transactionDest="performance"
- />,
- routerContext
- );
- await tick();
- wrapper.update();
- expect(wrapper.find('MetaData').exists()).toBe(true);
- expect(wrapper.find('div[data-test-id="quick-trace-body"]').text()).toEqual(
- 'Missing Trace'
- );
- expect(wrapper.find('div[data-test-id="quick-trace-footer"]').text()).toEqual(
- 'Read the docs'
- );
- });
- it('renders missing trace with hover card when feature disabled', async function () {
- const newEvent = TestStubs.Event();
- const newOrg = TestStubs.Organization();
- const wrapper = mountWithTheme(
- <WrappedQuickTraceMeta
- event={newEvent}
- project={project}
- organization={newOrg}
- location={location}
- quickTrace={emptyQuickTrace}
- traceMeta={emptyTraceMeta}
- anchor="left"
- errorDest="issue"
- transactionDest="performance"
- />,
- routerContext
- );
- await tick();
- wrapper.update();
- expect(wrapper.find('MetaData').exists()).toBe(true);
- expect(wrapper.find('div[data-test-id="quick-trace-body"]').text()).toEqual(
- 'Missing Trace'
- );
- expect(wrapper.find('div[data-test-id="quick-trace-footer"]').text()).toEqual(
- 'Read the docs'
- );
- expect(
- wrapper.find('div[data-test-id="quick-trace-footer"] Hovercard').exists()
- ).toEqual(true);
- });
- it('does not render when platform does not support tracing', async function () {
- const newProject = TestStubs.Project();
- const newEvent = TestStubs.Event();
- const wrapper = mountWithTheme(
- <WrappedQuickTraceMeta
- event={newEvent}
- project={newProject}
- organization={organization}
- location={location}
- quickTrace={emptyQuickTrace}
- traceMeta={emptyTraceMeta}
- anchor="left"
- errorDest="issue"
- transactionDest="performance"
- />,
- routerContext
- );
- await tick();
- wrapper.update();
- expect(wrapper.isEmptyRender()).toBe(true);
- });
- });
|