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

Updates rspec and variable

parent 38151e68
......@@ -66,7 +66,7 @@ export default {
showStacktrace() {
return Boolean(!this.loadingStacktrace && this.stacktrace && this.stacktrace.length);
},
errorTitle() {
issueTitle() {
return `${this.error.title}`;
},
errorUrl() {
......@@ -139,7 +139,7 @@ export default {
<div class="top-area align-items-center justify-content-between py-3">
<span v-if="!loadingStacktrace && stacktrace" v-html="reported"></span>
<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 :value="csrfToken" type="hidden" name="authenticity_token" />
<gl-button variant="success" @click="createIssue">
......
import { createLocalVue, shallowMount } from '@vue/test-utils';
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 ErrorDetails from '~/error_tracking/components/error_details.vue';
......@@ -20,7 +20,8 @@ describe('ErrorDetails', () => {
propsData: {
issueDetailsPath: '/123/details',
issueStackTracePath: '/stacktrace',
issueProjectPath: '/test-project/issues/new',
projectIssuesPath: '/test-project/issues/',
csrfToken: 'fakeToken',
},
});
}
......@@ -83,7 +84,7 @@ describe('ErrorDetails', () => {
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.error = {
id: 1,
......@@ -95,22 +96,16 @@ describe('ErrorDetails', () => {
user_count: 2,
};
mountComponent();
const button = wrapper.find(GlButton);
const title = 'Issue title';
const url = 'Sentry event: http://sentry.gitlab.net/gitlab';
const firstSeen = 'First seen: 2017-05-26T13:32:48Z';
const lastSeen = 'Last seen: 2018-05-26T13:32:48Z';
const count = 'Events: 12';
const userCount = 'Users: 2';
const issueDescription = `${url}${firstSeen}${lastSeen}${count}${userCount}`;
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);
const form = wrapper.find({ ref: 'sentryIssueForm' });
const csrfTokenInput = wrapper.find('input[name="authenticity_token"]');
const issueTitleInput = wrapper.find('input[name="issue[title]"]');
const issueDescriptionInput = wrapper.find('input[name="issue[description]"]');
expect(form).toExist();
expect(csrfTokenInput.attributes('value')).toBe('fakeToken');
expect(issueTitleInput.attributes('value')).toContain(wrapper.vm.issueTitle);
expect(issueDescriptionInput.attributes('value')).toContain(wrapper.vm.issueDescription);
});
describe('Stacktrace', () => {
......
......@@ -81,7 +81,7 @@ describe Projects::ErrorTrackingHelper do
let(:route_params) { [project.owner, project, issue_id, { format: :json }] }
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(:issue_project_path) { new_project_issue_path(project) }
let(:issues_path) { project_issues_path(project) }
let(:result) { helper.error_details_data(project, issue_id) }
......@@ -93,8 +93,8 @@ describe Projects::ErrorTrackingHelper do
expect(result['issue-stack-trace-path']).to eq stack_trace_path
end
it 'returns the correct path for creating a new issue' do
expect(result['issue-project-path']).to eq issue_project_path
it 'creates an issue and redirects to issue show page' do
expect(result['project-issues-path']).to eq issues_path
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