Commit a384893a authored by Illya Klymov's avatar Illya Klymov

Ensure setData calls are properly handled

After `setData` component is updating in async way
Ensure `nextTick` is called for that
parent 6e39c0ad
...@@ -70,6 +70,7 @@ describe('Design management toolbar component', () => { ...@@ -70,6 +70,7 @@ describe('Design management toolbar component', () => {
it('links back to designs list', () => { it('links back to designs list', () => {
createComponent(); createComponent();
return wrapper.vm.$nextTick().then(() => {
const link = wrapper.find('a'); const link = wrapper.find('a');
expect(link.props('to')).toEqual({ expect(link.props('to')).toEqual({
...@@ -79,6 +80,7 @@ describe('Design management toolbar component', () => { ...@@ -79,6 +80,7 @@ describe('Design management toolbar component', () => {
}, },
}); });
}); });
});
it('renders delete button on latest designs version with logged in user', () => { it('renders delete button on latest designs version with logged in user', () => {
createComponent(); createComponent();
......
...@@ -29,6 +29,8 @@ describe('Design management pagination component', () => { ...@@ -29,6 +29,8 @@ describe('Design management pagination component', () => {
designs: [{ id: '1' }, { id: '2' }], designs: [{ id: '1' }, { id: '2' }],
}); });
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); });
});
}); });
...@@ -50,50 +50,68 @@ describe('Design management design version dropdown component', () => { ...@@ -50,50 +50,68 @@ describe('Design management design version dropdown component', () => {
it('renders design version dropdown button', () => { it('renders design version dropdown button', () => {
createComponent(); createComponent();
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); });
});
it('renders design version list', () => { it('renders design version list', () => {
createComponent(); createComponent();
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); });
});
describe('selected version name', () => { describe('selected version name', () => {
it('has "latest" on most recent version item', () => { it('has "latest" on most recent version item', () => {
createComponent(); createComponent();
return wrapper.vm.$nextTick().then(() => {
expect(findVersionLink(0).text()).toContain('latest'); expect(findVersionLink(0).text()).toContain('latest');
}); });
}); });
});
describe('versions list', () => { describe('versions list', () => {
it('displays latest version text by default', () => { it('displays latest version text by default', () => {
createComponent(); createComponent();
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlDropdown).attributes('text')).toBe('Showing Latest Version'); expect(wrapper.find(GlDropdown).attributes('text')).toBe('Showing Latest Version');
}); });
});
it('displays latest version text when only 1 version is present', () => { it('displays latest version text when only 1 version is present', () => {
createComponent({ maxVersions: 1 }); createComponent({ maxVersions: 1 });
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlDropdown).attributes('text')).toBe('Showing Latest Version'); expect(wrapper.find(GlDropdown).attributes('text')).toBe('Showing Latest Version');
}); });
});
it('displays version text when the current version is not the latest', () => { it('displays version text when the current version is not the latest', () => {
createComponent({ $route: designRouteFactory(PREVIOUS_VERSION_ID) }); createComponent({ $route: designRouteFactory(PREVIOUS_VERSION_ID) });
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlDropdown).attributes('text')).toBe(`Showing Version #1`); expect(wrapper.find(GlDropdown).attributes('text')).toBe(`Showing Version #1`);
}); });
});
it('displays latest version text when the current version is the latest', () => { it('displays latest version text when the current version is the latest', () => {
createComponent({ $route: designRouteFactory(LATEST_VERSION_ID) }); createComponent({ $route: designRouteFactory(LATEST_VERSION_ID) });
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(GlDropdown).attributes('text')).toBe('Showing Latest Version'); expect(wrapper.find(GlDropdown).attributes('text')).toBe('Showing Latest Version');
}); });
});
it('should have the same length as apollo query', () => { it('should have the same length as apollo query', () => {
createComponent(); createComponent();
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.findAll(GlDropdownItem).length).toEqual(wrapper.vm.allVersions.length); expect(wrapper.findAll(GlDropdownItem).length).toEqual(wrapper.vm.allVersions.length);
}); });
}); });
});
}); });
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Design management design index page renders design index 1`] = `
<div
class="design-detail fixed-top w-100 position-bottom-0 d-flex justify-content-center flex-column flex-lg-row"
>
<div
class="d-flex overflow-hidden flex-lg-grow-1 flex-column"
>
<designdestroyer-stub
filenames="test.jpg"
iid="1"
projectpath=""
/>
<div
class="d-flex flex-column h-100 mh-100 position-relative"
>
<div
class="p-3"
>
<!---->
</div>
<designimage-stub
image="test.jpg"
name="test.jpg"
/>
<designoverlay-stub
notes="[object Object]"
position="[object Object]"
/>
</div>
</div>
<div
class="image-notes"
>
<designdiscussion-stub
designid="1"
discussion="[object Object]"
discussionindex="1"
markdownpreviewpath="//preview_markdown?target_type=Issue"
noteableid="design-id"
/>
<!---->
</div>
</div>
`;
exports[`Design management design index page sets loading state 1`] = `
<div
class="design-detail fixed-top w-100 position-bottom-0 d-flex justify-content-center flex-column flex-lg-row"
>
<glloadingicon-stub
class="align-self-center"
color="orange"
label="Loading"
size="xl"
/>
</div>
`;
exports[`Design management design index page with error GlAlert is rendered in correct position with correct content 1`] = ` exports[`Design management design index page with error GlAlert is rendered in correct position with correct content 1`] = `
<div <div
class="design-detail fixed-top w-100 position-bottom-0 d-flex justify-content-center flex-column flex-lg-row" class="design-detail fixed-top w-100 position-bottom-0 d-flex justify-content-center flex-column flex-lg-row"
...@@ -60,29 +123,3 @@ exports[`Design management design index page with error GlAlert is rendered in c ...@@ -60,29 +123,3 @@ exports[`Design management design index page with error GlAlert is rendered in c
</div> </div>
</div> </div>
`; `;
exports[`Design management design index page renders design index 1`] = `
<div
class="design-detail fixed-top w-100 position-bottom-0 d-flex justify-content-center flex-column flex-lg-row"
>
<glloadingicon-stub
class="align-self-center"
color="orange"
label="Loading"
size="xl"
/>
</div>
`;
exports[`Design management design index page sets loading state 1`] = `
<div
class="design-detail fixed-top w-100 position-bottom-0 d-flex justify-content-center flex-column flex-lg-row"
>
<glloadingicon-stub
class="align-self-center"
color="orange"
label="Loading"
size="xl"
/>
</div>
`;
...@@ -81,8 +81,10 @@ describe('Design management design index page', () => { ...@@ -81,8 +81,10 @@ describe('Design management design index page', () => {
it('sets loading state', () => { it('sets loading state', () => {
createComponent(true); createComponent(true);
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); });
});
it('renders design index', () => { it('renders design index', () => {
setDesign(); setDesign();
...@@ -91,9 +93,11 @@ describe('Design management design index page', () => { ...@@ -91,9 +93,11 @@ describe('Design management design index page', () => {
design, design,
}); });
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
expect(wrapper.find(GlAlert).exists()).toBe(false); expect(wrapper.find(GlAlert).exists()).toBe(false);
}); });
});
describe('when has no discussions', () => { describe('when has no discussions', () => {
beforeEach(() => { beforeEach(() => {
......
...@@ -110,8 +110,10 @@ describe('Design management index page', () => { ...@@ -110,8 +110,10 @@ describe('Design management index page', () => {
it('renders loading icon', () => { it('renders loading icon', () => {
createComponent({ loading: true }); createComponent({ loading: true });
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); });
});
it('renders error', () => { it('renders error', () => {
createComponent(); createComponent();
...@@ -153,13 +155,15 @@ describe('Design management index page', () => { ...@@ -153,13 +155,15 @@ describe('Design management index page', () => {
createComponent(); createComponent();
}); });
it('renders empty text', () => { it('renders empty text', () =>
wrapper.vm.$nextTick().then(() => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); }));
it('does not render a toolbar with buttons', () => { it('does not render a toolbar with buttons', () =>
wrapper.vm.$nextTick().then(() => {
expect(findToolbar().exists()).toBe(false); expect(findToolbar().exists()).toBe(false);
}); }));
}); });
describe('uploading designs', () => { describe('uploading designs', () => {
......
...@@ -132,8 +132,10 @@ describe('packages_list', () => { ...@@ -132,8 +132,10 @@ describe('packages_list', () => {
it('deleteItemConfirmation emit package:delete', () => { it('deleteItemConfirmation emit package:delete', () => {
wrapper.setData({ itemToBeDeleted: { id: 2 } }); wrapper.setData({ itemToBeDeleted: { id: 2 } });
wrapper.vm.deleteItemConfirmation(); wrapper.vm.deleteItemConfirmation();
return wrapper.vm.$nextTick(() => {
expect(wrapper.emitted('package:delete')).toEqual([[2]]); expect(wrapper.emitted('package:delete')).toEqual([[2]]);
}); });
});
it('deleteItemCanceled resets itemToBeDeleted', () => { it('deleteItemCanceled resets itemToBeDeleted', () => {
wrapper.setData({ itemToBeDeleted: 1 }); wrapper.setData({ itemToBeDeleted: 1 });
......
...@@ -72,8 +72,10 @@ describe('EpicsSelect', () => { ...@@ -72,8 +72,10 @@ describe('EpicsSelect', () => {
query: 'foo', query: 'foo',
}); });
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.classes()).toContain('has-value'); expect(wrapper.classes()).toContain('has-value');
}); });
});
it('should render input element', () => { it('should render input element', () => {
const inputEl = wrapper.find('input'); const inputEl = wrapper.find('input');
...@@ -89,11 +91,14 @@ describe('EpicsSelect', () => { ...@@ -89,11 +91,14 @@ describe('EpicsSelect', () => {
wrapper.setData({ wrapper.setData({
query: 'foo', query: 'foo',
}); });
return wrapper.vm.$nextTick().then(() => {
const iconEl = wrapper.find(Icon); const iconEl = wrapper.find(Icon);
expect(iconEl.exists()).toBe(true); expect(iconEl.exists()).toBe(true);
expect(iconEl.attributes('name')).toBe('search'); expect(iconEl.attributes('name')).toBe('search');
}); });
});
it('should render input clear button', () => { it('should render input clear button', () => {
const clearButtonEl = wrapper.find(GlButton); const clearButtonEl = wrapper.find(GlButton);
......
...@@ -25,6 +25,7 @@ describe('KnativeDomainEditor', () => { ...@@ -25,6 +25,7 @@ describe('KnativeDomainEditor', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
describe('knative has an assigned IP address', () => { describe('knative has an assigned IP address', () => {
...@@ -101,13 +102,17 @@ describe('KnativeDomainEditor', () => { ...@@ -101,13 +102,17 @@ describe('KnativeDomainEditor', () => {
describe('when knative domain name input changes', () => { describe('when knative domain name input changes', () => {
it('emits "set" event with updated domain name', () => { it('emits "set" event with updated domain name', () => {
createComponent({ knative });
const newHostname = 'newhostname.com'; const newHostname = 'newhostname.com';
wrapper.setData({ knativeHostname: newHostname }); wrapper.setData({ knativeHostname: newHostname });
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('set')[0]).toEqual([newHostname]); expect(wrapper.emitted('set')[0]).toEqual([newHostname]);
}); });
}); });
});
describe('when updating knative domain name failed', () => { describe('when updating knative domain name failed', () => {
beforeEach(() => { beforeEach(() => {
......
...@@ -167,9 +167,11 @@ describe('ClusterFormDropdown', () => { ...@@ -167,9 +167,11 @@ describe('ClusterFormDropdown', () => {
vm.setProps({ items }); vm.setProps({ items });
vm.setData({ searchQuery }); vm.setData({ searchQuery });
return vm.vm.$nextTick().then(() => {
expect(vm.findAll('.js-dropdown-item').length).toEqual(1); expect(vm.findAll('.js-dropdown-item').length).toEqual(1);
expect(vm.find('.js-dropdown-item').text()).toEqual(secondItem.name); expect(vm.find('.js-dropdown-item').text()).toEqual(secondItem.name);
}); });
});
it('focuses dropdown search input when dropdown is displayed', () => { it('focuses dropdown search input when dropdown is displayed', () => {
const dropdownEl = vm.find('.dropdown').element; const dropdownEl = vm.find('.dropdown').element;
......
...@@ -72,8 +72,10 @@ describe('ServiceCredentialsForm', () => { ...@@ -72,8 +72,10 @@ describe('ServiceCredentialsForm', () => {
it('enables submit button when role ARN is not provided', () => { it('enables submit button when role ARN is not provided', () => {
vm.setData({ roleArn: '123' }); vm.setData({ roleArn: '123' });
return vm.vm.$nextTick().then(() => {
expect(findSubmitButton().attributes('disabled')).toBeFalsy(); expect(findSubmitButton().attributes('disabled')).toBeFalsy();
}); });
});
it('dispatches createRole action when form is submitted', () => { it('dispatches createRole action when form is submitted', () => {
findForm().trigger('submit'); findForm().trigger('submit');
...@@ -86,6 +88,8 @@ describe('ServiceCredentialsForm', () => { ...@@ -86,6 +88,8 @@ describe('ServiceCredentialsForm', () => {
vm.setData({ roleArn: '123' }); // set role ARN to enable button vm.setData({ roleArn: '123' }); // set role ARN to enable button
state.isCreatingRole = true; state.isCreatingRole = true;
return vm.vm.$nextTick();
}); });
it('disables submit button', () => { it('disables submit button', () => {
......
...@@ -40,15 +40,19 @@ describe('Issuable suggestions app component', () => { ...@@ -40,15 +40,19 @@ describe('Issuable suggestions app component', () => {
it('renders component', () => { it('renders component', () => {
wrapper.setData(data); wrapper.setData(data);
return wrapper.vm.$nextTick(() => {
expect(wrapper.isEmpty()).toBe(false); expect(wrapper.isEmpty()).toBe(false);
}); });
});
it('does not render with empty search', () => { it('does not render with empty search', () => {
wrapper.setProps({ search: '' }); wrapper.setProps({ search: '' });
wrapper.setData(data); wrapper.setData(data);
return wrapper.vm.$nextTick(() => {
expect(wrapper.isVisible()).toBe(false); expect(wrapper.isVisible()).toBe(false);
}); });
});
it('does not render when loading', () => { it('does not render when loading', () => {
wrapper.setData({ wrapper.setData({
...@@ -56,14 +60,18 @@ describe('Issuable suggestions app component', () => { ...@@ -56,14 +60,18 @@ describe('Issuable suggestions app component', () => {
loading: 1, loading: 1,
}); });
return wrapper.vm.$nextTick(() => {
expect(wrapper.isVisible()).toBe(false); expect(wrapper.isVisible()).toBe(false);
}); });
});
it('does not render with empty issues data', () => { it('does not render with empty issues data', () => {
wrapper.setData({ issues: [] }); wrapper.setData({ issues: [] });
return wrapper.vm.$nextTick(() => {
expect(wrapper.isVisible()).toBe(false); expect(wrapper.isVisible()).toBe(false);
}); });
});
it('renders list of issues', () => { it('renders list of issues', () => {
wrapper.setData(data); wrapper.setData(data);
......
...@@ -41,8 +41,10 @@ describe('MR Popover', () => { ...@@ -41,8 +41,10 @@ describe('MR Popover', () => {
}, },
}); });
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); });
});
it('does not show CI Icon if there is no pipeline data', () => { it('does not show CI Icon if there is no pipeline data', () => {
wrapper.setData({ wrapper.setData({
...@@ -55,7 +57,9 @@ describe('MR Popover', () => { ...@@ -55,7 +57,9 @@ describe('MR Popover', () => {
}, },
}); });
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.contains('ciicon-stub')).toBe(false); expect(wrapper.contains('ciicon-stub')).toBe(false);
}); });
}); });
});
}); });
...@@ -162,6 +162,7 @@ describe('table registry', () => { ...@@ -162,6 +162,7 @@ describe('table registry', () => {
describe('delete registry', () => { describe('delete registry', () => {
beforeEach(() => { beforeEach(() => {
wrapper.setData({ selectedItems: [0] }); wrapper.setData({ selectedItems: [0] });
return wrapper.vm.$nextTick();
}); });
it('should be possible to delete a registry', () => { it('should be possible to delete a registry', () => {
...@@ -317,6 +318,7 @@ describe('table registry', () => { ...@@ -317,6 +318,7 @@ describe('table registry', () => {
describe('single tag delete', () => { describe('single tag delete', () => {
beforeEach(() => { beforeEach(() => {
wrapper.setData({ itemsToBeDeleted: [0] }); wrapper.setData({ itemsToBeDeleted: [0] });
return wrapper.vm.$nextTick();
}); });
it('send an event when delete button is clicked', () => { it('send an event when delete button is clicked', () => {
...@@ -345,6 +347,7 @@ describe('table registry', () => { ...@@ -345,6 +347,7 @@ describe('table registry', () => {
beforeEach(() => { beforeEach(() => {
const items = [0, 1, 2]; const items = [0, 1, 2];
wrapper.setData({ itemsToBeDeleted: items, selectedItems: items }); wrapper.setData({ itemsToBeDeleted: items, selectedItems: items });
return wrapper.vm.$nextTick();
}); });
it('send an event when delete button is clicked', () => { it('send an event when delete button is clicked', () => {
......
...@@ -49,14 +49,18 @@ describe('Repository breadcrumbs component', () => { ...@@ -49,14 +49,18 @@ describe('Repository breadcrumbs component', () => {
vm.setData({ userPermissions: { forkProject: false, createMergeRequestIn: false } }); vm.setData({ userPermissions: { forkProject: false, createMergeRequestIn: false } });
return vm.vm.$nextTick(() => {
expect(vm.find(GlDropdown).exists()).toBe(false); expect(vm.find(GlDropdown).exists()).toBe(false);
}); });
});
it('renders add to tree dropdown when permissions are true', () => { it('renders add to tree dropdown when permissions are true', () => {
factory('/', { canCollaborate: true }); factory('/', { canCollaborate: true });
vm.setData({ userPermissions: { forkProject: true, createMergeRequestIn: true } }); vm.setData({ userPermissions: { forkProject: true, createMergeRequestIn: true } });
return vm.vm.$nextTick(() => {
expect(vm.find(GlDropdown).exists()).toBe(true); expect(vm.find(GlDropdown).exists()).toBe(true);
}); });
});
}); });
...@@ -58,8 +58,10 @@ describe('Repository last commit component', () => { ...@@ -58,8 +58,10 @@ describe('Repository last commit component', () => {
`('$label when loading icon $loading is true', ({ loading }) => { `('$label when loading icon $loading is true', ({ loading }) => {
factory(createCommitData(), loading); factory(createCommitData(), loading);
return vm.vm.$nextTick(() => {
expect(vm.find(GlLoadingIcon).exists()).toBe(loading); expect(vm.find(GlLoadingIcon).exists()).toBe(loading);
}); });
});
it('renders commit widget', () => { it('renders commit widget', () => {
factory(); factory();
......
...@@ -33,8 +33,10 @@ describe('Repository file preview component', () => { ...@@ -33,8 +33,10 @@ describe('Repository file preview component', () => {
vm.setData({ readme: { html: '<div class="blob">test</div>' } }); vm.setData({ readme: { html: '<div class="blob">test</div>' } });
return vm.vm.$nextTick(() => {
expect(vm.element).toMatchSnapshot(); expect(vm.element).toMatchSnapshot();
}); });
});
it('renders loading icon', () => { it('renders loading icon', () => {
factory({ factory({
...@@ -44,6 +46,8 @@ describe('Repository file preview component', () => { ...@@ -44,6 +46,8 @@ describe('Repository file preview component', () => {
vm.setData({ loading: 1 }); vm.setData({ loading: 1 });
return vm.vm.$nextTick(() => {
expect(vm.find(GlLoadingIcon).exists()).toBe(true); expect(vm.find(GlLoadingIcon).exists()).toBe(true);
}); });
});
}); });
...@@ -53,10 +53,12 @@ describe('Repository table component', () => { ...@@ -53,10 +53,12 @@ describe('Repository table component', () => {
vm.setData({ ref }); vm.setData({ ref });
return vm.vm.$nextTick(() => {
expect(vm.find('.table').attributes('aria-label')).toEqual( expect(vm.find('.table').attributes('aria-label')).toEqual(
`Files, directories, and submodules in the path ${path} for commit reference ${ref}`, `Files, directories, and submodules in the path ${path} for commit reference ${ref}`,
); );
}); });
});
it('shows loading icon', () => { it('shows loading icon', () => {
factory({ path: '/', isLoading: true }); factory({ path: '/', isLoading: true });
......
...@@ -46,8 +46,10 @@ describe('Repository table row component', () => { ...@@ -46,8 +46,10 @@ describe('Repository table row component', () => {
currentPath: '/', currentPath: '/',
}); });
return vm.vm.$nextTick().then(() => {
expect(vm.element).toMatchSnapshot(); expect(vm.element).toMatchSnapshot();
}); });
});
it.each` it.each`
type | component | componentName type | component | componentName
...@@ -63,8 +65,10 @@ describe('Repository table row component', () => { ...@@ -63,8 +65,10 @@ describe('Repository table row component', () => {
currentPath: '/', currentPath: '/',
}); });
return vm.vm.$nextTick().then(() => {
expect(vm.find(component).exists()).toBe(true); expect(vm.find(component).exists()).toBe(true);
}); });
});
it.each` it.each`
type | pushes type | pushes
...@@ -80,6 +84,7 @@ describe('Repository table row component', () => { ...@@ -80,6 +84,7 @@ describe('Repository table row component', () => {
currentPath: '/', currentPath: '/',
}); });
return vm.vm.$nextTick().then(() => {
vm.trigger('click'); vm.trigger('click');
if (pushes) { if (pushes) {
...@@ -88,6 +93,7 @@ describe('Repository table row component', () => { ...@@ -88,6 +93,7 @@ describe('Repository table row component', () => {
expect($router.push).not.toHaveBeenCalled(); expect($router.push).not.toHaveBeenCalled();
} }
}); });
});
it.each` it.each`
type | pushes type | pushes
...@@ -103,6 +109,7 @@ describe('Repository table row component', () => { ...@@ -103,6 +109,7 @@ describe('Repository table row component', () => {
currentPath: '/', currentPath: '/',
}); });
return vm.vm.$nextTick().then(() => {
vm.trigger('click'); vm.trigger('click');
if (pushes) { if (pushes) {
...@@ -113,6 +120,7 @@ describe('Repository table row component', () => { ...@@ -113,6 +120,7 @@ describe('Repository table row component', () => {
expect(external).toBeFalsy(); expect(external).toBeFalsy();
} }
}); });
});
it('renders commit ID for submodule', () => { it('renders commit ID for submodule', () => {
factory({ factory({
...@@ -123,8 +131,10 @@ describe('Repository table row component', () => { ...@@ -123,8 +131,10 @@ describe('Repository table row component', () => {
currentPath: '/', currentPath: '/',
}); });
return vm.vm.$nextTick().then(() => {
expect(vm.find('.commit-sha').text()).toContain('1'); expect(vm.find('.commit-sha').text()).toContain('1');
}); });
});
it('renders link with href', () => { it('renders link with href', () => {
factory({ factory({
...@@ -136,8 +146,10 @@ describe('Repository table row component', () => { ...@@ -136,8 +146,10 @@ describe('Repository table row component', () => {
currentPath: '/', currentPath: '/',
}); });
return vm.vm.$nextTick().then(() => {
expect(vm.find('a').attributes('href')).toEqual('https://test.com'); expect(vm.find('a').attributes('href')).toEqual('https://test.com');
}); });
});
it('renders LFS badge', () => { it('renders LFS badge', () => {
factory({ factory({
...@@ -149,8 +161,10 @@ describe('Repository table row component', () => { ...@@ -149,8 +161,10 @@ describe('Repository table row component', () => {
lfsOid: '1', lfsOid: '1',
}); });
return vm.vm.$nextTick().then(() => {
expect(vm.find(GlBadge).exists()).toBe(true); expect(vm.find(GlBadge).exists()).toBe(true);
}); });
});
it('renders commit and web links with href for submodule', () => { it('renders commit and web links with href for submodule', () => {
factory({ factory({
...@@ -163,9 +177,11 @@ describe('Repository table row component', () => { ...@@ -163,9 +177,11 @@ describe('Repository table row component', () => {
currentPath: '/', currentPath: '/',
}); });
return vm.vm.$nextTick().then(() => {
expect(vm.find('a').attributes('href')).toEqual('https://test.com'); expect(vm.find('a').attributes('href')).toEqual('https://test.com');
expect(vm.find(GlLink).attributes('href')).toEqual('https://test.com/commit'); expect(vm.find(GlLink).attributes('href')).toEqual('https://test.com/commit');
}); });
});
it('renders lock icon', () => { it('renders lock icon', () => {
factory({ factory({
...@@ -178,6 +194,8 @@ describe('Repository table row component', () => { ...@@ -178,6 +194,8 @@ describe('Repository table row component', () => {
vm.setData({ commit: { lockLabel: 'Locked by Root', committedDate: '2019-01-01' } }); vm.setData({ commit: { lockLabel: 'Locked by Root', committedDate: '2019-01-01' } });
return vm.vm.$nextTick().then(() => {
expect(vm.find(Icon).exists()).toBe(true); expect(vm.find(Icon).exists()).toBe(true);
}); });
});
}); });
...@@ -78,9 +78,13 @@ describe('Confidential Issue Sidebar Block', () => { ...@@ -78,9 +78,13 @@ describe('Confidential Issue Sidebar Block', () => {
it('displays the edit form when editable', () => { it('displays the edit form when editable', () => {
wrapper.setData({ edit: false }); wrapper.setData({ edit: false });
return wrapper.vm
.$nextTick()
.then(() => {
wrapper.find({ ref: 'editLink' }).trigger('click'); wrapper.find({ ref: 'editLink' }).trigger('click');
return wrapper.vm.$nextTick();
return wrapper.vm.$nextTick().then(() => { })
.then(() => {
expect(wrapper.find(EditForm).exists()).toBe(true); expect(wrapper.find(EditForm).exists()).toBe(true);
}); });
}); });
...@@ -88,9 +92,13 @@ describe('Confidential Issue Sidebar Block', () => { ...@@ -88,9 +92,13 @@ describe('Confidential Issue Sidebar Block', () => {
it('displays the edit form when opened from collapsed state', () => { it('displays the edit form when opened from collapsed state', () => {
wrapper.setData({ edit: false }); wrapper.setData({ edit: false });
return wrapper.vm
.$nextTick()
.then(() => {
wrapper.find({ ref: 'collapseIcon' }).trigger('click'); wrapper.find({ ref: 'collapseIcon' }).trigger('click');
return wrapper.vm.$nextTick();
return wrapper.vm.$nextTick().then(() => { })
.then(() => {
expect(wrapper.find(EditForm).exists()).toBe(true); expect(wrapper.find(EditForm).exists()).toBe(true);
}); });
}); });
......
...@@ -64,8 +64,10 @@ describe('Commits header component', () => { ...@@ -64,8 +64,10 @@ describe('Commits header component', () => {
createComponent(); createComponent();
wrapper.setData({ expanded: false }); wrapper.setData({ expanded: false });
return wrapper.vm.$nextTick().then(() => {
expect(findIcon().props('name')).toBe('chevron-right'); expect(findIcon().props('name')).toBe('chevron-right');
}); });
});
describe('when squash is disabled', () => { describe('when squash is disabled', () => {
beforeEach(() => { beforeEach(() => {
......
...@@ -43,7 +43,10 @@ describe('Error Tracking directive', () => { ...@@ -43,7 +43,10 @@ describe('Error Tracking directive', () => {
wrapper.setData({ trackingOptions }); wrapper.setData({ trackingOptions });
const { category, action, label, property, value } = trackingOptions; const { category, action, label, property, value } = trackingOptions;
return wrapper.vm.$nextTick(() => {
button.trigger('click'); button.trigger('click');
expect(Tracking.event).toHaveBeenCalledWith(category, action, { label, property, value }); expect(Tracking.event).toHaveBeenCalledWith(category, action, { label, property, value });
}); });
});
}); });
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