Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ interface IssueExceptionStackTraceProps {
groupingCurrentLevel?: Group['metadata']['current_level'];
hasScmSourceContext?: boolean;
isStandalone?: boolean;
showBanners?: boolean;
}

export function IssueExceptionStackTrace({
Expand All @@ -63,6 +64,7 @@ export function IssueExceptionStackTrace({
groupingCurrentLevel,
hasScmSourceContext = false,
isStandalone = false,
showBanners = true,
values,
}: IssueExceptionStackTraceProps) {
const {isMinified, isNewestFirst, view} = useStackTraceViewState();
Expand Down Expand Up @@ -115,7 +117,7 @@ export function IssueExceptionStackTrace({
/>
</Stack>
) : null}
{exception.stacktrace && (
{showBanners && exception.stacktrace && (
<ErrorBoundary customComponent={null}>
<StacktraceBanners event={event} stacktrace={exception.stacktrace} />
</ErrorBoundary>
Expand Down Expand Up @@ -186,7 +188,9 @@ export function IssueExceptionStackTrace({
newestFirst={isNewestFirst}
onExceptionClick={expandException}
/>
{exception.stacktrace && index === firstVisibleExceptionIndex ? (
{showBanners &&
exception.stacktrace &&
index === firstVisibleExceptionIndex ? (
<ErrorBoundary customComponent={null}>
<StacktraceBanners event={event} stacktrace={exception.stacktrace} />
</ErrorBoundary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,65 @@
import {EventFixture} from 'sentry-fixture/event';
import {EventEntryChainedExceptionFixture} from 'sentry-fixture/eventEntryChainedException';
import {EventEntryStacktraceFixture} from 'sentry-fixture/eventEntryStacktrace';
import {FrameFixture} from 'sentry-fixture/frame';

import {render, screen} from 'sentry-test/reactTestingLibrary';
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';

import {SharedIssueStackTrace} from 'sentry/components/stackTrace/issueStackTrace/sharedIssueStackTrace';

describe('SharedIssueStackTrace', () => {
const entry = EventEntryStacktraceFixture();
const event = EventFixture({entries: [entry]});

afterEach(() => {
jest.restoreAllMocks();
localStorage.clear();
});

it('keeps shared native display choices local and formats raw frames without requests', async () => {
const storageKey = 'issue-details-stracktrace-display-org-slug-project-slug';
const savedOptions = JSON.stringify(['raw-stack-trace']);
localStorage.setItem(storageKey, savedOptions);
const stacktrace = {
...entry.data,
frames: [
FrameFixture({
platform: 'cocoa',
function: 'causeCrash',
rawFunction: null,
module: null,
}),
],
};
const nativeEvent = EventFixture({
platform: 'cocoa',
entries: [{type: 'stacktrace', data: stacktrace}],
});
const request = jest.spyOn(MockApiClient.prototype, 'request');
const {unmount} = render(
<SharedIssueStackTrace event={nativeEvent} stacktrace={stacktrace} />
);

expect(await screen.findByText('causeCrash')).toBeInTheDocument();
expect(screen.queryByText(/causeCrash/, {selector: 'pre'})).not.toBeInTheDocument();
await userEvent.click(screen.getByRole('button', {name: 'Display options'}));
await userEvent.click(screen.getByRole('option', {name: 'Raw Stack Trace'}));
await userEvent.keyboard('{Escape}');
expect(screen.getByText(/causeCrash/, {selector: 'pre'})).toBeInTheDocument();

await userEvent.click(screen.getByRole('button', {name: 'Display options'}));
await userEvent.click(screen.getByRole('option', {name: 'Full Stack Trace'}));
await userEvent.keyboard('{Escape}');
expect(screen.queryByText(/causeCrash/, {selector: 'pre'})).not.toBeInTheDocument();
expect(localStorage.getItem(storageKey)).toBe(savedOptions);

unmount();
render(<SharedIssueStackTrace event={nativeEvent} stacktrace={stacktrace} />);
expect(await screen.findByText('causeCrash')).toBeInTheDocument();
expect(screen.queryByText(/causeCrash/, {selector: 'pre'})).not.toBeInTheDocument();
expect(request).not.toHaveBeenCalled();
});

it('renders a single exception', async () => {
render(
<SharedIssueStackTrace
Expand All @@ -32,6 +83,22 @@ describe('SharedIssueStackTrace', () => {
expect(screen.getAllByTestId('core-stacktrace-frame-row').length).toBeGreaterThan(0);
});

it('renders chained exceptions with expandable frame lists', async () => {
const chained = EventEntryChainedExceptionFixture();
render(
<SharedIssueStackTrace
event={EventFixture({platform: 'python', entries: [chained]})}
values={chained.data.values ?? []}
/>
);
expect(
await screen.findByText(/chained exceptions in this event/)
).toBeInTheDocument();
expect(screen.getByText('func4')).not.toBeVisible();
await userEvent.click(screen.getByRole('button', {name: /ValueError/}));
expect(screen.getByText('func4')).toBeVisible();
});

it('renders a standalone stacktrace', async () => {
render(<SharedIssueStackTrace event={event} stacktrace={entry.data} />);

Expand Down
Loading
Loading