Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-01-15 15:10:31 +00:00
parent 0e11c62b96
commit 39a5262a05
24 changed files with 225 additions and 127 deletions

View File

@ -1,5 +1,5 @@
<script> <script>
import { GlTooltipDirective, GlButton, GlLink, GlLoadingIcon } from '@gitlab/ui'; import { GlTooltipDirective, GlButton, GlLink, GlLoadingIcon, GlBadge } from '@gitlab/ui';
import CiStatus from '~/vue_shared/components/ci_icon.vue'; import CiStatus from '~/vue_shared/components/ci_icon.vue';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import { accessValue } from './accessors'; import { accessValue } from './accessors';
@ -15,6 +15,7 @@ export default {
GlButton, GlButton,
GlLink, GlLink,
GlLoadingIcon, GlLoadingIcon,
GlBadge,
}, },
inject: { inject: {
dataMethod: { dataMethod: {
@ -172,7 +173,9 @@ export default {
</div> </div>
</div> </div>
<div class="gl-pt-2"> <div class="gl-pt-2">
<span class="badge badge-primary" data-testid="downstream-pipeline-label">{{ label }}</span> <gl-badge size="sm" variant="info" data-testid="downstream-pipeline-label">
{{ label }}
</gl-badge>
</div> </div>
<gl-button <gl-button
:id="buttonId" :id="buttonId"

View File

@ -45,6 +45,7 @@ export default {
...mapState({ ...mapState({
modalTitle: (state) => state.modal.title || '', modalTitle: (state) => state.modal.title || '',
modalData: (state) => state.modal.data || {}, modalData: (state) => state.modal.data || {},
modalOpen: (state) => state.modal.open || false,
}), }),
...mapGetters(['summaryStatus']), ...mapGetters(['summaryStatus']),
groupedSummaryText() { groupedSummaryText() {
@ -76,7 +77,7 @@ export default {
this.fetchReports(); this.fetchReports();
}, },
methods: { methods: {
...mapActions(['setEndpoint', 'fetchReports']), ...mapActions(['setEndpoint', 'fetchReports', 'closeModal']),
reportText(report) { reportText(report) {
const { name, summary } = report || {}; const { name, summary } = report || {};
@ -170,8 +171,12 @@ export default {
class="report-block-group-list" class="report-block-group-list"
/> />
</template> </template>
<modal
<modal :title="modalTitle" :modal-data="modalData" /> :visible="modalOpen"
:title="modalTitle"
:modal-data="modalData"
@hide="closeModal"
/>
</div> </div>
</template> </template>
</report-section> </report-section>

View File

@ -1,15 +1,21 @@
<script> <script>
// import { sprintf, __ } from '~/locale'; import { GlModal, GlLink, GlSprintf } from '@gitlab/ui';
import DeprecatedModal2 from '~/vue_shared/components/deprecated_modal_2.vue';
import CodeBlock from '~/vue_shared/components/code_block.vue'; import CodeBlock from '~/vue_shared/components/code_block.vue';
import { fieldTypes } from '../constants'; import { fieldTypes } from '../constants';
export default { export default {
components: { components: {
Modal: DeprecatedModal2,
CodeBlock, CodeBlock,
GlModal,
GlLink,
GlSprintf,
}, },
props: { props: {
visible: {
type: Boolean,
required: true,
},
title: { title: {
type: String, type: String,
required: true, required: true,
@ -23,39 +29,43 @@ export default {
}; };
</script> </script>
<template> <template>
<modal <gl-modal
id="modal-mrwidget-reports" :visible="visible"
:header-title-text="title" modal-id="modal-mrwidget-reports"
class="modal-security-report-dast modal-hide-footer" :title="title"
:hide-footer="true"
@hide="$emit('hide')"
> >
<slot> <div
<div v-for="(field, key, index) in modalData"
v-for="(field, key, index) in modalData" v-if="field.value"
v-if="field.value" :key="index"
:key="index" class="row gl-mt-3 gl-mb-3"
class="row gl-mt-3 gl-mb-3" >
> <strong class="col-sm-3 text-right"> {{ field.text }}: </strong>
<strong class="col-sm-3 text-right"> {{ field.text }}: </strong>
<div class="col-sm-9 text-secondary"> <div class="col-sm-9 text-secondary">
<code-block v-if="field.type === $options.fieldTypes.codeBock" :code="field.value" /> <code-block v-if="field.type === $options.fieldTypes.codeBock" :code="field.value" />
<template v-else-if="field.type === $options.fieldTypes.link"> <gl-link
<a :href="field.value" target="_blank" rel="noopener noreferrer" class="js-modal-link"> v-else-if="field.type === $options.fieldTypes.link"
{{ field.value }} :href="field.value"
</a> target="_blank"
</template> >
{{ field.value }}
</gl-link>
<template v-else-if="field.type === $options.fieldTypes.seconds">{{ <gl-sprintf
sprintf(__('%{value} s'), { value: field.value }) v-else-if="field.type === $options.fieldTypes.seconds"
}}</template> :message="__('%{value} s')"
>
<template #value>{{ field.value }}</template>
</gl-sprintf>
<template v-else-if="field.type === $options.fieldTypes.text"> <template v-else-if="field.type === $options.fieldTypes.text">
{{ field.value }} {{ field.value }}
</template> </template>
</div>
</div> </div>
</slot> </div>
<div slot="footer"></div> </gl-modal>
</modal>
</template> </template>

View File

@ -1,5 +1,4 @@
import Visibility from 'visibilityjs'; import Visibility from 'visibilityjs';
import $ from 'jquery';
import axios from '../../lib/utils/axios_utils'; import axios from '../../lib/utils/axios_utils';
import Poll from '../../lib/utils/poll'; import Poll from '../../lib/utils/poll';
import * as types from './mutation_types'; import * as types from './mutation_types';
@ -78,10 +77,6 @@ export const receiveReportsSuccess = ({ commit }, response) => {
export const receiveReportsError = ({ commit }) => commit(types.RECEIVE_REPORTS_ERROR); export const receiveReportsError = ({ commit }) => commit(types.RECEIVE_REPORTS_ERROR);
export const openModal = ({ dispatch }, payload) => { export const openModal = ({ commit }, payload) => commit(types.SET_ISSUE_MODAL_DATA, payload);
dispatch('setModalData', payload);
$('#modal-mrwidget-reports').modal('show'); export const closeModal = ({ commit }, payload) => commit(types.RESET_ISSUE_MODAL_DATA, payload);
};
export const setModalData = ({ commit }, payload) => commit(types.SET_ISSUE_MODAL_DATA, payload);

View File

@ -4,3 +4,4 @@ export const REQUEST_REPORTS = 'REQUEST_REPORTS';
export const RECEIVE_REPORTS_SUCCESS = 'RECEIVE_REPORTS_SUCCESS'; export const RECEIVE_REPORTS_SUCCESS = 'RECEIVE_REPORTS_SUCCESS';
export const RECEIVE_REPORTS_ERROR = 'RECEIVE_REPORTS_ERROR'; export const RECEIVE_REPORTS_ERROR = 'RECEIVE_REPORTS_ERROR';
export const SET_ISSUE_MODAL_DATA = 'SET_ISSUE_MODAL_DATA'; export const SET_ISSUE_MODAL_DATA = 'SET_ISSUE_MODAL_DATA';
export const RESET_ISSUE_MODAL_DATA = 'RESET_ISSUE_MODAL_DATA';

View File

@ -52,5 +52,19 @@ export default {
}; };
} }
}); });
state.modal.open = true;
},
[types.RESET_ISSUE_MODAL_DATA](state) {
state.modal.open = false;
// Resetting modal data
state.modal.title = null;
Object.keys(state.modal.data).forEach((key) => {
state.modal.data[key] = {
...state.modal.data[key],
value: null,
};
});
}, },
}; };

View File

@ -38,6 +38,7 @@ export default () => ({
modal: { modal: {
title: null, title: null,
open: false,
data: { data: {
class: { class: {

View File

@ -51,7 +51,7 @@ module Milestoneable
# Overridden on EE module # Overridden on EE module
# #
def supports_milestone? def supports_milestone?
respond_to?(:milestone_id) && !incident? respond_to?(:milestone_id)
end end
end end

View File

@ -14,23 +14,23 @@
%span= _('Runners can be:') %span= _('Runners can be:')
%ul %ul
%li %li
%span.badge.badge-success shared %span.badge.badge-pill.gl-badge.sm.badge-success shared
\- \-
= _('Runs jobs from all unassigned projects.') = _('Runs jobs from all unassigned projects.')
%li %li
%span.badge.badge-success group %span.badge.badge-pill.gl-badge.sm.badge-success group
\- \-
= _('Runs jobs from all unassigned projects in its group.') = _('Runs jobs from all unassigned projects in its group.')
%li %li
%span.badge.badge-info specific %span.badge.badge-pill.gl-badge.sm.badge-info specific
\- \-
= _('Runs jobs from assigned projects.') = _('Runs jobs from assigned projects.')
%li %li
%span.badge.badge-warning locked %span.badge.badge-pill.gl-badge.sm.badge-warning locked
\- \-
= _('Cannot be assigned to other projects.') = _('Cannot be assigned to other projects.')
%li %li
%span.badge.badge-danger paused %span.badge.badge-pill.gl-badge.sm.badge-danger paused
\- \-
= _('Not available to run jobs.') = _('Not available to run jobs.')

View File

@ -43,16 +43,16 @@
.label-container .label-container
- if job.tags.any? - if job.tags.any?
- job.tags.each do |tag| - job.tags.each do |tag|
%span.badge.badge-primary %span.badge.badge-pill.gl-badge.sm.badge-primary
= tag = tag
- if job.try(:trigger_request) - if job.try(:trigger_request)
%span.badge.badge-info= _('triggered') %span.badge.badge-pill.gl-badge.sm.badge-info= _('triggered')
- if job.try(:allow_failure) && !job.success? - if job.try(:allow_failure) && !job.success?
%span.badge.badge-warning= _('allowed to fail') %span.badge.badge-pill.gl-badge.sm.badge-warning= _('allowed to fail')
- if job.schedulable? - if job.schedulable?
%span.badge.badge-info= s_('DelayedJobs|delayed') %span.badge.badge-pill.gl-badge.sm.badge-info= s_('DelayedJobs|delayed')
- elsif job.action? - elsif job.action?
%span.badge.badge-info= _('manual') %span.badge.badge-pill.gl-badge.sm.badge-info= _('manual')
- if pipeline_link - if pipeline_link
%td %td

View File

@ -21,24 +21,24 @@
.icon-container .icon-container
= sprite_icon('flag') = sprite_icon('flag')
- if @pipeline.child? - if @pipeline.child?
%span.js-pipeline-child.badge.badge-primary.has-tooltip{ title: s_("Pipelines|This is a child pipeline within the parent pipeline") } %span.js-pipeline-child.badge.badge-pill.gl-badge.sm.badge-primary.has-tooltip{ title: s_("Pipelines|This is a child pipeline within the parent pipeline") }
= s_('Pipelines|Child pipeline') = s_('Pipelines|Child pipeline')
= surround '(', ')' do = surround '(', ')' do
= link_to s_('Pipelines|parent'), pipeline_path(@pipeline.triggered_by_pipeline), class: 'text-white text-underline' = link_to s_('Pipelines|parent'), pipeline_path(@pipeline.triggered_by_pipeline), class: 'text-white text-underline'
- if @pipeline.latest? - if @pipeline.latest?
%span.js-pipeline-url-latest.badge.badge-success.has-tooltip{ title: _("Latest pipeline for the most recent commit on this branch") } %span.js-pipeline-url-latest.badge.badge-pill.gl-badge.sm.badge-success.has-tooltip{ title: _("Latest pipeline for the most recent commit on this branch") }
latest latest
- if @pipeline.has_yaml_errors? - if @pipeline.has_yaml_errors?
%span.js-pipeline-url-yaml.badge.badge-danger.has-tooltip{ title: @pipeline.yaml_errors } %span.js-pipeline-url-yaml.badge.badge-pill.gl-badge.sm.badge-danger.has-tooltip{ title: @pipeline.yaml_errors }
yaml invalid yaml invalid
- if @pipeline.failure_reason? - if @pipeline.failure_reason?
%span.js-pipeline-url-failure.badge.badge-danger.has-tooltip{ title: @pipeline.failure_reason } %span.js-pipeline-url-failure.badge.badge-pill.gl-badge.sm.badge-danger.has-tooltip{ title: @pipeline.failure_reason }
error error
- if @pipeline.auto_devops_source? - if @pipeline.auto_devops_source?
- popover_title_text = html_escape(_('This pipeline makes use of a predefined CI/CD configuration enabled by %{b_open}Auto DevOps.%{b_close}')) % { b_open: '<b>'.html_safe, b_close: '</b>'.html_safe } - popover_title_text = html_escape(_('This pipeline makes use of a predefined CI/CD configuration enabled by %{b_open}Auto DevOps.%{b_close}')) % { b_open: '<b>'.html_safe, b_close: '</b>'.html_safe }
- popover_content_url = help_page_path('topics/autodevops/index.md') - popover_content_url = help_page_path('topics/autodevops/index.md')
- popover_content_text = _('Learn more about Auto DevOps') - popover_content_text = _('Learn more about Auto DevOps')
%a.js-pipeline-url-autodevops.badge.badge-info.autodevops-badge{ href: "#", tabindex: "0", role: "button", data: { container: "body", %a.js-pipeline-url-autodevops.badge.badge-pill.gl-badge.sm.badge-info.autodevops-badge{ href: "#", tabindex: "0", role: "button", data: { container: "body",
toggle: "popover", toggle: "popover",
placement: "top", placement: "top",
html: "true", html: "true",
@ -48,10 +48,10 @@
} } } }
Auto DevOps Auto DevOps
- if @pipeline.detached_merge_request_pipeline? - if @pipeline.detached_merge_request_pipeline?
%span.js-pipeline-url-mergerequest.badge.badge-info.has-tooltip{ title: _('Pipelines for merge requests are configured. A detached pipeline runs in the context of the merge request, and not against the merged result. Learn more in the documentation for Pipelines for Merged Results.') } %span.js-pipeline-url-mergerequest.badge.badge-pill.gl-badge.sm.badge-info.has-tooltip{ title: _('Pipelines for merge requests are configured. A detached pipeline runs in the context of the merge request, and not against the merged result. Learn more in the documentation for Pipelines for Merged Results.') }
detached detached
- if @pipeline.stuck? - if @pipeline.stuck?
%span.js-pipeline-url-stuck.badge.badge-warning %span.js-pipeline-url-stuck.badge.badge-pill.gl-badge.sm.badge-warning
stuck stuck
.well-segment.branch-info .well-segment.branch-info

View File

@ -58,7 +58,7 @@
.selectbox.hide-collapsed .selectbox.hide-collapsed
= f.hidden_field 'milestone_id', value: milestone[:id], id: nil = f.hidden_field 'milestone_id', value: milestone[:id], id: nil
= dropdown_tag('Milestone', options: { title: _('Assign milestone'), toggle_class: 'js-milestone-select js-extra-options', filter: true, dropdown_class: 'dropdown-menu-selectable', placeholder: _('Search milestones'), data: { show_no: true, field_name: "#{issuable_type}[milestone_id]", project_id: issuable_sidebar[:project_id], issuable_id: issuable_sidebar[:id], ability_name: issuable_type, issue_update: issuable_sidebar[:issuable_json_path], use_id: true, default_no: true, selected: milestone[:title], null_default: true, display: 'static' }}) = dropdown_tag('Milestone', options: { title: _('Assign milestone'), toggle_class: 'js-milestone-select js-extra-options', filter: true, dropdown_class: 'dropdown-menu-selectable', placeholder: _('Search milestones'), data: { show_no: true, field_name: "#{issuable_type}[milestone_id]", project_id: issuable_sidebar[:project_id], issuable_id: issuable_sidebar[:id], ability_name: issuable_type, issue_update: issuable_sidebar[:issuable_json_path], use_id: true, default_no: true, selected: milestone[:title], null_default: true, display: 'static' }})
- if @project.group.present? - if @project.group.present? && issuable_sidebar[:supports_iterations]
= render_if_exists 'shared/issuable/iteration_select', can_edit: can_edit_issuable, group_path: @project.group.full_path, project_path: issuable_sidebar[:project_full_path], issue_iid: issuable_sidebar[:iid], issuable_type: issuable_type = render_if_exists 'shared/issuable/iteration_select', can_edit: can_edit_issuable, group_path: @project.group.full_path, project_path: issuable_sidebar[:project_full_path], issue_iid: issuable_sidebar[:iid], issuable_type: issuable_type
- if issuable_sidebar[:supports_time_tracking] - if issuable_sidebar[:supports_time_tracking]

View File

@ -5,8 +5,8 @@
%div %div
%ul %ul
%li %li
%span.badge.badge-success active %span.badge.badge-pill.gl-badge.sm.badge-success active
= _('- Available to run jobs.') = _('- Available to run jobs.')
%li %li
%span.badge.badge-danger paused %span.badge.badge-pill.gl-badge.sm.badge-danger paused
= _('- Not available to run jobs.') = _('- Not available to run jobs.')

View File

@ -0,0 +1,5 @@
---
title: 'Update Issue Incidents to allow the milestones feature to be used in the sidebar and quick actions'
merge_request: 51456
author:
type: changed

View File

@ -0,0 +1,5 @@
---
title: Add gl-badge to CI badges
merge_request: 51547
author: Yogi (@yo)
type: other

View File

@ -0,0 +1,5 @@
---
title: Add gl-badge to CI runners
merge_request: 51548
author: Yogi (@yo)
type: other

View File

@ -45,7 +45,7 @@ RSpec.describe 'Incident details', :js do
expect(page).to have_selector('.right-sidebar[data-issuable-type="issue"]') expect(page).to have_selector('.right-sidebar[data-issuable-type="issue"]')
expect(sidebar).to have_selector('.incident-severity') expect(sidebar).to have_selector('.incident-severity')
expect(sidebar).not_to have_selector('.milestone') expect(sidebar).to have_selector('.milestone')
end end
end end
end end

View File

@ -223,8 +223,8 @@ RSpec.describe "User creates issue" do
expect(page).not_to have_selector('.epic-dropdown-container') expect(page).not_to have_selector('.epic-dropdown-container')
end end
it 'hides the milestone select' do it 'shows the milestone select' do
expect(page).not_to have_selector('.qa-issuable-milestone-dropdown') expect(page).to have_selector('.qa-issuable-milestone-dropdown')
end end
it 'hides the weight input' do it 'hides the weight input' do

View File

@ -605,11 +605,14 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
within(".js-report-section-container") do within(".js-report-section-container") do
click_button 'addTest' click_button 'addTest'
expect(page).to have_content('6.66')
expect(page).to have_content(sample_java_failed_message.gsub(/\s+/, ' ').strip)
end end
end end
within("#modal-mrwidget-reports") do
expect(page).to have_content('addTest')
expect(page).to have_content('6.66')
expect(page).to have_content(sample_java_failed_message.gsub(/\s+/, ' ').strip)
end
end end
end end
end end
@ -650,11 +653,14 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
within(".js-report-section-container") do within(".js-report-section-container") do
click_button 'Test#sum when a is 1 and b is 3 returns summary' click_button 'Test#sum when a is 1 and b is 3 returns summary'
expect(page).to have_content('2.22')
expect(page).to have_content(sample_rspec_failed_message.gsub(/\s+/, ' ').strip)
end end
end end
within("#modal-mrwidget-reports") do
expect(page).to have_content('Test#sum when a is 1 and b is 3 returns summary')
expect(page).to have_content('2.22')
expect(page).to have_content(sample_rspec_failed_message.gsub(/\s+/, ' ').strip)
end
end end
end end
end end
@ -694,10 +700,13 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
within(".js-report-section-container") do within(".js-report-section-container") do
click_button 'addTest' click_button 'addTest'
expect(page).to have_content('5.55')
end end
end end
within("#modal-mrwidget-reports") do
expect(page).to have_content('addTest')
expect(page).to have_content('5.55')
end
end end
end end
end end
@ -738,10 +747,13 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
within(".js-report-section-container") do within(".js-report-section-container") do
click_button 'addTest' click_button 'addTest'
expect(page).to have_content('8.88')
end end
end end
within("#modal-mrwidget-reports") do
expect(page).to have_content('addTest')
expect(page).to have_content('8.88')
end
end end
end end
end end
@ -782,10 +794,13 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
within(".js-report-section-container") do within(".js-report-section-container") do
click_button 'Test#sum when a is 4 and b is 4 returns summary' click_button 'Test#sum when a is 4 and b is 4 returns summary'
expect(page).to have_content('4.44')
end end
end end
within("#modal-mrwidget-reports") do
expect(page).to have_content('Test#sum when a is 4 and b is 4 returns summary')
expect(page).to have_content('4.44')
end
end end
end end
end end
@ -825,10 +840,13 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
within(".js-report-section-container") do within(".js-report-section-container") do
click_button 'addTest' click_button 'addTest'
expect(page).to have_content('5.55')
end end
end end
within("#modal-mrwidget-reports") do
expect(page).to have_content('addTest')
expect(page).to have_content('5.55')
end
end end
end end
end end

View File

@ -1,54 +1,63 @@
import Vue from 'vue'; import { GlLink, GlSprintf } from '@gitlab/ui';
import mountComponent from 'helpers/vue_mount_component_helper'; import { shallowMount } from '@vue/test-utils';
import { trimText } from 'helpers/text_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import component from '~/reports/components/modal.vue';
import CodeBlock from '~/vue_shared/components/code_block.vue';
import ReportsModal from '~/reports/components/modal.vue';
import state from '~/reports/store/state'; import state from '~/reports/store/state';
const StubbedGlModal = { template: '<div><slot></slot></div>', name: 'GlModal', props: ['title'] };
describe('Grouped Test Reports Modal', () => { describe('Grouped Test Reports Modal', () => {
const Component = Vue.extend(component);
const modalDataStructure = state().modal.data; const modalDataStructure = state().modal.data;
const title = 'Test#sum when a is 1 and b is 2 returns summary';
// populate data // populate data
modalDataStructure.execution_time.value = 0.009411; modalDataStructure.execution_time.value = 0.009411;
modalDataStructure.system_output.value = 'Failure/Error: is_expected.to eq(3)\n\n'; modalDataStructure.system_output.value = 'Failure/Error: is_expected.to eq(3)\n\n';
modalDataStructure.class.value = 'link'; modalDataStructure.class.value = 'link';
let vm; let wrapper;
beforeEach(() => { beforeEach(() => {
vm = mountComponent(Component, { wrapper = extendedWrapper(
title: 'Test#sum when a is 1 and b is 2 returns summary', shallowMount(ReportsModal, {
modalData: modalDataStructure, propsData: {
}); title,
modalData: modalDataStructure,
visible: true,
},
stubs: { GlModal: StubbedGlModal, GlSprintf },
}),
);
}); });
afterEach(() => { afterEach(() => {
vm.$destroy(); wrapper.destroy();
}); });
it('renders code block', () => { it('renders code block', () => {
expect(vm.$el.querySelector('code').textContent).toEqual( expect(wrapper.find(CodeBlock).props().code).toEqual(modalDataStructure.system_output.value);
modalDataStructure.system_output.value,
);
}); });
it('renders link', () => { it('renders link', () => {
expect(vm.$el.querySelector('.js-modal-link').getAttribute('href')).toEqual( const link = wrapper.findComponent(GlLink);
modalDataStructure.class.value,
);
expect(trimText(vm.$el.querySelector('.js-modal-link').textContent)).toEqual( expect(link.attributes().href).toEqual(modalDataStructure.class.value);
modalDataStructure.class.value,
); expect(link.text()).toEqual(modalDataStructure.class.value);
}); });
it('renders seconds', () => { it('renders seconds', () => {
expect(vm.$el.textContent).toContain(`${modalDataStructure.execution_time.value} s`); expect(wrapper.text()).toContain(`${modalDataStructure.execution_time.value} s`);
}); });
it('render title', () => { it('render title', () => {
expect(trimText(vm.$el.querySelector('.modal-title').textContent)).toEqual( expect(wrapper.findComponent(StubbedGlModal).props().title).toEqual(title);
'Test#sum when a is 1 and b is 2 returns summary', });
);
it('re-emits hide event', () => {
wrapper.findComponent(StubbedGlModal).vm.$emit('hide');
expect(wrapper.emitted().hide).toEqual([[]]);
}); });
}); });

View File

@ -11,7 +11,7 @@ import {
receiveReportsSuccess, receiveReportsSuccess,
receiveReportsError, receiveReportsError,
openModal, openModal,
setModalData, closeModal,
} from '~/reports/store/actions'; } from '~/reports/store/actions';
import state from '~/reports/store/state'; import state from '~/reports/store/state';
import * as types from '~/reports/store/mutation_types'; import * as types from '~/reports/store/mutation_types';
@ -144,22 +144,9 @@ describe('Reports Store Actions', () => {
}); });
describe('openModal', () => { describe('openModal', () => {
it('should dispatch setModalData', (done) => {
testAction(
openModal,
{ name: 'foo' },
mockedState,
[],
[{ type: 'setModalData', payload: { name: 'foo' } }],
done,
);
});
});
describe('setModalData', () => {
it('should commit SET_ISSUE_MODAL_DATA', (done) => { it('should commit SET_ISSUE_MODAL_DATA', (done) => {
testAction( testAction(
setModalData, openModal,
{ name: 'foo' }, { name: 'foo' },
mockedState, mockedState,
[{ type: types.SET_ISSUE_MODAL_DATA, payload: { name: 'foo' } }], [{ type: types.SET_ISSUE_MODAL_DATA, payload: { name: 'foo' } }],
@ -168,4 +155,17 @@ describe('Reports Store Actions', () => {
); );
}); });
}); });
describe('closeModal', () => {
it('should commit RESET_ISSUE_MODAL_DATA', (done) => {
testAction(
closeModal,
{},
mockedState,
[{ type: types.RESET_ISSUE_MODAL_DATA, payload: {} }],
[],
done,
);
});
});
}); });

View File

@ -127,5 +127,32 @@ describe('Reports Store Mutations', () => {
expect(stateCopy.modal.data.execution_time.value).toEqual(issue.execution_time); expect(stateCopy.modal.data.execution_time.value).toEqual(issue.execution_time);
expect(stateCopy.modal.data.system_output.value).toEqual(issue.system_output); expect(stateCopy.modal.data.system_output.value).toEqual(issue.system_output);
}); });
it('should open modal', () => {
expect(stateCopy.modal.open).toEqual(true);
});
});
describe('RESET_ISSUE_MODAL_DATA', () => {
beforeEach(() => {
mutations[types.SET_ISSUE_MODAL_DATA](stateCopy, {
issue,
});
mutations[types.RESET_ISSUE_MODAL_DATA](stateCopy);
});
it('should reset modal title', () => {
expect(stateCopy.modal.title).toEqual(null);
});
it('should reset modal data', () => {
expect(stateCopy.modal.data.execution_time.value).toEqual(null);
expect(stateCopy.modal.data.system_output.value).toEqual(null);
});
it('should close modal', () => {
expect(stateCopy.modal.open).toEqual(false);
});
}); });
}); });

View File

@ -104,8 +104,8 @@ RSpec.describe Milestoneable do
context "for incidents" do context "for incidents" do
let(:incident) { build(:incident) } let(:incident) { build(:incident) }
it 'returns false' do it 'returns true' do
expect(incident.supports_milestone?).to be_falsy expect(incident.supports_milestone?).to be_truthy
end end
end end
end end

View File

@ -153,8 +153,8 @@ RSpec.describe Notes::QuickActionsService do
expect(execute(note)).to be_empty expect(execute(note)).to be_empty
end end
it 'does not assign the milestone' do it 'assigns the milestone' do
expect { execute(note) }.not_to change { issue.reload.milestone } expect { execute(note) }.to change { issue.reload.milestone }.from(nil).to(milestone)
end end
end end
@ -195,8 +195,8 @@ RSpec.describe Notes::QuickActionsService do
expect(execute(note)).to be_empty expect(execute(note)).to be_empty
end end
it 'does not remove the milestone' do it 'removes the milestone' do
expect { execute(note) }.not_to change { issue.reload.milestone } expect { execute(note) }.to change { issue.reload.milestone }.from(milestone).to(nil)
end end
end end