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-10-18 03:07:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-18 03:07:45 +0300
commit7c077d960393e14b56d43cceaa7f609c703ac55f (patch)
treec3a5d79554b9be1d7434c8e9a8fcae35ab64af32 /spec
parentda35510cdad8f8d3cb6c119682dc2735531983cd (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/projects/clusters/eks_spec.rb34
-rw-r--r--spec/features/projects/clusters/gcp_spec.rb2
-rw-r--r--spec/features/projects/clusters_spec.rb2
-rw-r--r--spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js1
-rw-r--r--spec/frontend/error_tracking/utils_spec.js27
-rw-r--r--spec/frontend/monitoring/utils_spec.js54
-rw-r--r--spec/frontend/vue_shared/directives/track_event_spec.js49
-rw-r--r--spec/lib/gitlab/gitaly_client/conflict_files_stitcher_spec.rb2
-rw-r--r--spec/lib/gitlab/tracking/incident_management_spec.rb78
-rw-r--r--spec/services/issues/zoom_link_service_spec.rb13
10 files changed, 260 insertions, 2 deletions
diff --git a/spec/features/projects/clusters/eks_spec.rb b/spec/features/projects/clusters/eks_spec.rb
new file mode 100644
index 00000000000..758dccd6e49
--- /dev/null
+++ b/spec/features/projects/clusters/eks_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'AWS EKS Cluster', :js do
+ let(:project) { create(:project) }
+ let(:user) { create(:user) }
+
+ before do
+ project.add_maintainer(user)
+ gitlab_sign_in(user)
+ allow(Projects::ClustersController).to receive(:STATUS_POLLING_INTERVAL) { 100 }
+ end
+
+ context 'when user does not have a cluster and visits cluster index page' do
+ let(:project_id) { 'test-project-1234' }
+
+ before do
+ visit project_clusters_path(project)
+
+ click_link 'Add Kubernetes cluster'
+ end
+
+ context 'when user creates a cluster on AWS EKS' do
+ before do
+ click_link 'Amazon EKS'
+ end
+
+ it 'user sees a form to create an EKS cluster' do
+ expect(page).to have_selector(:css, '.js-create-eks-cluster')
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/clusters/gcp_spec.rb b/spec/features/projects/clusters/gcp_spec.rb
index a11237db508..b5ab9faa14b 100644
--- a/spec/features/projects/clusters/gcp_spec.rb
+++ b/spec/features/projects/clusters/gcp_spec.rb
@@ -177,6 +177,7 @@ describe 'Gcp Cluster', :js do
context 'when user has not dismissed GCP signup offer' do
before do
+ stub_feature_flags(create_eks_clusters: false)
visit project_clusters_path(project)
end
@@ -200,6 +201,7 @@ describe 'Gcp Cluster', :js do
context 'when user has dismissed GCP signup offer' do
before do
+ stub_feature_flags(create_eks_clusters: false)
visit project_clusters_path(project)
end
diff --git a/spec/features/projects/clusters_spec.rb b/spec/features/projects/clusters_spec.rb
index d1cd19dff2d..67d14d0a58a 100644
--- a/spec/features/projects/clusters_spec.rb
+++ b/spec/features/projects/clusters_spec.rb
@@ -74,7 +74,7 @@ describe 'Clusters', :js do
visit project_clusters_path(project)
click_link 'Add Kubernetes cluster'
- click_link 'Create new Cluster on GKE'
+ click_link 'Create new Cluster'
end
it 'user sees a link to create a GKE cluster' do
diff --git a/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js b/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js
index 321dc5bd6ba..69290f6dfa9 100644
--- a/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js
+++ b/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js
@@ -123,6 +123,7 @@ describe('EksClusterConfigurationForm', () => {
store,
propsData: {
gitlabManagedClusterHelpPath: '',
+ kubernetesIntegrationHelpPath: '',
},
});
});
diff --git a/spec/frontend/error_tracking/utils_spec.js b/spec/frontend/error_tracking/utils_spec.js
new file mode 100644
index 00000000000..0e9047cd375
--- /dev/null
+++ b/spec/frontend/error_tracking/utils_spec.js
@@ -0,0 +1,27 @@
+import * as errorTrackingUtils from '~/error_tracking/utils';
+
+const externalUrl = 'https://sentry.io/organizations/test-sentry-nk/issues/1/?project=1';
+
+describe('Error Tracking Events', () => {
+ describe('trackViewInSentryOptions', () => {
+ it('should return correct event options', () => {
+ expect(errorTrackingUtils.trackViewInSentryOptions(externalUrl)).toEqual({
+ category: 'Error Tracking',
+ action: 'click_view_in_sentry',
+ label: 'External Url',
+ property: externalUrl,
+ });
+ });
+ });
+
+ describe('trackClickErrorLinkToSentryOptions', () => {
+ it('should return correct event options', () => {
+ expect(errorTrackingUtils.trackClickErrorLinkToSentryOptions(externalUrl)).toEqual({
+ category: 'Error Tracking',
+ action: 'click_error_link_to_sentry',
+ label: 'Error Link',
+ property: externalUrl,
+ });
+ });
+ });
+});
diff --git a/spec/frontend/monitoring/utils_spec.js b/spec/frontend/monitoring/utils_spec.js
new file mode 100644
index 00000000000..1e8d5753885
--- /dev/null
+++ b/spec/frontend/monitoring/utils_spec.js
@@ -0,0 +1,54 @@
+import * as monitoringUtils from '~/monitoring/utils';
+
+describe('Snowplow Events', () => {
+ const generatedLink = 'http://chart.link.com';
+ const chartTitle = 'Some metric chart';
+
+ describe('trackGenerateLinkToChartEventOptions', () => {
+ it('should return Cluster Monitoring options if located on Cluster Health Dashboard', () => {
+ document.body.dataset.page = 'groups:clusters:show';
+
+ expect(monitoringUtils.generateLinkToChartOptions(generatedLink)).toEqual({
+ category: 'Cluster Monitoring',
+ action: 'generate_link_to_cluster_metric_chart',
+ label: 'Chart link',
+ property: generatedLink,
+ });
+ });
+
+ it('should return Incident Management event options if located on Metrics Dashboard', () => {
+ document.body.dataset.page = 'metrics:show';
+
+ expect(monitoringUtils.generateLinkToChartOptions(generatedLink)).toEqual({
+ category: 'Incident Management::Embedded metrics',
+ action: 'generate_link_to_metrics_chart',
+ label: 'Chart link',
+ property: generatedLink,
+ });
+ });
+ });
+
+ describe('trackDownloadCSVEvent', () => {
+ it('should return Cluster Monitoring options if located on Cluster Health Dashboard', () => {
+ document.body.dataset.page = 'groups:clusters:show';
+
+ expect(monitoringUtils.downloadCSVOptions(chartTitle)).toEqual({
+ category: 'Cluster Monitoring',
+ action: 'download_csv_of_cluster_metric_chart',
+ label: 'Chart title',
+ property: chartTitle,
+ });
+ });
+
+ it('should return Incident Management event options if located on Metrics Dashboard', () => {
+ document.body.dataset.page = 'metriss:show';
+
+ expect(monitoringUtils.downloadCSVOptions(chartTitle)).toEqual({
+ category: 'Incident Management::Embedded metrics',
+ action: 'download_csv_of_metrics_dashboard_chart',
+ label: 'Chart title',
+ property: chartTitle,
+ });
+ });
+ });
+});
diff --git a/spec/frontend/vue_shared/directives/track_event_spec.js b/spec/frontend/vue_shared/directives/track_event_spec.js
new file mode 100644
index 00000000000..d63f6ae05b4
--- /dev/null
+++ b/spec/frontend/vue_shared/directives/track_event_spec.js
@@ -0,0 +1,49 @@
+import Vue from 'vue';
+import { createLocalVue, shallowMount } from '@vue/test-utils';
+import Tracking from '~/tracking';
+import TrackEvent from '~/vue_shared/directives/track_event';
+
+jest.mock('~/tracking');
+
+const Component = Vue.component('dummy-element', {
+ directives: {
+ TrackEvent,
+ },
+ data() {
+ return {
+ trackingOptions: null,
+ };
+ },
+ template: '<button id="trackable" v-track-event="trackingOptions"></button>',
+});
+
+const localVue = createLocalVue();
+let wrapper;
+let button;
+
+describe('Error Tracking directive', () => {
+ beforeEach(() => {
+ wrapper = shallowMount(localVue.extend(Component), {
+ localVue,
+ });
+ button = wrapper.find('#trackable');
+ });
+
+ it('should not track the event if required arguments are not provided', () => {
+ button.trigger('click');
+ expect(Tracking.event).not.toHaveBeenCalled();
+ });
+
+ it('should track event on click if tracking info provided', () => {
+ const trackingOptions = {
+ category: 'Tracking',
+ action: 'click_trackable_btn',
+ label: 'Trackable Info',
+ };
+
+ wrapper.setData({ trackingOptions });
+ const { category, action, label, property, value } = trackingOptions;
+ button.trigger('click');
+ expect(Tracking.event).toHaveBeenCalledWith(category, action, { label, property, value });
+ });
+});
diff --git a/spec/lib/gitlab/gitaly_client/conflict_files_stitcher_spec.rb b/spec/lib/gitlab/gitaly_client/conflict_files_stitcher_spec.rb
index 1c933410bd5..a3602463756 100644
--- a/spec/lib/gitlab/gitaly_client/conflict_files_stitcher_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/conflict_files_stitcher_spec.rb
@@ -32,7 +32,7 @@ describe Gitlab::GitalyClient::ConflictFilesStitcher do
double(files: [double(header: nil, content: content_2[11..-1])])
]
- conflict_files = described_class.new(messages).to_a
+ conflict_files = described_class.new(messages, target_repository.gitaly_repository).to_a
expect(conflict_files.size).to be(2)
diff --git a/spec/lib/gitlab/tracking/incident_management_spec.rb b/spec/lib/gitlab/tracking/incident_management_spec.rb
new file mode 100644
index 00000000000..6f7e04b7c16
--- /dev/null
+++ b/spec/lib/gitlab/tracking/incident_management_spec.rb
@@ -0,0 +1,78 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::Tracking::IncidentManagement do
+ describe '.track_from_params' do
+ shared_examples 'a tracked event' do |label, value = nil|
+ it 'creates the tracking event with the correct details' do
+ expect(::Gitlab::Tracking)
+ .to receive(:event)
+ .with(
+ 'IncidentManagement::Settings',
+ label,
+ value || kind_of(Hash)
+ )
+ end
+ end
+
+ after do
+ described_class.track_from_params(params)
+ end
+
+ context 'known params' do
+ known_params = described_class.tracking_keys
+
+ known_params.each do |key, values|
+ context "param #{key}" do
+ let(:params) { { key => '1' } }
+
+ it_behaves_like 'a tracked event', "enabled_#{known_params[key][:name]}"
+ end
+ end
+
+ context 'different input values' do
+ shared_examples 'the correct prefixed event name' do |input, enabled|
+ let(:params) { { issue_template_key: input } }
+
+ it 'matches' do
+ expect(::Gitlab::Tracking)
+ .to receive(:event)
+ .with(
+ anything,
+ "#{enabled}_issue_template_on_alerts",
+ anything
+ )
+ end
+ end
+
+ it_behaves_like 'the correct prefixed event name', 1, 'enabled'
+ it_behaves_like 'the correct prefixed event name', '1', 'enabled'
+ it_behaves_like 'the correct prefixed event name', 'template', 'enabled'
+ it_behaves_like 'the correct prefixed event name', '', 'disabled'
+ it_behaves_like 'the correct prefixed event name', nil, 'disabled'
+ end
+
+ context 'param with label' do
+ let(:params) { { issue_template_key: '1' } }
+
+ it_behaves_like 'a tracked event', "enabled_issue_template_on_alerts", { label: 'Template name', property: '1' }
+ end
+
+ context 'param without label' do
+ let(:params) { { create_issue: '1' } }
+
+ it_behaves_like 'a tracked event', "enabled_issue_auto_creation_on_alerts", {}
+ end
+ end
+
+ context 'unknown params' do
+ let(:params) { { 'unknown' => '1' } }
+
+ it 'does not create the tracking event' do
+ expect(::Gitlab::Tracking)
+ .not_to receive(:event)
+ end
+ end
+ end
+end
diff --git a/spec/services/issues/zoom_link_service_spec.rb b/spec/services/issues/zoom_link_service_spec.rb
index 595d06d5331..ba3f007c917 100644
--- a/spec/services/issues/zoom_link_service_spec.rb
+++ b/spec/services/issues/zoom_link_service_spec.rb
@@ -51,6 +51,12 @@ describe Issues::ZoomLinkService do
expect(result.payload[:description])
.to eq("#{issue.description}\n\n#{zoom_link}")
end
+
+ it 'tracks the add event' do
+ expect(Gitlab::Tracking).to receive(:event)
+ .with('IncidentManagement::ZoomIntegration', 'add_zoom_meeting', label: 'Issue ID', value: issue.id)
+ result
+ end
end
shared_examples 'cannot add link' do
@@ -135,6 +141,13 @@ describe Issues::ZoomLinkService do
.to eq(issue.description.delete_suffix("\n\n#{zoom_link}"))
end
+ it 'tracks the remove event' do
+ expect(Gitlab::Tracking).to receive(:event)
+ .with('IncidentManagement::ZoomIntegration', 'remove_zoom_meeting', label: 'Issue ID', value: issue.id)
+
+ result
+ end
+
context 'with insufficient permissions' do
include_context 'insufficient permissions'
include_examples 'cannot remove link'