Skip to content
代码片段 群组 项目
未验证 提交 2dc514a0 编辑于 作者: Payton Burdette's avatar Payton Burdette 提交者: GitLab
浏览文件

Merge branch 'pipeline-minigraph-dropdown-migration-pt2' into 'master'

Pipeline MiniGraph: Migrate dropdown to GlDisclosureDropdown (Pt. 2)

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/144606



Merged-by: default avatarPayton Burdette <pburdette@gitlab.com>
Approved-by: default avatarJulia Miocene <jmiocene@gitlab.com>
Approved-by: default avatarStan Hu <stanhu@gmail.com>
Approved-by: default avatarPayton Burdette <pburdette@gitlab.com>
Reviewed-by: default avatarSascha Eggenberger <seggenberger@gitlab.com>
Co-authored-by: default avatarSascha Eggenberger <seggenberger@gitlab.com>
Co-authored-by: default avatarPhil Hughes <me@iamphill.com>
No related branches found
No related tags found
无相关合并请求
显示
181 个添加127 个删除
...@@ -80,7 +80,9 @@ export default { ...@@ -80,7 +80,9 @@ export default {
* different apps it avoids repetition & complexity. * different apps it avoids repetition & complexity.
* *
*/ */
onClickAction() { onClickAction(e) {
e.preventDefault();
if (this.withConfirmationModal) { if (this.withConfirmationModal) {
this.$emit('showActionConfirmationModal'); this.$emit('showActionConfirmationModal');
} else { } else {
......
<script> <script>
import { GlTooltipDirective, GlLink } from '@gitlab/ui'; import { GlDisclosureDropdownItem, GlTooltipDirective } from '@gitlab/ui';
import ActionComponent from '~/ci/common/private/job_action_component.vue'; import ActionComponent from '~/ci/common/private/job_action_component.vue';
import JobNameComponent from '~/ci/common/private/job_name_component.vue'; import JobNameComponent from '~/ci/common/private/job_name_component.vue';
import { ICONS } from '~/ci/constants'; import { ICONS } from '~/ci/constants';
...@@ -44,7 +44,7 @@ export default { ...@@ -44,7 +44,7 @@ export default {
components: { components: {
ActionComponent, ActionComponent,
JobNameComponent, JobNameComponent,
GlLink, GlDisclosureDropdownItem,
}, },
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
...@@ -72,8 +72,14 @@ export default { ...@@ -72,8 +72,14 @@ export default {
}, },
}, },
computed: { computed: {
boundary() { alternativeTooltipConfig() {
return this.dropdownLength === 1 ? 'viewport' : 'scrollParent'; const boundary = this.dropdownLength === 1 ? 'viewport' : 'scrollParent';
return {
boundary,
placement: 'bottom',
customClass: 'gl-pointer-events-none',
};
}, },
detailsPath() { detailsPath() {
return this.status?.details_path; return this.status?.details_path;
...@@ -81,9 +87,18 @@ export default { ...@@ -81,9 +87,18 @@ export default {
hasDetails() { hasDetails() {
return this.status?.has_details; return this.status?.has_details;
}, },
item() {
return {
text: this.job.name,
href: this.hasDetails ? this.detailsPath : '',
};
},
status() { status() {
return this.job?.status ? this.job.status : {}; return this.job?.status ? this.job.status : {};
}, },
tooltipConfig() {
return this.hasDetails ? this.$options.tooltipConfig : this.alternativeTooltipConfig;
},
tooltipText() { tooltipText() {
const textBuilder = []; const textBuilder = [];
const { name: jobName } = this.job; const { name: jobName } = this.job;
...@@ -123,6 +138,9 @@ export default { ...@@ -123,6 +138,9 @@ export default {
? this.$options.i18n.runAgainTooltipText ? this.$options.i18n.runAgainTooltipText
: title; : title;
}, },
testid() {
return this.hasDetails ? 'job-with-link' : 'job-without-link';
},
}, },
errorCaptured(err, _vm, info) { errorCaptured(err, _vm, info) {
reportToSentry('pipelines_job_item', `pipelines_job_item error: ${err}, info: ${info}`); reportToSentry('pipelines_job_item', `pipelines_job_item error: ${err}, info: ${info}`);
...@@ -130,37 +148,38 @@ export default { ...@@ -130,37 +148,38 @@ export default {
}; };
</script> </script>
<template> <template>
<div <gl-disclosure-dropdown-item
class="ci-job-component gl-display-flex gl-align-items-center gl-justify-content-space-between" :item="item"
class="ci-job-component"
:class="[
cssClassJobName,
{
'js-pipeline-graph-job-link gl-text-gray-900 gl-active-text-decoration-none gl-focus-text-decoration-none gl-hover-text-decoration-none': hasDetails,
'js-job-component-tooltip non-details-job-component': !hasDetails,
},
]"
:data-testid="testid"
> >
<gl-link <template #list-item>
v-if="hasDetails" <div
v-gl-tooltip="$options.tooltipConfig" class="gl-display-flex gl-align-items-center gl-justify-content-space-between gl-mt-n2 gl-mb-n2 gl-ml-n2"
:href="detailsPath" >
:title="tooltipText" <job-name-component
:class="cssClassJobName" v-gl-tooltip="tooltipConfig"
class="js-pipeline-graph-job-link menu-item gl-text-gray-900 gl-active-text-decoration-none gl-focus-text-decoration-none gl-hover-text-decoration-none" :title="tooltipText"
data-testid="job-with-link" :name="job.name"
> :status="job.status"
<job-name-component :name="job.name" :status="job.status" /> data-testid="job-name"
</gl-link> />
<div
v-else
v-gl-tooltip="{ boundary, placement: 'bottom', customClass: 'gl-pointer-events-none' }"
:title="tooltipText"
:class="cssClassJobName"
class="js-job-component-tooltip non-details-job-component menu-item"
data-testid="job-without-link"
>
<job-name-component :name="job.name" :status="job.status" />
</div>
<action-component <action-component
v-if="hasJobAction" v-if="hasJobAction"
:tooltip-text="jobActionTooltipText" :tooltip-text="jobActionTooltipText"
:link="status.action.path" :link="status.action.path"
:action-icon="status.action.icon" :action-icon="status.action.icon"
/> class="gl-mt-n2 gl-mr-n2"
</div> />
</div>
</template>
</gl-disclosure-dropdown-item>
</template> </template>
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* 4. Commit widget * 4. Commit widget
*/ */
import { GlDropdown, GlLoadingIcon, GlTooltipDirective } from '@gitlab/ui'; import { GlDisclosureDropdown, GlButton, GlLoadingIcon, GlTooltipDirective } from '@gitlab/ui';
import CiIcon from '~/vue_shared/components/ci_icon/ci_icon.vue'; import CiIcon from '~/vue_shared/components/ci_icon/ci_icon.vue';
import { createAlert } from '~/alert'; import { createAlert } from '~/alert';
import eventHub from '~/ci/event_hub'; import eventHub from '~/ci/event_hub';
...@@ -28,14 +28,11 @@ export default { ...@@ -28,14 +28,11 @@ export default {
stage: __('Stage:'), stage: __('Stage:'),
viewStageLabel: __('View Stage: %{title}'), viewStageLabel: __('View Stage: %{title}'),
}, },
dropdownPopperOpts: {
placement: 'bottom',
positionFixed: true,
},
components: { components: {
CiIcon, CiIcon,
GlLoadingIcon, GlLoadingIcon,
GlDropdown, GlDisclosureDropdown,
GlButton,
LegacyJobItem, LegacyJobItem,
}, },
directives: { directives: {
...@@ -95,7 +92,7 @@ export default { ...@@ -95,7 +92,7 @@ export default {
this.isLoading = false; this.isLoading = false;
}) })
.catch(() => { .catch(() => {
this.$refs.dropdown.hide(); this.$refs.dropdown.close();
this.isLoading = false; this.isLoading = false;
createAlert({ createAlert({
...@@ -111,58 +108,66 @@ export default { ...@@ -111,58 +108,66 @@ export default {
</script> </script>
<template> <template>
<gl-dropdown <gl-disclosure-dropdown
ref="dropdown" ref="dropdown"
v-gl-tooltip.hover.ds0
v-gl-tooltip="stage.title"
data-testid="mini-pipeline-graph-dropdown" data-testid="mini-pipeline-graph-dropdown"
class="mini-pipeline-graph-dropdown"
variant="link" variant="link"
:aria-label="stageAriaLabel(stage.title)" :aria-label="stageAriaLabel(stage.title)"
:lazy="true" no-caret
:popper-opts="$options.dropdownPopperOpts" @hidden="onHideDropdown"
:toggle-class="['gl-rounded-full!']" @shown="onShowDropdown"
menu-class="mini-pipeline-graph-dropdown-menu"
@hide="onHideDropdown"
@show="onShowDropdown"
> >
<template #button-content> <template #toggle>
<ci-icon :status="stage.status" :show-tooltip="false" :use-link="false" class="gl-mb-0!" /> <gl-button
v-gl-tooltip.ds0="isDropdownOpen ? '' : stage.title"
variant="link"
class="gl-rounded-full!"
data-testid="mini-pipeline-graph-dropdown-toggle"
>
<ci-icon :status="stage.status" :show-tooltip="false" :use-link="false" class="gl-mb-0!" />
</gl-button>
</template> </template>
<div v-if="isLoading" class="gl--flex-center gl-p-2" data-testid="pipeline-stage-loading-state">
<template #header>
<div
class="gl-display-flex gl-align-items-center gl-p-4! gl-min-h-8 gl-border-b-1 gl-border-b-solid gl-border-b-gray-200 gl-font-sm gl-font-weight-bold gl-line-height-1"
>
<span class="gl-mr-1">{{ $options.i18n.stage }}</span>
<span data-testid="pipeline-stage-dropdown-menu-title">{{ stageName }}</span>
</div>
</template>
<div
v-if="isLoading"
class="gl-display-flex gl-py-3 gl-px-4"
data-testid="pipeline-stage-loading-state"
>
<gl-loading-icon size="sm" class="gl-mr-3" /> <gl-loading-icon size="sm" class="gl-mr-3" />
<p class="gl-line-height-normal gl-mb-0">{{ $options.i18n.loadingText }}</p> <p class="gl-line-height-normal gl-mb-0">{{ $options.i18n.loadingText }}</p>
</div> </div>
<ul <ul
v-else v-else
class="js-builds-dropdown-list scrollable-menu" class="mini-pipeline-graph-dropdown-menu gl-overflow-y-auto gl-m-0 gl-p-0"
data-testid="mini-pipeline-graph-dropdown-menu-list" data-testid="mini-pipeline-graph-dropdown-menu-list"
> >
<div class="gl--flex-center gl-border-b gl-font-weight-bold gl-mb-3 gl-pb-3"> <legacy-job-item
<span class="gl-mr-1">{{ $options.i18n.stage }}</span> v-for="job in dropdownContent"
<span data-testid="pipeline-stage-dropdown-menu-title">{{ stageName }}</span> :key="job.id"
</div> :dropdown-length="dropdownContent.length"
<li v-for="job in dropdownContent" :key="job.id"> :job="job"
<legacy-job-item css-class-job-name="pipeline-job-item"
:dropdown-length="dropdownContent.length" />
:job="job"
css-class-job-name="pipeline-job-item"
/>
</li>
<template v-if="isMergeTrain">
<li class="gl-dropdown-divider" role="presentation">
<hr role="separator" aria-orientation="horizontal" class="dropdown-divider" />
</li>
<li>
<div
class="gl-display-flex gl-align-items-center"
data-testid="warning-message-merge-trains"
>
<div class="menu-item gl-font-sm gl-text-gray-300!">
{{ $options.i18n.mergeTrainMessage }}
</div>
</div>
</li>
</template>
</ul> </ul>
</gl-dropdown>
<template #footer>
<div
v-if="!isLoading && isMergeTrain"
class="gl-font-sm gl-text-secondary gl-py-3 gl-px-4 gl-border-t"
data-testid="warning-message-merge-trains"
>
{{ $options.i18n.mergeTrainMessage }}
</div>
</template>
</gl-disclosure-dropdown>
</template> </template>
...@@ -21,15 +21,7 @@ ...@@ -21,15 +21,7 @@
- mini graph in Commit widget pipeline - mini graph in Commit widget pipeline
*/ */
@mixin pipeline-graph-dropdown-menu() { @mixin pipeline-graph-dropdown-menu() {
width: auto; max-height: $gl-max-dropdown-max-height;
max-width: 400px;
// override dropdown.scss
&.dropdown-menu li button,
&.dropdown-menu li a.ci-action-icon-container {
padding: 0;
text-align: center;
}
.ci-action-icon-container { .ci-action-icon-container {
position: absolute; position: absolute;
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
border-bottom: 2px solid $gray-200; border-bottom: 2px solid $gray-200;
position: absolute; position: absolute;
right: -4px; right: -4px;
top: 11px; top: 12px;
width: 4px; width: 4px;
} }
} }
......
...@@ -75,8 +75,8 @@ ...@@ -75,8 +75,8 @@
expect(page).to have_selector('[data-testid="mini-pipeline-graph-dropdown"]') expect(page).to have_selector('[data-testid="mini-pipeline-graph-dropdown"]')
end end
it 'does not allow retry for merge train pipeline' do it 'does not allow retry for merge train pipeline', :js do
find('[data-testid="mini-pipeline-graph-dropdown"] .dropdown-toggle').click find_by_testid('mini-pipeline-graph-dropdown-toggle').click
page.within '.ci-job-component' do page.within '.ci-job-component' do
expect(page).to have_selector('[data-testid="ci-icon"]') expect(page).to have_selector('[data-testid="ci-icon"]')
expect(page).not_to have_selector('.retry') expect(page).not_to have_selector('.retry')
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
end end
end end
context 'when commit has pipelines and feature flag is disabled' do context 'when commit has pipelines and feature flag is disabled', :js do
let(:pipeline) do let(:pipeline) do
create( create(
:ci_pipeline, :ci_pipeline,
...@@ -58,11 +58,11 @@ ...@@ -58,11 +58,11 @@
it 'displays a mini pipeline graph' do it 'displays a mini pipeline graph' do
expect(page).to have_selector('[data-testid="commit-box-pipeline-mini-graph"]') expect(page).to have_selector('[data-testid="commit-box-pipeline-mini-graph"]')
first('[data-testid="mini-pipeline-graph-dropdown"]').click find_by_testid('mini-pipeline-graph-dropdown-toggle').click
wait_for_requests wait_for_requests
page.within '.js-builds-dropdown-list' do within_testid('mini-pipeline-graph-dropdown') do
expect(page).to have_selector('[data-testid="status_running_borderless-icon"]') expect(page).to have_selector('[data-testid="status_running_borderless-icon"]')
expect(page).to have_content(build.stage_name) expect(page).to have_content(build.stage_name)
end end
......
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
end end
end end
context 'with manual actions' do context 'with manual actions', :js do
let!(:manual) do let!(:manual) do
create(:ci_build, :manual, create(:ci_build, :manual,
pipeline: pipeline, pipeline: pipeline,
...@@ -286,7 +286,7 @@ ...@@ -286,7 +286,7 @@
end end
it 'has link to the manual action' do it 'has link to the manual action' do
find('[data-testid="pipelines-manual-actions-dropdown"]').click find_by_testid('pipelines-manual-actions-dropdown').click
wait_for_requests wait_for_requests
...@@ -295,11 +295,13 @@ ...@@ -295,11 +295,13 @@
context 'when manual action was played' do context 'when manual action was played' do
before do before do
find('[data-testid="pipelines-manual-actions-dropdown"] button').click find_by_testid('pipelines-manual-actions-dropdown').click
wait_for_requests wait_for_requests
click_button('manual build') click_button('manual build')
wait_for_all_requests
end end
it 'enqueues manual action job', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/409984' do it 'enqueues manual action job', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/409984' do
...@@ -325,8 +327,8 @@ ...@@ -325,8 +327,8 @@
expect(page).to have_selector('[data-testid="pipelines-manual-actions-dropdown"] [data-testid="play-icon"]') expect(page).to have_selector('[data-testid="pipelines-manual-actions-dropdown"] [data-testid="play-icon"]')
end end
it "has link to the delayed job's action" do it "has link to the delayed job's action", :js do
find('[data-testid="pipelines-manual-actions-dropdown"] button').click find_by_testid('pipelines-manual-actions-dropdown').click
wait_for_requests wait_for_requests
...@@ -344,8 +346,8 @@ ...@@ -344,8 +346,8 @@
stage: 'test') stage: 'test')
end end
it "shows 00:00:00 as the remaining time" do it "shows 00:00:00 as the remaining time", :js do
find('[data-testid="pipelines-manual-actions-dropdown"] button').click find_by_testid('pipelines-manual-actions-dropdown').click
wait_for_requests wait_for_requests
...@@ -535,32 +537,60 @@ ...@@ -535,32 +537,60 @@
expect(page).to have_selector(dropdown_selector) expect(page).to have_selector(dropdown_selector)
end end
context 'when clicking a stage badge' do context 'when clicking a stage badge', :js do
it 'opens a dropdown' do it 'opens a dropdown' do
find(dropdown_selector).click find_by_testid('mini-pipeline-graph-dropdown-toggle').click
wait_for_requests
expect(page).to have_link build.name expect(page).to have_link build.name
end end
it 'is possible to cancel pending build' do it 'is possible to cancel pending build' do
find(dropdown_selector).click find_by_testid('mini-pipeline-graph-dropdown-toggle').click
find('.js-ci-action').click
wait_for_requests
find_by_testid('ci-action-button').click
wait_for_requests wait_for_requests
expect(build.reload).to be_canceled expect(build.reload).to be_canceled
end end
context 'manual job', :js do
let!(:build) do
create(:ci_build, :manual, pipeline: pipeline, stage: 'build', name: 'manual-build')
end
it 'is possible to play manual build' do
find_by_testid('mini-pipeline-graph-dropdown-toggle').click
wait_for_requests
within first('[data-testid="job-with-link"]') do
expect(find_by_testid('play-icon')).to be_visible
end
find_by_testid('ci-action-button').click
wait_for_requests
expect(find('[data-testid="mini-pipeline-graph-dropdown-toggle"][aria-expanded="true"]')).to be_visible
end
end
end end
context 'for a failed pipeline' do context 'for a failed pipeline', :js do
let!(:build) do let!(:build) do
create(:ci_build, :failed, pipeline: pipeline, stage: 'build', name: 'build') create(:ci_build, :failed, pipeline: pipeline, stage: 'build', name: 'build')
end end
it 'displays the failure reason' do it 'displays the failure reason' do
find(dropdown_selector).click find_by_testid('mini-pipeline-graph-dropdown-toggle').click
wait_for_requests
within('.js-builds-dropdown-list') do within_testid('mini-pipeline-graph-dropdown') do
build_element = page.find('.pipeline-job-item') build_element = page.find('.pipeline-job-item [data-testid="job-name"]')
expect(build_element['title']).to eq('build - failed - (unknown failure)') expect(build_element['title']).to eq('build - failed - (unknown failure)')
end end
end end
......
import { GlDropdown } from '@gitlab/ui'; import { GlDisclosureDropdown } from '@gitlab/ui';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
...@@ -53,8 +53,9 @@ describe('Pipelines stage component', () => { ...@@ -53,8 +53,9 @@ describe('Pipelines stage component', () => {
const findCiActionBtn = () => wrapper.find('.js-ci-action'); const findCiActionBtn = () => wrapper.find('.js-ci-action');
const findCiIcon = () => wrapper.findComponent(CiIcon); const findCiIcon = () => wrapper.findComponent(CiIcon);
const findDropdown = () => wrapper.findComponent(GlDropdown); const findDropdown = () => wrapper.findComponent(GlDisclosureDropdown);
const findDropdownToggle = () => wrapper.find('button.dropdown-toggle'); const findDropdownToggle = () =>
wrapper.find('[data-testid="mini-pipeline-graph-dropdown-toggle"]');
const findDropdownMenu = () => const findDropdownMenu = () =>
wrapper.find('[data-testid="mini-pipeline-graph-dropdown-menu-list"]'); wrapper.find('[data-testid="mini-pipeline-graph-dropdown-menu-list"]');
const findDropdownMenuTitle = () => const findDropdownMenuTitle = () =>
...@@ -78,8 +79,9 @@ describe('Pipelines stage component', () => { ...@@ -78,8 +79,9 @@ describe('Pipelines stage component', () => {
}); });
it('displays loading state while jobs are being fetched', async () => { it('displays loading state while jobs are being fetched', async () => {
jest.runOnlyPendingTimers(); // eslint-disable-next-line no-restricted-syntax
await nextTick(); wrapper.setData({ isLoading: true });
await waitForPromises();
expect(findLoadingState().exists()).toBe(true); expect(findLoadingState().exists()).toBe(true);
expect(findLoadingState().text()).toBe(LegacyPipelineStage.i18n.loadingText); expect(findLoadingState().text()).toBe(LegacyPipelineStage.i18n.loadingText);
...@@ -144,7 +146,7 @@ describe('Pipelines stage component', () => { ...@@ -144,7 +146,7 @@ describe('Pipelines stage component', () => {
await axios.waitForAll(); await axios.waitForAll();
await waitForPromises(); await waitForPromises();
expect(findDropdown().classes('show')).toBe(false); expect(findDropdownToggle().attributes('aria-expanded')).toBe('false');
}); });
}); });
...@@ -197,7 +199,7 @@ describe('Pipelines stage component', () => { ...@@ -197,7 +199,7 @@ describe('Pipelines stage component', () => {
await clickCiAction(); await clickCiAction();
await waitForPromises(); await waitForPromises();
expect(findDropdown().classes('show')).toBe(true); expect(findDropdownToggle().attributes('aria-expanded')).toBe('true');
}); });
}); });
......
...@@ -96,7 +96,7 @@ describe('Pipelines', () => { ...@@ -96,7 +96,7 @@ describe('Pipelines', () => {
const findCiLintButton = () => wrapper.findByTestId('ci-lint-button'); const findCiLintButton = () => wrapper.findByTestId('ci-lint-button');
const findCleanCacheButton = () => wrapper.findByTestId('clear-cache-button'); const findCleanCacheButton = () => wrapper.findByTestId('clear-cache-button');
const findStagesDropdownToggle = () => const findStagesDropdownToggle = () =>
wrapper.find('[data-testid="mini-pipeline-graph-dropdown"] .dropdown-toggle'); wrapper.find('.mini-pipeline-graph-dropdown [data-testid="base-dropdown-toggle"]');
const findPipelineUrlLinks = () => wrapper.findAll('[data-testid="pipeline-url-link"]'); const findPipelineUrlLinks = () => wrapper.findAll('[data-testid="pipeline-url-link"]');
const createComponent = ({ props = {}, withPermissions = true } = {}) => { const createComponent = ({ props = {}, withPermissions = true } = {}) => {
...@@ -769,6 +769,11 @@ describe('Pipelines', () => { ...@@ -769,6 +769,11 @@ describe('Pipelines', () => {
.onGet(mockPipelineWithStages.details.stages[0].dropdown_path) .onGet(mockPipelineWithStages.details.stages[0].dropdown_path)
.reply(HTTP_STATUS_OK, stageReply); .reply(HTTP_STATUS_OK, stageReply);
// cancelMock is getting overwritten in pipelines_service.js#L29
// so we have to spy on it again here
cancelMock = { cancel: jest.fn() };
jest.spyOn(axios.CancelToken, 'source').mockReturnValue(cancelMock);
createComponent(); createComponent();
stopMock = jest.spyOn(window, 'clearTimeout'); stopMock = jest.spyOn(window, 'clearTimeout');
...@@ -789,13 +794,9 @@ describe('Pipelines', () => { ...@@ -789,13 +794,9 @@ describe('Pipelines', () => {
await findStagesDropdownToggle().trigger('click'); await findStagesDropdownToggle().trigger('click');
jest.runOnlyPendingTimers(); jest.runOnlyPendingTimers();
// cancelMock is getting overwritten in pipelines_service.js#L29
// so we have to spy on it again here
cancelMock = jest.spyOn(axios.CancelToken, 'source');
await waitForPromises(); await waitForPromises();
expect(cancelMock).toHaveBeenCalled(); expect(cancelMock.cancel).toHaveBeenCalled();
expect(stopMock).toHaveBeenCalled(); expect(stopMock).toHaveBeenCalled();
expect(restartMock).toHaveBeenCalledWith( expect(restartMock).toHaveBeenCalledWith(
`${mockPipelinesResponse.pipelines[0].path}/stage.json?stage=build`, `${mockPipelinesResponse.pipelines[0].path}/stage.json?stage=build`,
...@@ -807,7 +808,7 @@ describe('Pipelines', () => { ...@@ -807,7 +808,7 @@ describe('Pipelines', () => {
jest.runOnlyPendingTimers(); jest.runOnlyPendingTimers();
await waitForPromises(); await waitForPromises();
expect(cancelMock).not.toHaveBeenCalled(); expect(cancelMock.cancel).not.toHaveBeenCalled();
expect(stopMock).toHaveBeenCalled(); expect(stopMock).toHaveBeenCalled();
expect(restartMock).toHaveBeenCalledWith( expect(restartMock).toHaveBeenCalledWith(
`${mockPipelinesResponse.pipelines[0].path}/stage.json?stage=build`, `${mockPipelinesResponse.pipelines[0].path}/stage.json?stage=build`,
......
...@@ -38,6 +38,7 @@ import StatusIcon from '~/vue_merge_request_widget/components/extensions/status_ ...@@ -38,6 +38,7 @@ import StatusIcon from '~/vue_merge_request_widget/components/extensions/status_
import getStateQuery from '~/vue_merge_request_widget/queries/get_state.query.graphql'; import getStateQuery from '~/vue_merge_request_widget/queries/get_state.query.graphql';
import getStateSubscription from '~/vue_merge_request_widget/queries/get_state.subscription.graphql'; import getStateSubscription from '~/vue_merge_request_widget/queries/get_state.subscription.graphql';
import readyToMergeSubscription from '~/vue_merge_request_widget/queries/states/ready_to_merge.subscription.graphql'; import readyToMergeSubscription from '~/vue_merge_request_widget/queries/states/ready_to_merge.subscription.graphql';
import securityReportMergeRequestDownloadPathsQuery from '~/vue_merge_request_widget/extensions/security_reports/graphql/security_report_merge_request_download_paths.query.graphql';
import readyToMergeQuery from 'ee_else_ce/vue_merge_request_widget/queries/states/ready_to_merge.query.graphql'; import readyToMergeQuery from 'ee_else_ce/vue_merge_request_widget/queries/states/ready_to_merge.query.graphql';
import approvalsQuery from 'ee_else_ce/vue_merge_request_widget/components/approvals/queries/approvals.query.graphql'; import approvalsQuery from 'ee_else_ce/vue_merge_request_widget/components/approvals/queries/approvals.query.graphql';
import approvedBySubscription from 'ee_else_ce/vue_merge_request_widget/components/approvals/queries/approvals.subscription.graphql'; import approvedBySubscription from 'ee_else_ce/vue_merge_request_widget/components/approvals/queries/approvals.subscription.graphql';
...@@ -123,6 +124,8 @@ describe('MrWidgetOptions', () => { ...@@ -123,6 +124,8 @@ describe('MrWidgetOptions', () => {
conflictsStateQuery, conflictsStateQuery,
jest.fn().mockResolvedValue({ data: { project: { mergeRequest: {} } } }), jest.fn().mockResolvedValue({ data: { project: { mergeRequest: {} } } }),
], ],
[securityReportMergeRequestDownloadPathsQuery, jest.fn().mockResolvedValue(null)],
...(options.apolloMock || []),
]; ];
const subscriptionHandlers = [ const subscriptionHandlers = [
[approvedBySubscription, () => mockedApprovalsSubscription], [approvedBySubscription, () => mockedApprovalsSubscription],
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册