Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-04 12:06:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-04 12:06:33 +0300
commitc4038d4bdff93b260cbdcd69f9a6c0b07a849457 (patch)
tree7b74ce5a60a97324dec5c61ac477ca74e3db36e9 /spec
parentd07169c8ae0ebad0f23d03f01aeaf9acfa7e02d1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/error_tracking/components/error_details_spec.js70
-rw-r--r--spec/helpers/projects/error_tracking_helper_spec.rb6
2 files changed, 41 insertions, 35 deletions
diff --git a/spec/frontend/error_tracking/components/error_details_spec.js b/spec/frontend/error_tracking/components/error_details_spec.js
index cf91c840cc4..72f3577c530 100644
--- a/spec/frontend/error_tracking/components/error_details_spec.js
+++ b/spec/frontend/error_tracking/components/error_details_spec.js
@@ -1,6 +1,7 @@
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 LoadingButton from '~/vue_shared/components/loading_button.vue';
import Stacktrace from '~/error_tracking/components/stacktrace.vue';
import ErrorDetails from '~/error_tracking/components/error_details.vue';
@@ -15,12 +16,14 @@ describe('ErrorDetails', () => {
function mountComponent() {
wrapper = shallowMount(ErrorDetails, {
+ stubs: { LoadingButton },
localVue,
store,
propsData: {
issueDetailsPath: '/123/details',
issueStackTracePath: '/stacktrace',
- issueProjectPath: '/test-project/issues/new',
+ projectIssuesPath: '/test-project/issues/',
+ csrfToken: 'fakeToken',
},
});
}
@@ -83,36 +86,6 @@ describe('ErrorDetails', () => {
expect(wrapper.find(Stacktrace).exists()).toBe(false);
});
- it('should allow an issue to be created with title and description', () => {
- store.state.details.loading = false;
- store.state.details.error = {
- id: 1,
- title: 'Issue title',
- external_url: 'http://sentry.gitlab.net/gitlab',
- first_seen: '2017-05-26T13:32:48Z',
- last_seen: '2018-05-26T13:32:48Z',
- count: 12,
- 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);
- });
-
describe('Stacktrace', () => {
it('should show stacktrace', () => {
store.state.details.loading = false;
@@ -132,5 +105,38 @@ describe('ErrorDetails', () => {
expect(wrapper.find(Stacktrace).exists()).toBe(false);
});
});
+
+ describe('When a user clicks the create issue button', () => {
+ beforeEach(() => {
+ store.state.details.loading = false;
+ store.state.details.error = {
+ id: 1,
+ title: 'Issue title',
+ external_url: 'http://sentry.gitlab.net/gitlab',
+ first_seen: '2017-05-26T13:32:48Z',
+ last_seen: '2018-05-26T13:32:48Z',
+ count: 12,
+ user_count: 2,
+ };
+ mountComponent();
+ });
+
+ it('should set the form values with title and description', () => {
+ const csrfTokenInput = wrapper.find('glforminput-stub[name="authenticity_token"]');
+ const issueTitleInput = wrapper.find('glforminput-stub[name="issue[title]"]');
+ const issueDescriptionInput = wrapper.find('input[name="issue[description]"]');
+ expect(csrfTokenInput.attributes('value')).toBe('fakeToken');
+ expect(issueTitleInput.attributes('value')).toContain(wrapper.vm.issueTitle);
+ expect(issueDescriptionInput.attributes('value')).toContain(wrapper.vm.issueDescription);
+ });
+
+ it('should submit the form', () => {
+ window.HTMLFormElement.prototype.submit = () => {};
+ const submitSpy = jest.spyOn(wrapper.vm.$refs.sentryIssueForm, 'submit');
+ wrapper.find('button').trigger('click');
+ expect(submitSpy).toHaveBeenCalled();
+ submitSpy.mockRestore();
+ });
+ });
});
});
diff --git a/spec/helpers/projects/error_tracking_helper_spec.rb b/spec/helpers/projects/error_tracking_helper_spec.rb
index fdffdca22fb..753144eef89 100644
--- a/spec/helpers/projects/error_tracking_helper_spec.rb
+++ b/spec/helpers/projects/error_tracking_helper_spec.rb
@@ -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