Commit ce04a2bb authored by Fernando's avatar Fernando

Rework license compliance tab unit tests

* Rework to use mount instead of shallow mount
to confirm content rendered correctly

Remove left over code
parent 11dd1bb1
import { shallowMount } from '@vue/test-utils'; import { shallowMount, mount } from '@vue/test-utils';
import Vue from 'vue'; import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import { GlEmptyState, GlLoadingIcon, GlTab, GlTabs, GlAlert } from '@gitlab/ui'; import { GlEmptyState, GlLoadingIcon, GlTab, GlTabs, GlAlert, GlBadge } from '@gitlab/ui';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import { REPORT_STATUS } from 'ee/license_compliance/store/modules/list/constants'; import { REPORT_STATUS } from 'ee/license_compliance/store/modules/list/constants';
...@@ -41,6 +41,15 @@ const createComponent = ({ state, props, options }) => { ...@@ -41,6 +41,15 @@ const createComponent = ({ state, props, options }) => {
state: { state: {
managedLicenses, managedLicenses,
}, },
getters: {
isAddingNewLicense: () => false,
hasPendingLicenses: () => false,
isLicenseBeingUpdated: () => () => false,
},
actions: {
fetchManagedLicenses: noop,
setLicenseApproval: noop,
},
}, },
licenseList: { licenseList: {
namespaced: true, namespaced: true,
...@@ -60,7 +69,9 @@ const createComponent = ({ state, props, options }) => { ...@@ -60,7 +69,9 @@ const createComponent = ({ state, props, options }) => {
}, },
}); });
wrapper = shallowMount(LicenseComplianceApp, { const mountFunc = options && options.mount ? mount : shallowMount;
wrapper = mountFunc(LicenseComplianceApp, {
propsData: { propsData: {
emptyStateSvgPath, emptyStateSvgPath,
documentationPath, documentationPath,
...@@ -153,9 +164,6 @@ describe('Project Licenses', () => { ...@@ -153,9 +164,6 @@ describe('Project Licenses', () => {
generatedAt: '', generatedAt: '',
status: REPORT_STATUS.ok, status: REPORT_STATUS.ok,
}, },
pageInfo: {
total: 24,
},
}, },
options: { options: {
provide: { provide: {
...@@ -179,14 +187,6 @@ describe('Project Licenses', () => { ...@@ -179,14 +187,6 @@ describe('Project Licenses', () => {
expect(wrapper.find(DetectedLicensesTable).exists()).toBe(true); expect(wrapper.find(DetectedLicensesTable).exists()).toBe(true);
}); });
it('it renders the correct count in "Detected in project" tab', () => {
expect(wrapper.vm.licenseCount).toBe(24);
});
it('it renders the correct count in "Policies" tab', () => {
expect(wrapper.vm.policyCount).toBe(2);
});
it('it renders the "Policies" table', () => { it('it renders the "Policies" table', () => {
expect(wrapper.find(LicenseManagement).exists()).toBe(true); expect(wrapper.find(LicenseManagement).exists()).toBe(true);
}); });
...@@ -195,6 +195,56 @@ describe('Project Licenses', () => { ...@@ -195,6 +195,56 @@ describe('Project Licenses', () => {
expect(wrapper.find(PipelineInfo).exists()).toBe(true); expect(wrapper.find(PipelineInfo).exists()).toBe(true);
}); });
describe('when the tabs are rendered', () => {
beforeEach(() => {
createComponent({
state: {
initialized: true,
isLoading: false,
licenses: [
{
name: 'MIT',
classification: LICENSE_APPROVAL_CLASSIFICATION.DENIED,
components: [],
},
],
reportInfo: {
jobPath: '/',
generatedAt: '',
status: REPORT_STATUS.ok,
},
pageInfo: {
total: 1,
},
},
options: {
provide: {
glFeatures: { licensePolicyList: true },
},
mount: true,
},
});
});
it('it renders the correct count in "Detected in project" tab', () => {
expect(
wrapper
.findAll(GlBadge)
.at(0)
.text(),
).toBe('1');
});
it('it renders the correct count in "Policies" tab', () => {
expect(
wrapper
.findAll(GlBadge)
.at(1)
.text(),
).toBe('2');
});
});
describe('when there are policy violations', () => { describe('when there are policy violations', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
......
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