Commit f6826053 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch '197137-remove-REST-for-Sentry-error-details' into 'master'

Remove REST call and related logic for error details page

See merge request gitlab-org/gitlab!23980
parents 52bd02f2 8c7826e5
...@@ -54,10 +54,6 @@ export default { ...@@ -54,10 +54,6 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
issueDetailsPath: {
type: String,
required: true,
},
issueStackTracePath: { issueStackTracePath: {
type: String, type: String,
required: true, required: true,
...@@ -72,7 +68,7 @@ export default { ...@@ -72,7 +68,7 @@ export default {
}, },
}, },
apollo: { apollo: {
GQLerror: { error: {
query, query,
variables() { variables() {
return { return {
...@@ -81,19 +77,19 @@ export default { ...@@ -81,19 +77,19 @@ export default {
}; };
}, },
pollInterval: 2000, pollInterval: 2000,
update: data => data.project.sentryDetailedError, update: data => data.project.sentryErrors.detailedError,
error: () => createFlash(__('Failed to load error details from Sentry.')), error: () => createFlash(__('Failed to load error details from Sentry.')),
result(res) { result(res) {
if (res.data.project?.sentryDetailedError) { if (res.data.project?.sentryErrors?.detailedError) {
this.$apollo.queries.GQLerror.stopPolling(); this.$apollo.queries.error.stopPolling();
this.setStatus(this.GQLerror.status); this.setStatus(this.error.status);
} }
}, },
}, },
}, },
data() { data() {
return { return {
GQLerror: null, error: null,
issueCreationInProgress: false, issueCreationInProgress: false,
isAlertVisible: false, isAlertVisible: false,
closedIssueId: null, closedIssueId: null,
...@@ -101,8 +97,6 @@ export default { ...@@ -101,8 +97,6 @@ export default {
}, },
computed: { computed: {
...mapState('details', [ ...mapState('details', [
'error',
'loading',
'loadingStacktrace', 'loadingStacktrace',
'stacktraceData', 'stacktraceData',
'updatingResolveStatus', 'updatingResolveStatus',
...@@ -114,28 +108,23 @@ export default { ...@@ -114,28 +108,23 @@ export default {
return sprintf( return sprintf(
__('Reported %{timeAgo} by %{reportedBy}'), __('Reported %{timeAgo} by %{reportedBy}'),
{ {
reportedBy: `<strong>${this.GQLerror.culprit}</strong>`, reportedBy: `<strong>${this.error.culprit}</strong>`,
timeAgo: this.timeFormatted(this.stacktraceData.date_received), timeAgo: this.timeFormatted(this.stacktraceData.date_received),
}, },
false, false,
); );
}, },
firstReleaseLink() { firstReleaseLink() {
return `${this.error.external_base_url}/releases/${this.GQLerror.firstReleaseShortVersion}`; return `${this.error.externalBaseUrl}/releases/${this.error.firstReleaseShortVersion}`;
}, },
lastReleaseLink() { lastReleaseLink() {
return `${this.error.external_base_url}releases/${this.GQLerror.lastReleaseShortVersion}`; return `${this.error.externalBaseUrl}/releases/${this.error.lastReleaseShortVersion}`;
},
showDetails() {
return Boolean(
!this.loading && !this.$apollo.queries.GQLerror.loading && this.error && this.GQLerror,
);
}, },
showStacktrace() { showStacktrace() {
return Boolean(!this.loadingStacktrace && this.stacktrace && this.stacktrace.length); return Boolean(this.stacktrace?.length);
}, },
issueTitle() { issueTitle() {
return this.GQLerror.title; return this.error.title;
}, },
issueDescription() { issueDescription() {
return sprintf( return sprintf(
...@@ -144,13 +133,13 @@ export default { ...@@ -144,13 +133,13 @@ export default {
), ),
{ {
description: '# Error Details:\n', description: '# Error Details:\n',
errorUrl: `${this.GQLerror.externalUrl}\n`, errorUrl: `${this.error.externalUrl}\n`,
firstSeen: `\n${this.GQLerror.firstSeen}\n`, firstSeen: `\n${this.error.firstSeen}\n`,
lastSeen: `${this.GQLerror.lastSeen}\n`, lastSeen: `${this.error.lastSeen}\n`,
countLabel: n__('- Event', '- Events', this.GQLerror.count), countLabel: n__('- Event', '- Events', this.error.count),
count: `${this.GQLerror.count}\n`, count: `${this.error.count}\n`,
userCountLabel: n__('- User', '- Users', this.GQLerror.userCount), userCountLabel: n__('- User', '- Users', this.error.userCount),
userCount: `${this.GQLerror.userCount}\n`, userCount: `${this.error.userCount}\n`,
}, },
false, false,
); );
...@@ -171,12 +160,10 @@ export default { ...@@ -171,12 +160,10 @@ export default {
}, },
}, },
mounted() { mounted() {
this.startPollingDetails(this.issueDetailsPath);
this.startPollingStacktrace(this.issueStackTracePath); this.startPollingStacktrace(this.issueStackTracePath);
}, },
methods: { methods: {
...mapActions('details', [ ...mapActions('details', [
'startPollingDetails',
'startPollingStacktrace', 'startPollingStacktrace',
'updateStatus', 'updateStatus',
'setStatus', 'setStatus',
...@@ -214,10 +201,10 @@ export default { ...@@ -214,10 +201,10 @@ export default {
<template> <template>
<div> <div>
<div v-if="$apollo.queries.GQLerror.loading || loading" class="py-3"> <div v-if="$apollo.queries.error.loading" class="py-3">
<gl-loading-icon :size="3" /> <gl-loading-icon :size="3" />
</div> </div>
<div v-else-if="showDetails" class="error-details"> <div v-else-if="error" class="error-details">
<gl-alert v-if="isAlertVisible" @dismiss="isAlertVisible = false"> <gl-alert v-if="isAlertVisible" @dismiss="isAlertVisible = false">
<gl-sprintf <gl-sprintf
:message=" :message="
...@@ -232,7 +219,7 @@ export default { ...@@ -232,7 +219,7 @@ export default {
<div class="top-area align-items-center justify-content-between py-3"> <div class="top-area align-items-center justify-content-between py-3">
<span v-if="!loadingStacktrace && stacktrace" v-html="reported"></span> <span v-if="!loadingStacktrace && stacktrace" v-html="reported"></span>
<div class="d-inline-flex"> <div class="d-inline-flex ml-lg-auto">
<loading-button <loading-button
:label="ignoreBtnLabel" :label="ignoreBtnLabel"
:loading="updatingIgnoreStatus" :loading="updatingIgnoreStatus"
...@@ -247,10 +234,10 @@ export default { ...@@ -247,10 +234,10 @@ export default {
@click="onResolveStatusUpdate" @click="onResolveStatusUpdate"
/> />
<gl-button <gl-button
v-if="error.gitlab_issue" v-if="error.gitlabIssuePath"
class="ml-2" class="ml-2"
data-qa-selector="view_issue_button" data-qa-selector="view_issue_button"
:href="error.gitlab_issue" :href="error.gitlabIssuePath"
variant="success" variant="success"
> >
{{ __('View issue') }} {{ __('View issue') }}
...@@ -264,13 +251,13 @@ export default { ...@@ -264,13 +251,13 @@ export default {
<gl-form-input class="hidden" name="issue[title]" :value="issueTitle" /> <gl-form-input class="hidden" name="issue[title]" :value="issueTitle" />
<input name="issue[description]" :value="issueDescription" type="hidden" /> <input name="issue[description]" :value="issueDescription" type="hidden" />
<gl-form-input <gl-form-input
:value="GQLerror.sentryId" :value="error.sentryId"
class="hidden" class="hidden"
name="issue[sentry_issue_attributes][sentry_issue_identifier]" name="issue[sentry_issue_attributes][sentry_issue_identifier]"
/> />
<gl-form-input :value="csrfToken" class="hidden" name="authenticity_token" /> <gl-form-input :value="csrfToken" class="hidden" name="authenticity_token" />
<loading-button <loading-button
v-if="!error.gitlab_issue" v-if="!error.gitlabIssuePath"
class="btn-success" class="btn-success"
:label="__('Create issue')" :label="__('Create issue')"
:loading="issueCreationInProgress" :loading="issueCreationInProgress"
...@@ -281,8 +268,8 @@ export default { ...@@ -281,8 +268,8 @@ export default {
</div> </div>
</div> </div>
<div> <div>
<tooltip-on-truncate :title="GQLerror.title" truncate-target="child" placement="top"> <tooltip-on-truncate :title="error.title" truncate-target="child" placement="top">
<h2 class="text-truncate">{{ GQLerror.title }}</h2> <h2 class="text-truncate">{{ error.title }}</h2>
</tooltip-on-truncate> </tooltip-on-truncate>
<template v-if="error.tags"> <template v-if="error.tags">
<gl-badge <gl-badge
...@@ -297,53 +284,51 @@ export default { ...@@ -297,53 +284,51 @@ export default {
</gl-badge> </gl-badge>
</template> </template>
<ul> <ul>
<li v-if="GQLerror.gitlabCommit"> <li v-if="error.gitlabCommit">
<strong class="bold">{{ __('GitLab commit') }}:</strong> <strong class="bold">{{ __('GitLab commit') }}:</strong>
<gl-link :href="GQLerror.gitlabCommitPath"> <gl-link :href="error.gitlabCommitPath">
<span>{{ GQLerror.gitlabCommit.substr(0, 10) }}</span> <span>{{ error.gitlabCommit.substr(0, 10) }}</span>
</gl-link> </gl-link>
</li> </li>
<li v-if="error.gitlab_issue"> <li v-if="error.gitlabIssuePath">
<strong class="bold">{{ __('GitLab Issue') }}:</strong> <strong class="bold">{{ __('GitLab Issue') }}:</strong>
<gl-link :href="error.gitlab_issue"> <gl-link :href="error.gitlabIssuePath">
<span>{{ error.gitlab_issue }}</span> <span>{{ error.gitlabIssuePath }}</span>
</gl-link> </gl-link>
</li> </li>
<li> <li>
<strong class="bold">{{ __('Sentry event') }}:</strong> <strong class="bold">{{ __('Sentry event') }}:</strong>
<gl-link <gl-link
v-track-event="trackClickErrorLinkToSentryOptions(GQLerror.externalUrl)" v-track-event="trackClickErrorLinkToSentryOptions(error.externalUrl)"
class="d-inline-flex align-items-center" class="d-inline-flex align-items-center"
:href="GQLerror.externalUrl" :href="error.externalUrl"
target="_blank" target="_blank"
> >
<span class="text-truncate">{{ GQLerror.externalUrl }}</span> <span class="text-truncate">{{ error.externalUrl }}</span>
<icon name="external-link" class="ml-1 flex-shrink-0" /> <icon name="external-link" class="ml-1 flex-shrink-0" />
</gl-link> </gl-link>
</li> </li>
<li v-if="GQLerror.firstReleaseShortVersion"> <li v-if="error.firstReleaseShortVersion">
<strong class="bold">{{ __('First seen') }}:</strong> <strong class="bold">{{ __('First seen') }}:</strong>
{{ formatDate(GQLerror.firstSeen) }} {{ formatDate(error.firstSeen) }}
<gl-link :href="firstReleaseLink" target="_blank"> <gl-link :href="firstReleaseLink" target="_blank">
<span> <span>{{ __('Release') }}: {{ error.firstReleaseShortVersion.substr(0, 10) }}</span>
{{ __('Release') }}: {{ GQLerror.firstReleaseShortVersion.substr(0, 10) }}
</span>
</gl-link> </gl-link>
</li> </li>
<li v-if="GQLerror.lastReleaseShortVersion"> <li v-if="error.lastReleaseShortVersion">
<strong class="bold">{{ __('Last seen') }}:</strong> <strong class="bold">{{ __('Last seen') }}:</strong>
{{ formatDate(GQLerror.lastSeen) }} {{ formatDate(error.lastSeen) }}
<gl-link :href="lastReleaseLink" target="_blank"> <gl-link :href="lastReleaseLink" target="_blank">
<span>{{ __('Release') }}: {{ GQLerror.lastReleaseShortVersion.substr(0, 10) }}</span> <span>{{ __('Release') }}: {{ error.lastReleaseShortVersion.substr(0, 10) }}</span>
</gl-link> </gl-link>
</li> </li>
<li> <li>
<strong class="bold">{{ __('Events') }}:</strong> <strong class="bold">{{ __('Events') }}:</strong>
<span>{{ GQLerror.count }}</span> <span>{{ error.count }}</span>
</li> </li>
<li> <li>
<strong class="bold">{{ __('Users') }}:</strong> <strong class="bold">{{ __('Users') }}:</strong>
<span>{{ GQLerror.userCount }}</span> <span>{{ error.userCount }}</span>
</li> </li>
</ul> </ul>
...@@ -351,7 +336,7 @@ export default { ...@@ -351,7 +336,7 @@ export default {
<gl-loading-icon :size="3" /> <gl-loading-icon :size="3" />
</div> </div>
<template v-if="showStacktrace"> <template v-else-if="showStacktrace">
<h3 class="my-4">{{ __('Stack trace') }}</h3> <h3 class="my-4">{{ __('Stack trace') }}</h3>
<stacktrace :entries="stacktrace" /> <stacktrace :entries="stacktrace" />
</template> </template>
......
...@@ -26,7 +26,6 @@ export default () => { ...@@ -26,7 +26,6 @@ export default () => {
issueId, issueId,
projectPath, projectPath,
issueUpdatePath, issueUpdatePath,
issueDetailsPath,
issueStackTracePath, issueStackTracePath,
projectIssuesPath, projectIssuesPath,
} = domEl.dataset; } = domEl.dataset;
...@@ -36,7 +35,6 @@ export default () => { ...@@ -36,7 +35,6 @@ export default () => {
issueId, issueId,
projectPath, projectPath,
issueUpdatePath, issueUpdatePath,
issueDetailsPath,
issueStackTracePath, issueStackTracePath,
projectIssuesPath, projectIssuesPath,
csrfToken: csrf.token, csrfToken: csrf.token,
......
query errorDetails($fullPath: ID!, $errorId: ID!) { query errorDetails($fullPath: ID!, $errorId: ID!) {
project(fullPath: $fullPath) { project(fullPath: $fullPath) {
sentryDetailedError(id: $errorId) { sentryErrors {
detailedError(id: $errorId) {
id id
sentryId sentryId
title title
...@@ -11,11 +12,18 @@ query errorDetails($fullPath: ID!, $errorId: ID!) { ...@@ -11,11 +12,18 @@ query errorDetails($fullPath: ID!, $errorId: ID!) {
lastSeen lastSeen
message message
culprit culprit
tags {
level
logger
}
externalUrl externalUrl
externalBaseUrl
firstReleaseShortVersion firstReleaseShortVersion
lastReleaseShortVersion lastReleaseShortVersion
gitlabCommit gitlabCommit
gitlabCommitPath gitlabCommitPath
gitlabIssuePath
}
} }
} }
} }
...@@ -5,36 +5,11 @@ import Poll from '~/lib/utils/poll'; ...@@ -5,36 +5,11 @@ import Poll from '~/lib/utils/poll';
import { __ } from '~/locale'; import { __ } from '~/locale';
let stackTracePoll; let stackTracePoll;
let detailPoll;
const stopPolling = poll => { const stopPolling = poll => {
if (poll) poll.stop(); if (poll) poll.stop();
}; };
export function startPollingDetails({ commit }, endpoint) {
detailPoll = new Poll({
resource: service,
method: 'getSentryData',
data: { endpoint },
successCallback: ({ data }) => {
if (!data) {
return;
}
commit(types.SET_ERROR, data.error);
commit(types.SET_LOADING, false);
stopPolling(detailPoll);
},
errorCallback: () => {
commit(types.SET_LOADING, false);
createFlash(__('Failed to load error details from Sentry.'));
},
});
detailPoll.makeRequest();
}
export function startPollingStacktrace({ commit }, endpoint) { export function startPollingStacktrace({ commit }, endpoint) {
stackTracePoll = new Poll({ stackTracePoll = new Poll({
resource: service, resource: service,
......
export const SET_ERROR = 'SET_ERRORS';
export const SET_LOADING = 'SET_LOADING';
export const SET_LOADING_STACKTRACE = 'SET_LOADING_STACKTRACE'; export const SET_LOADING_STACKTRACE = 'SET_LOADING_STACKTRACE';
export const SET_STACKTRACE_DATA = 'SET_STACKTRACE_DATA'; export const SET_STACKTRACE_DATA = 'SET_STACKTRACE_DATA';
import * as types from './mutation_types'; import * as types from './mutation_types';
export default { export default {
[types.SET_ERROR](state, data) {
state.error = data;
},
[types.SET_LOADING](state, loading) {
state.loading = loading;
},
[types.SET_LOADING_STACKTRACE](state, data) { [types.SET_LOADING_STACKTRACE](state, data) {
state.loadingStacktrace = data; state.loadingStacktrace = data;
}, },
......
export default () => ({ export default () => ({
error: {},
stacktraceData: {}, stacktraceData: {},
loading: true,
loadingStacktrace: true, loadingStacktrace: true,
updatingResolveStatus: false, updatingResolveStatus: false,
updatingIgnoreStatus: false, updatingIgnoreStatus: false,
......
...@@ -22,7 +22,6 @@ module Projects::ErrorTrackingHelper ...@@ -22,7 +22,6 @@ module Projects::ErrorTrackingHelper
{ {
'issue-id' => issue_id, 'issue-id' => issue_id,
'project-path' => project.full_path, 'project-path' => project.full_path,
'issue-details-path' => details_project_error_tracking_index_path(*opts),
'issue-update-path' => update_project_error_tracking_index_path(*opts), 'issue-update-path' => update_project_error_tracking_index_path(*opts),
'project-issues-path' => project_issues_path(project), 'project-issues-path' => project_issues_path(project),
'issue-stack-trace-path' => stack_trace_project_error_tracking_index_path(*opts) 'issue-stack-trace-path' => stack_trace_project_error_tracking_index_path(*opts)
......
...@@ -37,14 +37,13 @@ describe('ErrorDetails', () => { ...@@ -37,14 +37,13 @@ describe('ErrorDetails', () => {
projectPath: '/root/gitlab-test', projectPath: '/root/gitlab-test',
listPath: '/error_tracking', listPath: '/error_tracking',
issueUpdatePath: '/123', issueUpdatePath: '/123',
issueDetailsPath: '/123/details',
issueStackTracePath: '/stacktrace', issueStackTracePath: '/stacktrace',
projectIssuesPath: '/test-project/issues/', projectIssuesPath: '/test-project/issues/',
csrfToken: 'fakeToken', csrfToken: 'fakeToken',
}, },
}); });
wrapper.setData({ wrapper.setData({
GQLerror: { error: {
id: 'gid://gitlab/Gitlab::ErrorTracking::DetailedError/129381', id: 'gid://gitlab/Gitlab::ErrorTracking::DetailedError/129381',
sentryId: 129381, sentryId: 129381,
title: 'Issue title', title: 'Issue title',
...@@ -59,7 +58,6 @@ describe('ErrorDetails', () => { ...@@ -59,7 +58,6 @@ describe('ErrorDetails', () => {
beforeEach(() => { beforeEach(() => {
actions = { actions = {
startPollingDetails: () => {},
startPollingStacktrace: () => {}, startPollingStacktrace: () => {},
updateIgnoreStatus: jest.fn(), updateIgnoreStatus: jest.fn(),
updateResolveStatus: jest.fn().mockResolvedValue({ closed_issue_iid: 1 }), updateResolveStatus: jest.fn().mockResolvedValue({ closed_issue_iid: 1 }),
...@@ -71,8 +69,6 @@ describe('ErrorDetails', () => { ...@@ -71,8 +69,6 @@ describe('ErrorDetails', () => {
}; };
const state = { const state = {
error: {},
loading: true,
stacktraceData: {}, stacktraceData: {},
loadingStacktrace: true, loadingStacktrace: true,
}; };
...@@ -93,7 +89,7 @@ describe('ErrorDetails', () => { ...@@ -93,7 +89,7 @@ describe('ErrorDetails', () => {
$apollo: { $apollo: {
query, query,
queries: { queries: {
GQLerror: { error: {
loading: true, loading: true,
stopPolling: jest.fn(), stopPolling: jest.fn(),
}, },
...@@ -122,9 +118,7 @@ describe('ErrorDetails', () => { ...@@ -122,9 +118,7 @@ describe('ErrorDetails', () => {
describe('Error details', () => { describe('Error details', () => {
beforeEach(() => { beforeEach(() => {
store.state.details.loading = false; mocks.$apollo.queries.error.loading = false;
store.state.details.error.id = 1;
mocks.$apollo.queries.GQLerror.loading = false;
mountComponent(); mountComponent();
}); });
...@@ -138,16 +132,22 @@ describe('ErrorDetails', () => { ...@@ -138,16 +132,22 @@ describe('ErrorDetails', () => {
describe('Badges', () => { describe('Badges', () => {
it('should show language and error level badges', () => { it('should show language and error level badges', () => {
store.state.details.error.tags = { level: 'error', logger: 'ruby' }; wrapper.setData({
mountComponent(); error: {
tags: { level: 'error', logger: 'ruby' },
},
});
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.findAll(GlBadge).length).toBe(2); expect(wrapper.findAll(GlBadge).length).toBe(2);
}); });
}); });
it('should NOT show the badge if the tag is not present', () => { it('should NOT show the badge if the tag is not present', () => {
store.state.details.error.tags = { level: 'error' }; wrapper.setData({
mountComponent(); error: {
tags: { level: 'error' },
},
});
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.findAll(GlBadge).length).toBe(1); expect(wrapper.findAll(GlBadge).length).toBe(1);
}); });
...@@ -156,8 +156,11 @@ describe('ErrorDetails', () => { ...@@ -156,8 +156,11 @@ describe('ErrorDetails', () => {
it.each(Object.keys(severityLevel))( it.each(Object.keys(severityLevel))(
'should set correct severity level variant for %s badge', 'should set correct severity level variant for %s badge',
level => { level => {
store.state.details.error.tags = { level: severityLevel[level] }; wrapper.setData({
mountComponent(); error: {
tags: { level: severityLevel[level] },
},
});
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlBadge).attributes('variant')).toEqual( expect(wrapper.find(GlBadge).attributes('variant')).toEqual(
severityLevelVariant[severityLevel[level]], severityLevelVariant[severityLevel[level]],
...@@ -167,8 +170,11 @@ describe('ErrorDetails', () => { ...@@ -167,8 +170,11 @@ describe('ErrorDetails', () => {
); );
it('should fallback for ERROR severityLevelVariant when severityLevel is unknown', () => { it('should fallback for ERROR severityLevelVariant when severityLevel is unknown', () => {
store.state.details.error.tags = { level: 'someNewErrorLevel' }; wrapper.setData({
mountComponent(); error: {
tags: { level: 'someNewErrorLevel' },
},
});
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlBadge).attributes('variant')).toEqual( expect(wrapper.find(GlBadge).attributes('variant')).toEqual(
severityLevelVariant[severityLevel.ERROR], severityLevelVariant[severityLevel.ERROR],
...@@ -180,7 +186,6 @@ describe('ErrorDetails', () => { ...@@ -180,7 +186,6 @@ describe('ErrorDetails', () => {
describe('Stacktrace', () => { describe('Stacktrace', () => {
it('should show stacktrace', () => { it('should show stacktrace', () => {
store.state.details.loadingStacktrace = false; store.state.details.loadingStacktrace = false;
mountComponent();
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false); expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
expect(wrapper.find(Stacktrace).exists()).toBe(true); expect(wrapper.find(Stacktrace).exists()).toBe(true);
...@@ -190,11 +195,12 @@ describe('ErrorDetails', () => { ...@@ -190,11 +195,12 @@ describe('ErrorDetails', () => {
it('should NOT show stacktrace if no entries', () => { it('should NOT show stacktrace if no entries', () => {
store.state.details.loadingStacktrace = false; store.state.details.loadingStacktrace = false;
store.getters = { 'details/sentryUrl': () => 'sentry.io', 'details/stacktrace': () => [] }; store.getters = { 'details/sentryUrl': () => 'sentry.io', 'details/stacktrace': () => [] };
mountComponent(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false); expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
expect(wrapper.find(Stacktrace).exists()).toBe(false); expect(wrapper.find(Stacktrace).exists()).toBe(false);
}); });
}); });
});
describe('When a user clicks the create issue button', () => { describe('When a user clicks the create issue button', () => {
beforeEach(() => { beforeEach(() => {
...@@ -331,19 +337,18 @@ describe('ErrorDetails', () => { ...@@ -331,19 +337,18 @@ describe('ErrorDetails', () => {
}); });
describe('GitLab issue link', () => { describe('GitLab issue link', () => {
const gitlabIssue = 'https://gitlab.example.com/issues/1'; const gitlabIssuePath = 'https://gitlab.example.com/issues/1';
const findGitLabLink = () => wrapper.find(`[href="${gitlabIssue}"]`); const findGitLabLink = () => wrapper.find(`[href="${gitlabIssuePath}"]`);
const findCreateIssueButton = () => wrapper.find('[data-qa-selector="create_issue_button"]'); const findCreateIssueButton = () => wrapper.find('[data-qa-selector="create_issue_button"]');
const findViewIssueButton = () => wrapper.find('[data-qa-selector="view_issue_button"]'); const findViewIssueButton = () => wrapper.find('[data-qa-selector="view_issue_button"]');
describe('is present', () => { describe('is present', () => {
beforeEach(() => { beforeEach(() => {
store.state.details.loading = false; wrapper.setData({
store.state.details.error = { error: {
id: 1, gitlabIssuePath,
gitlab_issue: gitlabIssue, },
}; });
mountComponent();
}); });
it('should display the View issue button', () => { it('should display the View issue button', () => {
...@@ -361,12 +366,11 @@ describe('ErrorDetails', () => { ...@@ -361,12 +366,11 @@ describe('ErrorDetails', () => {
describe('is not present', () => { describe('is not present', () => {
beforeEach(() => { beforeEach(() => {
store.state.details.loading = false; wrapper.setData({
store.state.details.error = { error: {
id: 1, gitlabIssuePath: null,
gitlab_issue: null, },
}; });
mountComponent();
}); });
it('should not display the View issue button', () => { it('should not display the View issue button', () => {
...@@ -390,9 +394,9 @@ describe('ErrorDetails', () => { ...@@ -390,9 +394,9 @@ describe('ErrorDetails', () => {
const findGitLabCommitLink = () => wrapper.find(`[href$="${gitlabCommitPath}"]`); const findGitLabCommitLink = () => wrapper.find(`[href$="${gitlabCommitPath}"]`);
it('should display a link', () => { it('should display a link', () => {
mocks.$apollo.queries.GQLerror.loading = false; mocks.$apollo.queries.error.loading = false;
wrapper.setData({ wrapper.setData({
GQLerror: { error: {
gitlabCommit, gitlabCommit,
gitlabCommitPath, gitlabCommitPath,
}, },
...@@ -403,9 +407,9 @@ describe('ErrorDetails', () => { ...@@ -403,9 +407,9 @@ describe('ErrorDetails', () => {
}); });
it('should not display a link', () => { it('should not display a link', () => {
mocks.$apollo.queries.GQLerror.loading = false; mocks.$apollo.queries.error.loading = false;
wrapper.setData({ wrapper.setData({
GQLerror: { error: {
gitlabCommit: null, gitlabCommit: null,
}, },
}); });
......
...@@ -26,53 +26,6 @@ describe('Sentry error details store actions', () => { ...@@ -26,53 +26,6 @@ describe('Sentry error details store actions', () => {
} }
}); });
describe('startPollingDetails', () => {
const endpoint = '123/details';
it('should commit SET_ERROR with received response', done => {
const payload = { error: { id: 1 } };
mockedAdapter.onGet().reply(200, payload);
testAction(
actions.startPollingDetails,
{ endpoint },
{},
[
{ type: types.SET_ERROR, payload: payload.error },
{ type: types.SET_LOADING, payload: false },
],
[],
() => {
done();
},
);
});
it('should show flash on API error', done => {
mockedAdapter.onGet().reply(400);
testAction(
actions.startPollingDetails,
{ endpoint },
{},
[{ type: types.SET_LOADING, payload: false }],
[],
() => {
expect(createFlash).toHaveBeenCalledTimes(1);
done();
},
);
});
it('should not restart polling when receiving an empty 204 response', done => {
mockedRestart = jest.spyOn(Poll.prototype, 'restart');
mockedAdapter.onGet().reply(204);
testAction(actions.startPollingDetails, { endpoint }, {}, [], [], () => {
expect(mockedRestart).toHaveBeenCalledTimes(0);
done();
});
});
});
describe('startPollingStacktrace', () => { describe('startPollingStacktrace', () => {
const endpoint = '123/stacktrace'; const endpoint = '123/stacktrace';
it('should commit SET_ERROR with received response', done => { it('should commit SET_ERROR with received response', done => {
......
...@@ -83,7 +83,6 @@ describe Projects::ErrorTrackingHelper do ...@@ -83,7 +83,6 @@ describe Projects::ErrorTrackingHelper do
describe '#error_details_data' do describe '#error_details_data' do
let(:issue_id) { 1234 } let(:issue_id) { 1234 }
let(:route_params) { [project.owner, project, issue_id, { format: :json }] } let(:route_params) { [project.owner, project, issue_id, { format: :json }] }
let(:details_path) { details_namespace_project_error_tracking_index_path(*route_params) }
let(:project_path) { project.full_path } let(:project_path) { project.full_path }
let(:stack_trace_path) { stack_trace_namespace_project_error_tracking_index_path(*route_params) } let(:stack_trace_path) { stack_trace_namespace_project_error_tracking_index_path(*route_params) }
let(:issues_path) { project_issues_path(project) } let(:issues_path) { project_issues_path(project) }
...@@ -98,10 +97,6 @@ describe Projects::ErrorTrackingHelper do ...@@ -98,10 +97,6 @@ describe Projects::ErrorTrackingHelper do
expect(result['project-path']).to eq project_path expect(result['project-path']).to eq project_path
end end
it 'returns the correct details path' do
expect(result['issue-details-path']).to eq details_path
end
it 'returns the correct stack trace path' do it 'returns the correct stack trace path' do
expect(result['issue-stack-trace-path']).to eq stack_trace_path expect(result['issue-stack-trace-path']).to eq stack_trace_path
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment