Commit 56be7263 authored by Illya Klymov's avatar Illya Klymov

Fix operations on destroyed wrappers

@vue/test-utils 1.x introduced check for performing operations on
destroyed wrappers. This commit fixes discovered occurences of such
behavior as part of migration preparation
parent 0e1bd185
......@@ -92,6 +92,8 @@ describe('EE - DastProfiles', () => {
});
it(`shows a "Scanner Profile" dropdown item that links to ${TEST_NEW_DAST_SCANNER_PROFILE_PATH}`, () => {
createComponent();
expect(getSiteProfilesDropdownItem('Scanner Profile').getAttribute('href')).toBe(
TEST_NEW_DAST_SCANNER_PROFILE_PATH,
);
......
......@@ -3,6 +3,7 @@ import { mount, shallowMount } from '@vue/test-utils';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises';
import AlertDetails from '~/alert_management/components/alert_details.vue';
import AlertSummaryRow from '~/alert_management/components/alert_summary_row.vue';
import {
......@@ -201,6 +202,11 @@ describe('AlertDetails', () => {
it('calls `$apollo.mutate` with `createIssueQuery`', () => {
const issueIid = '10';
mountComponent({
mountMethod: mount,
data: { alert: { ...mockAlert } },
});
jest
.spyOn(wrapper.vm.$apollo, 'mutate')
.mockResolvedValue({ data: { createAlertIssue: { issue: { iid: issueIid } } } });
......@@ -215,7 +221,7 @@ describe('AlertDetails', () => {
});
});
it('shows error alert when incident creation fails ', () => {
it('shows error alert when incident creation fails ', async () => {
const errorMsg = 'Something went wrong';
mountComponent({
mountMethod: mount,
......@@ -225,9 +231,8 @@ describe('AlertDetails', () => {
jest.spyOn(wrapper.vm.$apollo, 'mutate').mockRejectedValue(errorMsg);
findCreateIncidentBtn().trigger('click');
setImmediate(() => {
expect(findIncidentCreationAlert().text()).toBe(errorMsg);
});
await waitForPromises();
expect(findIncidentCreationAlert().text()).toBe(errorMsg);
});
});
......
......@@ -24,7 +24,7 @@ describe('UninstallApplicationButton', () => {
${UPDATING} | ${false} | ${true} | ${'Uninstall'}
${UNINSTALLING} | ${true} | ${true} | ${'Uninstalling'}
`('when app status is $status', ({ loading, disabled, status, text }) => {
beforeAll(() => {
beforeEach(() => {
createComponent({ status });
});
......
......@@ -116,6 +116,8 @@ describe('Design management toolbar component', () => {
});
it('renders download button with correct link', () => {
createComponent();
expect(wrapper.find(GlButton).attributes('href')).toBe(
'/-/designs/306/7f747adcd4693afadbe968d7ba7d983349b9012d',
);
......
......@@ -73,6 +73,8 @@ describe('LogAdvancedFilters', () => {
});
it('displays search tokens', () => {
initWrapper();
expect(getSearchToken(TOKEN_TYPE_POD_NAME)).toMatchObject({
title: 'Pod name',
unique: true,
......
......@@ -76,11 +76,15 @@ describe('AlertWidgetForm', () => {
});
it('shows correct title and button text', () => {
createComponent();
expect(modalTitle()).toBe('Add alert');
expect(submitButton().text()).toBe('Add');
});
it('sets tracking options for create alert', () => {
createComponent();
expect(submitButtonTrackingOpts()).toEqual(dataTrackingOptions.create);
});
......
......@@ -61,6 +61,7 @@ describe('operation settings external dashboard component', () => {
describe('expand/collapse button', () => {
it('renders as an expand button by default', () => {
mountComponent();
const button = wrapper.find(GlButton);
expect(button.text()).toBe('Expand');
......
......@@ -94,6 +94,8 @@ describe('MrWidgetPipelineContainer', () => {
describe('with artifacts path', () => {
it('renders the artifacts app', () => {
factory();
expect(wrapper.find(ArtifactsApp).isVisible()).toBe(true);
});
});
......
......@@ -98,6 +98,8 @@ describe('Commits header component', () => {
});
it('does has merge commit part of the message', () => {
createComponent();
expect(findHeaderWrapper().text()).toContain('1 merge commit');
});
});
......
......@@ -81,6 +81,7 @@ describe('User Popover Component', () => {
});
it('shows icon for location', () => {
createWrapper();
const iconEl = wrapper.find(GlIcon);
expect(iconEl.props('name')).toEqual('location');
......
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