|
@@ -8,6 +8,9 @@ import {
|
|
|
|
|
|
import {openModal} from 'sentry/actionCreators/modal';
|
|
|
import StacktraceLinkModal from 'sentry/components/events/interfaces/frame/stacktraceLinkModal';
|
|
|
+import * as analytics from 'sentry/utils/integrationUtil';
|
|
|
+
|
|
|
+jest.mock('sentry/utils/analytics/trackAdvancedAnalyticsEvent');
|
|
|
|
|
|
describe('StacktraceLinkModal', () => {
|
|
|
const org = TestStubs.Organization();
|
|
@@ -26,20 +29,25 @@ describe('StacktraceLinkModal', () => {
|
|
|
};
|
|
|
const onSubmit = jest.fn();
|
|
|
const closeModal = jest.fn();
|
|
|
+ const analyticsSpy = jest.spyOn(analytics, 'trackIntegrationAnalytics');
|
|
|
|
|
|
beforeEach(() => {
|
|
|
- MockApiClient.clearMockResponses();
|
|
|
- jest.clearAllMocks();
|
|
|
-
|
|
|
MockApiClient.addMockResponse({
|
|
|
url: `/organizations/${org.slug}/code-mappings/`,
|
|
|
method: 'POST',
|
|
|
});
|
|
|
-
|
|
|
MockApiClient.addMockResponse({
|
|
|
url: `/projects/${org.slug}/${project.slug}/stacktrace-link/`,
|
|
|
body: {config, sourceUrl, integrations: [integration]},
|
|
|
});
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
+ url: `/organizations/${org.slug}/derive-code-mappings/`,
|
|
|
+ body: [],
|
|
|
+ });
|
|
|
+ });
|
|
|
+ afterEach(() => {
|
|
|
+ MockApiClient.clearMockResponses();
|
|
|
+ jest.clearAllMocks();
|
|
|
});
|
|
|
|
|
|
it('links to source code with one GitHub integration', () => {
|
|
@@ -91,10 +99,7 @@ describe('StacktraceLinkModal', () => {
|
|
|
))
|
|
|
);
|
|
|
|
|
|
- userEvent.type(
|
|
|
- screen.getByRole('textbox', {name: 'Copy the URL and paste it below'}),
|
|
|
- 'sourceUrl{enter}'
|
|
|
- );
|
|
|
+ userEvent.paste(screen.getByRole('textbox', {name: 'Repository URL'}), 'sourceUrl');
|
|
|
userEvent.click(screen.getByRole('button', {name: 'Save'}));
|
|
|
await waitFor(() => {
|
|
|
expect(closeModal).toHaveBeenCalled();
|
|
@@ -126,7 +131,7 @@ describe('StacktraceLinkModal', () => {
|
|
|
);
|
|
|
|
|
|
userEvent.type(
|
|
|
- screen.getByRole('textbox', {name: 'Copy the URL and paste it below'}),
|
|
|
+ screen.getByRole('textbox', {name: 'Repository URL'}),
|
|
|
'sourceUrl{enter}'
|
|
|
);
|
|
|
userEvent.click(screen.getByRole('button', {name: 'Save'}));
|
|
@@ -141,4 +146,70 @@ describe('StacktraceLinkModal', () => {
|
|
|
'/settings/org-slug/integrations/github/1/'
|
|
|
);
|
|
|
});
|
|
|
+
|
|
|
+ it('displays suggestions from code mappings', async () => {
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
+ url: `/organizations/${org.slug}/derive-code-mappings/`,
|
|
|
+ body: [
|
|
|
+ {
|
|
|
+ filename: 'stack/root/file/stack/root/file/stack/root/file.py',
|
|
|
+ repo_name: 'getsentry/codemap',
|
|
|
+ repo_branch: 'master',
|
|
|
+ stacktrace_root: '/stack/root',
|
|
|
+ source_path: '/source/root/',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ filename: 'stack/root/file.py',
|
|
|
+ repo_name: 'getsentry/codemap',
|
|
|
+ repo_branch: 'master',
|
|
|
+ stacktrace_root: '/stack/root',
|
|
|
+ source_path: '/source/root/',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
+ url: `/projects/${org.slug}/${project.slug}/repo-path-parsing/`,
|
|
|
+ method: 'POST',
|
|
|
+ body: {...configData},
|
|
|
+ });
|
|
|
+
|
|
|
+ renderGlobalModal();
|
|
|
+ act(() =>
|
|
|
+ openModal(modalProps => (
|
|
|
+ <StacktraceLinkModal
|
|
|
+ {...modalProps}
|
|
|
+ filename={filename}
|
|
|
+ closeModal={closeModal}
|
|
|
+ integrations={[integration]}
|
|
|
+ organization={org}
|
|
|
+ project={project}
|
|
|
+ onSubmit={onSubmit}
|
|
|
+ />
|
|
|
+ ))
|
|
|
+ );
|
|
|
+
|
|
|
+ expect(
|
|
|
+ await screen.findByText(
|
|
|
+ 'Select from one of these suggestions or paste your URL below'
|
|
|
+ )
|
|
|
+ ).toBeInTheDocument();
|
|
|
+ const suggestion =
|
|
|
+ 'https://github.com/getsentry/codemap/blob/master/stack/root/file.py';
|
|
|
+ expect(screen.getByText(suggestion)).toBeInTheDocument();
|
|
|
+ expect(screen.getByRole('dialog')).toSnapshot();
|
|
|
+
|
|
|
+ // Paste and save suggestion
|
|
|
+ userEvent.paste(screen.getByRole('textbox', {name: 'Repository URL'}), suggestion);
|
|
|
+ userEvent.click(screen.getByRole('button', {name: 'Save'}));
|
|
|
+ await waitFor(() => {
|
|
|
+ expect(closeModal).toHaveBeenCalled();
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(analyticsSpy).toHaveBeenCalledWith(
|
|
|
+ 'integrations.stacktrace_complete_setup',
|
|
|
+ expect.objectContaining({
|
|
|
+ is_suggestion: true,
|
|
|
+ })
|
|
|
+ );
|
|
|
+ });
|
|
|
});
|