Commit 982d094a authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch 'xanf/fix-operations-on-destroyed-wrappers' into 'master'

Fix operations on destroyed wrappers

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