Commit 6471188f authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'xanf-vtu-30-sync' into 'master'

Fix tests failing in async mode

Closes #193491

See merge request gitlab-org/gitlab!22361
parents 62052283 6f761edc
...@@ -70,10 +70,11 @@ describe('Design management router', () => { ...@@ -70,10 +70,11 @@ describe('Design management router', () => {
it('pushes designs detail component', () => { it('pushes designs detail component', () => {
router.push('/designs/1'); router.push('/designs/1');
const detail = vm.find(DesignDetail); return vm.vm.$nextTick().then(() => {
const detail = vm.find(DesignDetail);
expect(detail.exists()).toBe(true); expect(detail.exists()).toBe(true);
expect(detail.props('id')).toEqual('1'); expect(detail.props('id')).toEqual('1');
});
}); });
}); });
}); });
...@@ -144,7 +144,10 @@ describe('dashboard', () => { ...@@ -144,7 +144,10 @@ describe('dashboard', () => {
it('should get the page info from the state', () => { it('should get the page info from the state', () => {
store.state.pageInfo = { totalResults: 100 }; store.state.pageInfo = { totalResults: 100 };
expect(wrapper.find(ProjectSelector).props('totalResults')).toBe(100);
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(ProjectSelector).props('totalResults')).toBe(100);
});
}); });
}); });
}); });
......
...@@ -95,8 +95,10 @@ describe('MavenInstallation', () => { ...@@ -95,8 +95,10 @@ describe('MavenInstallation', () => {
it('should track when the setup tab is clicked', () => { it('should track when the setup tab is clicked', () => {
setupTab().trigger('click'); setupTab().trigger('click');
expect(eventSpy).toHaveBeenCalledWith(undefined, TrackingActions.REGISTRY_SETUP, { return wrapper.vm.$nextTick(() => {
label, expect(eventSpy).toHaveBeenCalledWith(undefined, TrackingActions.REGISTRY_SETUP, {
label,
});
}); });
}); });
......
...@@ -90,8 +90,10 @@ describe('NpmInstallation', () => { ...@@ -90,8 +90,10 @@ describe('NpmInstallation', () => {
it('should track when the setup tab is clicked', () => { it('should track when the setup tab is clicked', () => {
setupTab().trigger('click'); setupTab().trigger('click');
expect(eventSpy).toHaveBeenCalledWith(undefined, TrackingActions.REGISTRY_SETUP, { return wrapper.vm.$nextTick().then(() => {
label, expect(eventSpy).toHaveBeenCalledWith(undefined, TrackingActions.REGISTRY_SETUP, {
label,
});
}); });
}); });
......
...@@ -90,14 +90,18 @@ describe('blocking mr input root', () => { ...@@ -90,14 +90,18 @@ describe('blocking mr input root', () => {
createComponent({ existingRefs: ['!1'] }); createComponent({ existingRefs: ['!1'] });
removeRef(0); removeRef(0);
expectShouldUpdateRefsToBe(true); return wrapper.vm.$nextTick().then(() => {
expectShouldUpdateRefsToBe(true);
});
}); });
it('is true after a ref is added', () => { it('is true after a ref is added', () => {
createComponent(); createComponent();
addTokenizedInput('foo'); addTokenizedInput('foo');
expectShouldUpdateRefsToBe(true); return wrapper.vm.$nextTick(() => {
expectShouldUpdateRefsToBe(true);
});
}); });
}); });
...@@ -129,7 +133,9 @@ describe('blocking mr input root', () => { ...@@ -129,7 +133,9 @@ describe('blocking mr input root', () => {
makeComponentWithHiddenMrs(); makeComponentWithHiddenMrs();
removeRef(2); removeRef(2);
expectRemoveHiddenBlockingMergeRequestsToBe(true); return wrapper.vm.$nextTick().then(() => {
expectRemoveHiddenBlockingMergeRequestsToBe(true);
});
}); });
}); });
}); });
......
...@@ -56,7 +56,9 @@ describe('EpicsSelect', () => { ...@@ -56,7 +56,9 @@ describe('EpicsSelect', () => {
issueId: 123, issueId: 123,
}); });
expect(wrapper.vm.$store.state.issueId).toBe(123); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.vm.$store.state.issueId).toBe(123);
});
}); });
}); });
...@@ -66,7 +68,9 @@ describe('EpicsSelect', () => { ...@@ -66,7 +68,9 @@ describe('EpicsSelect', () => {
initialEpic: mockEpic2, initialEpic: mockEpic2,
}); });
expect(wrapper.vm.$store.state.selectedEpic).toBe(mockEpic2); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.vm.$store.state.selectedEpic).toBe(mockEpic2);
});
}); });
}); });
......
...@@ -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', () => {
......
...@@ -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();
});
}); });
}); });
}); });
...@@ -24,7 +24,9 @@ describe('MR Popover', () => { ...@@ -24,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', () => {
......
...@@ -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();
});
}); });
}); });
...@@ -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);
});
}); });
}); });
}); });
......
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