CE-backport track uninstall button clicks

This commit is contained in:
Enrique Alcantara 2019-05-01 08:56:23 -04:00
parent f98758753a
commit 3945e18176
3 changed files with 26 additions and 4 deletions

View file

@ -1,6 +1,7 @@
<script>
import { GlModal } from '@gitlab/ui';
import { sprintf, s__ } from '~/locale';
import trackUninstallButtonClickMixin from 'ee_else_ce/clusters/mixins/track_uninstall_button_click';
import { INGRESS, CERT_MANAGER, PROMETHEUS, RUNNER, KNATIVE, JUPYTER } from '../constants';
const CUSTOM_APP_WARNING_TEXT = {
@ -20,6 +21,7 @@ export default {
components: {
GlModal,
},
mixins: [trackUninstallButtonClickMixin],
props: {
application: {
type: String,
@ -51,6 +53,12 @@ export default {
return `uninstall-${this.application}`;
},
},
methods: {
confirmUninstall() {
this.trackUninstallButtonClick(this.application);
this.$emit('confirm');
},
},
};
</script>
<template>
@ -60,7 +68,7 @@ export default {
:ok-title="title"
:modal-id="modalId"
:title="title"
@ok="$emit('confirm')"
@ok="confirmUninstall()"
>{{ warningText }} {{ customAppWarningText }}</gl-modal
>
</template>

View file

@ -0,0 +1,5 @@
export default {
methods: {
trackUninstallButtonClick: () => {},
},
};

View file

@ -29,10 +29,19 @@ describe('UninstallApplicationConfirmationModal', () => {
expect(wrapper.find(GlModal).attributes('ok-title')).toEqual(`Uninstall ${appTitle}`);
});
it('triggers confirm event when ok button is clicked', () => {
wrapper.find(GlModal).vm.$emit('ok');
describe('when ok button is clicked', () => {
beforeEach(() => {
jest.spyOn(wrapper.vm, 'trackUninstallButtonClick');
wrapper.find(GlModal).vm.$emit('ok');
});
expect(wrapper.emitted('confirm')).toBeTruthy();
it('emits confirm event', () => {
expect(wrapper.emitted('confirm')).toBeTruthy();
});
it('calls track uninstall button click mixin', () => {
expect(wrapper.vm.trackUninstallButtonClick).toHaveBeenCalledWith(INGRESS);
});
});
it('displays a warning text indicating the app will be uninstalled', () => {