Commit 24aea042 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'slashmanov/refactor-next-tick-2' into 'master'

Refactor nextTick to use a direct import from a Vue package (2/9)

See merge request gitlab-org/gitlab!79048
parents 1fb1c4ae 613a1087
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import GeoNodeDetails from 'ee/geo_nodes/components/details/geo_node_details.vue'; import GeoNodeDetails from 'ee/geo_nodes/components/details/geo_node_details.vue';
import GeoNodes from 'ee/geo_nodes/components/geo_nodes.vue'; import GeoNodes from 'ee/geo_nodes/components/geo_nodes.vue';
import GeoNodeHeader from 'ee/geo_nodes/components/header/geo_node_header.vue'; import GeoNodeHeader from 'ee/geo_nodes/components/header/geo_node_header.vue';
...@@ -46,12 +47,11 @@ describe('GeoNodes', () => { ...@@ -46,12 +47,11 @@ describe('GeoNodes', () => {
expect(findGeoNodeDetails().exists()).toBe(true); expect(findGeoNodeDetails().exists()).toBe(true);
}); });
it('is hidden when toggled', () => { it('is hidden when toggled', async () => {
findGeoNodeHeader().vm.$emit('collapse'); findGeoNodeHeader().vm.$emit('collapse');
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findGeoNodeDetails().exists()).toBe(false); expect(findGeoNodeDetails().exists()).toBe(false);
});
}); });
}); });
}); });
......
import { GlButton, GlModal } from '@gitlab/ui'; import { GlButton, GlModal } from '@gitlab/ui';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { sprintf } from '~/locale'; import { sprintf } from '~/locale';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
...@@ -140,7 +140,7 @@ describe('HandRaiseLeadButton', () => { ...@@ -140,7 +140,7 @@ describe('HandRaiseLeadButton', () => {
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
wrapper.setData({ countries, states, ...formData }); wrapper.setData({ countries, states, ...formData });
await wrapper.vm.$nextTick(); await nextTick();
expect(findModal().props('actionPrimary')).toStrictEqual({ expect(findModal().props('actionPrimary')).toStrictEqual({
text: PQL_MODAL_PRIMARY, text: PQL_MODAL_PRIMARY,
...@@ -164,7 +164,7 @@ describe('HandRaiseLeadButton', () => { ...@@ -164,7 +164,7 @@ describe('HandRaiseLeadButton', () => {
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
wrapper.setData({ countries, states, country: state }); wrapper.setData({ countries, states, country: state });
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findByTestId('state').exists()).toBe(display); expect(wrapper.findByTestId('state').exists()).toBe(display);
}); });
......
import { GlIcon } from '@gitlab/ui'; import { GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import PublishedCell from 'ee/incidents/components/published_cell.vue'; import PublishedCell from 'ee/incidents/components/published_cell.vue';
describe('Incidents Published Cell', () => { describe('Incidents Published Cell', () => {
...@@ -37,12 +38,11 @@ describe('Incidents Published Cell', () => { ...@@ -37,12 +38,11 @@ describe('Incidents Published Cell', () => {
expect(findCell().text()).toBe('Unpublished'); expect(findCell().text()).toBe('Unpublished');
}); });
it('render a status success icon if statusPagePublishedIncident returns true', () => { it('render a status success icon if statusPagePublishedIncident returns true', async () => {
wrapper.setProps({ statusPagePublishedIncident: true }); wrapper.setProps({ statusPagePublishedIncident: true });
return wrapper.vm.$nextTick().then(() => { await nextTick();
expect(findCell().findComponent(GlIcon).exists()).toBe(true); expect(findCell().findComponent(GlIcon).exists()).toBe(true);
});
}); });
}); });
}); });
import { GlEmptyState } from '@gitlab/ui'; import { GlEmptyState } from '@gitlab/ui';
import { GlColumnChart } from '@gitlab/ui/dist/charts'; import { GlColumnChart } from '@gitlab/ui/dist/charts';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import InsightsChart from 'ee/insights/components/insights_chart.vue'; import InsightsChart from 'ee/insights/components/insights_chart.vue';
...@@ -94,7 +94,7 @@ describe('Insights page component', () => { ...@@ -94,7 +94,7 @@ describe('Insights page component', () => {
it('reflects new state', async () => { it('reflects new state', async () => {
wrapper.setProps({ pageConfig: pageInfoNoCharts }); wrapper.setProps({ pageConfig: pageInfoNoCharts });
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(GlEmptyState).exists()).toBe(true); expect(wrapper.findComponent(GlEmptyState).exists()).toBe(true);
}); });
......
import { GlAlert, GlDropdown, GlDropdownItem, GlEmptyState } from '@gitlab/ui'; import { GlAlert, GlDropdown, GlDropdownItem, GlEmptyState } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import axios from 'axios'; import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import Vuex from 'vuex'; import Vuex from 'vuex';
...@@ -84,13 +84,13 @@ describe('Insights component', () => { ...@@ -84,13 +84,13 @@ describe('Insights component', () => {
}); });
it('has the correct nav tabs', async () => { it('has the correct nav tabs', async () => {
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(GlDropdown).exists()).toBe(true); expect(wrapper.findComponent(GlDropdown).exists()).toBe(true);
expect(wrapper.findComponent(GlDropdown).findComponent(GlDropdownItem).text()).toBe(title); expect(wrapper.findComponent(GlDropdown).findComponent(GlDropdownItem).text()).toBe(title);
}); });
it('should not disable the tab selector', async () => { it('should not disable the tab selector', async () => {
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(GlDropdown).attributes().disabled).toBeUndefined(); expect(wrapper.findComponent(GlDropdown).attributes().disabled).toBeUndefined();
}); });
}); });
...@@ -110,13 +110,13 @@ describe('Insights component', () => { ...@@ -110,13 +110,13 @@ describe('Insights component', () => {
}); });
it('has the correct nav tabs', async () => { it('has the correct nav tabs', async () => {
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(GlDropdown).exists()).toBe(true); expect(wrapper.findComponent(GlDropdown).exists()).toBe(true);
expect(wrapper.findComponent(GlDropdown).findComponent(GlDropdownItem).text()).toBe(title); expect(wrapper.findComponent(GlDropdown).findComponent(GlDropdownItem).text()).toBe(title);
}); });
it('disables the tab selector', async () => { it('disables the tab selector', async () => {
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(GlDropdown).attributes()).toMatchObject({ disabled: 'true' }); expect(wrapper.findComponent(GlDropdown).attributes()).toMatchObject({ disabled: 'true' });
}); });
}); });
...@@ -140,7 +140,7 @@ describe('Insights component', () => { ...@@ -140,7 +140,7 @@ describe('Insights component', () => {
}); });
it('enables the tab selector', async () => { it('enables the tab selector', async () => {
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(GlDropdown).attributes()).toMatchObject({ disabled: 'true' }); expect(wrapper.findComponent(GlDropdown).attributes()).toMatchObject({ disabled: 'true' });
}); });
}); });
...@@ -163,7 +163,7 @@ describe('Insights component', () => { ...@@ -163,7 +163,7 @@ describe('Insights component', () => {
}); });
it('disables the tab selector', async () => { it('disables the tab selector', async () => {
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(GlDropdown).attributes()).toMatchObject({ disabled: 'true' }); expect(wrapper.findComponent(GlDropdown).attributes()).toMatchObject({ disabled: 'true' });
}); });
}); });
...@@ -187,7 +187,7 @@ describe('Insights component', () => { ...@@ -187,7 +187,7 @@ describe('Insights component', () => {
}); });
it('enables the tab selector', async () => { it('enables the tab selector', async () => {
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(GlDropdown).attributes().disabled).toBeUndefined(); expect(wrapper.findComponent(GlDropdown).attributes().disabled).toBeUndefined();
}); });
}); });
...@@ -211,7 +211,7 @@ describe('Insights component', () => { ...@@ -211,7 +211,7 @@ describe('Insights component', () => {
}); });
it('enables the tab selector', async () => { it('enables the tab selector', async () => {
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(GlDropdown).attributes().disabled).toBeUndefined(); expect(wrapper.findComponent(GlDropdown).attributes().disabled).toBeUndefined();
}); });
}); });
...@@ -224,14 +224,14 @@ describe('Insights component', () => { ...@@ -224,14 +224,14 @@ describe('Insights component', () => {
}); });
it('it displays a warning', async () => { it('it displays a warning', async () => {
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(GlEmptyState).attributes()).toMatchObject({ expect(wrapper.findComponent(GlEmptyState).attributes()).toMatchObject({
title: 'Invalid Insights config file detected', title: 'Invalid Insights config file detected',
}); });
}); });
it('does not display dropdown', async () => { it('does not display dropdown', async () => {
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(GlDropdown).exists()).toBe(false); expect(wrapper.findComponent(GlDropdown).exists()).toBe(false);
}); });
}); });
...@@ -243,14 +243,14 @@ describe('Insights component', () => { ...@@ -243,14 +243,14 @@ describe('Insights component', () => {
}); });
it('it displays a warning', async () => { it('it displays a warning', async () => {
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(GlAlert).text()).toContain( expect(wrapper.findComponent(GlAlert).text()).toContain(
'This project is filtered out in the insights.yml file', 'This project is filtered out in the insights.yml file',
); );
}); });
it('does not display dropdown', async () => { it('does not display dropdown', async () => {
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(GlDropdown).exists()).toBe(false); expect(wrapper.findComponent(GlDropdown).exists()).toBe(false);
}); });
}); });
...@@ -281,7 +281,7 @@ describe('Insights component', () => { ...@@ -281,7 +281,7 @@ describe('Insights component', () => {
jest.runOnlyPendingTimers(); jest.runOnlyPendingTimers();
await wrapper.vm.$nextTick(); await nextTick();
expect(vuexStore.dispatch).toHaveBeenCalledWith('insights/setActiveTab', defaultKey); expect(vuexStore.dispatch).toHaveBeenCalledWith('insights/setActiveTab', defaultKey);
}); });
...@@ -297,7 +297,7 @@ describe('Insights component', () => { ...@@ -297,7 +297,7 @@ describe('Insights component', () => {
jest.runOnlyPendingTimers(); jest.runOnlyPendingTimers();
await wrapper.vm.$nextTick(); await nextTick();
expect(vuexStore.dispatch).toHaveBeenCalledWith('insights/setActiveTab', selectedKey); expect(vuexStore.dispatch).toHaveBeenCalledWith('insights/setActiveTab', selectedKey);
}); });
}); });
......
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import { nextTick } from 'vue';
import GitlabSlackApplication from 'ee/integrations/gitlab_slack_application/components/gitlab_slack_application.vue'; import GitlabSlackApplication from 'ee/integrations/gitlab_slack_application/components/gitlab_slack_application.vue';
import { addProjectToSlack } from 'ee/integrations/gitlab_slack_application/api'; import { addProjectToSlack } from 'ee/integrations/gitlab_slack_application/api';
import { i18n } from 'ee/integrations/gitlab_slack_application/constants'; import { i18n } from 'ee/integrations/gitlab_slack_application/constants';
...@@ -83,7 +84,7 @@ describe('GitlabSlackApplication', () => { ...@@ -83,7 +84,7 @@ describe('GitlabSlackApplication', () => {
addProjectToSlack.mockResolvedValue(addToSlackData); addProjectToSlack.mockResolvedValue(addToSlackData);
findProjectsDropdown().vm.$emit('project-selected', mockProject); findProjectsDropdown().vm.$emit('project-selected', mockProject);
await wrapper.vm.$nextTick(); await nextTick();
expect(findProjectsDropdown().props('selectedProject')).toBe(mockProject); expect(findProjectsDropdown().props('selectedProject')).toBe(mockProject);
expect(findGlButton().props('disabled')).toBe(false); expect(findGlButton().props('disabled')).toBe(false);
......
...@@ -2,6 +2,7 @@ import { GlAlert, GlLoadingIcon } from '@gitlab/ui'; ...@@ -2,6 +2,7 @@ import { GlAlert, GlLoadingIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { nextTick } from 'vue';
import JiraIssuesShow from 'ee/integrations/jira/issues_show/components/jira_issues_show_root.vue'; import JiraIssuesShow from 'ee/integrations/jira/issues_show/components/jira_issues_show_root.vue';
import JiraIssueSidebar from 'ee/integrations/jira/issues_show/components/sidebar/jira_issues_sidebar_root.vue'; import JiraIssueSidebar from 'ee/integrations/jira/issues_show/components/sidebar/jira_issues_sidebar_root.vue';
import { IssuableStatus } from '~/issues/constants'; import { IssuableStatus } from '~/issues/constants';
...@@ -124,7 +125,7 @@ describe('JiraIssuesShow', () => { ...@@ -124,7 +125,7 @@ describe('JiraIssuesShow', () => {
expect(jiraIssueSidebar.props('sidebarExpanded')).toBe(true); expect(jiraIssueSidebar.props('sidebarExpanded')).toBe(true);
jiraIssueSidebar.vm.$emit('sidebar-toggle'); jiraIssueSidebar.vm.$emit('sidebar-toggle');
await wrapper.vm.$nextTick(); await nextTick();
expect(jiraIssueSidebar.props('sidebarExpanded')).toBe(false); expect(jiraIssueSidebar.props('sidebarExpanded')).toBe(false);
}); });
......
import { GlEmptyState, GlLoadingIcon } from '@gitlab/ui'; import { GlEmptyState, GlLoadingIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import axios from 'axios'; import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import Vuex from 'vuex'; import Vuex from 'vuex';
...@@ -66,49 +66,44 @@ describe('Issue Analytics component', () => { ...@@ -66,49 +66,44 @@ describe('Issue Analytics component', () => {
expect(store.dispatch).toHaveBeenCalledWith('issueAnalytics/fetchChartData', TEST_HOST); expect(store.dispatch).toHaveBeenCalledWith('issueAnalytics/fetchChartData', TEST_HOST);
}); });
it('renders loading state when loading', () => { it('renders loading state when loading', async () => {
wrapper.vm.$store.state.issueAnalytics.loading = true; wrapper.vm.$store.state.issueAnalytics.loading = true;
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findLoadingIcon().exists()).toBe(true); expect(findLoadingIcon().exists()).toBe(true);
expect(findChartContainer().exists()).toBe(false); expect(findChartContainer().exists()).toBe(false);
});
}); });
it('renders chart when data is present', () => { it('renders chart when data is present', async () => {
wrapper.vm.$store.state.issueAnalytics.chartData = mockChartData; wrapper.vm.$store.state.issueAnalytics.chartData = mockChartData;
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findChartContainer().exists()).toBe(true); expect(findChartContainer().exists()).toBe(true);
});
}); });
it('fetches data when filters are applied', () => { it('fetches data when filters are applied', async () => {
wrapper.vm.$store.state.issueAnalytics.filters = '?hello=world'; wrapper.vm.$store.state.issueAnalytics.filters = '?hello=world';
return wrapper.vm.$nextTick(() => { await nextTick();
expect(store.dispatch).toHaveBeenCalledTimes(2); expect(store.dispatch).toHaveBeenCalledTimes(2);
expect(store.dispatch.mock.calls[1]).toEqual(['issueAnalytics/fetchChartData', TEST_HOST]); expect(store.dispatch.mock.calls[1]).toEqual(['issueAnalytics/fetchChartData', TEST_HOST]);
});
}); });
it('renders empty state when chart data is empty', () => { it('renders empty state when chart data is empty', async () => {
wrapper.vm.$store.state.issueAnalytics.chartData = {}; wrapper.vm.$store.state.issueAnalytics.chartData = {};
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findEmptyState().exists()).toBe(true); expect(findEmptyState().exists()).toBe(true);
expect(wrapper.vm.showNoDataEmptyState).toBe(true); expect(wrapper.vm.showNoDataEmptyState).toBe(true);
});
}); });
it('renders filters empty state when filters are applied and chart data is empty', () => { it('renders filters empty state when filters are applied and chart data is empty', async () => {
wrapper.vm.$store.state.issueAnalytics.chartData = {}; wrapper.vm.$store.state.issueAnalytics.chartData = {};
wrapper.vm.$store.state.issueAnalytics.filters = '?hello=world'; wrapper.vm.$store.state.issueAnalytics.filters = '?hello=world';
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findEmptyState().exists()).toBe(true); expect(findEmptyState().exists()).toBe(true);
expect(wrapper.vm.showFiltersEmptyState).toBe(true); expect(wrapper.vm.showFiltersEmptyState).toBe(true);
});
}); });
it('renders the issues table', () => { it('renders the issues table', () => {
......
import { GlForm } from '@gitlab/ui'; import { GlForm } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { ApolloMutation } from 'vue-apollo'; import { ApolloMutation } from 'vue-apollo';
import { nextTick } from 'vue';
import IterationForm from 'ee/iterations/components/iteration_form_without_vue_router.vue'; import IterationForm from 'ee/iterations/components/iteration_form_without_vue_router.vue';
import createIteration from 'ee/iterations/queries/create_iteration.mutation.graphql'; import createIteration from 'ee/iterations/queries/create_iteration.mutation.graphql';
import updateIteration from 'ee/iterations/queries/update_iteration.mutation.graphql'; import updateIteration from 'ee/iterations/queries/update_iteration.mutation.graphql';
...@@ -61,7 +62,6 @@ describe('Iteration Form', () => { ...@@ -61,7 +62,6 @@ describe('Iteration Form', () => {
const findCancelButton = () => wrapper.find('[data-testid="cancel-iteration"]'); const findCancelButton = () => wrapper.find('[data-testid="cancel-iteration"]');
const clickSave = () => findSaveButton().vm.$emit('click'); const clickSave = () => findSaveButton().vm.$emit('click');
const clickCancel = () => findCancelButton().vm.$emit('click'); const clickCancel = () => findCancelButton().vm.$emit('click');
const nextTick = () => wrapper.vm.$nextTick();
it('renders a form', () => { it('renders a form', () => {
createComponent(); createComponent();
...@@ -107,15 +107,14 @@ describe('Iteration Form', () => { ...@@ -107,15 +107,14 @@ describe('Iteration Form', () => {
}); });
}); });
it('redirects to Iteration page on success', () => { it('redirects to Iteration page on success', async () => {
createComponent(); createComponent();
clickSave(); clickSave();
return nextTick().then(() => { await nextTick();
expect(findSaveButton().props('loading')).toBe(true); expect(findSaveButton().props('loading')).toBe(true);
expect(visitUrl).toHaveBeenCalled(); expect(visitUrl).toHaveBeenCalled();
});
}); });
it('loading=false on error', () => { it('loading=false on error', () => {
...@@ -196,7 +195,7 @@ describe('Iteration Form', () => { ...@@ -196,7 +195,7 @@ describe('Iteration Form', () => {
}); });
}); });
it('emits updated event after successful mutation', () => { it('emits updated event after successful mutation', async () => {
createComponent({ createComponent({
props: propsWithIteration, props: propsWithIteration,
mutationResult: updateMutationSuccess, mutationResult: updateMutationSuccess,
...@@ -204,13 +203,12 @@ describe('Iteration Form', () => { ...@@ -204,13 +203,12 @@ describe('Iteration Form', () => {
clickSave(); clickSave();
return nextTick().then(() => { await nextTick();
expect(findSaveButton().props('loading')).toBe(true); expect(findSaveButton().props('loading')).toBe(true);
expect(wrapper.emitted('updated')).toHaveLength(1); expect(wrapper.emitted('updated')).toHaveLength(1);
});
}); });
it('emits updated event after failed mutation', () => { it('emits updated event after failed mutation', async () => {
createComponent({ createComponent({
props: propsWithIteration, props: propsWithIteration,
mutationResult: updateMutationFailure, mutationResult: updateMutationFailure,
...@@ -218,12 +216,11 @@ describe('Iteration Form', () => { ...@@ -218,12 +216,11 @@ describe('Iteration Form', () => {
clickSave(); clickSave();
return nextTick().then(() => { await nextTick();
expect(wrapper.emitted('updated')).toBeUndefined(); expect(wrapper.emitted('updated')).toBeUndefined();
});
}); });
it('emits cancel when cancel clicked', () => { it('emits cancel when cancel clicked', async () => {
createComponent({ createComponent({
props: propsWithIteration, props: propsWithIteration,
mutationResult: updateMutationSuccess, mutationResult: updateMutationSuccess,
...@@ -231,9 +228,8 @@ describe('Iteration Form', () => { ...@@ -231,9 +228,8 @@ describe('Iteration Form', () => {
clickCancel(); clickCancel();
return nextTick().then(() => { await nextTick();
expect(wrapper.emitted('cancel')).toHaveLength(1); expect(wrapper.emitted('cancel')).toHaveLength(1);
});
}); });
}); });
}); });
import { GlDropdown, GlDropdownItem, GlEmptyState, GlLoadingIcon, GlTab, GlTabs } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem, GlEmptyState, GlLoadingIcon, GlTab, GlTabs } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { nextTick } from 'vue';
import IterationForm from 'ee/iterations/components/iteration_form_without_vue_router.vue'; import IterationForm from 'ee/iterations/components/iteration_form_without_vue_router.vue';
import IterationReportTabs from 'ee/iterations/components/iteration_report_tabs.vue'; import IterationReportTabs from 'ee/iterations/components/iteration_report_tabs.vue';
import IterationReport from 'ee/iterations/components/iteration_report_without_vue_router.vue'; import IterationReport from 'ee/iterations/components/iteration_report_without_vue_router.vue';
...@@ -232,7 +233,7 @@ describe('Iterations report', () => { ...@@ -232,7 +233,7 @@ describe('Iterations report', () => {
clickEditButton(); clickEditButton();
await wrapper.vm.$nextTick(); await nextTick();
expect(window.history.pushState).toHaveBeenCalledWith( expect(window.history.pushState).toHaveBeenCalledWith(
{ prev: 'viewIteration' }, { prev: 'viewIteration' },
...@@ -264,7 +265,7 @@ describe('Iterations report', () => { ...@@ -264,7 +265,7 @@ describe('Iterations report', () => {
jest.spyOn(window.history, 'pushState').mockImplementation(() => {}); jest.spyOn(window.history, 'pushState').mockImplementation(() => {});
findIterationForm().vm.$emit('cancel'); findIterationForm().vm.$emit('cancel');
await wrapper.vm.$nextTick(); await nextTick();
expect(window.history.pushState).toHaveBeenCalledWith( expect(window.history.pushState).toHaveBeenCalledWith(
{ prev: 'editIteration' }, { prev: 'editIteration' },
...@@ -277,7 +278,7 @@ describe('Iterations report', () => { ...@@ -277,7 +278,7 @@ describe('Iterations report', () => {
jest.spyOn(window.history, 'pushState').mockImplementation(() => {}); jest.spyOn(window.history, 'pushState').mockImplementation(() => {});
findIterationForm().vm.$emit('updated'); findIterationForm().vm.$emit('updated');
await wrapper.vm.$nextTick(); await nextTick();
expect(window.history.pushState).toHaveBeenCalledWith( expect(window.history.pushState).toHaveBeenCalledWith(
{ prev: 'editIteration' }, { prev: 'editIteration' },
......
import { GlAlert, GlLoadingIcon, GlPagination, GlTab, GlTabs } from '@gitlab/ui'; import { GlAlert, GlLoadingIcon, GlPagination, GlTab, GlTabs } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import Iterations from 'ee/iterations/components/iterations.vue'; import Iterations from 'ee/iterations/components/iterations.vue';
import IterationsList from 'ee/iterations/components/iterations_list.vue'; import IterationsList from 'ee/iterations/components/iterations_list.vue';
import { Namespace } from 'ee/iterations/constants'; import { Namespace } from 'ee/iterations/constants';
...@@ -65,9 +66,9 @@ describe('Iterations', () => { ...@@ -65,9 +66,9 @@ describe('Iterations', () => {
describe('pagination', () => { describe('pagination', () => {
const findPagination = () => wrapper.findComponent(GlPagination); const findPagination = () => wrapper.findComponent(GlPagination);
const setPage = (page) => { const setPage = async (page) => {
findPagination().vm.$emit('input', page); findPagination().vm.$emit('input', page);
return findPagination().vm.$nextTick(); await nextTick();
}; };
beforeEach(() => { beforeEach(() => {
...@@ -133,7 +134,7 @@ describe('Iterations', () => { ...@@ -133,7 +134,7 @@ describe('Iterations', () => {
wrapper.findComponent(GlTabs).vm.$emit('activate-tab', 2); wrapper.findComponent(GlTabs).vm.$emit('activate-tab', 2);
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.vm.pagination).toEqual({ expect(wrapper.vm.pagination).toEqual({
currentPage: 1, currentPage: 1,
......
import { GlEmptyState, GlLoadingIcon, GlTab, GlTabs, GlAlert, GlBadge } from '@gitlab/ui'; import { GlEmptyState, GlLoadingIcon, GlTab, GlTabs, GlAlert, GlBadge } from '@gitlab/ui';
import { shallowMount, mount } from '@vue/test-utils'; import { shallowMount, mount } from '@vue/test-utils';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import LicenseComplianceApp from 'ee/license_compliance/components/app.vue'; import LicenseComplianceApp from 'ee/license_compliance/components/app.vue';
...@@ -290,12 +290,11 @@ describe('Project Licenses', () => { ...@@ -290,12 +290,11 @@ describe('Project Licenses', () => {
${'licenses'} | ${'#licenses'} ${'licenses'} | ${'#licenses'}
`( `(
'sets the location hash to "$expectedLocationHash" when the "$givenTab" tab is activate', 'sets the location hash to "$expectedLocationHash" when the "$givenTab" tab is activate',
({ givenActiveTab, expectedLocationHash }) => { async ({ givenActiveTab, expectedLocationHash }) => {
findByTestId(`${givenActiveTab}TabTitle`).trigger('click'); findByTestId(`${givenActiveTab}TabTitle`).trigger('click');
return wrapper.vm.$nextTick().then(() => { await nextTick();
expect(window.location.hash).toBe(expectedLocationHash); expect(window.location.hash).toBe(expectedLocationHash);
});
}, },
); );
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import DetectedLicensesTable from 'ee/license_compliance/components/detected_licenses_table.vue'; import DetectedLicensesTable from 'ee/license_compliance/components/detected_licenses_table.vue';
import LicensesTable from 'ee/license_compliance/components/licenses_table.vue'; import LicensesTable from 'ee/license_compliance/components/licenses_table.vue';
import createStore from 'ee/license_compliance/store'; import createStore from 'ee/license_compliance/store';
...@@ -29,7 +30,7 @@ describe('DetectedLicenesTable component', () => { ...@@ -29,7 +30,7 @@ describe('DetectedLicenesTable component', () => {
expect(componentWrapper.props()).toEqual(expect.objectContaining(props)); expect(componentWrapper.props()).toEqual(expect.objectContaining(props));
}; };
beforeEach(() => { beforeEach(async () => {
factory(); factory();
store.dispatch(`${namespace}/receiveLicensesSuccess`, { store.dispatch(`${namespace}/receiveLicensesSuccess`, {
...@@ -39,7 +40,7 @@ describe('DetectedLicenesTable component', () => { ...@@ -39,7 +40,7 @@ describe('DetectedLicenesTable component', () => {
jest.spyOn(store, 'dispatch').mockImplementation(); jest.spyOn(store, 'dispatch').mockImplementation();
return wrapper.vm.$nextTick(); await nextTick();
}); });
afterEach(() => { afterEach(() => {
...@@ -76,7 +77,7 @@ describe('DetectedLicenesTable component', () => { ...@@ -76,7 +77,7 @@ describe('DetectedLicenesTable component', () => {
`('given $context', ({ isLoading, errorLoading, isListEmpty, initialized }) => { `('given $context', ({ isLoading, errorLoading, isListEmpty, initialized }) => {
let moduleState; let moduleState;
beforeEach(() => { beforeEach(async () => {
moduleState = Object.assign(store.state[namespace], { moduleState = Object.assign(store.state[namespace], {
isLoading, isLoading,
errorLoading, errorLoading,
...@@ -88,7 +89,7 @@ describe('DetectedLicenesTable component', () => { ...@@ -88,7 +89,7 @@ describe('DetectedLicenesTable component', () => {
moduleState.pageInfo.total = 0; moduleState.pageInfo.total = 0;
} }
return wrapper.vm.$nextTick(); await nextTick();
}); });
// See https://github.com/jest-community/eslint-plugin-jest/issues/229 for // See https://github.com/jest-community/eslint-plugin-jest/issues/229 for
......
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { merge } from 'lodash'; import { merge } from 'lodash';
import dastProfilesMock from 'test_fixtures/graphql/on_demand_scans/graphql/dast_profiles.query.graphql.json'; import dastProfilesMock from 'test_fixtures/graphql/on_demand_scans/graphql/dast_profiles.query.graphql.json';
...@@ -204,7 +204,7 @@ describe('Saved tab', () => { ...@@ -204,7 +204,7 @@ describe('Saved tab', () => {
it('put the button in the loading and disabled state', async () => { it('put the button in the loading and disabled state', async () => {
const runScanButton = findRunScanButton(); const runScanButton = findRunScanButton();
runScanButton.vm.$emit('click'); runScanButton.vm.$emit('click');
await wrapper.vm.$nextTick(); await nextTick();
expect(runScanButton.props('loading')).toBe(true); expect(runScanButton.props('loading')).toBe(true);
expect(runScanButton.props('disabled')).toBe(true); expect(runScanButton.props('disabled')).toBe(true);
...@@ -242,7 +242,7 @@ describe('Saved tab', () => { ...@@ -242,7 +242,7 @@ describe('Saved tab', () => {
it('hides the error message when retrying the deletion', async () => { it('hides the error message when retrying the deletion', async () => {
findRunScanButton().vm.$emit('click'); findRunScanButton().vm.$emit('click');
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.text()).not.toContain(errorMessage); expect(wrapper.text()).not.toContain(errorMessage);
}); });
...@@ -328,7 +328,7 @@ describe('Saved tab', () => { ...@@ -328,7 +328,7 @@ describe('Saved tab', () => {
it('hides the error message when retrying the deletion', async () => { it('hides the error message when retrying the deletion', async () => {
findDeleteModal().vm.$emit('ok'); findDeleteModal().vm.$emit('ok');
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.text()).not.toContain(errorMessage); expect(wrapper.text()).not.toContain(errorMessage);
}); });
......
...@@ -2,6 +2,7 @@ import { GlForm, GlFormInput, GlSkeletonLoader } from '@gitlab/ui'; ...@@ -2,6 +2,7 @@ import { GlForm, GlFormInput, GlSkeletonLoader } from '@gitlab/ui';
import { shallowMount, mount, createLocalVue } from '@vue/test-utils'; import { shallowMount, mount, createLocalVue } from '@vue/test-utils';
import { merge } from 'lodash'; import { merge } from 'lodash';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { nextTick } from 'vue';
import OnDemandScansForm from 'ee/on_demand_scans_form/components/on_demand_scans_form.vue'; import OnDemandScansForm from 'ee/on_demand_scans_form/components/on_demand_scans_form.vue';
import ScannerProfileSelector from 'ee/on_demand_scans_form/components/profile_selector/scanner_profile_selector.vue'; import ScannerProfileSelector from 'ee/on_demand_scans_form/components/profile_selector/scanner_profile_selector.vue';
import SiteProfileSelector from 'ee/on_demand_scans_form/components/profile_selector/site_profile_selector.vue'; import SiteProfileSelector from 'ee/on_demand_scans_form/components/profile_selector/site_profile_selector.vue';
...@@ -90,13 +91,13 @@ describe('OnDemandScansForm', () => { ...@@ -90,13 +91,13 @@ describe('OnDemandScansForm', () => {
expect(findSiteProfilesSelector().attributes('value')).toBe(dastScan.dastSiteProfile.id); expect(findSiteProfilesSelector().attributes('value')).toBe(dastScan.dastSiteProfile.id);
}; };
const setValidFormData = () => { const setValidFormData = async () => {
findNameInput().vm.$emit('input', 'My daily scan'); findNameInput().vm.$emit('input', 'My daily scan');
findBranchInput().vm.$emit('input', selectedBranch); findBranchInput().vm.$emit('input', selectedBranch);
findScannerProfilesSelector().vm.$emit('input', passiveScannerProfile.id); findScannerProfilesSelector().vm.$emit('input', passiveScannerProfile.id);
findSiteProfilesSelector().vm.$emit('input', nonValidatedSiteProfile.id); findSiteProfilesSelector().vm.$emit('input', nonValidatedSiteProfile.id);
return wrapper.vm.$nextTick(); await nextTick();
}; };
const setupSuccess = ({ edit = false } = {}) => { const setupSuccess = ({ edit = false } = {}) => {
wrapper.vm.$apollo.mutate.mockResolvedValue({ wrapper.vm.$apollo.mutate.mockResolvedValue({
...@@ -112,7 +113,7 @@ describe('OnDemandScansForm', () => { ...@@ -112,7 +113,7 @@ describe('OnDemandScansForm', () => {
}; };
const selectProfile = (component) => async (profile) => { const selectProfile = (component) => async (profile) => {
wrapper.findComponent(component).vm.$emit('input', profile.id); wrapper.findComponent(component).vm.$emit('input', profile.id);
await wrapper.vm.$nextTick(); await nextTick();
}; };
const selectScannerProfile = selectProfile(ScannerProfileSelector); const selectScannerProfile = selectProfile(ScannerProfileSelector);
const selectSiteProfile = selectProfile(SiteProfileSelector); const selectSiteProfile = selectProfile(SiteProfileSelector);
...@@ -326,7 +327,7 @@ describe('OnDemandScansForm', () => { ...@@ -326,7 +327,7 @@ describe('OnDemandScansForm', () => {
); );
createShallowComponent(); createShallowComponent();
await wrapper.vm.$nextTick(); await nextTick();
expect(findNameInput().attributes('value')).toBe(dastScan.name); expect(findNameInput().attributes('value')).toBe(dastScan.name);
expect(findDescriptionInput().attributes('value')).toBe(dastScan.description); expect(findDescriptionInput().attributes('value')).toBe(dastScan.description);
...@@ -537,10 +538,10 @@ describe('OnDemandScansForm', () => { ...@@ -537,10 +538,10 @@ describe('OnDemandScansForm', () => {
`( `(
'profiles conflict prevention', 'profiles conflict prevention',
({ description, selectedScannerProfile, selectedSiteProfile, hasConflict }) => { ({ description, selectedScannerProfile, selectedSiteProfile, hasConflict }) => {
const setFormData = () => { const setFormData = async () => {
findScannerProfilesSelector().vm.$emit('input', selectedScannerProfile.id); findScannerProfilesSelector().vm.$emit('input', selectedScannerProfile.id);
findSiteProfilesSelector().vm.$emit('input', selectedSiteProfile.id); findSiteProfilesSelector().vm.$emit('input', selectedSiteProfile.id);
return wrapper.vm.$nextTick(); await nextTick();
}; };
it( it(
...@@ -661,7 +662,7 @@ describe('OnDemandScansForm', () => { ...@@ -661,7 +662,7 @@ describe('OnDemandScansForm', () => {
); );
createShallowComponent(); createShallowComponent();
await wrapper.vm.$nextTick(); await nextTick();
hasSiteProfileAttributes(); hasSiteProfileAttributes();
}); });
......
...@@ -2,6 +2,7 @@ import { GlSprintf, GlSkeletonLoader } from '@gitlab/ui'; ...@@ -2,6 +2,7 @@ import { GlSprintf, GlSkeletonLoader } from '@gitlab/ui';
import { createLocalVue } from '@vue/test-utils'; import { createLocalVue } from '@vue/test-utils';
import { merge } from 'lodash'; import { merge } from 'lodash';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { nextTick } from 'vue';
import DastProfilesSelector from 'ee/on_demand_scans_form/components/profile_selector/dast_profiles_selector.vue'; import DastProfilesSelector from 'ee/on_demand_scans_form/components/profile_selector/dast_profiles_selector.vue';
import ScannerProfileSelector from 'ee/on_demand_scans_form/components/profile_selector/scanner_profile_selector.vue'; import ScannerProfileSelector from 'ee/on_demand_scans_form/components/profile_selector/scanner_profile_selector.vue';
import SiteProfileSelector from 'ee/on_demand_scans_form/components/profile_selector/site_profile_selector.vue'; import SiteProfileSelector from 'ee/on_demand_scans_form/components/profile_selector/site_profile_selector.vue';
...@@ -140,10 +141,10 @@ describe('EE - DAST Profiles Selector', () => { ...@@ -140,10 +141,10 @@ describe('EE - DAST Profiles Selector', () => {
`( `(
'profiles conflict prevention', 'profiles conflict prevention',
({ description, selectedScannerProfile, selectedSiteProfile, hasConflict }) => { ({ description, selectedScannerProfile, selectedSiteProfile, hasConflict }) => {
const setFormData = () => { const setFormData = async () => {
findScannerProfilesSelector().vm.$emit('input', selectedScannerProfile.id); findScannerProfilesSelector().vm.$emit('input', selectedScannerProfile.id);
findSiteProfilesSelector().vm.$emit('input', selectedSiteProfile.id); findSiteProfilesSelector().vm.$emit('input', selectedSiteProfile.id);
return wrapper.vm.$nextTick(); await nextTick();
}; };
it( it(
......
import { GlDatepicker, GlFormCheckbox, GlFormGroup } from '@gitlab/ui'; import { GlDatepicker, GlFormCheckbox, GlFormGroup } from '@gitlab/ui';
import { merge } from 'lodash'; import { merge } from 'lodash';
import { nextTick } from 'vue';
import mockTimezones from 'test_fixtures/timezones/full.json'; import mockTimezones from 'test_fixtures/timezones/full.json';
import ScanSchedule from 'ee/on_demand_scans_form/components/scan_schedule.vue'; import ScanSchedule from 'ee/on_demand_scans_form/components/scan_schedule.vue';
import { SCAN_CADENCE_OPTIONS } from 'ee/on_demand_scans_form/settings'; import { SCAN_CADENCE_OPTIONS } from 'ee/on_demand_scans_form/settings';
...@@ -22,11 +23,11 @@ describe('ScanSchedule', () => { ...@@ -22,11 +23,11 @@ describe('ScanSchedule', () => {
const findCadenceInput = () => wrapper.findComponent(DropdownInput); const findCadenceInput = () => wrapper.findComponent(DropdownInput);
// Helpers // Helpers
const setTimeInputValue = (value) => { const setTimeInputValue = async (value) => {
const input = findTimeInput(); const input = findTimeInput();
input.element.value = value; input.element.value = value;
input.trigger('input'); input.trigger('input');
return wrapper.vm.$nextTick(); await nextTick();
}; };
const createComponent = (options = {}) => { const createComponent = (options = {}) => {
...@@ -135,14 +136,14 @@ describe('ScanSchedule', () => { ...@@ -135,14 +136,14 @@ describe('ScanSchedule', () => {
it('emits computed cadence value', async () => { it('emits computed cadence value', async () => {
findCadenceInput().vm.$emit('input', SCAN_CADENCE_OPTIONS[5].value); findCadenceInput().vm.$emit('input', SCAN_CADENCE_OPTIONS[5].value);
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.emitted().input[1][0].cadence).toEqual({ unit: 'MONTH', duration: 6 }); expect(wrapper.emitted().input[1][0].cadence).toEqual({ unit: 'MONTH', duration: 6 });
}); });
it('deactives schedule when checkbox is unchecked', async () => { it('deactives schedule when checkbox is unchecked', async () => {
findCheckbox().vm.$emit('input', false); findCheckbox().vm.$emit('input', false);
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.emitted().input).toHaveLength(2); expect(wrapper.emitted().input).toHaveLength(2);
expect(wrapper.emitted().input[1]).toEqual([ expect(wrapper.emitted().input[1]).toEqual([
......
import { GlSearchBoxByType, GlDropdown, GlDropdownItem, GlFormGroup } from '@gitlab/ui'; import { GlSearchBoxByType, GlDropdown, GlDropdownItem, GlFormGroup } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import mockTimezones from 'test_fixtures/timezones/full.json'; import mockTimezones from 'test_fixtures/timezones/full.json';
import AddEditScheduleForm, { import AddEditScheduleForm, {
i18n, i18n,
...@@ -97,7 +98,7 @@ describe('AddEditScheduleForm', () => { ...@@ -97,7 +98,7 @@ describe('AddEditScheduleForm', () => {
it('should filter options based on search term', async () => { it('should filter options based on search term', async () => {
const searchTerm = 'Pacific'; const searchTerm = 'Pacific';
findTimezoneSearchBox().vm.$emit('input', searchTerm); findTimezoneSearchBox().vm.$emit('input', searchTerm);
await wrapper.vm.$nextTick(); await nextTick();
const options = findDropdownOptions(); const options = findDropdownOptions();
expect(options).toHaveLength(1); expect(options).toHaveLength(1);
expect(options.at(0).text()).toContain(searchTerm); expect(options.at(0).text()).toContain(searchTerm);
...@@ -106,7 +107,7 @@ describe('AddEditScheduleForm', () => { ...@@ -106,7 +107,7 @@ describe('AddEditScheduleForm', () => {
it('should display no results item when there are no filter matches', async () => { it('should display no results item when there are no filter matches', async () => {
const searchTerm = 'someUnexistentTZ'; const searchTerm = 'someUnexistentTZ';
findTimezoneSearchBox().vm.$emit('input', searchTerm); findTimezoneSearchBox().vm.$emit('input', searchTerm);
await wrapper.vm.$nextTick(); await nextTick();
const options = findDropdownOptions(); const options = findDropdownOptions();
expect(options).toHaveLength(1); expect(options).toHaveLength(1);
expect(options.at(0).text()).toContain(i18n.noResults); expect(options.at(0).text()).toContain(i18n.noResults);
...@@ -116,7 +117,7 @@ describe('AddEditScheduleForm', () => { ...@@ -116,7 +117,7 @@ describe('AddEditScheduleForm', () => {
it('should add a checkmark to the selected option', async () => { it('should add a checkmark to the selected option', async () => {
const selectedTZOption = findDropdownOptions().at(0); const selectedTZOption = findDropdownOptions().at(0);
selectedTZOption.vm.$emit('click'); selectedTZOption.vm.$emit('click');
await wrapper.vm.$nextTick(); await nextTick();
expect(selectedTZOption.attributes('ischecked')).toBe('true'); expect(selectedTZOption.attributes('ischecked')).toBe('true');
}); });
}); });
......
import { GlModal, GlAlert, GlSprintf } from '@gitlab/ui'; import { GlModal, GlAlert, GlSprintf } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { nextTick } from 'vue';
import DeleteScheduleModal, { import DeleteScheduleModal, {
i18n, i18n,
} from 'ee/oncall_schedules/components/delete_schedule_modal.vue'; } from 'ee/oncall_schedules/components/delete_schedule_modal.vue';
...@@ -147,7 +148,7 @@ describe('DeleteScheduleModal', () => { ...@@ -147,7 +148,7 @@ describe('DeleteScheduleModal', () => {
createComponentWithApollo(); createComponentWithApollo();
await jest.runOnlyPendingTimers(); await jest.runOnlyPendingTimers();
await wrapper.vm.$nextTick(); await nextTick();
expect(findModal().attributes('data-testid')).toBe(`delete-schedule-modal-${schedule.iid}`); expect(findModal().attributes('data-testid')).toBe(`delete-schedule-modal-${schedule.iid}`);
}); });
......
import { GlDropdownItem, GlTokenSelector, GlFormGroup, GlToggle } from '@gitlab/ui'; import { GlDropdownItem, GlTokenSelector, GlFormGroup, GlToggle } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { cloneDeep, merge } from 'lodash'; import { cloneDeep, merge } from 'lodash';
import { nextTick } from 'vue';
import AddEditRotationForm from 'ee/oncall_schedules/components/rotations/components/add_edit_rotation_form.vue'; import AddEditRotationForm from 'ee/oncall_schedules/components/rotations/components/add_edit_rotation_form.vue';
import { formEmptyState } from 'ee/oncall_schedules/components/rotations/components/add_edit_rotation_modal.vue'; import { formEmptyState } from 'ee/oncall_schedules/components/rotations/components/add_edit_rotation_modal.vue';
import { LENGTH_ENUM } from 'ee/oncall_schedules/constants'; import { LENGTH_ENUM } from 'ee/oncall_schedules/constants';
...@@ -121,7 +122,7 @@ describe('AddEditRotationForm', () => { ...@@ -121,7 +122,7 @@ describe('AddEditRotationForm', () => {
}, },
}, },
}); });
await wrapper.vm.$nextTick(); await nextTick();
expect(findStartsOnTimeOptions().at(time).props('isChecked')).toBe(true); expect(findStartsOnTimeOptions().at(time).props('isChecked')).toBe(true);
}); });
}); });
...@@ -183,7 +184,7 @@ describe('AddEditRotationForm', () => { ...@@ -183,7 +184,7 @@ describe('AddEditRotationForm', () => {
}, },
}); });
findEndDateToggle().vm.$emit('change', true); findEndDateToggle().vm.$emit('change', true);
await wrapper.vm.$nextTick(); await nextTick();
expect(findEndsOnTimeOptions().at(time).props('isChecked')).toBe(true); expect(findEndsOnTimeOptions().at(time).props('isChecked')).toBe(true);
}); });
}); });
......
import { GlAlert, GlModal } from '@gitlab/ui'; import { GlAlert, GlModal } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { nextTick } from 'vue';
import AddEditRotationForm from 'ee/oncall_schedules/components/rotations/components/add_edit_rotation_form.vue'; import AddEditRotationForm from 'ee/oncall_schedules/components/rotations/components/add_edit_rotation_form.vue';
import AddEditRotationModal, { import AddEditRotationModal, {
i18n, i18n,
...@@ -147,7 +148,7 @@ describe('AddEditRotationModal', () => { ...@@ -147,7 +148,7 @@ describe('AddEditRotationModal', () => {
mutation: expect.any(Object), mutation: expect.any(Object),
variables: { input: expect.objectContaining({ projectPath }) }, variables: { input: expect.objectContaining({ projectPath }) },
}); });
await wrapper.vm.$nextTick(); await nextTick();
expect(findForm().props('form').name).toBe(undefined); expect(findForm().props('form').name).toBe(undefined);
}); });
...@@ -279,7 +280,7 @@ describe('AddEditRotationModal', () => { ...@@ -279,7 +280,7 @@ describe('AddEditRotationModal', () => {
it('should disable primary button when any of the fields is invalid', async () => { it('should disable primary button when any of the fields is invalid', async () => {
const form = findForm(); const form = findForm();
form.vm.$emit('update-rotation-form', { type: 'name', value: 'lalal' }); form.vm.$emit('update-rotation-form', { type: 'name', value: 'lalal' });
await wrapper.vm.$nextTick(); await nextTick();
expect(findModal().props('actionPrimary').attributes).toEqual( expect(findModal().props('actionPrimary').attributes).toEqual(
expect.arrayContaining([{ disabled: true }]), expect.arrayContaining([{ disabled: true }]),
); );
...@@ -297,7 +298,7 @@ describe('AddEditRotationModal', () => { ...@@ -297,7 +298,7 @@ describe('AddEditRotationModal', () => {
type: 'endsAt.date', type: 'endsAt.date',
value: new Date('12/10/2021'), value: new Date('12/10/2021'),
}); });
await wrapper.vm.$nextTick(); await nextTick();
expect(findModal().props('actionPrimary').attributes).toEqual( expect(findModal().props('actionPrimary').attributes).toEqual(
expect.arrayContaining([{ disabled: false }]), expect.arrayContaining([{ disabled: false }]),
); );
......
import { GlModal, GlAlert, GlSprintf } from '@gitlab/ui'; import { GlModal, GlAlert, GlSprintf } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { nextTick } from 'vue';
import DeleteRotationModal, { import DeleteRotationModal, {
i18n, i18n,
} from 'ee/oncall_schedules/components/rotations/components/delete_rotation_modal.vue'; } from 'ee/oncall_schedules/components/rotations/components/delete_rotation_modal.vue';
...@@ -153,7 +154,7 @@ describe('DeleteRotationModal', () => { ...@@ -153,7 +154,7 @@ describe('DeleteRotationModal', () => {
createComponentWithApollo(); createComponentWithApollo();
await jest.runOnlyPendingTimers(); await jest.runOnlyPendingTimers();
await wrapper.vm.$nextTick(); await nextTick();
expect(findModal().attributes('data-testid')).toBe(`delete-rotation-modal-${rotation.id}`); expect(findModal().attributes('data-testid')).toBe(`delete-rotation-modal-${rotation.id}`);
}); });
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import ProjectHeader from 'ee/operations/components/dashboard/project_header.vue'; import ProjectHeader from 'ee/operations/components/dashboard/project_header.vue';
import { trimText } from 'helpers/text_helper'; import { trimText } from 'helpers/text_helper';
import ProjectAvatar from '~/vue_shared/components/deprecated_project_avatar/default.vue'; import ProjectAvatar from '~/vue_shared/components/deprecated_project_avatar/default.vue';
...@@ -48,12 +49,11 @@ describe('project header component', () => { ...@@ -48,12 +49,11 @@ describe('project header component', () => {
expect(button.attributes('title')).toBe('Remove card'); expect(button.attributes('title')).toBe('Remove card');
}); });
it('emits project removal link on click', () => { it('emits project removal link on click', async () => {
wrapper.find('.js-remove-button').vm.$emit('click'); wrapper.find('.js-remove-button').vm.$emit('click');
return wrapper.vm.$nextTick().then(() => { await nextTick();
expect(wrapper.emitted().remove).toStrictEqual([[mockOneProject.remove_path]]); expect(wrapper.emitted().remove).toStrictEqual([[mockOneProject.remove_path]]);
});
}); });
}); });
......
import { GlTable, GlDeprecatedSkeletonLoading as GlSkeletonLoading } from '@gitlab/ui'; import { GlTable, GlDeprecatedSkeletonLoading as GlSkeletonLoading } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import MembersApp from 'ee/pages/groups/saml_providers/saml_members/index.vue'; import MembersApp from 'ee/pages/groups/saml_providers/saml_members/index.vue';
import createInitialState from 'ee/pages/groups/saml_providers/saml_members/store/state'; import createInitialState from 'ee/pages/groups/saml_providers/saml_members/store/state';
...@@ -66,12 +66,11 @@ describe('SAML providers members app', () => { ...@@ -66,12 +66,11 @@ describe('SAML providers members app', () => {
expect(wrapper.findComponent(GlTable).exists()).toBe(true); expect(wrapper.findComponent(GlTable).exists()).toBe(true);
}); });
it('requests next page when pagination component performs change', () => { it('requests next page when pagination component performs change', async () => {
const changeFn = wrapper.findComponent(TablePagination).props('change'); const changeFn = wrapper.findComponent(TablePagination).props('change');
changeFn(2); changeFn(2);
return wrapper.vm.$nextTick(() => { await nextTick();
expect(fetchPageMock).toHaveBeenCalledWith(expect.anything(), 2); expect(fetchPageMock).toHaveBeenCalledWith(expect.anything(), 2);
});
}); });
}); });
}); });
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import BlockingMrInputRoot from 'ee/projects/merge_requests/blocking_mr_input_root.vue'; import BlockingMrInputRoot from 'ee/projects/merge_requests/blocking_mr_input_root.vue';
import RelatedIssuableInput from '~/related_issues/components/related_issuable_input.vue'; import RelatedIssuableInput from '~/related_issues/components/related_issuable_input.vue';
...@@ -86,22 +87,20 @@ describe('blocking mr input root', () => { ...@@ -86,22 +87,20 @@ describe('blocking mr input root', () => {
expectShouldUpdateRefsToBe(false); expectShouldUpdateRefsToBe(false);
}); });
it('is true after a ref is removed', () => { it('is true after a ref is removed', async () => {
createComponent({ existingRefs: ['!1'] }); createComponent({ existingRefs: ['!1'] });
removeRef(0); removeRef(0);
return wrapper.vm.$nextTick().then(() => { await nextTick();
expectShouldUpdateRefsToBe(true); expectShouldUpdateRefsToBe(true);
});
}); });
it('is true after a ref is added', () => { it('is true after a ref is added', async () => {
createComponent(); createComponent();
addTokenizedInput('foo'); addTokenizedInput('foo');
return wrapper.vm.$nextTick(() => { await nextTick();
expectShouldUpdateRefsToBe(true); expectShouldUpdateRefsToBe(true);
});
}); });
}); });
...@@ -129,13 +128,12 @@ describe('blocking mr input root', () => { ...@@ -129,13 +128,12 @@ describe('blocking mr input root', () => {
expectRemoveHiddenBlockingMergeRequestsToBe(false); expectRemoveHiddenBlockingMergeRequestsToBe(false);
}); });
it('is false when ref has been removed', () => { it('is false when ref has been removed', async () => {
makeComponentWithHiddenMrs(); makeComponentWithHiddenMrs();
removeRef(2); removeRef(2);
return wrapper.vm.$nextTick().then(() => { await nextTick();
expectRemoveHiddenBlockingMergeRequestsToBe(true); expectRemoveHiddenBlockingMergeRequestsToBe(true);
});
}); });
}); });
}); });
......
import { GlToggle } from '@gitlab/ui'; import { GlToggle } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import MockAxiosAdapter from 'axios-mock-adapter'; import MockAxiosAdapter from 'axios-mock-adapter';
import { nextTick } from 'vue';
import CcValidationRequiredAlert from 'ee_component/billings/components/cc_validation_required_alert.vue'; import CcValidationRequiredAlert from 'ee_component/billings/components/cc_validation_required_alert.vue';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
...@@ -67,7 +68,7 @@ describe('projects/settings/components/shared_runners', () => { ...@@ -67,7 +68,7 @@ describe('projects/settings/components/shared_runners', () => {
it('credit card alert should be hidden after dismiss', async () => { it('credit card alert should be hidden after dismiss', async () => {
findCcValidationRequiredAlert().vm.$emit('dismiss'); findCcValidationRequiredAlert().vm.$emit('dismiss');
await wrapper.vm.$nextTick(); await nextTick();
expect(findCcValidationRequiredAlert().exists()).toBe(false); expect(findCcValidationRequiredAlert().exists()).toBe(false);
}); });
......
import { GlFormInput, GlButton, GlDropdownItem } from '@gitlab/ui'; import { GlFormInput, GlButton, GlDropdownItem } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import axios from 'axios'; import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import Vuex from 'vuex'; import Vuex from 'vuex';
...@@ -47,7 +47,7 @@ describe('RelatedItemsTree', () => { ...@@ -47,7 +47,7 @@ describe('RelatedItemsTree', () => {
expect(wrapper.vm.isSubmitButtonDisabled).toBe(true); expect(wrapper.vm.isSubmitButtonDisabled).toBe(true);
}); });
it('returns false when either `inputValue` prop is non-empty or `isSubmitting` prop is false', () => { it('returns false when either `inputValue` prop is non-empty or `isSubmitting` prop is false', async () => {
const wrapperWithInput = createComponent(false); const wrapperWithInput = createComponent(false);
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
...@@ -56,23 +56,21 @@ describe('RelatedItemsTree', () => { ...@@ -56,23 +56,21 @@ describe('RelatedItemsTree', () => {
inputValue: 'foo', inputValue: 'foo',
}); });
return wrapperWithInput.vm.$nextTick(() => { await nextTick();
expect(wrapperWithInput.vm.isSubmitButtonDisabled).toBe(false); expect(wrapperWithInput.vm.isSubmitButtonDisabled).toBe(false);
wrapperWithInput.destroy(); wrapperWithInput.destroy();
});
}); });
}); });
describe('buttonLabel', () => { describe('buttonLabel', () => {
it('returns string "Creating epic" when `isSubmitting` prop is true', () => { it('returns string "Creating epic" when `isSubmitting` prop is true', async () => {
const wrapperSubmitting = createComponent(true); const wrapperSubmitting = createComponent(true);
return wrapperSubmitting.vm.$nextTick(() => { await nextTick();
expect(wrapperSubmitting.vm.buttonLabel).toBe('Creating epic'); expect(wrapperSubmitting.vm.buttonLabel).toBe('Creating epic');
wrapperSubmitting.destroy(); wrapperSubmitting.destroy();
});
}); });
it('returns string "Create epic" when `isSubmitting` prop is false', () => { it('returns string "Create epic" when `isSubmitting` prop is false', () => {
......
...@@ -9,7 +9,7 @@ import { ...@@ -9,7 +9,7 @@ import {
GlDropdownSectionHeader, GlDropdownSectionHeader,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import mockProjects from 'test_fixtures_static/projects.json'; import mockProjects from 'test_fixtures_static/projects.json';
...@@ -72,16 +72,15 @@ describe('CreateIssueForm', () => { ...@@ -72,16 +72,15 @@ describe('CreateIssueForm', () => {
describe('computed', () => { describe('computed', () => {
describe('dropdownToggleText', () => { describe('dropdownToggleText', () => {
it('returns project name with name_with_namespace when `selectedProject` is not empty', () => { it('returns project name with name_with_namespace when `selectedProject` is not empty', async () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
wrapper.setData({ wrapper.setData({
selectedProject: mockProjects[0], selectedProject: mockProjects[0],
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.dropdownToggleText).toBe(mockProjects[0].name_with_namespace); expect(wrapper.vm.dropdownToggleText).toBe(mockProjects[0].name_with_namespace);
});
}); });
it('returns project name with namespace when `selectedProject` is not empty and dont have name_with_namespace', async () => { it('returns project name with namespace when `selectedProject` is not empty and dont have name_with_namespace', async () => {
const project = { ...mockProjects[0], name_with_namespace: undefined, namespace: 'foo' }; const project = { ...mockProjects[0], name_with_namespace: undefined, namespace: 'foo' };
...@@ -91,7 +90,7 @@ describe('CreateIssueForm', () => { ...@@ -91,7 +90,7 @@ describe('CreateIssueForm', () => {
selectedProject: project, selectedProject: project,
}); });
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.vm.dropdownToggleText).toBe(project.namespace); expect(wrapper.vm.dropdownToggleText).toBe(project.namespace);
}); });
...@@ -100,17 +99,16 @@ describe('CreateIssueForm', () => { ...@@ -100,17 +99,16 @@ describe('CreateIssueForm', () => {
describe('methods', () => { describe('methods', () => {
describe('cancel', () => { describe('cancel', () => {
it('emits event `cancel` on component', () => { it('emits event `cancel` on component', async () => {
wrapper.vm.cancel(); wrapper.vm.cancel();
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.emitted('cancel')).toBeTruthy(); expect(wrapper.emitted('cancel')).toBeTruthy();
});
}); });
}); });
describe('createIssue', () => { describe('createIssue', () => {
it('emits event `submit` on component when `selectedProject` is not empty', () => { it('emits event `submit` on component when `selectedProject` is not empty', async () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
wrapper.setData({ wrapper.setData({
...@@ -125,11 +123,10 @@ describe('CreateIssueForm', () => { ...@@ -125,11 +123,10 @@ describe('CreateIssueForm', () => {
wrapper.vm.createIssue(); wrapper.vm.createIssue();
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.emitted('submit')[0]).toEqual( expect(wrapper.emitted('submit')[0]).toEqual(
expect.arrayContaining([{ issuesEndpoint: 'foo', title: 'Some issue' }]), expect.arrayContaining([{ issuesEndpoint: 'foo', title: 'Some issue' }]),
); );
});
}); });
}); });
...@@ -164,21 +161,20 @@ describe('CreateIssueForm', () => { ...@@ -164,21 +161,20 @@ describe('CreateIssueForm', () => {
expect(projectsDropdownButton.props('text')).toBe('Select a project'); expect(projectsDropdownButton.props('text')).toBe('Select a project');
}); });
it('renders Projects dropdown contents', () => { it('renders Projects dropdown contents', async () => {
wrapper.vm.$store.dispatch('receiveProjectsSuccess', mockProjects); wrapper.vm.$store.dispatch('receiveProjectsSuccess', mockProjects);
return wrapper.vm.$nextTick(() => { await nextTick();
const projectsDropdownButton = wrapper.findComponent(GlDropdown); const projectsDropdownButton = wrapper.findComponent(GlDropdown);
const dropdownItems = projectsDropdownButton.findAllComponents(GlDropdownItem); const dropdownItems = projectsDropdownButton.findAllComponents(GlDropdownItem);
const dropdownItem = dropdownItems.at(0); const dropdownItem = dropdownItems.at(0);
expect(projectsDropdownButton.findComponent(GlSearchBoxByType).exists()).toBe(true); expect(projectsDropdownButton.findComponent(GlSearchBoxByType).exists()).toBe(true);
expect(projectsDropdownButton.findComponent(GlLoadingIcon).exists()).toBe(true); expect(projectsDropdownButton.findComponent(GlLoadingIcon).exists()).toBe(true);
expect(dropdownItems).toHaveLength(mockProjects.length); expect(dropdownItems).toHaveLength(mockProjects.length);
expect(dropdownItem.text()).toContain(mockProjects[0].name); expect(dropdownItem.text()).toContain(mockProjects[0].name);
expect(dropdownItem.text()).toContain(mockProjects[0].namespace.name); expect(dropdownItem.text()).toContain(mockProjects[0].namespace.name);
expect(dropdownItem.findComponent(ProjectAvatar).exists()).toBe(true); expect(dropdownItem.findComponent(ProjectAvatar).exists()).toBe(true);
});
}); });
it('renders dropdown contents without recent items when `recentItems` are empty', () => { it('renders dropdown contents without recent items when `recentItems` are empty', () => {
...@@ -195,7 +191,7 @@ describe('CreateIssueForm', () => { ...@@ -195,7 +191,7 @@ describe('CreateIssueForm', () => {
wrapper.vm.setRecentItems(); wrapper.vm.setRecentItems();
await wrapper.vm.$nextTick(); await nextTick();
const projectsDropdownButton = wrapper.findComponent(GlDropdown); const projectsDropdownButton = wrapper.findComponent(GlDropdown);
...@@ -216,7 +212,7 @@ describe('CreateIssueForm', () => { ...@@ -216,7 +212,7 @@ describe('CreateIssueForm', () => {
wrapper.vm.setRecentItems(); wrapper.vm.setRecentItems();
await wrapper.vm.$nextTick(); await nextTick();
const projectsDropdownButton = wrapper.findComponent(GlDropdown); const projectsDropdownButton = wrapper.findComponent(GlDropdown);
...@@ -229,7 +225,7 @@ describe('CreateIssueForm', () => { ...@@ -229,7 +225,7 @@ describe('CreateIssueForm', () => {
removeLocalstorageFrequentItems(); removeLocalstorageFrequentItems();
}); });
it('renders Projects dropdown contents containing only matching project when searchKey is provided', () => { it('renders Projects dropdown contents containing only matching project when searchKey is provided', async () => {
const searchKey = 'Underscore'; const searchKey = 'Underscore';
const filteredMockProjects = mockProjects.filter((project) => project.name === searchKey); const filteredMockProjects = mockProjects.filter((project) => project.name === searchKey);
jest.spyOn(wrapper.vm, 'fetchProjects').mockImplementation(jest.fn()); jest.spyOn(wrapper.vm, 'fetchProjects').mockImplementation(jest.fn());
...@@ -242,17 +238,12 @@ describe('CreateIssueForm', () => { ...@@ -242,17 +238,12 @@ describe('CreateIssueForm', () => {
searchKey, searchKey,
}); });
return wrapper.vm await nextTick();
.$nextTick() await wrapper.vm.$store.dispatch('receiveProjectsSuccess', filteredMockProjects);
.then(() => { expect(wrapper.findAllComponents(GlDropdownItem)).toHaveLength(1);
wrapper.vm.$store.dispatch('receiveProjectsSuccess', filteredMockProjects);
})
.then(() => {
expect(wrapper.findAllComponents(GlDropdownItem)).toHaveLength(1);
});
}); });
it('renders Projects dropdown contents containing string string "No matches found" when searchKey provided does not match any project', () => { it('renders Projects dropdown contents containing string string "No matches found" when searchKey provided does not match any project', async () => {
const searchKey = "this-project-shouldn't exist"; const searchKey = "this-project-shouldn't exist";
const filteredMockProjects = mockProjects.filter((project) => project.name === searchKey); const filteredMockProjects = mockProjects.filter((project) => project.name === searchKey);
jest.spyOn(wrapper.vm, 'fetchProjects').mockImplementation(jest.fn()); jest.spyOn(wrapper.vm, 'fetchProjects').mockImplementation(jest.fn());
...@@ -265,14 +256,9 @@ describe('CreateIssueForm', () => { ...@@ -265,14 +256,9 @@ describe('CreateIssueForm', () => {
searchKey, searchKey,
}); });
return wrapper.vm await nextTick();
.$nextTick() await wrapper.vm.$store.dispatch('receiveProjectsSuccess', filteredMockProjects);
.then(() => { expect(wrapper.find('.dropdown-contents').text()).toContain('No matches found');
wrapper.vm.$store.dispatch('receiveProjectsSuccess', filteredMockProjects);
})
.then(() => {
expect(wrapper.find('.dropdown-contents').text()).toContain('No matches found');
});
}); });
it('renders `Create issue` button', () => { it('renders `Create issue` button', () => {
...@@ -282,29 +268,27 @@ describe('CreateIssueForm', () => { ...@@ -282,29 +268,27 @@ describe('CreateIssueForm', () => {
expect(createIssueButton.text()).toBe('Create issue'); expect(createIssueButton.text()).toBe('Create issue');
}); });
it('renders loading icon within `Create issue` button when `itemCreateInProgress` is true', () => { it('renders loading icon within `Create issue` button when `itemCreateInProgress` is true', async () => {
wrapper.vm.$store.dispatch('requestCreateItem'); wrapper.vm.$store.dispatch('requestCreateItem');
return wrapper.vm.$nextTick(() => { await nextTick();
const createIssueButton = wrapper.findAllComponents(GlButton).at(0); const createIssueButton = wrapper.findAllComponents(GlButton).at(0);
expect(createIssueButton.exists()).toBe(true); expect(createIssueButton.exists()).toBe(true);
expect(createIssueButton.props('disabled')).toBe(true); expect(createIssueButton.props('disabled')).toBe(true);
expect(createIssueButton.props('loading')).toBe(true); expect(createIssueButton.props('loading')).toBe(true);
});
}); });
it('renders loading icon within `Create issue` button when `recentItemFetchInProgress` is true', () => { it('renders loading icon within `Create issue` button when `recentItemFetchInProgress` is true', async () => {
wrapper.vm.recentItemFetchInProgress = true; wrapper.vm.recentItemFetchInProgress = true;
return wrapper.vm.$nextTick(() => { await nextTick();
const createIssueButton = wrapper.findAllComponents(GlButton).at(0); const createIssueButton = wrapper.findAllComponents(GlButton).at(0);
expect(createIssueButton.exists()).toBe(true); expect(createIssueButton.exists()).toBe(true);
expect(createIssueButton.props()).toMatchObject({ expect(createIssueButton.props()).toMatchObject({
disabled: true, disabled: true,
loading: true, loading: true,
});
}); });
}); });
......
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import AxiosMockAdapter from 'axios-mock-adapter'; import AxiosMockAdapter from 'axios-mock-adapter';
import Vuex from 'vuex'; import Vuex from 'vuex';
...@@ -201,44 +201,41 @@ describe('RelatedItemsTreeApp', () => { ...@@ -201,44 +201,41 @@ describe('RelatedItemsTreeApp', () => {
}); });
}); });
it('renders loading icon when `state.itemsFetchInProgress` prop is true', () => { it('renders loading icon when `state.itemsFetchInProgress` prop is true', async () => {
wrapper.vm.$store.dispatch('requestItems', { wrapper.vm.$store.dispatch('requestItems', {
parentItem: mockParentItem, parentItem: mockParentItem,
isSubItem: false, isSubItem: false,
}); });
return wrapper.vm.$nextTick().then(() => { await nextTick();
expect(wrapper.findComponent(GlLoadingIcon).isVisible()).toBe(true); expect(wrapper.findComponent(GlLoadingIcon).isVisible()).toBe(true);
});
}); });
it('renders tree container element when `state.itemsFetchInProgress` prop is false', () => it('renders tree container element when `state.itemsFetchInProgress` prop is false', async () => {
wrapper.vm.$nextTick().then(() => { await nextTick();
expect(wrapper.find('.related-items-tree').isVisible()).toBe(true); expect(wrapper.find('.related-items-tree').isVisible()).toBe(true);
})); });
it('renders tree container element with `disabled-content` class when `state.itemsFetchInProgress` prop is false and `state.itemAddInProgress` or `state.itemCreateInProgress` is true', () => { it('renders tree container element with `disabled-content` class when `state.itemsFetchInProgress` prop is false and `state.itemAddInProgress` or `state.itemCreateInProgress` is true', async () => {
wrapper.vm.$store.dispatch('requestAddItem'); wrapper.vm.$store.dispatch('requestAddItem');
return wrapper.vm.$nextTick().then(() => { await nextTick();
expect(wrapper.find('.related-items-tree.disabled-content').isVisible()).toBe(true); expect(wrapper.find('.related-items-tree.disabled-content').isVisible()).toBe(true);
});
}); });
it('renders tree header component', () => it('renders tree header component', async () => {
wrapper.vm.$nextTick().then(() => { await nextTick();
expect(wrapper.findComponent(RelatedItemsTreeHeader).isVisible()).toBe(true); expect(wrapper.findComponent(RelatedItemsTreeHeader).isVisible()).toBe(true);
})); });
it('renders item add/create form container element', () => { it('renders item add/create form container element', async () => {
wrapper.vm.$store.dispatch('toggleAddItemForm', { wrapper.vm.$store.dispatch('toggleAddItemForm', {
toggleState: true, toggleState: true,
issuableType: issuableTypesMap.EPIC, issuableType: issuableTypesMap.EPIC,
}); });
return wrapper.vm.$nextTick().then(() => { await nextTick();
expect(wrapper.find('.add-item-form-container').isVisible()).toBe(true); expect(wrapper.find('.add-item-form-container').isVisible()).toBe(true);
});
}); });
it('does not render create issue form', () => { it('does not render create issue form', () => {
...@@ -265,7 +262,7 @@ describe('RelatedItemsTreeApp', () => { ...@@ -265,7 +262,7 @@ describe('RelatedItemsTreeApp', () => {
wrapper.vm.$store.state.autoCompleteIssues = autoCompleteIssues; wrapper.vm.$store.state.autoCompleteIssues = autoCompleteIssues;
wrapper.vm.$store.state.autoCompleteEpics = autoCompleteEpics; wrapper.vm.$store.state.autoCompleteEpics = autoCompleteEpics;
await wrapper.vm.$nextTick(); await nextTick();
expect(findAddItemForm().props()).toMatchObject({ expect(findAddItemForm().props()).toMatchObject({
autoCompleteIssues: expectedAutoCompleteIssues, autoCompleteIssues: expectedAutoCompleteIssues,
......
import { GlTooltip, GlIcon } from '@gitlab/ui'; import { GlTooltip, GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import EpicHealthStatus from 'ee/related_items_tree/components/epic_health_status.vue'; import EpicHealthStatus from 'ee/related_items_tree/components/epic_health_status.vue';
...@@ -222,13 +222,13 @@ describe('RelatedItemsTree', () => { ...@@ -222,13 +222,13 @@ describe('RelatedItemsTree', () => {
}); });
describe('when issuable-health-status feature is not available', () => { describe('when issuable-health-status feature is not available', () => {
beforeEach(() => { beforeEach(async () => {
wrapper.vm.$store.commit('SET_INITIAL_CONFIG', { wrapper.vm.$store.commit('SET_INITIAL_CONFIG', {
...mockInitialConfig, ...mockInitialConfig,
allowIssuableHealthStatus: false, allowIssuableHealthStatus: false,
}); });
return wrapper.vm.$nextTick(); await nextTick();
}); });
it('does not render health status', () => { it('does not render health status', () => {
...@@ -237,13 +237,13 @@ describe('RelatedItemsTree', () => { ...@@ -237,13 +237,13 @@ describe('RelatedItemsTree', () => {
}); });
describe('when issuable-health-status feature is available', () => { describe('when issuable-health-status feature is available', () => {
beforeEach(() => { beforeEach(async () => {
wrapper.vm.$store.commit('SET_INITIAL_CONFIG', { wrapper.vm.$store.commit('SET_INITIAL_CONFIG', {
...mockInitialConfig, ...mockInitialConfig,
allowIssuableHealthStatus: true, allowIssuableHealthStatus: true,
}); });
return wrapper.vm.$nextTick(); await nextTick();
}); });
it('does not render health status', () => { it('does not render health status', () => {
......
import { GlTooltip } from '@gitlab/ui'; import { GlTooltip } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import StateTooltip from 'ee/related_items_tree/components/state_tooltip.vue'; import StateTooltip from 'ee/related_items_tree/components/state_tooltip.vue';
// Ensure that mock dates dynamically computed from today // Ensure that mock dates dynamically computed from today
...@@ -48,24 +49,22 @@ describe('RelatedItemsTree', () => { ...@@ -48,24 +49,22 @@ describe('RelatedItemsTree', () => {
describe('computed', () => { describe('computed', () => {
describe('stateText', () => { describe('stateText', () => {
it('returns string `Created` when `isOpen` prop is true', () => { it('returns string `Created` when `isOpen` prop is true', async () => {
wrapper.setProps({ wrapper.setProps({
isOpen: true, isOpen: true,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.stateText).toBe('Created'); expect(wrapper.vm.stateText).toBe('Created');
});
}); });
it('returns string `Closed` when `isOpen` prop is false', () => { it('returns string `Closed` when `isOpen` prop is false', async () => {
wrapper.setProps({ wrapper.setProps({
isOpen: false, isOpen: false,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.stateText).toBe('Closed'); expect(wrapper.vm.stateText).toBe('Closed');
});
}); });
}); });
...@@ -94,46 +93,42 @@ describe('RelatedItemsTree', () => { ...@@ -94,46 +93,42 @@ describe('RelatedItemsTree', () => {
}); });
describe('stateTimeInWords', () => { describe('stateTimeInWords', () => {
it('returns string using `createdAtInWords` prop when `isOpen` is true', () => { it('returns string using `createdAtInWords` prop when `isOpen` is true', async () => {
wrapper.setProps({ wrapper.setProps({
isOpen: true, isOpen: true,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.stateTimeInWords).toBe('2 years ago'); expect(wrapper.vm.stateTimeInWords).toBe('2 years ago');
});
}); });
it('returns string using `closedAtInWords` prop when `isOpen` is false', () => { it('returns string using `closedAtInWords` prop when `isOpen` is false', async () => {
wrapper.setProps({ wrapper.setProps({
isOpen: false, isOpen: false,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.stateTimeInWords).toBe('1 year ago'); expect(wrapper.vm.stateTimeInWords).toBe('1 year ago');
});
}); });
}); });
describe('stateTimestamp', () => { describe('stateTimestamp', () => {
it('returns string using `createdAtTimestamp` prop when `isOpen` is true', () => { it('returns string using `createdAtTimestamp` prop when `isOpen` is true', async () => {
wrapper.setProps({ wrapper.setProps({
isOpen: true, isOpen: true,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.stateTimestamp).toContain(mockCreatedAtYear); expect(wrapper.vm.stateTimestamp).toContain(mockCreatedAtYear);
});
}); });
it('returns string using `closedAtInWords` prop when `isOpen` is false', () => { it('returns string using `closedAtInWords` prop when `isOpen` is false', async () => {
wrapper.setProps({ wrapper.setProps({
isOpen: false, isOpen: false,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.stateTimestamp).toContain(mockClosedAtYear); expect(wrapper.vm.stateTimestamp).toContain(mockClosedAtYear);
});
}); });
}); });
}); });
......
...@@ -94,10 +94,10 @@ describe('RelatedItemsTree', () => { ...@@ -94,10 +94,10 @@ describe('RelatedItemsTree', () => {
allowIssuableHealthStatus: true, allowIssuableHealthStatus: true,
}); });
}; };
const setShowLabels = (isShowingLabels) => { const setShowLabels = async (isShowingLabels) => {
wrapper.vm.$store.dispatch('setShowLabels', isShowingLabels); wrapper.vm.$store.dispatch('setShowLabels', isShowingLabels);
return nextTick(); await nextTick();
}; };
beforeEach(() => { beforeEach(() => {
...@@ -119,60 +119,55 @@ describe('RelatedItemsTree', () => { ...@@ -119,60 +119,55 @@ describe('RelatedItemsTree', () => {
describe('itemWebPath', () => { describe('itemWebPath', () => {
const mockPath = '/foo/bar'; const mockPath = '/foo/bar';
it('returns value of `item.path`', () => { it('returns value of `item.path`', async () => {
wrapper.setProps({ wrapper.setProps({
item: { ...mockItem, path: mockPath, webPath: undefined }, item: { ...mockItem, path: mockPath, webPath: undefined },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.itemWebPath).toBe(mockPath); expect(wrapper.vm.itemWebPath).toBe(mockPath);
});
}); });
it('returns value of `item.webPath` when `item.path` is undefined', () => { it('returns value of `item.webPath` when `item.path` is undefined', async () => {
wrapper.setProps({ wrapper.setProps({
item: { ...mockItem, path: undefined, webPath: mockPath }, item: { ...mockItem, path: undefined, webPath: mockPath },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.itemWebPath).toBe(mockPath); expect(wrapper.vm.itemWebPath).toBe(mockPath);
});
}); });
}); });
describe('isOpen', () => { describe('isOpen', () => {
it('returns true when `item.state` value is `opened`', () => { it('returns true when `item.state` value is `opened`', async () => {
wrapper.setProps({ wrapper.setProps({
item: { ...mockItem, state: ChildState.Open }, item: { ...mockItem, state: ChildState.Open },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findIssueIcon().attributes('name')).toBe('issues'); expect(findIssueIcon().attributes('name')).toBe('issues');
});
}); });
}); });
describe('isBlocked', () => { describe('isBlocked', () => {
it('returns true when `item.blocked` value is `true`', () => { it('returns true when `item.blocked` value is `true`', async () => {
wrapper.setProps({ wrapper.setProps({
item: { ...mockItem, blocked: true }, item: { ...mockItem, blocked: true },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findIssueIcon().attributes('name')).toBe('issue-block'); expect(findIssueIcon().attributes('name')).toBe('issue-block');
});
}); });
}); });
describe('isClosed', () => { describe('isClosed', () => {
it('returns true when `item.state` value is `closed`', () => { it('returns true when `item.state` value is `closed`', async () => {
wrapper.setProps({ wrapper.setProps({
item: { ...mockItem, state: ChildState.Closed }, item: { ...mockItem, state: ChildState.Closed },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findIssueIcon().attributes('name')).toBe('issue-closed'); expect(findIssueIcon().attributes('name')).toBe('issue-closed');
});
}); });
}); });
...@@ -219,60 +214,55 @@ describe('RelatedItemsTree', () => { ...@@ -219,60 +214,55 @@ describe('RelatedItemsTree', () => {
}); });
describe('stateText', () => { describe('stateText', () => {
it('returns string `Opened` when `item.state` value is `opened`', () => { it('returns string `Opened` when `item.state` value is `opened`', async () => {
wrapper.setProps({ wrapper.setProps({
item: { ...mockItem, state: ChildState.Open }, item: { ...mockItem, state: ChildState.Open },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findIssueIcon().props('ariaLabel')).toBe('Opened'); expect(findIssueIcon().props('ariaLabel')).toBe('Opened');
});
}); });
it('returns string `Closed` when `item.state` value is `closed`', () => { it('returns string `Closed` when `item.state` value is `closed`', async () => {
wrapper.setProps({ wrapper.setProps({
item: { ...mockItem, state: ChildState.Closed }, item: { ...mockItem, state: ChildState.Closed },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findIssueIcon().props('ariaLabel')).toBe('Closed'); expect(findIssueIcon().props('ariaLabel')).toBe('Closed');
});
}); });
}); });
describe('stateIconClass', () => { describe('stateIconClass', () => {
it('returns string `issue-token-state-icon-open gl-text-green-500` when `item.state` value is `opened`', () => { it('returns string `issue-token-state-icon-open gl-text-green-500` when `item.state` value is `opened`', async () => {
wrapper.setProps({ wrapper.setProps({
item: { ...mockItem, state: ChildState.Open }, item: { ...mockItem, state: ChildState.Open },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findIssueIcon().attributes('class')).toContain( expect(findIssueIcon().attributes('class')).toContain(
'issue-token-state-icon-open gl-text-green-500', 'issue-token-state-icon-open gl-text-green-500',
); );
});
}); });
it('return string `gl-text-red-500` when `item.blocked` value is `true`', () => { it('return string `gl-text-red-500` when `item.blocked` value is `true`', async () => {
wrapper.setProps({ wrapper.setProps({
item: { ...mockItem, blocked: true }, item: { ...mockItem, blocked: true },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findIssueIcon().attributes('class')).toContain('gl-text-red-500'); expect(findIssueIcon().attributes('class')).toContain('gl-text-red-500');
});
}); });
it('returns string `issue-token-state-icon-closed gl-text-blue-500` when `item.state` value is `closed`', () => { it('returns string `issue-token-state-icon-closed gl-text-blue-500` when `item.state` value is `closed`', async () => {
wrapper.setProps({ wrapper.setProps({
item: { ...mockItem, state: ChildState.Closed }, item: { ...mockItem, state: ChildState.Closed },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findIssueIcon().attributes('class')).toContain( expect(findIssueIcon().attributes('class')).toContain(
'issue-token-state-icon-closed gl-text-blue-500', 'issue-token-state-icon-closed gl-text-blue-500',
); );
});
}); });
}); });
...@@ -288,14 +278,13 @@ describe('RelatedItemsTree', () => { ...@@ -288,14 +278,13 @@ describe('RelatedItemsTree', () => {
expect(findLink().attributes('href')).toBe(mockItem.webPath); expect(findLink().attributes('href')).toBe(mockItem.webPath);
}); });
it('returns `null` when `itemWebPath` is empty', () => { it('returns `null` when `itemWebPath` is empty', async () => {
wrapper.setProps({ wrapper.setProps({
item: { ...mockItem, webPath: '' }, item: { ...mockItem, webPath: '' },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findLink().attributes('href')).toBeUndefined(); expect(findLink().attributes('href')).toBeUndefined();
});
}); });
}); });
...@@ -333,7 +322,7 @@ describe('RelatedItemsTree', () => { ...@@ -333,7 +322,7 @@ describe('RelatedItemsTree', () => {
item: mockItem, item: mockItem,
}); });
await wrapper.vm.$nextTick(); await nextTick();
expect(findIssueIcon().props('name')).toBe(stateIconName); expect(findIssueIcon().props('name')).toBe(stateIconName);
}); });
...@@ -440,7 +429,7 @@ describe('RelatedItemsTree', () => { ...@@ -440,7 +429,7 @@ describe('RelatedItemsTree', () => {
}, },
}); });
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(ItemDueDate).props('closed')).toBe(true); expect(wrapper.findComponent(ItemDueDate).props('closed')).toBe(true);
}); });
...@@ -459,7 +448,7 @@ describe('RelatedItemsTree', () => { ...@@ -459,7 +448,7 @@ describe('RelatedItemsTree', () => {
}, },
}); });
await wrapper.vm.$nextTick(); await nextTick();
const weight = wrapper.findComponent(ItemWeight); const weight = wrapper.findComponent(ItemWeight);
...@@ -503,7 +492,7 @@ describe('RelatedItemsTree', () => { ...@@ -503,7 +492,7 @@ describe('RelatedItemsTree', () => {
enableHealthStatus(); enableHealthStatus();
await wrapper.vm.$nextTick(); await nextTick();
expect(findIssueHealthStatus().exists()).toBe(true); expect(findIssueHealthStatus().exists()).toBe(true);
}); });
......
import { GlModal } from '@gitlab/ui'; import { GlModal } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import TreeItemRemoveModal from 'ee/related_items_tree/components/tree_item_remove_modal.vue'; import TreeItemRemoveModal from 'ee/related_items_tree/components/tree_item_remove_modal.vue';
...@@ -65,54 +65,50 @@ describe('RelatedItemsTree', () => { ...@@ -65,54 +65,50 @@ describe('RelatedItemsTree', () => {
}); });
describe('modalTitle', () => { describe('modalTitle', () => {
it('returns title for modal when item.type is `Epic`', () => { it('returns title for modal when item.type is `Epic`', async () => {
wrapper.vm.$store.dispatch('setRemoveItemModalProps', { wrapper.vm.$store.dispatch('setRemoveItemModalProps', {
parentItem: mockParentItem, parentItem: mockParentItem,
item: { ...mockItem, type: ChildType.Epic }, item: { ...mockItem, type: ChildType.Epic },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.modalTitle).toBe('Remove epic'); expect(wrapper.vm.modalTitle).toBe('Remove epic');
});
}); });
it('returns title for modal when item.type is `Issue`', () => { it('returns title for modal when item.type is `Issue`', async () => {
wrapper.vm.$store.dispatch('setRemoveItemModalProps', { wrapper.vm.$store.dispatch('setRemoveItemModalProps', {
parentItem: mockParentItem, parentItem: mockParentItem,
item: mockItem, item: mockItem,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.modalTitle).toBe('Remove issue'); expect(wrapper.vm.modalTitle).toBe('Remove issue');
});
}); });
}); });
describe('modalBody', () => { describe('modalBody', () => {
it('returns body text for modal when item.type is `Epic`', () => { it('returns body text for modal when item.type is `Epic`', async () => {
wrapper.vm.$store.dispatch('setRemoveItemModalProps', { wrapper.vm.$store.dispatch('setRemoveItemModalProps', {
parentItem: mockParentItem, parentItem: mockParentItem,
item: { ...mockItem, type: ChildType.Epic }, item: { ...mockItem, type: ChildType.Epic },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.modalBody).toBe( expect(wrapper.vm.modalBody).toBe(
'This will also remove any descendents of <b>Nostrum cum mollitia quia recusandae fugit deleniti voluptatem delectus.</b> from <b>Some sample epic</b>. Are you sure?', 'This will also remove any descendents of <b>Nostrum cum mollitia quia recusandae fugit deleniti voluptatem delectus.</b> from <b>Some sample epic</b>. Are you sure?',
); );
});
}); });
it('returns body text for modal when item.type is `Issue`', () => { it('returns body text for modal when item.type is `Issue`', async () => {
wrapper.vm.$store.dispatch('setRemoveItemModalProps', { wrapper.vm.$store.dispatch('setRemoveItemModalProps', {
parentItem: mockParentItem, parentItem: mockParentItem,
item: mockItem, item: mockItem,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.modalBody).toBe( expect(wrapper.vm.modalBody).toBe(
'Are you sure you want to remove <b>Nostrum cum mollitia quia recusandae fugit deleniti voluptatem delectus.</b> from <b>Some sample epic</b>?', 'Are you sure you want to remove <b>Nostrum cum mollitia quia recusandae fugit deleniti voluptatem delectus.</b> from <b>Some sample epic</b>?',
); );
});
}); });
}); });
}); });
......
import { GlButton, GlLoadingIcon, GlIcon } from '@gitlab/ui'; import { GlButton, GlLoadingIcon, GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import TreeItem from 'ee/related_items_tree/components/tree_item.vue'; import TreeItem from 'ee/related_items_tree/components/tree_item.vue';
...@@ -153,17 +153,16 @@ describe('RelatedItemsTree', () => { ...@@ -153,17 +153,16 @@ describe('RelatedItemsTree', () => {
expect(collapsedIcon.props('name')).toBe('chevron-right'); expect(collapsedIcon.props('name')).toBe('chevron-right');
}); });
it('renders loading icon when item expand is in progress', () => { it('renders loading icon when item expand is in progress', async () => {
wrapper.vm.$store.dispatch('requestItems', { wrapper.vm.$store.dispatch('requestItems', {
parentItem: mockItem, parentItem: mockItem,
isSubItem: true, isSubItem: true,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
const loadingIcon = wrapper.findComponent(GlLoadingIcon); const loadingIcon = wrapper.findComponent(GlLoadingIcon);
expect(loadingIcon.isVisible()).toBe(true); expect(loadingIcon.isVisible()).toBe(true);
});
}); });
it('renders tree item body component', () => { it('renders tree item body component', () => {
......
import { GlModal } from '@gitlab/ui'; import { GlModal } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import ImportRequirementsModal from 'ee/requirements/components/import_requirements_modal.vue'; import ImportRequirementsModal from 'ee/requirements/components/import_requirements_modal.vue';
const createComponent = ({ projectPath = 'gitLabTest' } = {}) => const createComponent = ({ projectPath = 'gitLabTest' } = {}) =>
...@@ -39,7 +40,7 @@ describe('ImportRequirementsModal', () => { ...@@ -39,7 +40,7 @@ describe('ImportRequirementsModal', () => {
describe('methods', () => { describe('methods', () => {
describe('handleCSVFile', () => { describe('handleCSVFile', () => {
it('sets the first file selected', () => { it('sets the first file selected', async () => {
const file = 'some file'; const file = 'some file';
const event = { const event = {
...@@ -49,9 +50,8 @@ describe('ImportRequirementsModal', () => { ...@@ -49,9 +50,8 @@ describe('ImportRequirementsModal', () => {
}; };
wrapper.vm.handleCSVFile(event); wrapper.vm.handleCSVFile(event);
wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.file).toBe(file); expect(wrapper.vm.file).toBe(file);
});
}); });
}); });
}); });
......
import { GlLink, GlButton } from '@gitlab/ui'; import { GlLink, GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import RequirementItem from 'ee/requirements/components/requirement_item.vue'; import RequirementItem from 'ee/requirements/components/requirement_item.vue';
import RequirementStatusBadge from 'ee/requirements/components/requirement_status_badge.vue'; import RequirementStatusBadge from 'ee/requirements/components/requirement_status_badge.vue';
...@@ -34,34 +35,32 @@ describe('RequirementItem', () => { ...@@ -34,34 +35,32 @@ describe('RequirementItem', () => {
describe('methods', () => { describe('methods', () => {
describe('handleArchiveClick', () => { describe('handleArchiveClick', () => {
it('emits `archiveClick` event on component with object containing `requirement.iid` & `state` as "ARCHIVED" as param', () => { it('emits `archiveClick` event on component with object containing `requirement.iid` & `state` as "ARCHIVED" as param', async () => {
wrapper.vm.handleArchiveClick(); wrapper.vm.handleArchiveClick();
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.emitted('archiveClick')).toBeTruthy(); expect(wrapper.emitted('archiveClick')).toBeTruthy();
expect(wrapper.emitted('archiveClick')[0]).toEqual([ expect(wrapper.emitted('archiveClick')[0]).toEqual([
{ {
iid: requirement1.iid, iid: requirement1.iid,
state: 'ARCHIVED', state: 'ARCHIVED',
}, },
]); ]);
});
}); });
}); });
describe('handleReopenClick', () => { describe('handleReopenClick', () => {
it('emits `reopenClick` event on component with object containing `requirement.iid` & `state` as "OPENED" as param', () => { it('emits `reopenClick` event on component with object containing `requirement.iid` & `state` as "OPENED" as param', async () => {
wrapperArchived.vm.handleReopenClick(); wrapperArchived.vm.handleReopenClick();
return wrapperArchived.vm.$nextTick(() => { await nextTick();
expect(wrapperArchived.emitted('reopenClick')).toBeTruthy(); expect(wrapperArchived.emitted('reopenClick')).toBeTruthy();
expect(wrapperArchived.emitted('reopenClick')[0]).toEqual([ expect(wrapperArchived.emitted('reopenClick')[0]).toEqual([
{ {
iid: requirementArchived.iid, iid: requirementArchived.iid,
state: 'OPENED', state: 'OPENED',
}, },
]); ]);
});
}); });
}); });
}); });
...@@ -71,14 +70,13 @@ describe('RequirementItem', () => { ...@@ -71,14 +70,13 @@ describe('RequirementItem', () => {
expect(wrapper.classes()).toContain('requirement'); expect(wrapper.classes()).toContain('requirement');
}); });
it('renders component container element with class `disabled-content` when `stateChangeRequestActive` prop is true', () => { it('renders component container element with class `disabled-content` when `stateChangeRequestActive` prop is true', async () => {
wrapper.setProps({ wrapper.setProps({
stateChangeRequestActive: true, stateChangeRequestActive: true,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.classes()).toContain('disabled-content'); expect(wrapper.classes()).toContain('disabled-content');
});
}); });
it('emits `show-click` event with requirement as param', () => { it('emits `show-click` event with requirement as param', () => {
...@@ -189,7 +187,7 @@ describe('RequirementItem', () => { ...@@ -189,7 +187,7 @@ describe('RequirementItem', () => {
expect(reopenButton.text()).toBe('Reopen'); expect(reopenButton.text()).toBe('Reopen');
}); });
it('does not render `Reopen` button when current requirement is archived and `requirement.userPermissions.adminRequirement` is false', () => { it('does not render `Reopen` button when current requirement is archived and `requirement.userPermissions.adminRequirement` is false', async () => {
wrapperArchived.setProps({ wrapperArchived.setProps({
requirement: { requirement: {
...requirementArchived, ...requirementArchived,
...@@ -200,9 +198,8 @@ describe('RequirementItem', () => { ...@@ -200,9 +198,8 @@ describe('RequirementItem', () => {
}, },
}); });
return wrapperArchived.vm.$nextTick(() => { await nextTick();
expect(wrapperArchived.find('.controls .requirement-reopen').exists()).toBe(false); expect(wrapperArchived.find('.controls .requirement-reopen').exists()).toBe(false);
});
}); });
}); });
}); });
import { GlBadge, GlIcon, GlTooltip } from '@gitlab/ui'; import { GlBadge, GlIcon, GlTooltip } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import RequirementStatusBadge from 'ee/requirements/components/requirement_status_badge.vue'; import RequirementStatusBadge from 'ee/requirements/components/requirement_status_badge.vue';
import { mockTestReport, mockTestReportFailed, mockTestReportMissing } from '../mock_data'; import { mockTestReport, mockTestReportFailed, mockTestReportMissing } from '../mock_data';
...@@ -49,28 +50,26 @@ describe('RequirementStatusBadge', () => { ...@@ -49,28 +50,26 @@ describe('RequirementStatusBadge', () => {
expect(wrapper.vm.testReportBadge).toEqual(successBadgeProps); expect(wrapper.vm.testReportBadge).toEqual(successBadgeProps);
}); });
it('returns object containing variant, icon, text and tooltipTitle when status is "FAILED"', () => { it('returns object containing variant, icon, text and tooltipTitle when status is "FAILED"', async () => {
wrapper.setProps({ wrapper.setProps({
testReport: mockTestReportFailed, testReport: mockTestReportFailed,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.testReportBadge).toEqual(failedBadgeProps); expect(wrapper.vm.testReportBadge).toEqual(failedBadgeProps);
});
}); });
it('returns object containing variant, icon, text and tooltipTitle when status missing', () => { it('returns object containing variant, icon, text and tooltipTitle when status missing', async () => {
wrapper.setProps({ wrapper.setProps({
testReport: mockTestReportMissing, testReport: mockTestReportMissing,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.testReportBadge).toEqual({ expect(wrapper.vm.testReportBadge).toEqual({
variant: 'warning', variant: 'warning',
icon: 'status_warning', icon: 'status_warning',
text: 'missing', text: 'missing',
tooltipTitle: '', tooltipTitle: '',
});
}); });
}); });
}); });
......
import { GlEmptyState, GlButton } from '@gitlab/ui'; import { GlEmptyState, GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import RequirementsEmptyState from 'ee/requirements/components/requirements_empty_state.vue'; import RequirementsEmptyState from 'ee/requirements/components/requirements_empty_state.vue';
import { FilterState } from 'ee/requirements/constants'; import { FilterState } from 'ee/requirements/constants';
...@@ -33,7 +34,7 @@ describe('RequirementsEmptyState', () => { ...@@ -33,7 +34,7 @@ describe('RequirementsEmptyState', () => {
describe('computed', () => { describe('computed', () => {
describe('emptyStateTitle', () => { describe('emptyStateTitle', () => {
it('returns string "There are no open requirements" when value of `filterBy` prop is "OPENED" and project has some requirements', () => { it('returns string "There are no open requirements" when value of `filterBy` prop is "OPENED" and project has some requirements', async () => {
wrapper.setProps({ wrapper.setProps({
requirementsCount: { requirementsCount: {
OPENED: 0, OPENED: 0,
...@@ -42,12 +43,11 @@ describe('RequirementsEmptyState', () => { ...@@ -42,12 +43,11 @@ describe('RequirementsEmptyState', () => {
}, },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.emptyStateTitle).toBe('There are no open requirements'); expect(wrapper.vm.emptyStateTitle).toBe('There are no open requirements');
});
}); });
it('returns string "There are no archived requirements" when value of `filterBy` prop is "ARCHIVED" and project has some requirements', () => { it('returns string "There are no archived requirements" when value of `filterBy` prop is "ARCHIVED" and project has some requirements', async () => {
wrapper.setProps({ wrapper.setProps({
filterBy: FilterState.archived, filterBy: FilterState.archived,
requirementsCount: { requirementsCount: {
...@@ -57,9 +57,8 @@ describe('RequirementsEmptyState', () => { ...@@ -57,9 +57,8 @@ describe('RequirementsEmptyState', () => {
}, },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.emptyStateTitle).toBe('There are no archived requirements'); expect(wrapper.vm.emptyStateTitle).toBe('There are no archived requirements');
});
}); });
it('returns a generic string when project has no requirements', () => { it('returns a generic string when project has no requirements', () => {
...@@ -76,7 +75,7 @@ describe('RequirementsEmptyState', () => { ...@@ -76,7 +75,7 @@ describe('RequirementsEmptyState', () => {
); );
}); });
it('returns a null when project has some requirements', () => { it('returns a null when project has some requirements', async () => {
wrapper.setProps({ wrapper.setProps({
requirementsCount: { requirementsCount: {
OPENED: 2, OPENED: 2,
...@@ -85,9 +84,8 @@ describe('RequirementsEmptyState', () => { ...@@ -85,9 +84,8 @@ describe('RequirementsEmptyState', () => {
}, },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.emptyStateDescription).toBeNull(); expect(wrapper.vm.emptyStateDescription).toBeNull();
});
}); });
}); });
}); });
...@@ -109,7 +107,7 @@ describe('RequirementsEmptyState', () => { ...@@ -109,7 +107,7 @@ describe('RequirementsEmptyState', () => {
expect(newReqButton.text()).toBe('New requirement'); expect(newReqButton.text()).toBe('New requirement');
}); });
it('does not render new requirement button when project some requirements', () => { it('does not render new requirement button when project some requirements', async () => {
wrapper.setProps({ wrapper.setProps({
requirementsCount: { requirementsCount: {
OPENED: 2, OPENED: 2,
...@@ -118,23 +116,21 @@ describe('RequirementsEmptyState', () => { ...@@ -118,23 +116,21 @@ describe('RequirementsEmptyState', () => {
}, },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
const newReqButton = wrapper.findComponent(GlButton); const newReqButton = wrapper.findComponent(GlButton);
expect(newReqButton.exists()).toBe(false); expect(newReqButton.exists()).toBe(false);
});
}); });
it('does not render new requirement button when user is not authenticated', () => { it('does not render new requirement button when user is not authenticated', async () => {
wrapper = createComponent({ wrapper = createComponent({
canCreateRequirement: false, canCreateRequirement: false,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
const newReqButton = wrapper.findComponent(GlButton); const newReqButton = wrapper.findComponent(GlButton);
expect(newReqButton.exists()).toBe(false); expect(newReqButton.exists()).toBe(false);
});
}); });
}); });
}); });
import { GlDeprecatedSkeletonLoading as GlSkeletonLoading, GlLoadingIcon } from '@gitlab/ui'; import { GlDeprecatedSkeletonLoading as GlSkeletonLoading, GlLoadingIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import RequirementsLoading from 'ee/requirements/components/requirements_loading.vue'; import RequirementsLoading from 'ee/requirements/components/requirements_loading.vue';
import { FilterState, mockRequirementsCount } from '../mock_data'; import { FilterState, mockRequirementsCount } from '../mock_data';
...@@ -50,17 +51,16 @@ describe('RequirementsLoading', () => { ...@@ -50,17 +51,16 @@ describe('RequirementsLoading', () => {
expect(wrapper.vm.loaderCount).toBe(2); expect(wrapper.vm.loaderCount).toBe(2);
}); });
it('returns value of remainder requirements for last page when current page is the last page total requirements are more than DEFAULT_PAGE_SIZE', () => { it('returns value of remainder requirements for last page when current page is the last page total requirements are more than DEFAULT_PAGE_SIZE', async () => {
wrapper.setProps({ wrapper.setProps({
currentPage: 2, currentPage: 2,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.loaderCount).toBe(1); expect(wrapper.vm.loaderCount).toBe(1);
});
}); });
it('returns value DEFAULT_PAGE_SIZE when current page is the last page total requirements are less than DEFAULT_PAGE_SIZE', () => { it('returns value DEFAULT_PAGE_SIZE when current page is the last page total requirements are less than DEFAULT_PAGE_SIZE', async () => {
wrapper.setProps({ wrapper.setProps({
currentPage: 1, currentPage: 1,
requirementsCount: { requirementsCount: {
...@@ -70,9 +70,8 @@ describe('RequirementsLoading', () => { ...@@ -70,9 +70,8 @@ describe('RequirementsLoading', () => {
}, },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.loaderCount).toBe(1); expect(wrapper.vm.loaderCount).toBe(1);
});
}); });
}); });
}); });
...@@ -87,7 +86,7 @@ describe('RequirementsLoading', () => { ...@@ -87,7 +86,7 @@ describe('RequirementsLoading', () => {
expect(loaders.at(0).props('lines')).toBe(2); expect(loaders.at(0).props('lines')).toBe(2);
}); });
it('renders gl-loading-icon component project has no requirements and current tab has nothing to show', () => { it('renders gl-loading-icon component project has no requirements and current tab has nothing to show', async () => {
wrapper.setProps({ wrapper.setProps({
requirementsCount: { requirementsCount: {
OPENED: 0, OPENED: 0,
...@@ -96,10 +95,9 @@ describe('RequirementsLoading', () => { ...@@ -96,10 +95,9 @@ describe('RequirementsLoading', () => {
}, },
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.find('.requirements-list-loading').exists()).toBe(false); expect(wrapper.find('.requirements-list-loading').exists()).toBe(false);
expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(true); expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(true);
});
}); });
}); });
}); });
import { GlTab, GlBadge, GlButton, GlTabs } from '@gitlab/ui'; import { GlTab, GlBadge, GlButton, GlTabs } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import RequirementsTabs from 'ee/requirements/components/requirements_tabs.vue'; import RequirementsTabs from 'ee/requirements/components/requirements_tabs.vue';
import { FilterState } from 'ee/requirements/constants'; import { FilterState } from 'ee/requirements/constants';
...@@ -64,56 +65,52 @@ describe('RequirementsTabs', () => { ...@@ -64,56 +65,52 @@ describe('RequirementsTabs', () => {
expect(tabEl.attributes('active')).toBeDefined(); expect(tabEl.attributes('active')).toBeDefined();
}); });
it('renders "New requirement" button when current tab is "Open" tab', () => { it('renders "New requirement" button when current tab is "Open" tab', async () => {
wrapper.setProps({ wrapper.setProps({
filterBy: FilterState.opened, filterBy: FilterState.opened,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
const buttonEl = wrapper.findAllComponents(GlButton).at(2); const buttonEl = wrapper.findAllComponents(GlButton).at(2);
expect(buttonEl.exists()).toBe(true); expect(buttonEl.exists()).toBe(true);
expect(buttonEl.text()).toBe('New requirement'); expect(buttonEl.text()).toBe('New requirement');
});
}); });
it('does not render "New requirement" button when current tab is not "Open" tab', () => { it('does not render "New requirement" button when current tab is not "Open" tab', async () => {
wrapper.setProps({ wrapper.setProps({
filterBy: FilterState.archived, filterBy: FilterState.archived,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
const buttonEl = wrapper.findComponent(GlButton); const buttonEl = wrapper.findComponent(GlButton);
expect(buttonEl.exists()).toBe(false); expect(buttonEl.exists()).toBe(false);
});
}); });
it('does not render "New requirement" button when `canCreateRequirement` prop is false', () => { it('does not render "New requirement" button when `canCreateRequirement` prop is false', async () => {
wrapper.setProps({ wrapper.setProps({
filterBy: FilterState.opened, filterBy: FilterState.opened,
canCreateRequirement: false, canCreateRequirement: false,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
const buttonEl = wrapper.findComponent(GlButton); const buttonEl = wrapper.findComponent(GlButton);
expect(buttonEl.exists()).toBe(false); expect(buttonEl.exists()).toBe(false);
});
}); });
it('disables "New requirement" button when `showCreateForm` is true', () => { it('disables "New requirement" button when `showCreateForm` is true', async () => {
wrapper.setProps({ wrapper.setProps({
showCreateForm: true, showCreateForm: true,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
const buttonEl = wrapper.findAllComponents(GlButton); const buttonEl = wrapper.findAllComponents(GlButton);
expect(buttonEl.at(0).props('disabled')).toBe(true); expect(buttonEl.at(0).props('disabled')).toBe(true);
expect(buttonEl.at(1).props('disabled')).toBe(true); expect(buttonEl.at(1).props('disabled')).toBe(true);
expect(buttonEl.at(2).props('disabled')).toBe(true); expect(buttonEl.at(2).props('disabled')).toBe(true);
});
}); });
}); });
}); });
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import RequirementItem from 'ee/requirements/components/requirement_item.vue'; import RequirementItem from 'ee/requirements/components/requirement_item.vue';
import { FilterState } from 'ee/requirements/constants'; import { FilterState } from 'ee/requirements/constants';
...@@ -51,7 +52,7 @@ describe('RequirementMeta Mixin', () => { ...@@ -51,7 +52,7 @@ describe('RequirementMeta Mixin', () => {
}, },
}); });
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.vm.isArchived).toBe(true); expect(wrapper.vm.isArchived).toBe(true);
}); });
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import CurrentDayIndicator from 'ee/roadmap/components/current_day_indicator.vue'; import CurrentDayIndicator from 'ee/roadmap/components/current_day_indicator.vue';
import { DATE_RANGES, PRESET_TYPES } from 'ee/roadmap/constants'; import { DATE_RANGES, PRESET_TYPES } from 'ee/roadmap/constants';
import { getTimeframeForRangeType } from 'ee/roadmap/utils/roadmap_utils'; import { getTimeframeForRangeType } from 'ee/roadmap/utils/roadmap_utils';
...@@ -54,7 +55,7 @@ describe('CurrentDayIndicator', () => { ...@@ -54,7 +55,7 @@ describe('CurrentDayIndicator', () => {
describe('computed', () => { describe('computed', () => {
describe('hasToday', () => { describe('hasToday', () => {
it('returns true when presetType is QUARTERS and currentDate is within current quarter', () => { it('returns true when presetType is QUARTERS and currentDate is within current quarter', async () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
wrapper.setData({ wrapper.setData({
...@@ -66,12 +67,11 @@ describe('CurrentDayIndicator', () => { ...@@ -66,12 +67,11 @@ describe('CurrentDayIndicator', () => {
timeframeItem: mockTimeframeQuarters[0], timeframeItem: mockTimeframeQuarters[0],
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.hasToday).toBe(true); expect(wrapper.vm.hasToday).toBe(true);
});
}); });
it('returns true when presetType is MONTHS and currentDate is within current month', () => { it('returns true when presetType is MONTHS and currentDate is within current month', async () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
wrapper.setData({ wrapper.setData({
...@@ -83,12 +83,11 @@ describe('CurrentDayIndicator', () => { ...@@ -83,12 +83,11 @@ describe('CurrentDayIndicator', () => {
timeframeItem: new Date(2020, 0, 1), timeframeItem: new Date(2020, 0, 1),
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.hasToday).toBe(true); expect(wrapper.vm.hasToday).toBe(true);
});
}); });
it('returns true when presetType is WEEKS and currentDate is within current week', () => { it('returns true when presetType is WEEKS and currentDate is within current week', async () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
wrapper.setData({ wrapper.setData({
...@@ -100,16 +99,15 @@ describe('CurrentDayIndicator', () => { ...@@ -100,16 +99,15 @@ describe('CurrentDayIndicator', () => {
timeframeItem: mockTimeframeWeeks[0], timeframeItem: mockTimeframeWeeks[0],
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.hasToday).toBe(true); expect(wrapper.vm.hasToday).toBe(true);
});
}); });
}); });
}); });
describe('methods', () => { describe('methods', () => {
describe('getIndicatorStyles', () => { describe('getIndicatorStyles', () => {
it('returns object containing `left` with value `34%` when presetType is QUARTERS', () => { it('returns object containing `left` with value `34%` when presetType is QUARTERS', async () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
wrapper.setData({ wrapper.setData({
...@@ -121,16 +119,15 @@ describe('CurrentDayIndicator', () => { ...@@ -121,16 +119,15 @@ describe('CurrentDayIndicator', () => {
timeframeItem: mockTimeframeQuarters[0], timeframeItem: mockTimeframeQuarters[0],
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.getIndicatorStyles()).toEqual( expect(wrapper.vm.getIndicatorStyles()).toEqual(
expect.objectContaining({ expect.objectContaining({
left: '34%', left: '34%',
}), }),
); );
});
}); });
it('returns object containing `left` with value `48%` when presetType is MONTHS', () => { it('returns object containing `left` with value `48%` when presetType is MONTHS', async () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
wrapper.setData({ wrapper.setData({
...@@ -142,16 +139,15 @@ describe('CurrentDayIndicator', () => { ...@@ -142,16 +139,15 @@ describe('CurrentDayIndicator', () => {
timeframeItem: new Date(2020, 0, 1), timeframeItem: new Date(2020, 0, 1),
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.getIndicatorStyles()).toEqual( expect(wrapper.vm.getIndicatorStyles()).toEqual(
expect.objectContaining({ expect.objectContaining({
left: '48%', left: '48%',
}), }),
); );
});
}); });
it('returns object containing `left` with value `7%` when presetType is WEEKS', () => { it('returns object containing `left` with value `7%` when presetType is WEEKS', async () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
wrapper.setData({ wrapper.setData({
...@@ -163,19 +159,18 @@ describe('CurrentDayIndicator', () => { ...@@ -163,19 +159,18 @@ describe('CurrentDayIndicator', () => {
timeframeItem: mockTimeframeWeeks[0], timeframeItem: mockTimeframeWeeks[0],
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.getIndicatorStyles()).toEqual( expect(wrapper.vm.getIndicatorStyles()).toEqual(
expect.objectContaining({ expect.objectContaining({
left: '7%', left: '7%',
}), }),
); );
});
}); });
}); });
}); });
describe('template', () => { describe('template', () => {
beforeEach(() => { beforeEach(async () => {
wrapper = createComponent(); wrapper = createComponent();
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
...@@ -183,7 +178,7 @@ describe('CurrentDayIndicator', () => { ...@@ -183,7 +178,7 @@ describe('CurrentDayIndicator', () => {
currentDate: mockTimeframeMonths[0], currentDate: mockTimeframeMonths[0],
}); });
return wrapper.vm.$nextTick(); await nextTick();
}); });
it('renders span element containing class `current-day-indicator`', () => { it('renders span element containing class `current-day-indicator`', () => {
......
...@@ -2,6 +2,7 @@ import { mount } from '@vue/test-utils'; ...@@ -2,6 +2,7 @@ import { mount } from '@vue/test-utils';
import { delay } from 'lodash'; import { delay } from 'lodash';
import { nextTick } from 'vue';
import CurrentDayIndicator from 'ee/roadmap/components/current_day_indicator.vue'; import CurrentDayIndicator from 'ee/roadmap/components/current_day_indicator.vue';
import EpicItemComponent from 'ee/roadmap/components/epic_item.vue'; import EpicItemComponent from 'ee/roadmap/components/epic_item.vue';
import EpicItemContainer from 'ee/roadmap/components/epic_item_container.vue'; import EpicItemContainer from 'ee/roadmap/components/epic_item_container.vue';
...@@ -144,7 +145,7 @@ describe('EpicItemComponent', () => { ...@@ -144,7 +145,7 @@ describe('EpicItemComponent', () => {
describe('methods', () => { describe('methods', () => {
describe('removeHighlight', () => { describe('removeHighlight', () => {
it('should wait 3 seconds before toggling `epic.newEpic` from true to false', () => { it('should wait 3 seconds before toggling `epic.newEpic` from true to false', async () => {
wrapper.setProps({ wrapper.setProps({
epic: { epic: {
...wrapper.vm.epic, ...wrapper.vm.epic,
...@@ -154,9 +155,8 @@ describe('EpicItemComponent', () => { ...@@ -154,9 +155,8 @@ describe('EpicItemComponent', () => {
wrapper.vm.removeHighlight(); wrapper.vm.removeHighlight();
return wrapper.vm.$nextTick().then(() => { await nextTick();
expect(delay).toHaveBeenCalledWith(expect.any(Function), 3000); expect(delay).toHaveBeenCalledWith(expect.any(Function), 3000);
});
}); });
}); });
}); });
......
import { GlIntersectionObserver, GlLoadingIcon } from '@gitlab/ui'; import { GlIntersectionObserver, GlLoadingIcon } from '@gitlab/ui';
import { nextTick } from 'vue';
import EpicItem from 'ee/roadmap/components/epic_item.vue'; import EpicItem from 'ee/roadmap/components/epic_item.vue';
import EpicsListSection from 'ee/roadmap/components/epics_list_section.vue'; import EpicsListSection from 'ee/roadmap/components/epics_list_section.vue';
import { import {
...@@ -130,14 +131,13 @@ describe('EpicsListSectionComponent', () => { ...@@ -130,14 +131,13 @@ describe('EpicsListSectionComponent', () => {
}); });
describe('epicsWithAssociatedParents', () => { describe('epicsWithAssociatedParents', () => {
it('should return epics which contain parent associations', () => { it('should return epics which contain parent associations', async () => {
wrapper.setProps({ wrapper.setProps({
epics: mockEpicsWithParents, epics: mockEpicsWithParents,
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.epicsWithAssociatedParents).toEqual(mockEpicsWithParents); expect(wrapper.vm.epicsWithAssociatedParents).toEqual(mockEpicsWithParents);
});
}); });
}); });
...@@ -172,42 +172,39 @@ describe('EpicsListSectionComponent', () => { ...@@ -172,42 +172,39 @@ describe('EpicsListSectionComponent', () => {
expect(wrapper.vm.bufferSize).toBe(16); expect(wrapper.vm.bufferSize).toBe(16);
}); });
it('sets value of `offsetLeft` with parentElement.offsetLeft', () => { it('sets value of `offsetLeft` with parentElement.offsetLeft', async () => {
return wrapper.vm.$nextTick(() => { await nextTick();
// During tests, there's no `$el.parentElement` present // During tests, there's no `$el.parentElement` present
// hence offsetLeft is 0. // hence offsetLeft is 0.
expect(wrapper.vm.offsetLeft).toBe(0); expect(wrapper.vm.offsetLeft).toBe(0);
});
}); });
it('calls `scrollToCurrentDay` following the component render', async () => { it('calls `scrollToCurrentDay` following the component render', async () => {
// Original method implementation waits for render cycle // Original method implementation waits for render cycle
// to complete at 2 levels before scrolling. // to complete at 2 levels before scrolling.
await wrapper.vm.$nextTick(); // set offsetLeft value await nextTick(); // set offsetLeft value
await wrapper.vm.$nextTick(); // Wait for nextTick before scroll await nextTick(); // Wait for nextTick before scroll
expect(scrollToCurrentDay).toHaveBeenCalledWith(wrapper.vm.$el); expect(scrollToCurrentDay).toHaveBeenCalledWith(wrapper.vm.$el);
}); });
it('sets style object to `emptyRowContainerStyles`', () => { it('sets style object to `emptyRowContainerStyles`', async () => {
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.emptyRowContainerStyles).toEqual( expect(wrapper.vm.emptyRowContainerStyles).toEqual(
expect.objectContaining({ expect.objectContaining({
height: '0px', height: '0px',
}), }),
); );
});
}); });
}); });
describe('getEmptyRowContainerStyles', () => { describe('getEmptyRowContainerStyles', () => {
it('returns empty object when there are no epics available to render', () => { it('returns empty object when there are no epics available to render', async () => {
wrapper.setProps({ wrapper.setProps({
epics: [], epics: [],
}); });
return wrapper.vm.$nextTick(() => { await nextTick();
expect(wrapper.vm.getEmptyRowContainerStyles()).toEqual({}); expect(wrapper.vm.getEmptyRowContainerStyles()).toEqual({});
});
}); });
it('returns object containing `height` when there epics available to render', () => { it('returns object containing `height` when there epics available to render', () => {
...@@ -276,7 +273,7 @@ describe('EpicsListSectionComponent', () => { ...@@ -276,7 +273,7 @@ describe('EpicsListSectionComponent', () => {
it('renders gl-loading icon when epicsFetchForNextPageInProgress is true', async () => { it('renders gl-loading icon when epicsFetchForNextPageInProgress is true', async () => {
wrapper.vm.$store.commit(REQUEST_EPICS_FOR_NEXT_PAGE); wrapper.vm.$store.commit(REQUEST_EPICS_FOR_NEXT_PAGE);
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findByTestId('next-page-loading').text()).toContain('Loading epics'); expect(wrapper.findByTestId('next-page-loading').text()).toContain('Loading epics');
expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(true); expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(true);
...@@ -293,15 +290,14 @@ describe('EpicsListSectionComponent', () => { ...@@ -293,15 +290,14 @@ describe('EpicsListSectionComponent', () => {
}); });
}); });
it('expands to show child epics when epic is toggled', () => { it('expands to show child epics when epic is toggled', async () => {
const epic = mockEpics[0]; const epic = mockEpics[0];
expect(store.state.childrenFlags[epic.id].itemExpanded).toBe(false); expect(store.state.childrenFlags[epic.id].itemExpanded).toBe(false);
wrapper.vm.toggleIsEpicExpanded(epic); wrapper.vm.toggleIsEpicExpanded(epic);
return wrapper.vm.$nextTick().then(() => { await nextTick();
expect(store.state.childrenFlags[epic.id].itemExpanded).toBe(true); expect(store.state.childrenFlags[epic.id].itemExpanded).toBe(true);
});
}); });
}); });
import { GlIcon, GlButton } from '@gitlab/ui'; import { GlIcon, GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import MilestoneTimeline from 'ee/roadmap/components/milestone_timeline.vue'; import MilestoneTimeline from 'ee/roadmap/components/milestone_timeline.vue';
import milestonesListSectionComponent from 'ee/roadmap/components/milestones_list_section.vue'; import milestonesListSectionComponent from 'ee/roadmap/components/milestones_list_section.vue';
import { import {
...@@ -117,8 +118,8 @@ describe('MilestonesListSectionComponent', () => { ...@@ -117,8 +118,8 @@ describe('MilestonesListSectionComponent', () => {
it('calls `scrollToCurrentDay` following the component render', async () => { it('calls `scrollToCurrentDay` following the component render', async () => {
// Original method implementation waits for render cycle // Original method implementation waits for render cycle
// to complete at 2 levels before scrolling. // to complete at 2 levels before scrolling.
await wrapper.vm.$nextTick(); // set offsetLeft value await nextTick(); // set offsetLeft value
await wrapper.vm.$nextTick(); // Wait for nextTick before scroll await nextTick(); // Wait for nextTick before scroll
expect(scrollToCurrentDay).toHaveBeenCalledWith(wrapper.vm.$el); expect(scrollToCurrentDay).toHaveBeenCalledWith(wrapper.vm.$el);
}); });
}); });
...@@ -194,10 +195,10 @@ describe('MilestonesListSectionComponent', () => { ...@@ -194,10 +195,10 @@ describe('MilestonesListSectionComponent', () => {
}); });
describe('when the milestone list is expanded', () => { describe('when the milestone list is expanded', () => {
beforeEach(() => { beforeEach(async () => {
findExpandButtonContainer().find(GlButton).vm.$emit('click'); findExpandButtonContainer().find(GlButton).vm.$emit('click');
return wrapper.vm.$nextTick(); await nextTick();
}); });
it('shows "chevron-right" icon when the milestone toggle button is clicked', () => { it('shows "chevron-right" icon when the milestone toggle button is clicked', () => {
......
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import EpicsListEmpty from 'ee/roadmap/components/epics_list_empty.vue'; import EpicsListEmpty from 'ee/roadmap/components/epics_list_empty.vue';
...@@ -131,7 +131,7 @@ describe('RoadmapApp', () => { ...@@ -131,7 +131,7 @@ describe('RoadmapApp', () => {
epicIid: mockFormattedEpic.iid, epicIid: mockFormattedEpic.iid,
}); });
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findComponent(RoadmapFilters).exists()).toBe(false); expect(wrapper.findComponent(RoadmapFilters).exists()).toBe(false);
}); });
......
import { GlSegmentedControl, GlDropdown, GlDropdownItem } from '@gitlab/ui'; import { GlSegmentedControl, GlDropdown, GlDropdownItem } from '@gitlab/ui';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import RoadmapFilters from 'ee/roadmap/components/roadmap_filters.vue'; import RoadmapFilters from 'ee/roadmap/components/roadmap_filters.vue';
...@@ -113,7 +113,7 @@ describe('RoadmapFilters', () => { ...@@ -113,7 +113,7 @@ describe('RoadmapFilters', () => {
}); });
wrapper.vm.$store.dispatch('setSortedBy', 'end_date_asc'); wrapper.vm.$store.dispatch('setSortedBy', 'end_date_asc');
await wrapper.vm.$nextTick(); await nextTick();
expect(global.window.location.href).toBe( expect(global.window.location.href).toBe(
`${TEST_HOST}/?state=${EPICS_STATES.CLOSED}&sort=end_date_asc&layout=MONTHS&author_username=root&label_name%5B%5D=Bug&milestone_title=4.0&confidential=true`, `${TEST_HOST}/?state=${EPICS_STATES.CLOSED}&sort=end_date_asc&layout=MONTHS&author_username=root&label_name%5B%5D=Bug&milestone_title=4.0&confidential=true`,
...@@ -136,7 +136,7 @@ describe('RoadmapFilters', () => { ...@@ -136,7 +136,7 @@ describe('RoadmapFilters', () => {
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
wrapper.setData({ selectedDaterange: DATE_RANGES.THREE_YEARS }); wrapper.setData({ selectedDaterange: DATE_RANGES.THREE_YEARS });
await wrapper.vm.$nextTick(); await nextTick();
wrapper.findComponent(GlSegmentedControl).vm.$emit('input', PRESET_TYPES.OPENED); wrapper.findComponent(GlSegmentedControl).vm.$emit('input', PRESET_TYPES.OPENED);
...@@ -243,7 +243,7 @@ describe('RoadmapFilters', () => { ...@@ -243,7 +243,7 @@ describe('RoadmapFilters', () => {
'not[myReactionEmoji]': 'thumbs_up', 'not[myReactionEmoji]': 'thumbs_up',
}); });
await wrapper.vm.$nextTick(); await nextTick();
expect(filteredSearchBar.props('initialFilterValue')).toEqual(mockInitialFilterValue); expect(filteredSearchBar.props('initialFilterValue')).toEqual(mockInitialFilterValue);
}); });
...@@ -252,11 +252,11 @@ describe('RoadmapFilters', () => { ...@@ -252,11 +252,11 @@ describe('RoadmapFilters', () => {
jest.spyOn(wrapper.vm, 'setFilterParams'); jest.spyOn(wrapper.vm, 'setFilterParams');
jest.spyOn(wrapper.vm, 'fetchEpics'); jest.spyOn(wrapper.vm, 'fetchEpics');
await wrapper.vm.$nextTick(); await nextTick();
filteredSearchBar.vm.$emit('onFilter', mockInitialFilterValue); filteredSearchBar.vm.$emit('onFilter', mockInitialFilterValue);
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.vm.setFilterParams).toHaveBeenCalledWith({ expect(wrapper.vm.setFilterParams).toHaveBeenCalledWith({
authorUsername: 'root', authorUsername: 'root',
...@@ -274,11 +274,11 @@ describe('RoadmapFilters', () => { ...@@ -274,11 +274,11 @@ describe('RoadmapFilters', () => {
jest.spyOn(wrapper.vm, 'setSortedBy'); jest.spyOn(wrapper.vm, 'setSortedBy');
jest.spyOn(wrapper.vm, 'fetchEpics'); jest.spyOn(wrapper.vm, 'fetchEpics');
await wrapper.vm.$nextTick(); await nextTick();
filteredSearchBar.vm.$emit('onSort', 'end_date_asc'); filteredSearchBar.vm.$emit('onSort', 'end_date_asc');
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.vm.setSortedBy).toHaveBeenCalledWith('end_date_asc'); expect(wrapper.vm.setSortedBy).toHaveBeenCalledWith('end_date_asc');
expect(wrapper.vm.fetchEpics).toHaveBeenCalled(); expect(wrapper.vm.fetchEpics).toHaveBeenCalled();
...@@ -290,7 +290,7 @@ describe('RoadmapFilters', () => { ...@@ -290,7 +290,7 @@ describe('RoadmapFilters', () => {
filteredSearchBar.vm.$emit('onFilter', [], false); filteredSearchBar.vm.$emit('onFilter', [], false);
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.vm.setFilterParams).not.toHaveBeenCalled(); expect(wrapper.vm.setFilterParams).not.toHaveBeenCalled();
expect(wrapper.vm.fetchEpics).not.toHaveBeenCalled(); expect(wrapper.vm.fetchEpics).not.toHaveBeenCalled();
...@@ -340,7 +340,7 @@ describe('RoadmapFilters', () => { ...@@ -340,7 +340,7 @@ describe('RoadmapFilters', () => {
timeframeRangeType: DATE_RANGES.CURRENT_QUARTER, timeframeRangeType: DATE_RANGES.CURRENT_QUARTER,
}); });
await wrapperWithDaterangeFilter.vm.$nextTick(); await nextTick();
}); });
afterEach(() => { afterEach(() => {
...@@ -351,7 +351,7 @@ describe('RoadmapFilters', () => { ...@@ -351,7 +351,7 @@ describe('RoadmapFilters', () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
wrapperWithDaterangeFilter.setData({ selectedDaterange: DATE_RANGES.CURRENT_QUARTER }); wrapperWithDaterangeFilter.setData({ selectedDaterange: DATE_RANGES.CURRENT_QUARTER });
await wrapperWithDaterangeFilter.vm.$nextTick(); await nextTick();
const daterangeDropdown = wrapperWithDaterangeFilter.findByTestId('daterange-dropdown'); const daterangeDropdown = wrapperWithDaterangeFilter.findByTestId('daterange-dropdown');
...@@ -374,7 +374,7 @@ describe('RoadmapFilters', () => { ...@@ -374,7 +374,7 @@ describe('RoadmapFilters', () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
wrapperWithDaterangeFilter.setData({ selectedDaterange }); wrapperWithDaterangeFilter.setData({ selectedDaterange });
await wrapperWithDaterangeFilter.vm.$nextTick(); await nextTick();
const layoutSwitches = wrapperWithDaterangeFilter.findComponent(GlSegmentedControl); const layoutSwitches = wrapperWithDaterangeFilter.findComponent(GlSegmentedControl);
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import EpicsListSection from 'ee/roadmap/components/epics_list_section.vue'; import EpicsListSection from 'ee/roadmap/components/epics_list_section.vue';
...@@ -97,7 +97,7 @@ describe('RoadmapShell', () => { ...@@ -97,7 +97,7 @@ describe('RoadmapShell', () => {
it('emits `epicsListScrolled` event via eventHub', async () => { it('emits `epicsListScrolled` event via eventHub', async () => {
jest.spyOn(eventHub, '$emit').mockImplementation(() => {}); jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
await wrapper.vm.$nextTick(); await nextTick();
wrapper.vm.handleScroll(); wrapper.vm.handleScroll();
expect(eventHub.$emit).toHaveBeenCalledWith('epicsListScrolled', expect.any(Object)); expect(eventHub.$emit).toHaveBeenCalledWith('epicsListScrolled', expect.any(Object));
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { merge } from 'lodash'; import { merge } from 'lodash';
import { nextTick } from 'vue';
import ConfigurationForm from 'ee/security_configuration/api_fuzzing/components/configuration_form.vue'; import ConfigurationForm from 'ee/security_configuration/api_fuzzing/components/configuration_form.vue';
import { SCAN_MODES } from 'ee/security_configuration/api_fuzzing/constants'; import { SCAN_MODES } from 'ee/security_configuration/api_fuzzing/constants';
import ConfigurationSnippetModal from 'ee/security_configuration/components/configuration_snippet_modal.vue'; import ConfigurationSnippetModal from 'ee/security_configuration/components/configuration_snippet_modal.vue';
...@@ -111,7 +112,7 @@ describe('EE - ApiFuzzingConfigurationForm', () => { ...@@ -111,7 +112,7 @@ describe('EE - ApiFuzzingConfigurationForm', () => {
it('the specificationfile input becomes visible and has the correct labels', async () => { it('the specificationfile input becomes visible and has the correct labels', async () => {
const selectedScanMode = SCAN_MODES[scanMode]; const selectedScanMode = SCAN_MODES[scanMode];
findScanModeInput().vm.$emit('input', scanMode); findScanModeInput().vm.$emit('input', scanMode);
await wrapper.vm.$nextTick(); await nextTick();
const specificationFileInput = findSpecificationFileInput(); const specificationFileInput = findSpecificationFileInput();
expect(specificationFileInput.exists()).toBe(true); expect(specificationFileInput.exists()).toBe(true);
...@@ -181,7 +182,7 @@ describe('EE - ApiFuzzingConfigurationForm', () => { ...@@ -181,7 +182,7 @@ describe('EE - ApiFuzzingConfigurationForm', () => {
it('when a scan profile is selected, its YAML is visible', async () => { it('when a scan profile is selected, its YAML is visible', async () => {
const [selectedScanProfile] = apiFuzzingCiConfiguration.scanProfiles; const [selectedScanProfile] = apiFuzzingCiConfiguration.scanProfiles;
findScanProfileDropdownInput().vm.$emit('input', selectedScanProfile.name); findScanProfileDropdownInput().vm.$emit('input', selectedScanProfile.name);
await wrapper.vm.$nextTick(); await nextTick();
expect(findScanProfileYamlViewer().exists()).toBe(true); expect(findScanProfileYamlViewer().exists()).toBe(true);
expect(findScanProfileYamlViewer().text()).toBe(selectedScanProfile.yaml.trim()); expect(findScanProfileYamlViewer().text()).toBe(selectedScanProfile.yaml.trim());
...@@ -227,7 +228,7 @@ describe('EE - ApiFuzzingConfigurationForm', () => { ...@@ -227,7 +228,7 @@ describe('EE - ApiFuzzingConfigurationForm', () => {
jest.spyOn(wrapper.vm.$refs[CONFIGURATION_SNIPPET_MODAL_ID], 'show'); jest.spyOn(wrapper.vm.$refs[CONFIGURATION_SNIPPET_MODAL_ID], 'show');
await setFormData(); await setFormData();
wrapper.find('form').trigger('submit'); wrapper.find('form').trigger('submit');
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.vm.$refs[CONFIGURATION_SNIPPET_MODAL_ID].show).toHaveBeenCalled(); expect(wrapper.vm.$refs[CONFIGURATION_SNIPPET_MODAL_ID].show).toHaveBeenCalled();
expect(findConfigurationSnippetModal().props()).toEqual({ expect(findConfigurationSnippetModal().props()).toEqual({
......
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import ExpandableSection from 'ee/security_configuration/components/expandable_section.vue'; import ExpandableSection from 'ee/security_configuration/components/expandable_section.vue';
import { stubTransition } from 'helpers/stub_transition'; import { stubTransition } from 'helpers/stub_transition';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
...@@ -82,7 +83,7 @@ describe('ExpandableSection component', () => { ...@@ -82,7 +83,7 @@ describe('ExpandableSection component', () => {
}); });
it('hides the content by default', async () => { it('hides the content by default', async () => {
await wrapper.vm.$nextTick(); await nextTick();
expect(findContent().isVisible()).toBe(false); expect(findContent().isVisible()).toBe(false);
}); });
...@@ -95,7 +96,7 @@ describe('ExpandableSection component', () => { ...@@ -95,7 +96,7 @@ describe('ExpandableSection component', () => {
await waitForPromises(); await waitForPromises();
const button = findButton(); const button = findButton();
button.trigger('click'); button.trigger('click');
return wrapper.vm.$nextTick(); await nextTick();
}); });
it('shows the content', () => { it('shows the content', () => {
......
import { GlFormInput, GlLink } from '@gitlab/ui'; import { GlFormInput, GlLink } from '@gitlab/ui';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { nextTick } from 'vue';
import { SCHEMA_TO_PROP_SIZE_MAP } from 'ee/security_configuration/components/constants'; import { SCHEMA_TO_PROP_SIZE_MAP } from 'ee/security_configuration/components/constants';
import FormInput from 'ee/security_configuration/components/form_input.vue'; import FormInput from 'ee/security_configuration/components/form_input.vue';
...@@ -114,9 +115,9 @@ describe('FormInput component', () => { ...@@ -114,9 +115,9 @@ describe('FormInput component', () => {
}); });
describe('disabling the input', () => { describe('disabling the input', () => {
beforeEach(() => { beforeEach(async () => {
wrapper.setProps({ disabled: true }); wrapper.setProps({ disabled: true });
return wrapper.vm.$nextTick(); await nextTick();
}); });
it('does not display the custom value message', () => { it('does not display the custom value message', () => {
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { nextTick } from 'vue';
import Actions from 'ee/security_configuration/corpus_management/components/columns/actions.vue'; import Actions from 'ee/security_configuration/corpus_management/components/columns/actions.vue';
import CorpusTable from 'ee/security_configuration/corpus_management/components/corpus_table.vue'; import CorpusTable from 'ee/security_configuration/corpus_management/components/corpus_table.vue';
import { corpuses } from './mock_data'; import { corpuses } from './mock_data';
...@@ -58,7 +59,7 @@ describe('Corpus table', () => { ...@@ -58,7 +59,7 @@ describe('Corpus table', () => {
describe('with no corpuses', () => { describe('with no corpuses', () => {
it('renders the empty state', async () => { it('renders the empty state', async () => {
wrapper.setProps({ corpuses: [] }); wrapper.setProps({ corpuses: [] });
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.text()).toContain('Currently, there are no uploaded or generated corpuses'); expect(wrapper.text()).toContain('Currently, there are no uploaded or generated corpuses');
}); });
}); });
......
import { GlAlert, GlForm, GlModal } from '@gitlab/ui'; import { GlAlert, GlForm, GlModal } from '@gitlab/ui';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import merge from 'lodash/merge'; import merge from 'lodash/merge';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import BaseDastProfileForm from 'ee/security_configuration/dast_profiles/components/base_dast_profile_form.vue'; import BaseDastProfileForm from 'ee/security_configuration/dast_profiles/components/base_dast_profile_form.vue';
...@@ -169,7 +169,7 @@ describe('BaseDastProfileForm', () => { ...@@ -169,7 +169,7 @@ describe('BaseDastProfileForm', () => {
expectSubmitNotLoading(); expectSubmitNotLoading();
submitForm(); submitForm();
await wrapper.vm.$nextTick(); await nextTick();
expect(findSubmitButton().props('loading')).toBe(true); expect(findSubmitButton().props('loading')).toBe(true);
}); });
......
import { GlAlert } from '@gitlab/ui'; import { GlAlert } from '@gitlab/ui';
import { within } from '@testing-library/dom'; import { within } from '@testing-library/dom';
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue, { nextTick } from 'vue';
import { merge } from 'lodash'; import { merge } from 'lodash';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import DastFailedSiteValidations from 'ee/security_configuration/dast_profiles/components/dast_failed_site_validations.vue'; import DastFailedSiteValidations from 'ee/security_configuration/dast_profiles/components/dast_failed_site_validations.vue';
...@@ -108,7 +108,7 @@ describe('EE - DastFailedSiteValidations', () => { ...@@ -108,7 +108,7 @@ describe('EE - DastFailedSiteValidations', () => {
expect(findValidationModal().exists()).toBe(false); expect(findValidationModal().exists()).toBe(false);
findFirstRetryButton().click(); findFirstRetryButton().click();
await wrapper.vm.$nextTick(); await nextTick();
const modal = findValidationModal(); const modal = findValidationModal();
expect(modal.exists()).toBe(true); expect(modal.exists()).toBe(true);
...@@ -117,20 +117,20 @@ describe('EE - DastFailedSiteValidations', () => { ...@@ -117,20 +117,20 @@ describe('EE - DastFailedSiteValidations', () => {
it('destroys the modal after it has been hidden', async () => { it('destroys the modal after it has been hidden', async () => {
findFirstRetryButton().click(); findFirstRetryButton().click();
await wrapper.vm.$nextTick(); await nextTick();
const modal = findValidationModal(); const modal = findValidationModal();
expect(modal.exists()).toBe(true); expect(modal.exists()).toBe(true);
modal.vm.$emit('hidden'); modal.vm.$emit('hidden');
await wrapper.vm.$nextTick(); await nextTick();
expect(modal.exists()).toBe(false); expect(modal.exists()).toBe(false);
}); });
it('triggers the dastSiteValidationRevoke GraphQL mutation', async () => { it('triggers the dastSiteValidationRevoke GraphQL mutation', async () => {
findFirstDismissButton().click(); findFirstDismissButton().click();
await wrapper.vm.$nextTick(); await nextTick();
expect(wrapper.findAllComponents(GlAlert)).toHaveLength(1); expect(wrapper.findAllComponents(GlAlert)).toHaveLength(1);
expect(requestHandlers.dastSiteValidationRevoke).toHaveBeenCalledWith({ expect(requestHandlers.dastSiteValidationRevoke).toHaveBeenCalledWith({
......
...@@ -2,6 +2,7 @@ import { GlModal } from '@gitlab/ui'; ...@@ -2,6 +2,7 @@ import { GlModal } from '@gitlab/ui';
import { within } from '@testing-library/dom'; import { within } from '@testing-library/dom';
import { mount, shallowMount, createWrapper } from '@vue/test-utils'; import { mount, shallowMount, createWrapper } from '@vue/test-utils';
import { merge } from 'lodash'; import { merge } from 'lodash';
import { nextTick } from 'vue';
import DastProfilesList from 'ee/security_configuration/dast_profiles/components/dast_profiles_list.vue'; import DastProfilesList from 'ee/security_configuration/dast_profiles/components/dast_profiles_list.vue';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import { siteProfiles as profiles, policySiteProfiles } from '../mocks/mock_data'; import { siteProfiles as profiles, policySiteProfiles } from '../mocks/mock_data';
...@@ -204,7 +205,7 @@ describe('EE - DastProfilesList', () => { ...@@ -204,7 +205,7 @@ describe('EE - DastProfilesList', () => {
getCurrentProfileDeleteButton().trigger('click'); getCurrentProfileDeleteButton().trigger('click');
await wrapper.vm.$nextTick(); await nextTick();
expect( expect(
within(getModal().element).getByText(/are you sure you want to delete this profile/i), within(getModal().element).getByText(/are you sure you want to delete this profile/i),
...@@ -216,7 +217,7 @@ describe('EE - DastProfilesList', () => { ...@@ -216,7 +217,7 @@ describe('EE - DastProfilesList', () => {
getCurrentProfileDeleteButton().trigger('click'); getCurrentProfileDeleteButton().trigger('click');
await wrapper.vm.$nextTick(); await nextTick();
getModal().vm.$emit('ok'); getModal().vm.$emit('ok');
......
...@@ -2,6 +2,7 @@ import { GlDropdown, GlTabs } from '@gitlab/ui'; ...@@ -2,6 +2,7 @@ import { GlDropdown, GlTabs } from '@gitlab/ui';
import { within } from '@testing-library/dom'; import { within } from '@testing-library/dom';
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import { merge } from 'lodash'; import { merge } from 'lodash';
import { nextTick } from 'vue';
import DastFailedSiteValidations from 'ee/security_configuration/dast_profiles/components/dast_failed_site_validations.vue'; import DastFailedSiteValidations from 'ee/security_configuration/dast_profiles/components/dast_failed_site_validations.vue';
import DastProfiles from 'ee/security_configuration/dast_profiles/components/dast_profiles.vue'; import DastProfiles from 'ee/security_configuration/dast_profiles/components/dast_profiles.vue';
import setWindowLocation from 'helpers/set_window_location_helper'; import setWindowLocation from 'helpers/set_window_location_helper';
...@@ -188,7 +189,7 @@ describe('EE - DastProfiles', () => { ...@@ -188,7 +189,7 @@ describe('EE - DastProfiles', () => {
wrapper.setData({ wrapper.setData({
profileTypes: { [profileType]: givenData }, profileTypes: { [profileType]: givenData },
}); });
await wrapper.vm.$nextTick(); await nextTick();
expect(getProfilesComponent(profileType)[propGetter](key)).toEqual(expectedValue); expect(getProfilesComponent(profileType)[propGetter](key)).toEqual(expectedValue);
}, },
......
import { GlFormCheckbox } from '@gitlab/ui'; import { GlFormCheckbox } from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import DastSiteAuthSection from 'ee/security_configuration/dast_profiles/dast_site_profiles/components/dast_site_auth_section.vue'; import DastSiteAuthSection from 'ee/security_configuration/dast_profiles/dast_site_profiles/components/dast_site_auth_section.vue';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
...@@ -30,9 +31,9 @@ describe('DastSiteAuthSection', () => { ...@@ -30,9 +31,9 @@ describe('DastSiteAuthSection', () => {
const findAuthForm = () => wrapper.findByTestId('auth-form'); const findAuthForm = () => wrapper.findByTestId('auth-form');
const findAuthCheckbox = () => wrapper.findComponent(GlFormCheckbox); const findAuthCheckbox = () => wrapper.findComponent(GlFormCheckbox);
const setAuthentication = ({ enabled }) => { const setAuthentication = async ({ enabled }) => {
findAuthCheckbox().vm.$emit('input', enabled); findAuthCheckbox().vm.$emit('input', enabled);
return wrapper.vm.$nextTick(); await nextTick();
}; };
const getLatestInputEventPayload = () => { const getLatestInputEventPayload = () => {
const latestInputEvent = [...wrapper.emitted('input')].pop(); const latestInputEvent = [...wrapper.emitted('input')].pop();
...@@ -118,7 +119,7 @@ describe('DastSiteAuthSection', () => { ...@@ -118,7 +119,7 @@ describe('DastSiteAuthSection', () => {
input.setValue(inputFieldValue); input.setValue(inputFieldValue);
input.trigger('blur'); input.trigger('blur');
}); });
await wrapper.vm.$nextTick(); await nextTick();
expect(getLatestInputEventPayload().state).toBe(true); expect(getLatestInputEventPayload().state).toBe(true);
}); });
}); });
......
...@@ -2,6 +2,7 @@ import { GlLink } from '@gitlab/ui'; ...@@ -2,6 +2,7 @@ import { GlLink } from '@gitlab/ui';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { merge } from 'lodash'; import { merge } from 'lodash';
import { nextTick } from 'vue';
import DynamicFields from 'ee/security_configuration/components/dynamic_fields.vue'; import DynamicFields from 'ee/security_configuration/components/dynamic_fields.vue';
import ExpandableSection from 'ee/security_configuration/components/expandable_section.vue'; import ExpandableSection from 'ee/security_configuration/components/expandable_section.vue';
import AnalyzerConfiguration from 'ee/security_configuration/sast/components/analyzer_configuration.vue'; import AnalyzerConfiguration from 'ee/security_configuration/sast/components/analyzer_configuration.vue';
...@@ -233,9 +234,9 @@ describe('ConfigurationForm component', () => { ...@@ -233,9 +234,9 @@ describe('ConfigurationForm component', () => {
}); });
describe('when alert-tip is dismissed', () => { describe('when alert-tip is dismissed', () => {
beforeEach(() => { beforeEach(async () => {
findAnalyzersSectionTip().vm.$emit('dismiss'); findAnalyzersSectionTip().vm.$emit('dismiss');
return wrapper.vm.$nextTick(); await nextTick();
}); });
it('should not be displayed', () => { it('should not be displayed', () => {
......
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