Commit 4b544817 authored by lauraMon's avatar lauraMon Committed by Martin Wortschack

Updates rspec and variable

parent 38151e68
...@@ -66,7 +66,7 @@ export default { ...@@ -66,7 +66,7 @@ export default {
showStacktrace() { showStacktrace() {
return Boolean(!this.loadingStacktrace && this.stacktrace && this.stacktrace.length); return Boolean(!this.loadingStacktrace && this.stacktrace && this.stacktrace.length);
}, },
errorTitle() { issueTitle() {
return `${this.error.title}`; return `${this.error.title}`;
}, },
errorUrl() { errorUrl() {
...@@ -139,7 +139,7 @@ export default { ...@@ -139,7 +139,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>
<form ref="sentryIssueForm" :action="projectIssuesPath" method="POST"> <form ref="sentryIssueForm" :action="projectIssuesPath" method="POST">
<input name="issue[title]" :value="errorTitle" type="hidden" /> <input name="issue[title]" :value="issueTitle" type="hidden" />
<input name="issue[description]" :value="issueDescription" type="hidden" /> <input name="issue[description]" :value="issueDescription" type="hidden" />
<input :value="csrfToken" type="hidden" name="authenticity_token" /> <input :value="csrfToken" type="hidden" name="authenticity_token" />
<gl-button variant="success" @click="createIssue"> <gl-button variant="success" @click="createIssue">
......
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import { GlButton, GlLoadingIcon, GlLink } from '@gitlab/ui'; import { GlLoadingIcon, GlLink } from '@gitlab/ui';
import Stacktrace from '~/error_tracking/components/stacktrace.vue'; import Stacktrace from '~/error_tracking/components/stacktrace.vue';
import ErrorDetails from '~/error_tracking/components/error_details.vue'; import ErrorDetails from '~/error_tracking/components/error_details.vue';
...@@ -20,7 +20,8 @@ describe('ErrorDetails', () => { ...@@ -20,7 +20,8 @@ describe('ErrorDetails', () => {
propsData: { propsData: {
issueDetailsPath: '/123/details', issueDetailsPath: '/123/details',
issueStackTracePath: '/stacktrace', issueStackTracePath: '/stacktrace',
issueProjectPath: '/test-project/issues/new', projectIssuesPath: '/test-project/issues/',
csrfToken: 'fakeToken',
}, },
}); });
} }
...@@ -83,7 +84,7 @@ describe('ErrorDetails', () => { ...@@ -83,7 +84,7 @@ describe('ErrorDetails', () => {
expect(wrapper.find(Stacktrace).exists()).toBe(false); expect(wrapper.find(Stacktrace).exists()).toBe(false);
}); });
it('should allow an issue to be created with title and description', () => { it('should create an issue with title and description', () => {
store.state.details.loading = false; store.state.details.loading = false;
store.state.details.error = { store.state.details.error = {
id: 1, id: 1,
...@@ -95,22 +96,16 @@ describe('ErrorDetails', () => { ...@@ -95,22 +96,16 @@ describe('ErrorDetails', () => {
user_count: 2, user_count: 2,
}; };
mountComponent(); mountComponent();
const button = wrapper.find(GlButton);
const title = 'Issue title'; const form = wrapper.find({ ref: 'sentryIssueForm' });
const url = 'Sentry event: http://sentry.gitlab.net/gitlab'; const csrfTokenInput = wrapper.find('input[name="authenticity_token"]');
const firstSeen = 'First seen: 2017-05-26T13:32:48Z'; const issueTitleInput = wrapper.find('input[name="issue[title]"]');
const lastSeen = 'Last seen: 2018-05-26T13:32:48Z'; const issueDescriptionInput = wrapper.find('input[name="issue[description]"]');
const count = 'Events: 12';
const userCount = 'Users: 2'; expect(form).toExist();
expect(csrfTokenInput.attributes('value')).toBe('fakeToken');
const issueDescription = `${url}${firstSeen}${lastSeen}${count}${userCount}`; expect(issueTitleInput.attributes('value')).toContain(wrapper.vm.issueTitle);
expect(issueDescriptionInput.attributes('value')).toContain(wrapper.vm.issueDescription);
const issueLink = `/test-project/issues/new?issue[title]=${encodeURIComponent(
title,
)}&issue[description]=${encodeURIComponent(issueDescription)}`;
expect(button.exists()).toBe(true);
expect(button.attributes().href).toBe(issueLink);
}); });
describe('Stacktrace', () => { describe('Stacktrace', () => {
......
...@@ -81,7 +81,7 @@ describe Projects::ErrorTrackingHelper do ...@@ -81,7 +81,7 @@ describe Projects::ErrorTrackingHelper do
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(:details_path) { details_namespace_project_error_tracking_index_path(*route_params) }
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(:issue_project_path) { new_project_issue_path(project) } let(:issues_path) { project_issues_path(project) }
let(:result) { helper.error_details_data(project, issue_id) } let(:result) { helper.error_details_data(project, issue_id) }
...@@ -93,8 +93,8 @@ describe Projects::ErrorTrackingHelper do ...@@ -93,8 +93,8 @@ describe Projects::ErrorTrackingHelper 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
it 'returns the correct path for creating a new issue' do it 'creates an issue and redirects to issue show page' do
expect(result['issue-project-path']).to eq issue_project_path expect(result['project-issues-path']).to eq issues_path
end end
end end
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