Commit ec8e1aa7 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch 'xanf-fix-wrong-search' into 'master'

Fix tests which are failing in @vue/test-utils 1.x" due to search by name

See merge request gitlab-org/gitlab!40209
parents 8cc902d9 5aaa2296
...@@ -16,8 +16,7 @@ let wrapper; ...@@ -16,8 +16,7 @@ let wrapper;
const managedLicenses = [approvedLicense, blacklistedLicense]; const managedLicenses = [approvedLicense, blacklistedLicense];
const PaginatedListMock = { const PaginatedList = {
name: 'PaginatedList',
props: ['list'], props: ['list'],
template: ` template: `
<div> <div>
...@@ -64,7 +63,7 @@ const createComponent = ({ state, getters, props, actionMocks, isAdmin, options, ...@@ -64,7 +63,7 @@ const createComponent = ({ state, getters, props, actionMocks, isAdmin, options,
...props, ...props,
}, },
stubs: { stubs: {
PaginatedList: PaginatedListMock, PaginatedList,
}, },
provide: { provide: {
glFeatures: { licenseComplianceDeniesMr: false }, glFeatures: { licenseComplianceDeniesMr: false },
...@@ -98,7 +97,7 @@ describe('License Management', () => { ...@@ -98,7 +97,7 @@ describe('License Management', () => {
getters: { hasPendingLicenses: () => true }, getters: { hasPendingLicenses: () => true },
isAdmin, isAdmin,
}); });
expect(wrapper.find({ name: 'PaginatedList' }).props('list')).toBe(managedLicenses); expect(wrapper.find(PaginatedList).props('list')).toBe(managedLicenses);
}); });
describe('when not loading', () => { describe('when not loading', () => {
...@@ -107,7 +106,7 @@ describe('License Management', () => { ...@@ -107,7 +106,7 @@ describe('License Management', () => {
}); });
it('should render list of managed licenses', () => { it('should render list of managed licenses', () => {
expect(wrapper.find({ name: 'PaginatedList' }).props('list')).toBe(managedLicenses); expect(wrapper.find(PaginatedList).props('list')).toBe(managedLicenses);
}); });
}); });
......
...@@ -3,15 +3,13 @@ import waitForPromises from 'helpers/wait_for_promises'; ...@@ -3,15 +3,13 @@ import waitForPromises from 'helpers/wait_for_promises';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import axios from 'axios'; import axios from 'axios';
import AlertMetrics from '~/alert_management/components/alert_metrics.vue'; import AlertMetrics from '~/alert_management/components/alert_metrics.vue';
import MetricEmbed from '~/monitoring/components/embeds/metric_embed.vue';
jest.mock('~/monitoring/stores', () => ({ jest.mock('~/monitoring/stores', () => ({
monitoringDashboard: {}, monitoringDashboard: {},
})); }));
const mockEmbedName = 'MetricsEmbedStub';
jest.mock('~/monitoring/components/embeds/metric_embed.vue', () => ({ jest.mock('~/monitoring/components/embeds/metric_embed.vue', () => ({
name: mockEmbedName,
render(h) { render(h) {
return h('div'); return h('div');
}, },
...@@ -26,13 +24,10 @@ describe('Alert Metrics', () => { ...@@ -26,13 +24,10 @@ describe('Alert Metrics', () => {
propsData: { propsData: {
...props, ...props,
}, },
stubs: {
MetricEmbed: true,
},
}); });
} }
const findChart = () => wrapper.find({ name: mockEmbedName }); const findChart = () => wrapper.find(MetricEmbed);
const findEmptyState = () => wrapper.find({ ref: 'emptyState' }); const findEmptyState = () => wrapper.find({ ref: 'emptyState' });
afterEach(() => { afterEach(() => {
......
...@@ -39,13 +39,22 @@ describe('EnvironmentLogs', () => { ...@@ -39,13 +39,22 @@ describe('EnvironmentLogs', () => {
}; };
const updateControlBtnsMock = jest.fn(); const updateControlBtnsMock = jest.fn();
const LogControlButtonsStub = {
template: '<div/>',
methods: {
update: updateControlBtnsMock,
},
props: {
scrollDownButtonDisabled: false,
},
};
const findEnvironmentsDropdown = () => wrapper.find('.js-environments-dropdown'); const findEnvironmentsDropdown = () => wrapper.find('.js-environments-dropdown');
const findSimpleFilters = () => wrapper.find({ ref: 'log-simple-filters' }); const findSimpleFilters = () => wrapper.find({ ref: 'log-simple-filters' });
const findAdvancedFilters = () => wrapper.find({ ref: 'log-advanced-filters' }); const findAdvancedFilters = () => wrapper.find({ ref: 'log-advanced-filters' });
const findElasticsearchNotice = () => wrapper.find({ ref: 'elasticsearchNotice' }); const findElasticsearchNotice = () => wrapper.find({ ref: 'elasticsearchNotice' });
const findLogControlButtons = () => wrapper.find({ name: 'log-control-buttons-stub' }); const findLogControlButtons = () => wrapper.find(LogControlButtonsStub);
const findInfiniteScroll = () => wrapper.find({ ref: 'infiniteScroll' }); const findInfiniteScroll = () => wrapper.find({ ref: 'infiniteScroll' });
const findLogTrace = () => wrapper.find({ ref: 'logTrace' }); const findLogTrace = () => wrapper.find({ ref: 'logTrace' });
...@@ -76,16 +85,7 @@ describe('EnvironmentLogs', () => { ...@@ -76,16 +85,7 @@ describe('EnvironmentLogs', () => {
propsData, propsData,
store, store,
stubs: { stubs: {
LogControlButtons: { LogControlButtons: LogControlButtonsStub,
name: 'log-control-buttons-stub',
template: '<div/>',
methods: {
update: updateControlBtnsMock,
},
props: {
scrollDownButtonDisabled: false,
},
},
GlInfiniteScroll: { GlInfiniteScroll: {
name: 'gl-infinite-scroll', name: 'gl-infinite-scroll',
template: ` template: `
......
import Vuex from 'vuex'; import Vuex from 'vuex';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import { GlIcon } from '@gitlab/ui';
import notesModule from '~/notes/stores/modules'; import notesModule from '~/notes/stores/modules';
import DiscussionCounter from '~/notes/components/discussion_counter.vue'; import DiscussionCounter from '~/notes/components/discussion_counter.vue';
import { noteableDataMock, discussionMock, notesDataMock, userDataMock } from '../mock_data'; import { noteableDataMock, discussionMock, notesDataMock, userDataMock } from '../mock_data';
...@@ -112,13 +113,13 @@ describe('DiscussionCounter component', () => { ...@@ -112,13 +113,13 @@ describe('DiscussionCounter component', () => {
updateStoreWithExpanded(true); updateStoreWithExpanded(true);
expect(wrapper.vm.allExpanded).toBe(true); expect(wrapper.vm.allExpanded).toBe(true);
expect(toggleAllButton.find({ name: 'angle-up' }).exists()).toBe(true); expect(toggleAllButton.find(GlIcon).props().name).toBe('angle-up');
toggleAllButton.trigger('click'); toggleAllButton.trigger('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.vm.allExpanded).toBe(false); expect(wrapper.vm.allExpanded).toBe(false);
expect(toggleAllButton.find({ name: 'angle-down' }).exists()).toBe(true); expect(toggleAllButton.find(GlIcon).props().name).toBe('angle-down');
}); });
}); });
...@@ -126,13 +127,13 @@ describe('DiscussionCounter component', () => { ...@@ -126,13 +127,13 @@ describe('DiscussionCounter component', () => {
updateStoreWithExpanded(false); updateStoreWithExpanded(false);
expect(wrapper.vm.allExpanded).toBe(false); expect(wrapper.vm.allExpanded).toBe(false);
expect(toggleAllButton.find({ name: 'angle-down' }).exists()).toBe(true); expect(toggleAllButton.find(GlIcon).props().name).toBe('angle-down');
toggleAllButton.trigger('click'); toggleAllButton.trigger('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.vm.allExpanded).toBe(true); expect(wrapper.vm.allExpanded).toBe(true);
expect(toggleAllButton.find({ name: 'angle-up' }).exists()).toBe(true); expect(toggleAllButton.find(GlIcon).props().name).toBe('angle-up');
}); });
}); });
}); });
......
...@@ -23,7 +23,7 @@ describe('packages_list', () => { ...@@ -23,7 +23,7 @@ describe('packages_list', () => {
const findPackagesListLoader = () => wrapper.find(PackagesListLoader); const findPackagesListLoader = () => wrapper.find(PackagesListLoader);
const findPackageListPagination = () => wrapper.find(GlPagination); const findPackageListPagination = () => wrapper.find(GlPagination);
const findPackageListDeleteModal = () => wrapper.find(GlModal); const findPackageListDeleteModal = () => wrapper.find(GlModal);
const findEmptySlot = () => wrapper.find({ name: 'empty-slot-stub' }); const findEmptySlot = () => wrapper.find(EmptySlotStub);
const findPackagesListRow = () => wrapper.find(PackagesListRow); const findPackagesListRow = () => wrapper.find(PackagesListRow);
const createStore = (isGroupPage, packages, isLoading) => { const createStore = (isGroupPage, packages, isLoading) => {
......
...@@ -27,14 +27,14 @@ describe('Project Feature Settings', () => { ...@@ -27,14 +27,14 @@ describe('Project Feature Settings', () => {
describe('Hidden name input', () => { describe('Hidden name input', () => {
it('should set the hidden name input if the name exists', () => { it('should set the hidden name input if the name exists', () => {
expect(wrapper.find({ name: 'Test' }).props().value).toBe(1); expect(wrapper.find(`input[name=${defaultProps.name}]`).attributes().value).toBe('1');
}); });
it('should not set the hidden name input if the name does not exist', () => { it('should not set the hidden name input if the name does not exist', () => {
wrapper.setProps({ name: null }); wrapper.setProps({ name: null });
return wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.find({ name: 'Test' }).exists()).toBe(false); expect(wrapper.find(`input[name=${defaultProps.name}]`).exists()).toBe(false);
}); });
}); });
}); });
......
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