123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- import {mountWithTheme} from 'sentry-test/enzyme';
- import Threads from 'sentry/components/events/interfaces/threads';
- import {OrganizationContext} from 'sentry/views/organizationContext';
- describe('Threads', () => {
- const entries = TestStubs.Entries()[0];
- const event = TestStubs.Event({entries});
- const organization = TestStubs.Organization();
- const exceptionEntry = entries[0];
- const data = exceptionEntry.data;
- const type = exceptionEntry.type;
- it('Display multiple frames', () => {
- const newEvent = {
- ...event,
- entries: [
- {
- ...event.entries[0],
- data: {
- ...event.entries[0].data,
- values: [
- event.entries[0].data.values[0],
- {
- module: 'example.application',
- type: 'Error',
- value: 'an error occurred',
- stacktrace: {
- frames: [
- {
- function: 'main',
- module: 'example.application',
- lineNo: 1,
- filename: 'application',
- },
- {
- function: 'doThing',
- module: 'example.application',
- lineNo: 2,
- filename: 'application',
- },
- ],
- },
- },
- ],
- },
- },
- event.entries[1],
- event.entries[2],
- ],
- };
- const wrapper = mountWithTheme(
- <OrganizationContext.Provider value={organization}>
- <Threads
- type={type}
- data={data}
- orgId="org-slug"
- projectId="project-id"
- event={newEvent}
- />
- </OrganizationContext.Provider>
- );
- // Total frames passed
- const totalFramesPasses =
- newEvent.entries[0].data.values[0].stacktrace.frames.length +
- newEvent.entries[0].data.values[1].stacktrace.frames.length;
- expect(wrapper.find('Line').length).toBe(totalFramesPasses);
- });
- it('Display no frame', () => {
- const wrapper = mountWithTheme(
- <OrganizationContext.Provider value={organization}>
- <Threads
- type={type}
- data={{...data, values: [{...data.values[0], stacktrace: null}]}}
- orgId="org-slug"
- projectId="project-id"
- event={{
- ...event,
- entries: [
- {
- ...event.entries[0],
- data: {
- ...event.entries[0].data,
- values: [{...event.entries[0].data.values[0], id: 0, stacktrace: null}],
- },
- },
- event.entries[1],
- event.entries[2],
- ],
- }}
- />
- </OrganizationContext.Provider>
- );
- // no exceptions or stacktraces have been found
- expect(wrapper.find('Line').length).toBe(0);
- });
- describe('Displays the stack trace of an exception if all threadIds of exceptionEntry.data.values do not match the threadId of the active thread and if the active thread has crashed equals true', () => {
- const threadsEntry = entries[1];
- it('Displays the exception stacktrace', () => {
- const wrapper = mountWithTheme(
- <OrganizationContext.Provider value={organization}>
- <Threads
- type={threadsEntry.type}
- data={threadsEntry.data}
- orgId="org-slug"
- projectId="project-id"
- event={event}
- />
- </OrganizationContext.Provider>
- );
- // envent.entries[0].data.values[0].stacktrace is defined
- expect(wrapper.find('Line').length).toBe(1);
- });
- it('Displays the the active thread stacktrace', () => {
- const wrapper = mountWithTheme(
- <OrganizationContext.Provider value={organization}>
- <Threads
- type={threadsEntry.type}
- data={threadsEntry.data}
- orgId="org-slug"
- projectId="project-id"
- event={{
- ...event,
- entries: [
- {
- ...event.entries[0],
- data: {
- ...event.entries[0].data,
- values: [{...event.entries[0].data.values[0], stacktrace: null}],
- },
- },
- event.entries[1],
- event.entries[2],
- ],
- }}
- />
- </OrganizationContext.Provider>
- );
- // the 'threads' entry has a stack trace with 23 frames, but as one of them is duplicated, we only display 22
- expect(wrapper.find('Line').length).toBe(22);
- });
- });
- });
|