summaryrefslogtreecommitdiff
path: root/spec/frontend
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-18 00:07:45 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-18 00:07:45 +0000
commit7c077d960393e14b56d43cceaa7f609c703ac55f (patch)
treec3a5d79554b9be1d7434c8e9a8fcae35ab64af32 /spec/frontend
parentda35510cdad8f8d3cb6c119682dc2735531983cd (diff)
downloadgitlab-ce-7c077d960393e14b56d43cceaa7f609c703ac55f.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-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
4 files changed, 131 insertions, 0 deletions
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 });
+ });
+});