2021-10-27 12:09:41 +00:00
|
|
|
import { GlBadge, GlLink, GlIcon, GlButton, GlDropdown } from '@gitlab/ui';
|
2021-01-19 12:10:46 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
2021-02-14 18:09:20 +00:00
|
|
|
import MockAdapter from 'axios-mock-adapter';
|
2021-01-19 12:10:46 +00:00
|
|
|
import Vue, { nextTick } from 'vue';
|
2021-01-21 18:09:11 +00:00
|
|
|
import VueApollo from 'vue-apollo';
|
2021-11-24 12:10:21 +00:00
|
|
|
import * as Sentry from '@sentry/browser';
|
2021-01-21 18:09:11 +00:00
|
|
|
import createMockApollo from 'helpers/mock_apollo_helper';
|
2021-09-29 12:11:22 +00:00
|
|
|
import waitForPromises from 'helpers/wait_for_promises';
|
2021-05-13 00:10:23 +00:00
|
|
|
import { securityReportMergeRequestDownloadPathsQueryResponse } from 'jest/vue_shared/security_reports/mock_data';
|
2021-10-26 18:09:19 +00:00
|
|
|
import api from '~/api';
|
2019-12-05 18:07:51 +00:00
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2022-01-11 18:16:38 +00:00
|
|
|
import Poll from '~/lib/utils/poll';
|
2021-02-14 18:09:20 +00:00
|
|
|
import { setFaviconOverlay } from '~/lib/utils/favicon';
|
2017-05-26 15:47:34 +00:00
|
|
|
import notify from '~/lib/utils/notify';
|
2020-03-02 18:07:42 +00:00
|
|
|
import SmartInterval from '~/smart_interval';
|
2021-09-29 15:11:47 +00:00
|
|
|
import {
|
|
|
|
registerExtension,
|
|
|
|
registeredExtensions,
|
|
|
|
} from '~/vue_merge_request_widget/components/extensions';
|
2019-12-05 12:07:43 +00:00
|
|
|
import { SUCCESS } from '~/vue_merge_request_widget/components/deployment/constants';
|
2021-02-14 18:09:20 +00:00
|
|
|
import eventHub from '~/vue_merge_request_widget/event_hub';
|
|
|
|
import MrWidgetOptions from '~/vue_merge_request_widget/mr_widget_options.vue';
|
|
|
|
import { stateKey } from '~/vue_merge_request_widget/stores/state_maps';
|
2021-11-24 12:10:21 +00:00
|
|
|
import StatusIcon from '~/vue_merge_request_widget/components/extensions/status_icon.vue';
|
2021-08-02 15:08:56 +00:00
|
|
|
import securityReportMergeRequestDownloadPathsQuery from '~/vue_shared/security_reports/graphql/queries/security_report_merge_request_download_paths.query.graphql';
|
2021-02-01 15:08:56 +00:00
|
|
|
import { faviconDataUrl, overlayDataUrl } from '../lib/utils/mock_data';
|
|
|
|
import mockData from './mock_data';
|
2021-11-24 12:10:21 +00:00
|
|
|
import {
|
|
|
|
workingExtension,
|
|
|
|
collapsedDataErrorExtension,
|
|
|
|
fullDataErrorExtension,
|
2022-01-11 18:16:38 +00:00
|
|
|
pollingExtension,
|
|
|
|
pollingErrorExtension,
|
2021-11-24 12:10:21 +00:00
|
|
|
} from './test_extensions';
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-10-26 18:09:19 +00:00
|
|
|
jest.mock('~/api.js');
|
|
|
|
|
2020-03-02 18:07:42 +00:00
|
|
|
jest.mock('~/smart_interval');
|
|
|
|
|
2021-01-08 09:10:50 +00:00
|
|
|
jest.mock('~/lib/utils/favicon');
|
|
|
|
|
2021-01-21 18:09:11 +00:00
|
|
|
Vue.use(VueApollo);
|
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
describe('MrWidgetOptions', () => {
|
|
|
|
let wrapper;
|
2019-12-05 18:07:51 +00:00
|
|
|
let mock;
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-05-27 12:10:56 +00:00
|
|
|
const COLLABORATION_MESSAGE = 'Members who can merge are allowed to add commits';
|
2022-03-24 12:07:26 +00:00
|
|
|
const findExtensionToggleButton = () =>
|
|
|
|
wrapper.find('[data-testid="widget-extension"] [data-testid="toggle-button"]');
|
2018-12-27 13:58:40 +00:00
|
|
|
|
2017-05-09 04:15:34 +00:00
|
|
|
beforeEach(() => {
|
2019-12-05 18:07:51 +00:00
|
|
|
gl.mrWidgetData = { ...mockData };
|
|
|
|
gon.features = { asyncMrWidget: true };
|
|
|
|
|
|
|
|
mock = new MockAdapter(axios);
|
|
|
|
mock.onGet(mockData.merge_request_widget_path).reply(() => [200, { ...mockData }]);
|
|
|
|
mock.onGet(mockData.merge_request_cached_widget_path).reply(() => [200, { ...mockData }]);
|
2017-05-09 04:15:34 +00:00
|
|
|
});
|
|
|
|
|
2018-09-25 13:49:05 +00:00
|
|
|
afterEach(() => {
|
2019-12-05 18:07:51 +00:00
|
|
|
mock.restore();
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
2020-02-27 21:09:17 +00:00
|
|
|
|
2019-12-05 18:07:51 +00:00
|
|
|
gl.mrWidgetData = {};
|
|
|
|
gon.features = {};
|
2018-09-25 13:49:05 +00:00
|
|
|
});
|
|
|
|
|
2021-01-21 18:09:11 +00:00
|
|
|
const createComponent = (mrData = mockData, options = {}) => {
|
2021-01-19 12:10:46 +00:00
|
|
|
if (wrapper) {
|
|
|
|
wrapper.destroy();
|
2020-02-27 21:09:17 +00:00
|
|
|
}
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper = mount(MrWidgetOptions, {
|
|
|
|
propsData: {
|
|
|
|
mrData: { ...mrData },
|
|
|
|
},
|
2021-01-21 18:09:11 +00:00
|
|
|
...options,
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2020-03-02 18:07:42 +00:00
|
|
|
|
|
|
|
return axios.waitForAll();
|
2020-02-27 21:09:17 +00:00
|
|
|
};
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
const findSuggestPipeline = () => wrapper.find('[data-testid="mr-suggest-pipeline"]');
|
|
|
|
const findSuggestPipelineButton = () => findSuggestPipeline().find('button');
|
|
|
|
const findSecurityMrWidget = () => wrapper.find('[data-testid="security-mr-widget"]');
|
2020-08-04 09:09:45 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('default', () => {
|
|
|
|
beforeEach(() => {
|
2021-02-01 15:08:56 +00:00
|
|
|
jest.spyOn(document, 'dispatchEvent');
|
2020-03-02 18:07:42 +00:00
|
|
|
return createComponent();
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('data', () => {
|
|
|
|
it('should instantiate Store and Service', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.mr).toBeDefined();
|
|
|
|
expect(wrapper.vm.service).toBeDefined();
|
2017-05-09 04:15:34 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('computed', () => {
|
|
|
|
describe('componentName', () => {
|
2021-08-17 18:10:35 +00:00
|
|
|
it.each`
|
|
|
|
state | componentName
|
|
|
|
${'merged'} | ${'mr-widget-merged'}
|
|
|
|
${'conflicts'} | ${'mr-widget-conflicts'}
|
|
|
|
${'shaMismatch'} | ${'sha-mismatch'}
|
|
|
|
`('should translate $state into $componentName', ({ state, componentName }) => {
|
|
|
|
wrapper.vm.mr.state = state;
|
|
|
|
|
|
|
|
expect(wrapper.vm.componentName).toEqual(componentName);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2017-05-09 04:15:34 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('shouldRenderPipelines', () => {
|
|
|
|
it('should return true when hasCI is true', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.hasCI = true;
|
2020-02-17 15:09:01 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.shouldRenderPipelines).toBeTruthy();
|
2020-02-17 15:09:01 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should return false when hasCI is false', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.hasCI = false;
|
2020-02-17 15:09:01 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.shouldRenderPipelines).toBeFalsy();
|
2020-02-17 15:09:01 +00:00
|
|
|
});
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2020-02-17 15:09:01 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('shouldRenderRelatedLinks', () => {
|
|
|
|
it('should return false for the initial data', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.shouldRenderRelatedLinks).toBeFalsy();
|
2020-02-17 15:09:01 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should return true if there is relatedLinks in MR', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
Vue.set(wrapper.vm.mr, 'relatedLinks', {});
|
2020-02-17 15:09:01 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.shouldRenderRelatedLinks).toBeTruthy();
|
2020-02-17 15:09:01 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('shouldRenderSourceBranchRemovalStatus', () => {
|
2020-02-17 15:09:01 +00:00
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.state = 'readyToMerge';
|
2020-02-17 15:09:01 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should return true when cannot remove source branch and branch will be removed', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.canRemoveSourceBranch = false;
|
|
|
|
wrapper.vm.mr.shouldRemoveSourceBranch = true;
|
2020-02-27 21:09:17 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.shouldRenderSourceBranchRemovalStatus).toEqual(true);
|
2020-02-17 15:09:01 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should return false when can remove source branch and branch will be removed', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.canRemoveSourceBranch = true;
|
|
|
|
wrapper.vm.mr.shouldRemoveSourceBranch = true;
|
2020-02-17 15:09:01 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.shouldRenderSourceBranchRemovalStatus).toEqual(false);
|
2020-02-17 15:09:01 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should return false when cannot remove source branch and branch will not be removed', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.canRemoveSourceBranch = false;
|
|
|
|
wrapper.vm.mr.shouldRemoveSourceBranch = false;
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.shouldRenderSourceBranchRemovalStatus).toEqual(false);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should return false when in merged state', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.canRemoveSourceBranch = false;
|
|
|
|
wrapper.vm.mr.shouldRemoveSourceBranch = true;
|
|
|
|
wrapper.vm.mr.state = 'merged';
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.shouldRenderSourceBranchRemovalStatus).toEqual(false);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-03-12 12:08:47 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should return false when in nothing to merge state', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.canRemoveSourceBranch = false;
|
|
|
|
wrapper.vm.mr.shouldRemoveSourceBranch = true;
|
|
|
|
wrapper.vm.mr.state = 'nothingToMerge';
|
2018-03-08 13:33:59 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.shouldRenderSourceBranchRemovalStatus).toEqual(false);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-03-08 13:33:59 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('shouldRenderCollaborationStatus', () => {
|
|
|
|
describe('when collaboration is allowed', () => {
|
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.allowCollaboration = true;
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-03-08 13:33:59 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('when merge request is opened', () => {
|
2022-04-13 21:09:57 +00:00
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.isOpen = true;
|
2022-04-13 21:09:57 +00:00
|
|
|
return nextTick();
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-03-08 13:33:59 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should render collaboration status', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.text()).toContain(COLLABORATION_MESSAGE);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
|
|
|
});
|
2018-03-12 12:08:47 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('when merge request is not opened', () => {
|
2022-04-13 21:09:57 +00:00
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.isOpen = false;
|
2022-04-13 21:09:57 +00:00
|
|
|
return nextTick();
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-03-12 12:08:47 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should not render collaboration status', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.text()).not.toContain(COLLABORATION_MESSAGE);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-03-12 12:08:47 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('when collaboration is not allowed', () => {
|
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.allowCollaboration = false;
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-03-12 12:08:47 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('when merge request is opened', () => {
|
2022-04-13 21:09:57 +00:00
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.isOpen = true;
|
2022-04-13 21:09:57 +00:00
|
|
|
return nextTick();
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-12-25 20:41:32 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should not render collaboration status', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.text()).not.toContain(COLLABORATION_MESSAGE);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
|
|
|
});
|
2018-12-25 20:41:32 +00:00
|
|
|
});
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-12-25 20:41:32 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('showMergePipelineForkWarning', () => {
|
|
|
|
describe('when the source project and target project are the same', () => {
|
2022-04-13 21:09:57 +00:00
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
Vue.set(wrapper.vm.mr, 'mergePipelinesEnabled', true);
|
|
|
|
Vue.set(wrapper.vm.mr, 'sourceProjectId', 1);
|
|
|
|
Vue.set(wrapper.vm.mr, 'targetProjectId', 1);
|
2022-04-13 21:09:57 +00:00
|
|
|
return nextTick();
|
2018-12-25 20:41:32 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should be false', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.showMergePipelineForkWarning).toEqual(false);
|
2018-12-25 20:41:32 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('when merge pipelines are not enabled', () => {
|
2022-04-13 21:09:57 +00:00
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
Vue.set(wrapper.vm.mr, 'mergePipelinesEnabled', false);
|
|
|
|
Vue.set(wrapper.vm.mr, 'sourceProjectId', 1);
|
|
|
|
Vue.set(wrapper.vm.mr, 'targetProjectId', 2);
|
2022-04-13 21:09:57 +00:00
|
|
|
return nextTick();
|
2018-12-25 20:41:32 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should be false', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.showMergePipelineForkWarning).toEqual(false);
|
2018-12-25 20:41:32 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('when merge pipelines are enabled _and_ the source project and target project are different', () => {
|
2022-04-13 21:09:57 +00:00
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
Vue.set(wrapper.vm.mr, 'mergePipelinesEnabled', true);
|
|
|
|
Vue.set(wrapper.vm.mr, 'sourceProjectId', 1);
|
|
|
|
Vue.set(wrapper.vm.mr, 'targetProjectId', 2);
|
2022-04-13 21:09:57 +00:00
|
|
|
return nextTick();
|
2018-12-25 20:41:32 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should be true', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.showMergePipelineForkWarning).toEqual(true);
|
2018-12-25 20:41:32 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-12-09 03:09:24 +00:00
|
|
|
|
|
|
|
describe('formattedHumanAccess', () => {
|
|
|
|
it('when user is a tool admin but not a member of project', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.humanAccess = null;
|
2020-12-09 03:09:24 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.formattedHumanAccess).toEqual('');
|
2020-12-09 03:09:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('when user a member of the project', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.humanAccess = 'Owner';
|
2020-12-09 03:09:24 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.formattedHumanAccess).toEqual('owner');
|
2020-12-09 03:09:24 +00:00
|
|
|
});
|
|
|
|
});
|
2018-12-25 20:41:32 +00:00
|
|
|
});
|
2019-04-15 13:25:48 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('methods', () => {
|
|
|
|
describe('checkStatus', () => {
|
2020-03-10 09:08:10 +00:00
|
|
|
let cb;
|
|
|
|
let isCbExecuted;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2021-01-19 18:11:04 +00:00
|
|
|
jest.spyOn(wrapper.vm.service, 'checkStatus').mockResolvedValue({ data: mockData });
|
2021-01-19 12:10:46 +00:00
|
|
|
jest.spyOn(wrapper.vm.mr, 'setData').mockImplementation(() => {});
|
|
|
|
jest.spyOn(wrapper.vm, 'handleNotification').mockImplementation(() => {});
|
2019-04-15 13:25:48 +00:00
|
|
|
|
2020-03-10 09:08:10 +00:00
|
|
|
isCbExecuted = false;
|
|
|
|
cb = () => {
|
2020-02-27 21:09:17 +00:00
|
|
|
isCbExecuted = true;
|
|
|
|
};
|
2020-03-10 09:08:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should tell service to check status if document is visible', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.checkStatus(cb);
|
2019-04-15 13:25:48 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
return nextTick().then(() => {
|
|
|
|
expect(wrapper.vm.service.checkStatus).toHaveBeenCalled();
|
|
|
|
expect(wrapper.vm.mr.setData).toHaveBeenCalled();
|
|
|
|
expect(wrapper.vm.handleNotification).toHaveBeenCalledWith(mockData);
|
2020-02-27 21:09:17 +00:00
|
|
|
expect(isCbExecuted).toBeTruthy();
|
|
|
|
});
|
2019-04-15 13:25:48 +00:00
|
|
|
});
|
|
|
|
});
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('initPolling', () => {
|
|
|
|
it('should call SmartInterval', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.initPolling();
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2020-03-02 18:07:42 +00:00
|
|
|
expect(SmartInterval).toHaveBeenCalledWith(
|
|
|
|
expect.objectContaining({
|
2021-01-19 12:10:46 +00:00
|
|
|
callback: wrapper.vm.checkStatus,
|
2020-03-02 18:07:42 +00:00
|
|
|
}),
|
|
|
|
);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2017-05-09 04:15:34 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('initDeploymentsPolling', () => {
|
|
|
|
it('should call SmartInterval', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.initDeploymentsPolling();
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2020-03-02 18:07:42 +00:00
|
|
|
expect(SmartInterval).toHaveBeenCalledWith(
|
|
|
|
expect.objectContaining({
|
2021-01-19 12:10:46 +00:00
|
|
|
callback: wrapper.vm.fetchPreMergeDeployments,
|
2020-03-02 18:07:42 +00:00
|
|
|
}),
|
|
|
|
);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2017-05-09 04:15:34 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('fetchDeployments', () => {
|
|
|
|
it('should fetch deployments', () => {
|
2020-03-02 18:07:42 +00:00
|
|
|
jest
|
2021-01-19 12:10:46 +00:00
|
|
|
.spyOn(wrapper.vm.service, 'fetchDeployments')
|
2021-01-19 18:11:04 +00:00
|
|
|
.mockResolvedValue({ data: [{ id: 1, status: SUCCESS }] });
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.fetchPreMergeDeployments();
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
return nextTick().then(() => {
|
|
|
|
expect(wrapper.vm.service.fetchDeployments).toHaveBeenCalled();
|
|
|
|
expect(wrapper.vm.mr.deployments.length).toEqual(1);
|
|
|
|
expect(wrapper.vm.mr.deployments[0].id).toBe(1);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-03-09 16:35:31 +00:00
|
|
|
});
|
2017-05-09 04:15:34 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('fetchActionsContent', () => {
|
|
|
|
it('should fetch content of Cherry Pick and Revert modals', () => {
|
2020-03-02 18:07:42 +00:00
|
|
|
jest
|
2021-01-19 12:10:46 +00:00
|
|
|
.spyOn(wrapper.vm.service, 'fetchMergeActionsContent')
|
2021-01-19 18:11:04 +00:00
|
|
|
.mockResolvedValue({ data: 'hello world' });
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.fetchActionsContent();
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
return nextTick().then(() => {
|
|
|
|
expect(wrapper.vm.service.fetchMergeActionsContent).toHaveBeenCalled();
|
2020-02-27 21:09:17 +00:00
|
|
|
expect(document.body.textContent).toContain('hello world');
|
2021-02-01 15:08:56 +00:00
|
|
|
expect(document.dispatchEvent).toHaveBeenCalledWith(
|
|
|
|
new CustomEvent('merged:UpdateActions'),
|
|
|
|
);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
|
|
|
});
|
2017-05-09 04:15:34 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('bindEventHubListeners', () => {
|
2020-03-02 18:07:42 +00:00
|
|
|
it.each`
|
|
|
|
event | method | methodArgs
|
2020-12-23 21:10:24 +00:00
|
|
|
${'MRWidgetUpdateRequested'} | ${'checkStatus'} | ${(x) => [x]}
|
|
|
|
${'MRWidgetRebaseSuccess'} | ${'checkStatus'} | ${(x) => [x, true]}
|
2020-03-02 18:07:42 +00:00
|
|
|
${'FetchActionsContent'} | ${'fetchActionsContent'} | ${() => []}
|
|
|
|
${'EnablePolling'} | ${'resumePolling'} | ${() => []}
|
|
|
|
${'DisablePolling'} | ${'stopPolling'} | ${() => []}
|
|
|
|
`('should bind to $event', ({ event, method, methodArgs }) => {
|
2021-01-19 12:10:46 +00:00
|
|
|
jest.spyOn(wrapper.vm, method).mockImplementation();
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2020-03-02 18:07:42 +00:00
|
|
|
const eventArg = {};
|
|
|
|
eventHub.$emit(event, eventArg);
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm[method]).toHaveBeenCalledWith(...methodArgs(eventArg));
|
2020-03-02 18:07:42 +00:00
|
|
|
});
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2020-03-02 18:07:42 +00:00
|
|
|
it('should bind to SetBranchRemoveFlag', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.mr.isRemovingSourceBranch).toBe(false);
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2020-03-02 18:07:42 +00:00
|
|
|
eventHub.$emit('SetBranchRemoveFlag', [true]);
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.mr.isRemovingSourceBranch).toBe(true);
|
2020-03-02 18:07:42 +00:00
|
|
|
});
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2020-03-02 18:07:42 +00:00
|
|
|
it('should bind to FailedToMerge', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.state = '';
|
|
|
|
wrapper.vm.mr.mergeError = '';
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2020-03-02 18:07:42 +00:00
|
|
|
const mergeError = 'Something bad happened!';
|
|
|
|
eventHub.$emit('FailedToMerge', mergeError);
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.mr.state).toBe('failedToMerge');
|
|
|
|
expect(wrapper.vm.mr.mergeError).toBe(mergeError);
|
2020-03-02 18:07:42 +00:00
|
|
|
});
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2020-03-02 18:07:42 +00:00
|
|
|
it('should bind to UpdateWidgetData', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
jest.spyOn(wrapper.vm.mr, 'setData').mockImplementation();
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2020-03-02 18:07:42 +00:00
|
|
|
const data = { ...mockData };
|
|
|
|
eventHub.$emit('UpdateWidgetData', data);
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.mr.setData).toHaveBeenCalledWith(data);
|
2019-12-05 18:07:51 +00:00
|
|
|
});
|
2017-05-09 04:15:34 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('setFavicon', () => {
|
|
|
|
let faviconElement;
|
2017-09-06 16:14:34 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
const favicon = document.createElement('link');
|
|
|
|
favicon.setAttribute('id', 'favicon');
|
2022-05-12 09:08:08 +00:00
|
|
|
favicon.setAttribute('data-original-href', faviconDataUrl);
|
2020-02-27 21:09:17 +00:00
|
|
|
document.body.appendChild(favicon);
|
2017-09-06 16:14:34 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
faviconElement = document.getElementById('favicon');
|
|
|
|
});
|
2017-09-06 16:14:34 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
afterEach(() => {
|
|
|
|
document.body.removeChild(document.getElementById('favicon'));
|
|
|
|
});
|
2017-09-06 16:14:34 +00:00
|
|
|
|
2021-01-08 09:10:50 +00:00
|
|
|
it('should call setFavicon method', async () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.ciStatusFaviconPath = overlayDataUrl;
|
2021-01-08 09:10:50 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
await wrapper.vm.setFaviconHelper();
|
2021-01-08 09:10:50 +00:00
|
|
|
|
|
|
|
expect(setFaviconOverlay).toHaveBeenCalledWith(overlayDataUrl);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2022-04-13 21:09:57 +00:00
|
|
|
it('should not call setFavicon when there is no ciStatusFaviconPath', async () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.ciStatusFaviconPath = null;
|
2022-04-13 21:09:57 +00:00
|
|
|
await wrapper.vm.setFaviconHelper();
|
|
|
|
expect(faviconElement.getAttribute('href')).toEqual(null);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2017-05-09 04:15:34 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('handleNotification', () => {
|
|
|
|
const data = {
|
|
|
|
ci_status: 'running',
|
|
|
|
title: 'title',
|
|
|
|
pipeline: { details: { status: { label: 'running-label' } } },
|
|
|
|
};
|
2017-05-26 15:47:34 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
beforeEach(() => {
|
2020-03-02 18:07:42 +00:00
|
|
|
jest.spyOn(notify, 'notifyMe').mockImplementation(() => {});
|
2017-05-26 15:47:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.ciStatus = 'failed';
|
|
|
|
wrapper.vm.mr.gitlabLogo = 'logo.png';
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2017-05-26 15:47:34 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should call notifyMe', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.handleNotification(data);
|
2017-05-26 15:47:34 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
expect(notify.notifyMe).toHaveBeenCalledWith(
|
|
|
|
'Pipeline running-label',
|
|
|
|
'Pipeline running-label for "title"',
|
|
|
|
'logo.png',
|
|
|
|
);
|
|
|
|
});
|
2017-05-26 15:47:34 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should not call notifyMe if the status has not changed', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.ciStatus = data.ci_status;
|
2017-05-26 15:47:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.handleNotification(data);
|
2018-02-12 07:20:52 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
expect(notify.notifyMe).not.toHaveBeenCalled();
|
2018-02-12 07:20:52 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('should not notify if no pipeline provided', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.handleNotification({
|
2020-02-27 21:09:17 +00:00
|
|
|
...data,
|
|
|
|
pipeline: undefined,
|
|
|
|
});
|
2017-05-26 15:47:34 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
expect(notify.notifyMe).not.toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|
2019-12-05 18:07:51 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('resumePolling', () => {
|
2020-03-02 18:07:42 +00:00
|
|
|
it('should call stopTimer on pollingInterval', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
jest.spyOn(wrapper.vm.pollingInterval, 'resume').mockImplementation(() => {});
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.resumePolling();
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.pollingInterval.resume).toHaveBeenCalled();
|
2020-03-02 18:07:42 +00:00
|
|
|
});
|
2017-05-09 04:15:34 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('stopPolling', () => {
|
2020-03-02 18:07:42 +00:00
|
|
|
it('should call stopTimer on pollingInterval', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
jest.spyOn(wrapper.vm.pollingInterval, 'stopTimer').mockImplementation(() => {});
|
2019-12-05 18:07:51 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.stopPolling();
|
2017-05-09 04:15:34 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.vm.pollingInterval.stopTimer).toHaveBeenCalled();
|
2020-03-02 18:07:42 +00:00
|
|
|
});
|
2017-05-09 04:15:34 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('rendering relatedLinks', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({
|
|
|
|
...mockData,
|
|
|
|
issues_links: {
|
|
|
|
closing: `
|
|
|
|
<a class="close-related-link" href="#">
|
|
|
|
Close
|
|
|
|
</a>
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
return nextTick();
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2017-12-19 17:50:38 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('renders if there are relatedLinks', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.find('.close-related-link').exists()).toBe(true);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2017-12-19 17:50:38 +00:00
|
|
|
|
2022-04-13 21:09:57 +00:00
|
|
|
it('does not render if state is nothingToMerge', async () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.state = stateKey.nothingToMerge;
|
2022-04-13 21:09:57 +00:00
|
|
|
await nextTick();
|
|
|
|
expect(wrapper.find('.close-related-link').exists()).toBe(false);
|
2017-12-19 17:50:38 +00:00
|
|
|
});
|
|
|
|
});
|
2018-03-08 13:33:59 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('rendering source branch removal status', () => {
|
2022-04-13 21:09:57 +00:00
|
|
|
it('renders when user cannot remove branch and branch should be removed', async () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.canRemoveSourceBranch = false;
|
|
|
|
wrapper.vm.mr.shouldRemoveSourceBranch = true;
|
|
|
|
wrapper.vm.mr.state = 'readyToMerge';
|
2018-03-08 13:33:59 +00:00
|
|
|
|
2022-04-13 21:09:57 +00:00
|
|
|
await nextTick();
|
|
|
|
const tooltip = wrapper.find('[data-testid="question-o-icon"]');
|
2018-03-08 13:33:59 +00:00
|
|
|
|
2022-04-13 21:09:57 +00:00
|
|
|
expect(wrapper.text()).toContain('Deletes the source branch');
|
|
|
|
expect(tooltip.attributes('title')).toBe(
|
|
|
|
'A user with write access to the source branch selected this option',
|
|
|
|
);
|
2018-03-08 13:33:59 +00:00
|
|
|
});
|
2018-03-12 12:08:47 +00:00
|
|
|
|
2022-04-13 21:09:57 +00:00
|
|
|
it('does not render in merged state', async () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.canRemoveSourceBranch = false;
|
|
|
|
wrapper.vm.mr.shouldRemoveSourceBranch = true;
|
|
|
|
wrapper.vm.mr.state = 'merged';
|
2018-03-12 12:08:47 +00:00
|
|
|
|
2022-04-13 21:09:57 +00:00
|
|
|
await nextTick();
|
|
|
|
expect(wrapper.text()).toContain('The source branch has been deleted');
|
|
|
|
expect(wrapper.text()).not.toContain('Deletes the source branch');
|
2018-03-12 12:08:47 +00:00
|
|
|
});
|
|
|
|
});
|
2018-03-09 16:35:31 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('rendering deployments', () => {
|
|
|
|
const changes = [
|
|
|
|
{
|
|
|
|
path: 'index.html',
|
2021-04-22 12:09:49 +00:00
|
|
|
external_url: 'http://root-main-patch-91341.volatile-watch.surge.sh/index.html',
|
2020-02-27 21:09:17 +00:00
|
|
|
},
|
2018-10-22 08:31:24 +00:00
|
|
|
{
|
2020-02-27 21:09:17 +00:00
|
|
|
path: 'imgs/gallery.html',
|
2021-04-22 12:09:49 +00:00
|
|
|
external_url: 'http://root-main-patch-91341.volatile-watch.surge.sh/imgs/gallery.html',
|
2018-10-22 08:31:24 +00:00
|
|
|
},
|
|
|
|
{
|
2020-02-27 21:09:17 +00:00
|
|
|
path: 'about/',
|
2021-04-22 12:09:49 +00:00
|
|
|
external_url: 'http://root-main-patch-91341.volatile-watch.surge.sh/about/',
|
2018-10-22 08:31:24 +00:00
|
|
|
},
|
2020-02-27 21:09:17 +00:00
|
|
|
];
|
|
|
|
const deploymentMockData = {
|
|
|
|
id: 15,
|
|
|
|
name: 'review/diplo',
|
|
|
|
url: '/root/acets-review-apps/environments/15',
|
|
|
|
stop_url: '/root/acets-review-apps/environments/15/stop',
|
|
|
|
metrics_url: '/root/acets-review-apps/environments/15/deployments/1/metrics',
|
|
|
|
metrics_monitoring_url: '/root/acets-review-apps/environments/15/metrics',
|
|
|
|
external_url: 'http://diplo.',
|
|
|
|
external_url_formatted: 'diplo.',
|
|
|
|
deployed_at: '2017-03-22T22:44:42.258Z',
|
|
|
|
deployed_at_formatted: 'Mar 22, 2017 10:44pm',
|
|
|
|
changes,
|
|
|
|
status: SUCCESS,
|
|
|
|
};
|
2018-03-09 16:35:31 +00:00
|
|
|
|
2022-04-13 21:09:57 +00:00
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.deployments.push(
|
2020-02-27 21:09:17 +00:00
|
|
|
{
|
|
|
|
...deploymentMockData,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
...deploymentMockData,
|
|
|
|
id: deploymentMockData.id + 1,
|
|
|
|
},
|
|
|
|
);
|
2018-03-09 16:35:31 +00:00
|
|
|
|
2022-04-13 21:09:57 +00:00
|
|
|
return nextTick();
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders multiple deployments', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.findAll('.deploy-heading').length).toBe(2);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-10-22 08:31:24 +00:00
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('renders dropdpown with multiple file changes', () => {
|
|
|
|
expect(
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.find('.js-mr-wigdet-deployment-dropdown').findAll('.js-filtered-dropdown-result')
|
|
|
|
.length,
|
2020-02-27 21:09:17 +00:00
|
|
|
).toEqual(changes.length);
|
|
|
|
});
|
2018-10-22 08:31:24 +00:00
|
|
|
});
|
2018-10-29 11:34:41 +00:00
|
|
|
|
2020-07-17 03:09:14 +00:00
|
|
|
describe('code quality widget', () => {
|
|
|
|
it('renders the component', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.find('.js-codequality-widget').exists()).toBe(true);
|
2020-07-17 03:09:14 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('pipeline for target branch after merge', () => {
|
|
|
|
describe('with information for target branch pipeline', () => {
|
2022-04-13 21:09:57 +00:00
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.state = 'merged';
|
|
|
|
wrapper.vm.mr.mergePipeline = {
|
2020-02-27 21:09:17 +00:00
|
|
|
id: 127,
|
|
|
|
user: {
|
2018-10-29 11:34:41 +00:00
|
|
|
id: 1,
|
|
|
|
name: 'Administrator',
|
|
|
|
username: 'root',
|
|
|
|
state: 'active',
|
|
|
|
avatar_url: null,
|
|
|
|
web_url: 'http://localhost:3000/root',
|
|
|
|
status_tooltip_html: null,
|
|
|
|
path: '/root',
|
|
|
|
},
|
2020-02-27 21:09:17 +00:00
|
|
|
active: true,
|
|
|
|
coverage: null,
|
|
|
|
source: 'push',
|
|
|
|
created_at: '2018-10-22T11:41:35.186Z',
|
|
|
|
updated_at: '2018-10-22T11:41:35.433Z',
|
|
|
|
path: '/root/ci-web-terminal/pipelines/127',
|
|
|
|
flags: {
|
|
|
|
latest: true,
|
|
|
|
stuck: true,
|
|
|
|
auto_devops: false,
|
|
|
|
yaml_errors: false,
|
|
|
|
retryable: false,
|
|
|
|
cancelable: true,
|
|
|
|
failure_reason: false,
|
|
|
|
},
|
|
|
|
details: {
|
|
|
|
status: {
|
|
|
|
icon: 'status_pending',
|
|
|
|
text: 'pending',
|
|
|
|
label: 'pending',
|
|
|
|
group: 'pending',
|
|
|
|
tooltip: 'pending',
|
|
|
|
has_details: true,
|
|
|
|
details_path: '/root/ci-web-terminal/pipelines/127',
|
|
|
|
illustration: null,
|
|
|
|
favicon:
|
|
|
|
'/assets/ci_favicons/favicon_status_pending-5bdf338420e5221ca24353b6bff1c9367189588750632e9a871b7af09ff6a2ae.png',
|
|
|
|
},
|
|
|
|
duration: null,
|
|
|
|
finished_at: null,
|
|
|
|
stages: [
|
|
|
|
{
|
|
|
|
name: 'test',
|
|
|
|
title: 'test: pending',
|
|
|
|
status: {
|
|
|
|
icon: 'status_pending',
|
|
|
|
text: 'pending',
|
|
|
|
label: 'pending',
|
|
|
|
group: 'pending',
|
|
|
|
tooltip: 'pending',
|
|
|
|
has_details: true,
|
|
|
|
details_path: '/root/ci-web-terminal/pipelines/127#test',
|
|
|
|
illustration: null,
|
|
|
|
favicon:
|
|
|
|
'/assets/ci_favicons/favicon_status_pending-5bdf338420e5221ca24353b6bff1c9367189588750632e9a871b7af09ff6a2ae.png',
|
|
|
|
},
|
|
|
|
path: '/root/ci-web-terminal/pipelines/127#test',
|
|
|
|
dropdown_path: '/root/ci-web-terminal/pipelines/127/stage.json?stage=test',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
artifacts: [],
|
|
|
|
manual_actions: [],
|
|
|
|
scheduled_actions: [],
|
|
|
|
},
|
|
|
|
ref: {
|
2021-04-22 12:09:49 +00:00
|
|
|
name: 'main',
|
|
|
|
path: '/root/ci-web-terminal/commits/main',
|
2020-02-27 21:09:17 +00:00
|
|
|
tag: false,
|
|
|
|
branch: true,
|
|
|
|
},
|
|
|
|
commit: {
|
|
|
|
id: 'aa1939133d373c94879becb79d91828a892ee319',
|
|
|
|
short_id: 'aa193913',
|
2021-04-22 12:09:49 +00:00
|
|
|
title: "Merge branch 'main-test' into 'main'",
|
2020-02-27 21:09:17 +00:00
|
|
|
created_at: '2018-10-22T11:41:33.000Z',
|
|
|
|
parent_ids: [
|
|
|
|
'4622f4dd792468993003caf2e3be978798cbe096',
|
|
|
|
'76598df914cdfe87132d0c3c40f80db9fa9396a4',
|
|
|
|
],
|
|
|
|
message:
|
2021-04-22 12:09:49 +00:00
|
|
|
"Merge branch 'main-test' into 'main'\n\nUpdate .gitlab-ci.yml\n\nSee merge request root/ci-web-terminal!1",
|
2020-02-27 21:09:17 +00:00
|
|
|
author_name: 'Administrator',
|
|
|
|
author_email: 'admin@example.com',
|
|
|
|
authored_date: '2018-10-22T11:41:33.000Z',
|
|
|
|
committer_name: 'Administrator',
|
|
|
|
committer_email: 'admin@example.com',
|
|
|
|
committed_date: '2018-10-22T11:41:33.000Z',
|
|
|
|
author: {
|
|
|
|
id: 1,
|
|
|
|
name: 'Administrator',
|
|
|
|
username: 'root',
|
|
|
|
state: 'active',
|
|
|
|
avatar_url: null,
|
|
|
|
web_url: 'http://localhost:3000/root',
|
|
|
|
status_tooltip_html: null,
|
|
|
|
path: '/root',
|
|
|
|
},
|
|
|
|
author_gravatar_url: null,
|
|
|
|
commit_url:
|
|
|
|
'http://localhost:3000/root/ci-web-terminal/commit/aa1939133d373c94879becb79d91828a892ee319',
|
|
|
|
commit_path: '/root/ci-web-terminal/commit/aa1939133d373c94879becb79d91828a892ee319',
|
|
|
|
},
|
|
|
|
cancel_path: '/root/ci-web-terminal/pipelines/127/cancel',
|
|
|
|
};
|
2022-04-13 21:09:57 +00:00
|
|
|
return nextTick();
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders pipeline block', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.find('.js-post-merge-pipeline').exists()).toBe(true);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('with post merge deployments', () => {
|
2022-04-13 21:09:57 +00:00
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.postMergeDeployments = [
|
2020-02-27 21:09:17 +00:00
|
|
|
{
|
|
|
|
id: 15,
|
|
|
|
name: 'review/diplo',
|
|
|
|
url: '/root/acets-review-apps/environments/15',
|
|
|
|
stop_url: '/root/acets-review-apps/environments/15/stop',
|
|
|
|
metrics_url: '/root/acets-review-apps/environments/15/deployments/1/metrics',
|
|
|
|
metrics_monitoring_url: '/root/acets-review-apps/environments/15/metrics',
|
|
|
|
external_url: 'http://diplo.',
|
|
|
|
external_url_formatted: 'diplo.',
|
|
|
|
deployed_at: '2017-03-22T22:44:42.258Z',
|
|
|
|
deployed_at_formatted: 'Mar 22, 2017 10:44pm',
|
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
path: 'index.html',
|
2021-04-22 12:09:49 +00:00
|
|
|
external_url: 'http://root-main-patch-91341.volatile-watch.surge.sh/index.html',
|
2020-02-27 21:09:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'imgs/gallery.html',
|
|
|
|
external_url:
|
2021-04-22 12:09:49 +00:00
|
|
|
'http://root-main-patch-91341.volatile-watch.surge.sh/imgs/gallery.html',
|
2020-02-27 21:09:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'about/',
|
2021-04-22 12:09:49 +00:00
|
|
|
external_url: 'http://root-main-patch-91341.volatile-watch.surge.sh/about/',
|
2020-02-27 21:09:17 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
status: 'success',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2022-04-13 21:09:57 +00:00
|
|
|
return nextTick();
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders post deployment information', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.find('.js-post-deployment').exists()).toBe(true);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
|
|
|
});
|
2018-10-29 11:34:41 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('without information for target branch pipeline', () => {
|
2022-04-13 21:09:57 +00:00
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.state = 'merged';
|
2020-02-27 21:09:17 +00:00
|
|
|
|
2022-04-13 21:09:57 +00:00
|
|
|
return nextTick();
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render pipeline block', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.find('.js-post-merge-pipeline').exists()).toBe(false);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-10-29 11:34:41 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
describe('when state is not merged', () => {
|
2022-04-13 21:09:57 +00:00
|
|
|
beforeEach(() => {
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.state = 'archived';
|
2018-10-29 11:34:41 +00:00
|
|
|
|
2022-04-13 21:09:57 +00:00
|
|
|
return nextTick();
|
2018-10-29 11:34:41 +00:00
|
|
|
});
|
|
|
|
|
2020-02-27 21:09:17 +00:00
|
|
|
it('does not render pipeline block', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.find('.js-post-merge-pipeline').exists()).toBe(false);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render post deployment information', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(wrapper.find('.js-post-deployment').exists()).toBe(false);
|
2018-10-29 11:34:41 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-08-04 09:09:45 +00:00
|
|
|
it('should not suggest pipelines when feature flag is not present', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(findSuggestPipeline().exists()).toBe(false);
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
|
|
|
});
|
2018-10-29 11:34:41 +00:00
|
|
|
|
2020-10-12 21:08:56 +00:00
|
|
|
describe('security widget', () => {
|
|
|
|
describe.each`
|
2021-02-02 12:10:15 +00:00
|
|
|
context | hasPipeline | shouldRender
|
|
|
|
${'there is a pipeline'} | ${true} | ${true}
|
|
|
|
${'no pipeline'} | ${false} | ${false}
|
|
|
|
`('given $context', ({ hasPipeline, shouldRender }) => {
|
2020-10-12 21:08:56 +00:00
|
|
|
beforeEach(() => {
|
2021-01-21 18:09:11 +00:00
|
|
|
const mrData = {
|
2020-10-12 21:08:56 +00:00
|
|
|
...mockData,
|
2021-01-21 18:09:11 +00:00
|
|
|
...(hasPipeline ? {} : { pipeline: null }),
|
|
|
|
};
|
|
|
|
|
|
|
|
// Override top-level mocked requests, which always use a fresh copy of
|
|
|
|
// mockData, which always includes the full pipeline object.
|
|
|
|
mock.onGet(mockData.merge_request_widget_path).reply(() => [200, mrData]);
|
|
|
|
mock.onGet(mockData.merge_request_cached_widget_path).reply(() => [200, mrData]);
|
|
|
|
|
|
|
|
return createComponent(mrData, {
|
|
|
|
apolloProvider: createMockApollo([
|
|
|
|
[
|
2021-05-13 00:10:23 +00:00
|
|
|
securityReportMergeRequestDownloadPathsQuery,
|
|
|
|
async () => ({ data: securityReportMergeRequestDownloadPathsQueryResponse }),
|
2021-01-21 18:09:11 +00:00
|
|
|
],
|
|
|
|
]),
|
2020-10-12 21:08:56 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-01-21 18:09:11 +00:00
|
|
|
it(shouldRender ? 'renders' : 'does not render', () => {
|
|
|
|
expect(findSecurityMrWidget().exists()).toBe(shouldRender);
|
|
|
|
});
|
2020-10-12 21:08:56 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-11-20 00:09:06 +00:00
|
|
|
describe('suggestPipeline', () => {
|
2020-02-27 21:09:17 +00:00
|
|
|
beforeEach(() => {
|
2020-08-04 09:09:45 +00:00
|
|
|
mock.onAny().reply(200);
|
2020-09-30 21:10:09 +00:00
|
|
|
});
|
2020-03-02 18:07:42 +00:00
|
|
|
|
2020-10-27 06:08:27 +00:00
|
|
|
describe('given feature flag is enabled', () => {
|
2020-09-30 21:10:09 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
2020-08-04 09:09:45 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
wrapper.vm.mr.hasCI = false;
|
2020-09-30 21:10:09 +00:00
|
|
|
});
|
2018-10-29 11:34:41 +00:00
|
|
|
|
2020-09-30 21:10:09 +00:00
|
|
|
it('should suggest pipelines when none exist', () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(findSuggestPipeline().exists()).toBe(true);
|
2020-09-30 21:10:09 +00:00
|
|
|
});
|
2018-10-29 11:34:41 +00:00
|
|
|
|
2020-09-30 21:10:09 +00:00
|
|
|
it.each([
|
|
|
|
{ isDismissedSuggestPipeline: true },
|
|
|
|
{ mergeRequestAddCiConfigPath: null },
|
|
|
|
{ hasCI: true },
|
2020-12-23 21:10:24 +00:00
|
|
|
])('with %s, should not suggest pipeline', async (obj) => {
|
2021-01-19 12:10:46 +00:00
|
|
|
Object.assign(wrapper.vm.mr, obj);
|
2020-08-04 09:09:45 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
await nextTick();
|
2018-10-29 11:34:41 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(findSuggestPipeline().exists()).toBe(false);
|
2020-09-30 21:10:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should allow dismiss of the suggest pipeline message', async () => {
|
2021-01-19 12:10:46 +00:00
|
|
|
await findSuggestPipelineButton().trigger('click');
|
2020-09-30 21:10:09 +00:00
|
|
|
|
2021-01-19 12:10:46 +00:00
|
|
|
expect(findSuggestPipeline().exists()).toBe(false);
|
2020-09-30 21:10:09 +00:00
|
|
|
});
|
2020-02-27 21:09:17 +00:00
|
|
|
});
|
2018-10-29 11:34:41 +00:00
|
|
|
});
|
2021-09-29 12:11:22 +00:00
|
|
|
|
|
|
|
describe('mock extension', () => {
|
2022-01-11 18:16:38 +00:00
|
|
|
let pollRequest;
|
|
|
|
|
2021-09-29 12:11:22 +00:00
|
|
|
beforeEach(() => {
|
2022-01-11 18:16:38 +00:00
|
|
|
pollRequest = jest.spyOn(Poll.prototype, 'makeRequest');
|
|
|
|
|
2022-03-24 12:07:26 +00:00
|
|
|
registerExtension(workingExtension());
|
2021-09-29 15:11:47 +00:00
|
|
|
|
2021-09-29 12:11:22 +00:00
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
2021-09-29 15:11:47 +00:00
|
|
|
afterEach(() => {
|
2022-01-11 18:16:38 +00:00
|
|
|
pollRequest.mockRestore();
|
|
|
|
|
2021-09-29 15:11:47 +00:00
|
|
|
registeredExtensions.extensions = [];
|
|
|
|
});
|
2021-09-29 12:11:22 +00:00
|
|
|
|
2021-09-29 15:11:47 +00:00
|
|
|
it('renders collapsed data', async () => {
|
2021-09-29 12:11:22 +00:00
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
expect(wrapper.text()).toContain('Test extension summary count: 1');
|
|
|
|
});
|
|
|
|
|
2021-10-26 18:09:19 +00:00
|
|
|
it('triggers trackRedisHllUserEvent API call', async () => {
|
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
wrapper
|
|
|
|
.find('[data-testid="widget-extension"] [data-testid="toggle-button"]')
|
|
|
|
.trigger('click');
|
|
|
|
|
2021-11-24 12:10:21 +00:00
|
|
|
await nextTick();
|
2021-10-26 18:09:19 +00:00
|
|
|
|
|
|
|
expect(api.trackRedisHllUserEvent).toHaveBeenCalledWith('test_expand_event');
|
|
|
|
});
|
|
|
|
|
2021-09-29 12:11:22 +00:00
|
|
|
it('renders full data', async () => {
|
|
|
|
await waitForPromises();
|
|
|
|
|
2022-03-24 12:07:26 +00:00
|
|
|
findExtensionToggleButton().trigger('click');
|
2021-09-29 12:11:22 +00:00
|
|
|
|
2021-11-24 12:10:21 +00:00
|
|
|
await nextTick();
|
2021-09-29 12:11:22 +00:00
|
|
|
|
2021-10-22 12:09:12 +00:00
|
|
|
expect(
|
|
|
|
wrapper.find('[data-testid="widget-extension-top-level"]').find(GlDropdown).exists(),
|
|
|
|
).toBe(false);
|
|
|
|
|
2022-02-22 21:13:56 +00:00
|
|
|
await nextTick();
|
|
|
|
|
2021-09-29 12:11:22 +00:00
|
|
|
const collapsedSection = wrapper.find('[data-testid="widget-extension-collapsed-section"]');
|
|
|
|
expect(collapsedSection.exists()).toBe(true);
|
|
|
|
expect(collapsedSection.text()).toContain('Hello world');
|
|
|
|
|
|
|
|
// Renders icon in the row
|
|
|
|
expect(collapsedSection.find(GlIcon).exists()).toBe(true);
|
2021-09-30 12:12:36 +00:00
|
|
|
expect(collapsedSection.find(GlIcon).props('name')).toBe('status-failed');
|
2021-09-29 12:11:22 +00:00
|
|
|
|
|
|
|
// Renders badge in the row
|
|
|
|
expect(collapsedSection.find(GlBadge).exists()).toBe(true);
|
|
|
|
expect(collapsedSection.find(GlBadge).text()).toBe('Closed');
|
|
|
|
|
|
|
|
// Renders a link in the row
|
|
|
|
expect(collapsedSection.find(GlLink).exists()).toBe(true);
|
|
|
|
expect(collapsedSection.find(GlLink).text()).toBe('GitLab.com');
|
2021-10-27 12:09:41 +00:00
|
|
|
|
|
|
|
expect(collapsedSection.find(GlButton).exists()).toBe(true);
|
|
|
|
expect(collapsedSection.find(GlButton).text()).toBe('Full report');
|
2021-09-29 12:11:22 +00:00
|
|
|
});
|
2022-01-11 18:16:38 +00:00
|
|
|
|
|
|
|
it('extension polling is not called if enablePolling flag is not passed', () => {
|
|
|
|
// called one time due to parent component polling (mount)
|
|
|
|
expect(pollRequest).toHaveBeenCalledTimes(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-03-24 12:07:26 +00:00
|
|
|
describe('expansion', () => {
|
|
|
|
it('hides collapse button', async () => {
|
|
|
|
registerExtension(workingExtension(false));
|
|
|
|
createComponent();
|
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
expect(findExtensionToggleButton().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows collapse button', async () => {
|
|
|
|
registerExtension(workingExtension(true));
|
|
|
|
createComponent();
|
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
expect(findExtensionToggleButton().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-01-11 18:16:38 +00:00
|
|
|
describe('mock polling extension', () => {
|
|
|
|
let pollRequest;
|
|
|
|
let pollStop;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
pollRequest = jest.spyOn(Poll.prototype, 'makeRequest');
|
|
|
|
pollStop = jest.spyOn(Poll.prototype, 'stop');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
pollRequest.mockRestore();
|
|
|
|
pollStop.mockRestore();
|
|
|
|
|
|
|
|
registeredExtensions.extensions = [];
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('success', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
registerExtension(pollingExtension);
|
|
|
|
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not make additional requests after poll is successful', () => {
|
|
|
|
// called two times due to parent component polling (mount) and extension polling
|
|
|
|
expect(pollRequest).toHaveBeenCalledTimes(2);
|
|
|
|
expect(pollStop).toHaveBeenCalledTimes(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('error', () => {
|
|
|
|
let captureException;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
captureException = jest.spyOn(Sentry, 'captureException');
|
|
|
|
|
|
|
|
registerExtension(pollingErrorExtension);
|
|
|
|
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not make additional requests after poll has failed', () => {
|
|
|
|
// called two times due to parent component polling (mount) and extension polling
|
|
|
|
expect(pollRequest).toHaveBeenCalledTimes(2);
|
|
|
|
expect(pollStop).toHaveBeenCalledTimes(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('captures sentry error and displays error when poll has failed', () => {
|
|
|
|
expect(captureException).toHaveBeenCalledTimes(1);
|
|
|
|
expect(captureException).toHaveBeenCalledWith(new Error('Fetch error'));
|
2022-03-18 18:07:26 +00:00
|
|
|
expect(wrapper.findComponent(StatusIcon).props('iconName')).toBe('failed');
|
2022-01-11 18:16:38 +00:00
|
|
|
});
|
|
|
|
});
|
2021-09-29 12:11:22 +00:00
|
|
|
});
|
2021-11-24 12:10:21 +00:00
|
|
|
|
|
|
|
describe('mock extension errors', () => {
|
|
|
|
let captureException;
|
|
|
|
|
|
|
|
const itHandlesTheException = () => {
|
|
|
|
expect(captureException).toHaveBeenCalledTimes(1);
|
|
|
|
expect(captureException).toHaveBeenCalledWith(new Error('Fetch error'));
|
2022-03-18 18:07:26 +00:00
|
|
|
expect(wrapper.findComponent(StatusIcon).props('iconName')).toBe('failed');
|
2021-11-24 12:10:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
captureException = jest.spyOn(Sentry, 'captureException');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
registeredExtensions.extensions = [];
|
|
|
|
captureException = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('handles collapsed data fetch errors', async () => {
|
|
|
|
registerExtension(collapsedDataErrorExtension);
|
|
|
|
createComponent();
|
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
expect(
|
|
|
|
wrapper.find('[data-testid="widget-extension"] [data-testid="toggle-button"]').exists(),
|
|
|
|
).toBe(false);
|
|
|
|
itHandlesTheException();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('handles full data fetch errors', async () => {
|
|
|
|
registerExtension(fullDataErrorExtension);
|
|
|
|
createComponent();
|
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
expect(wrapper.findComponent(StatusIcon).props('iconName')).not.toBe('error');
|
|
|
|
wrapper
|
|
|
|
.find('[data-testid="widget-extension"] [data-testid="toggle-button"]')
|
|
|
|
.trigger('click');
|
|
|
|
|
|
|
|
await nextTick();
|
|
|
|
await waitForPromises();
|
|
|
|
|
|
|
|
itHandlesTheException();
|
|
|
|
});
|
|
|
|
});
|
2017-05-09 04:15:34 +00:00
|
|
|
});
|