Commit 76dcf498 authored by Fernando's avatar Fernando

Incorporate unit test feedback

* Use feature flag mixin
parent 4a7242fb
<script>
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { GlDeprecatedButton } from '@gitlab/ui';
import LoadingButton from '~/vue_shared/components/loading_button.vue';
import { LICENSE_APPROVAL_STATUS } from '../constants';
......@@ -12,6 +13,7 @@ export default {
GlDeprecatedButton,
LoadingButton,
},
mixins: [glFeatureFlagsMixin()],
LICENSE_APPROVAL_STATUS,
approvalStatusOptions: [
{
......@@ -53,7 +55,7 @@ export default {
return this.isInvalidLicense || this.licenseName.trim() === '' || this.approvalStatus === '';
},
isDescriptionEnabled() {
return gon.features.licenseComplianceDeniesMr;
return Boolean(this.glFeatures.licenseComplianceDeniesMr);
},
},
methods: {
......@@ -98,6 +100,7 @@ export default {
type="radio"
:data-qa-selector="`${option.value}_license_radio`"
:value="option.value"
:aria-describedby="`js-${option.value}-license-radio`"
/>
<label :for="`js-${option.value}-license-radio`" class="form-check-label pt-1">
{{ option.label }}
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`AddLicenseForm template does not show dropdown descriptions, if licenseComplianceDeniesMr feature flag is disabled 1`] = `undefined`;
import Vue from 'vue';
import { shallowMount } from '@vue/test-utils';
import LicenseIssueBody from 'ee/vue_shared/license_compliance/components/add_license_form.vue';
import mountComponent from 'helpers/vue_mount_component_helper';
import { LICENSE_APPROVAL_STATUS } from 'ee/vue_shared/license_compliance/constants';
......@@ -11,7 +12,6 @@ describe('AddLicenseForm', () => {
const findCancelButton = () => vm.$el.querySelector('.js-cancel');
beforeEach(() => {
window.gon = { features: { licenseComplianceDeniesMr: false } };
vm = mountComponent(Component);
});
......@@ -123,18 +123,22 @@ describe('AddLicenseForm', () => {
});
it('shows dropdown descriptions, if licenseComplianceDeniesMr feature flag is enabled', done => {
window.gon = { features: { licenseComplianceDeniesMr: true } };
vm = mountComponent(Component, { managedLicenses: [{ name: 'FOO' }] });
vm.licenseName = 'FOO';
const wrapper = shallowMount(LicenseIssueBody, {
propsData: {
managedLicenses: [{ name: 'FOO' }],
},
provide: {
glFeatures: { licenseComplianceDeniesMr: true },
},
});
Vue.nextTick(() => {
const feedbackElement = vm.$el.querySelectorAll('.text-secondary');
const formCheckElementMargin = vm.$el.querySelector('.form-check.mb-3');
const descriptionElement = wrapper.findAll('.text-secondary');
const formCheckElementMargin = wrapper.find('.form-check');
expect(feedbackElement[0].innerText.trim()).toBe(
'Acceptable license to be used in the project',
);
expect(descriptionElement.at(0).text()).toBe('Acceptable license to be used in the project');
expect(feedbackElement[1].innerText.trim()).toBe(
expect(descriptionElement.at(1).text()).toBe(
'Disallow merge request if detected and will instruct developer to remove',
);
......@@ -148,11 +152,9 @@ describe('AddLicenseForm', () => {
vm = mountComponent(Component, { managedLicenses: [{ name: 'FOO' }] });
vm.licenseName = 'FOO';
Vue.nextTick(() => {
const feedbackElement = vm.$el.querySelectorAll('.text-secondary');
const formCheckElementMargin = vm.$el.querySelector('.form-check.mb-3');
const formCheckElement = vm.$el.querySelector('.form-check');
expect(feedbackElement.length).toBe(0);
expect(formCheckElementMargin).toBeNull();
expect(formCheckElement.element).toMatchSnapshot();
done();
});
});
......
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