Commit d83c5120 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent a72a9af0
...@@ -177,7 +177,7 @@ module Banzai ...@@ -177,7 +177,7 @@ module Banzai
collection.where(id: to_query).each { |row| cache[row.id] = row } collection.where(id: to_query).each { |row| cache[row.id] = row }
end end
cache.values_at(*ids).compact ids.uniq.map { |id| cache[id] }.compact
else else
collection.where(id: ids) collection.where(id: ids)
end end
......
...@@ -216,6 +216,8 @@ describe('ClusterFormDropdown', () => { ...@@ -216,6 +216,8 @@ describe('ClusterFormDropdown', () => {
$(dropdownEl).trigger('shown.bs.dropdown'); $(dropdownEl).trigger('shown.bs.dropdown');
expect(vm.find(DropdownSearchInput).props('focused')).toBe(true); return vm.vm.$nextTick(() => {
expect(vm.find(DropdownSearchInput).props('focused')).toBe(true);
});
}); });
}); });
...@@ -197,7 +197,9 @@ describe('EksClusterConfigurationForm', () => { ...@@ -197,7 +197,9 @@ describe('EksClusterConfigurationForm', () => {
it('sets RoleDropdown hasErrors to true when loading roles failed', () => { it('sets RoleDropdown hasErrors to true when loading roles failed', () => {
rolesState.loadingItemsError = new Error(); rolesState.loadingItemsError = new Error();
expect(findRoleDropdown().props('hasErrors')).toEqual(true); return Vue.nextTick().then(() => {
expect(findRoleDropdown().props('hasErrors')).toEqual(true);
});
}); });
it('sets isLoadingRegions to RegionDropdown loading property', () => { it('sets isLoadingRegions to RegionDropdown loading property', () => {
...@@ -215,7 +217,9 @@ describe('EksClusterConfigurationForm', () => { ...@@ -215,7 +217,9 @@ describe('EksClusterConfigurationForm', () => {
it('sets loadingRegionsError to RegionDropdown error property', () => { it('sets loadingRegionsError to RegionDropdown error property', () => {
regionsState.loadingItemsError = new Error(); regionsState.loadingItemsError = new Error();
expect(findRegionDropdown().props('hasErrors')).toEqual(true); return Vue.nextTick().then(() => {
expect(findRegionDropdown().props('hasErrors')).toEqual(true);
});
}); });
it('disables KeyPairDropdown when no region is selected', () => { it('disables KeyPairDropdown when no region is selected', () => {
...@@ -245,7 +249,9 @@ describe('EksClusterConfigurationForm', () => { ...@@ -245,7 +249,9 @@ describe('EksClusterConfigurationForm', () => {
it('sets KeyPairDropdown hasErrors to true when loading key pairs fails', () => { it('sets KeyPairDropdown hasErrors to true when loading key pairs fails', () => {
keyPairsState.loadingItemsError = new Error(); keyPairsState.loadingItemsError = new Error();
expect(findKeyPairDropdown().props('hasErrors')).toEqual(true); return Vue.nextTick().then(() => {
expect(findKeyPairDropdown().props('hasErrors')).toEqual(true);
});
}); });
it('disables VpcDropdown when no region is selected', () => { it('disables VpcDropdown when no region is selected', () => {
...@@ -275,7 +281,9 @@ describe('EksClusterConfigurationForm', () => { ...@@ -275,7 +281,9 @@ describe('EksClusterConfigurationForm', () => {
it('sets VpcDropdown hasErrors to true when loading vpcs fails', () => { it('sets VpcDropdown hasErrors to true when loading vpcs fails', () => {
vpcsState.loadingItemsError = new Error(); vpcsState.loadingItemsError = new Error();
expect(findVpcDropdown().props('hasErrors')).toEqual(true); return Vue.nextTick().then(() => {
expect(findVpcDropdown().props('hasErrors')).toEqual(true);
});
}); });
it('disables SubnetDropdown when no vpc is selected', () => { it('disables SubnetDropdown when no vpc is selected', () => {
...@@ -305,7 +313,9 @@ describe('EksClusterConfigurationForm', () => { ...@@ -305,7 +313,9 @@ describe('EksClusterConfigurationForm', () => {
it('sets SubnetDropdown hasErrors to true when loading subnets fails', () => { it('sets SubnetDropdown hasErrors to true when loading subnets fails', () => {
subnetsState.loadingItemsError = new Error(); subnetsState.loadingItemsError = new Error();
expect(findSubnetDropdown().props('hasErrors')).toEqual(true); return Vue.nextTick().then(() => {
expect(findSubnetDropdown().props('hasErrors')).toEqual(true);
});
}); });
it('disables SecurityGroupDropdown when no vpc is selected', () => { it('disables SecurityGroupDropdown when no vpc is selected', () => {
...@@ -335,7 +345,9 @@ describe('EksClusterConfigurationForm', () => { ...@@ -335,7 +345,9 @@ describe('EksClusterConfigurationForm', () => {
it('sets SecurityGroupDropdown hasErrors to true when loading security groups fails', () => { it('sets SecurityGroupDropdown hasErrors to true when loading security groups fails', () => {
securityGroupsState.loadingItemsError = new Error(); securityGroupsState.loadingItemsError = new Error();
expect(findSecurityGroupDropdown().props('hasErrors')).toEqual(true); return Vue.nextTick().then(() => {
expect(findSecurityGroupDropdown().props('hasErrors')).toEqual(true);
});
}); });
describe('when region is selected', () => { describe('when region is selected', () => {
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Icon from '~/vue_shared/components/icon.vue';
import DiffStats from '~/diffs/components/diff_stats.vue'; import DiffStats from '~/diffs/components/diff_stats.vue';
describe('diff_stats', () => { describe('diff_stats', () => {
...@@ -22,9 +23,16 @@ describe('diff_stats', () => { ...@@ -22,9 +23,16 @@ describe('diff_stats', () => {
diffFilesLength: 300, diffFilesLength: 300,
}, },
}); });
const additions = wrapper.find('icon-stub[name="file-addition"]').element.parentNode;
const deletions = wrapper.find('icon-stub[name="file-deletion"]').element.parentNode; const findIcon = name =>
const filesChanged = wrapper.find('icon-stub[name="doc-code"]').element.parentNode; wrapper
.findAll(Icon)
.filter(c => c.attributes('name') === name)
.at(0).element.parentNode;
const additions = findIcon('file-addition');
const deletions = findIcon('file-deletion');
const filesChanged = findIcon('doc-code');
expect(additions.textContent).toContain('100'); expect(additions.textContent).toContain('100');
expect(deletions.textContent).toContain('200'); expect(deletions.textContent).toContain('200');
......
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import { GlLoadingIcon, GlLink, GlBadge } from '@gitlab/ui'; import { GlLoadingIcon, GlLink, GlBadge, GlFormInput } from '@gitlab/ui';
import LoadingButton from '~/vue_shared/components/loading_button.vue'; import LoadingButton from '~/vue_shared/components/loading_button.vue';
import Stacktrace from '~/error_tracking/components/stacktrace.vue'; import Stacktrace from '~/error_tracking/components/stacktrace.vue';
import ErrorDetails from '~/error_tracking/components/error_details.vue'; import ErrorDetails from '~/error_tracking/components/error_details.vue';
...@@ -14,6 +14,11 @@ describe('ErrorDetails', () => { ...@@ -14,6 +14,11 @@ describe('ErrorDetails', () => {
let actions; let actions;
let getters; let getters;
const findInput = name => {
const inputs = wrapper.findAll(GlFormInput).filter(c => c.attributes('name') === name);
return inputs.length ? inputs.at(0) : inputs;
};
function mountComponent() { function mountComponent() {
wrapper = shallowMount(ErrorDetails, { wrapper = shallowMount(ErrorDetails, {
stubs: { LoadingButton }, stubs: { LoadingButton },
...@@ -136,15 +141,15 @@ describe('ErrorDetails', () => { ...@@ -136,15 +141,15 @@ describe('ErrorDetails', () => {
}); });
it('should send sentry_issue_identifier', () => { it('should send sentry_issue_identifier', () => {
const sentryErrorIdInput = wrapper.find( const sentryErrorIdInput = findInput(
'glforminput-stub[name="issue[sentry_issue_attributes][sentry_issue_identifier]"', 'issue[sentry_issue_attributes][sentry_issue_identifier]',
); );
expect(sentryErrorIdInput.attributes('value')).toBe('129381'); expect(sentryErrorIdInput.attributes('value')).toBe('129381');
}); });
it('should set the form values with title and description', () => { it('should set the form values with title and description', () => {
const csrfTokenInput = wrapper.find('glforminput-stub[name="authenticity_token"]'); const csrfTokenInput = findInput('authenticity_token');
const issueTitleInput = wrapper.find('glforminput-stub[name="issue[title]"]'); const issueTitleInput = findInput('issue[title]');
const issueDescriptionInput = wrapper.find('input[name="issue[description]"]'); const issueDescriptionInput = wrapper.find('input[name="issue[description]"]');
expect(csrfTokenInput.attributes('value')).toBe('fakeToken'); expect(csrfTokenInput.attributes('value')).toBe('fakeToken');
expect(issueTitleInput.attributes('value')).toContain(wrapper.vm.issueTitle); expect(issueTitleInput.attributes('value')).toContain(wrapper.vm.issueTitle);
......
...@@ -57,7 +57,9 @@ describe('error tracking settings app', () => { ...@@ -57,7 +57,9 @@ describe('error tracking settings app', () => {
it('disables the button when saving', () => { it('disables the button when saving', () => {
store.state.settingsLoading = true; store.state.settingsLoading = true;
expect(wrapper.find('.js-error-tracking-button').attributes('disabled')).toBeTruthy(); return wrapper.vm.$nextTick(() => {
expect(wrapper.find('.js-error-tracking-button').attributes('disabled')).toBeTruthy();
});
}); });
}); });
}); });
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import MRPopover from '~/mr_popover/components/mr_popover'; import MRPopover from '~/mr_popover/components/mr_popover';
import CiIcon from '~/vue_shared/components/ci_icon.vue';
describe('MR Popover', () => { describe('MR Popover', () => {
let wrapper; let wrapper;
...@@ -23,7 +24,9 @@ describe('MR Popover', () => { ...@@ -23,7 +24,9 @@ describe('MR Popover', () => {
it('shows skeleton-loader while apollo is loading', () => { it('shows skeleton-loader while apollo is loading', () => {
wrapper.vm.$apollo.loading = true; wrapper.vm.$apollo.loading = true;
expect(wrapper.element).toMatchSnapshot(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.element).toMatchSnapshot();
});
}); });
describe('loaded state', () => { describe('loaded state', () => {
...@@ -58,7 +61,7 @@ describe('MR Popover', () => { ...@@ -58,7 +61,7 @@ describe('MR Popover', () => {
}); });
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.contains('ciicon-stub')).toBe(false); expect(wrapper.contains(CiIcon)).toBe(false);
}); });
}); });
}); });
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { STATUS_SUCCESS } from '~/reports/constants'; import { STATUS_SUCCESS } from '~/reports/constants';
import ReportItem from '~/reports/components/report_item.vue'; import ReportItem from '~/reports/components/report_item.vue';
import IssueStatusIcon from '~/reports/components/issue_status_icon.vue';
import { componentNames } from '~/reports/components/issue_body'; import { componentNames } from '~/reports/components/issue_body';
describe('ReportItem', () => { describe('ReportItem', () => {
...@@ -15,7 +16,7 @@ describe('ReportItem', () => { ...@@ -15,7 +16,7 @@ describe('ReportItem', () => {
}, },
}); });
expect(wrapper.find('issuestatusicon-stub').exists()).toBe(false); expect(wrapper.find(IssueStatusIcon).exists()).toBe(false);
}); });
it('shows status icon when unspecified', () => { it('shows status icon when unspecified', () => {
...@@ -27,7 +28,7 @@ describe('ReportItem', () => { ...@@ -27,7 +28,7 @@ describe('ReportItem', () => {
}, },
}); });
expect(wrapper.find('issuestatusicon-stub').exists()).toBe(true); expect(wrapper.find(IssueStatusIcon).exists()).toBe(true);
}); });
}); });
}); });
...@@ -66,39 +66,51 @@ describe('Repository last commit component', () => { ...@@ -66,39 +66,51 @@ describe('Repository last commit component', () => {
it('renders commit widget', () => { it('renders commit widget', () => {
factory(); factory();
expect(vm.element).toMatchSnapshot(); return vm.vm.$nextTick(() => {
expect(vm.element).toMatchSnapshot();
});
}); });
it('renders short commit ID', () => { it('renders short commit ID', () => {
factory(); factory();
expect(vm.find('.label-monospace').text()).toEqual('12345678'); return vm.vm.$nextTick(() => {
expect(vm.find('.label-monospace').text()).toEqual('12345678');
});
}); });
it('hides pipeline components when pipeline does not exist', () => { it('hides pipeline components when pipeline does not exist', () => {
factory(createCommitData({ pipeline: null })); factory(createCommitData({ pipeline: null }));
expect(vm.find('.js-commit-pipeline').exists()).toBe(false); return vm.vm.$nextTick(() => {
expect(vm.find('.js-commit-pipeline').exists()).toBe(false);
});
}); });
it('renders pipeline components', () => { it('renders pipeline components', () => {
factory(); factory();
expect(vm.find('.js-commit-pipeline').exists()).toBe(true); return vm.vm.$nextTick(() => {
expect(vm.find('.js-commit-pipeline').exists()).toBe(true);
});
}); });
it('hides author component when author does not exist', () => { it('hides author component when author does not exist', () => {
factory(createCommitData({ author: null })); factory(createCommitData({ author: null }));
expect(vm.find('.js-user-link').exists()).toBe(false); return vm.vm.$nextTick(() => {
expect(vm.find(UserAvatarLink).exists()).toBe(false); expect(vm.find('.js-user-link').exists()).toBe(false);
expect(vm.find(UserAvatarLink).exists()).toBe(false);
});
}); });
it('does not render description expander when description is null', () => { it('does not render description expander when description is null', () => {
factory(createCommitData({ description: null })); factory(createCommitData({ description: null }));
expect(vm.find('.text-expander').exists()).toBe(false); return vm.vm.$nextTick(() => {
expect(vm.find('.commit-row-description').exists()).toBe(false); expect(vm.find('.text-expander').exists()).toBe(false);
expect(vm.find('.commit-row-description').exists()).toBe(false);
});
}); });
it('expands commit description when clicking expander', () => { it('expands commit description when clicking expander', () => {
...@@ -113,6 +125,8 @@ describe('Repository last commit component', () => { ...@@ -113,6 +125,8 @@ describe('Repository last commit component', () => {
it('renders the signature HTML as returned by the backend', () => { it('renders the signature HTML as returned by the backend', () => {
factory(createCommitData({ signatureHtml: '<button>Verified</button>' })); factory(createCommitData({ signatureHtml: '<button>Verified</button>' }));
expect(vm.element).toMatchSnapshot(); return vm.vm.$nextTick().then(() => {
expect(vm.element).toMatchSnapshot();
});
}); });
}); });
...@@ -7,6 +7,11 @@ describe('Commit component', () => { ...@@ -7,6 +7,11 @@ describe('Commit component', () => {
let props; let props;
let wrapper; let wrapper;
const findIcon = name => {
const icons = wrapper.findAll(Icon).filter(c => c.attributes('name') === name);
return icons.length ? icons.at(0) : icons;
};
const findUserAvatar = () => wrapper.find(UserAvatarLink); const findUserAvatar = () => wrapper.find(UserAvatarLink);
const createComponent = propsData => { const createComponent = propsData => {
...@@ -71,7 +76,7 @@ describe('Commit component', () => { ...@@ -71,7 +76,7 @@ describe('Commit component', () => {
}); });
it('should render a tag icon if it represents a tag', () => { it('should render a tag icon if it represents a tag', () => {
expect(wrapper.find('icon-stub[name="tag"]').exists()).toBe(true); expect(findIcon('tag').exists()).toBe(true);
}); });
it('should render a link to the ref url', () => { it('should render a link to the ref url', () => {
...@@ -89,7 +94,7 @@ describe('Commit component', () => { ...@@ -89,7 +94,7 @@ describe('Commit component', () => {
}); });
it('should render icon for commit', () => { it('should render icon for commit', () => {
expect(wrapper.find('icon-stub[name="commit"]').exists()).toBe(true); expect(findIcon('commit').exists()).toBe(true);
}); });
describe('Given commit title and author props', () => { describe('Given commit title and author props', () => {
...@@ -162,7 +167,7 @@ describe('Commit component', () => { ...@@ -162,7 +167,7 @@ describe('Commit component', () => {
expect(refEl.attributes('title')).toBe(props.commitRef.name); expect(refEl.attributes('title')).toBe(props.commitRef.name);
expect(wrapper.find('icon-stub[name="branch"]').exists()).toBe(true); expect(findIcon('branch').exists()).toBe(true);
}); });
}); });
...@@ -195,7 +200,7 @@ describe('Commit component', () => { ...@@ -195,7 +200,7 @@ describe('Commit component', () => {
expect(refEl.attributes('title')).toBe(props.mergeRequestRef.title); expect(refEl.attributes('title')).toBe(props.mergeRequestRef.title);
expect(wrapper.find('icon-stub[name="git-merge"]').exists()).toBe(true); expect(findIcon('git-merge').exists()).toBe(true);
}); });
}); });
......
...@@ -49,7 +49,9 @@ describe('DropdownSearchInputComponent', () => { ...@@ -49,7 +49,9 @@ describe('DropdownSearchInputComponent', () => {
wrapper.setProps({ focused: true }); wrapper.setProps({ focused: true });
expect(inputEl.focus).toHaveBeenCalled(); return wrapper.vm.$nextTick().then(() => {
expect(inputEl.focus).toHaveBeenCalled();
});
}); });
}); });
}); });
...@@ -147,9 +147,12 @@ describe('UserAvatarList', () => { ...@@ -147,9 +147,12 @@ describe('UserAvatarList', () => {
it('with collapse clicked, it renders avatars up to breakpoint', () => { it('with collapse clicked, it renders avatars up to breakpoint', () => {
clickButton(); clickButton();
const links = wrapper.findAll(UserAvatarLink);
expect(links.length).toEqual(TEST_BREAKPOINT); return wrapper.vm.$nextTick(() => {
const links = wrapper.findAll(UserAvatarLink);
expect(links.length).toEqual(TEST_BREAKPOINT);
});
}); });
}); });
}); });
......
...@@ -312,6 +312,12 @@ describe Banzai::ReferenceParser::BaseParser do ...@@ -312,6 +312,12 @@ describe Banzai::ReferenceParser::BaseParser do
expect(subject.collection_objects_for_ids(Project, [project.id])) expect(subject.collection_objects_for_ids(Project, [project.id]))
.to eq([project]) .to eq([project])
end end
it 'will not overflow the stack' do
ids = 1.upto(1_000_000).to_a
expect { subject.collection_objects_for_ids(User, ids) }.not_to raise_error
end
end end
end end
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
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