Commit d3a2c5a8 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch '327738-create-and-delete-options-should-remain-visible-in-vs-dropdown' into 'master'

Create and Delete options should remain visible in VS dropdown

See merge request gitlab-org/gitlab!74683
parents 97c1d0d8 17755bf7
...@@ -4,7 +4,6 @@ import { ...@@ -4,7 +4,6 @@ import {
GlButton, GlButton,
GlDropdown, GlDropdown,
GlDropdownItem, GlDropdownItem,
GlDropdownDivider,
GlModal, GlModal,
GlModalDirective, GlModalDirective,
GlSprintf, GlSprintf,
...@@ -34,7 +33,6 @@ export default { ...@@ -34,7 +33,6 @@ export default {
GlButton, GlButton,
GlDropdown, GlDropdown,
GlDropdownItem, GlDropdownItem,
GlDropdownDivider,
GlModal, GlModal,
GlSprintf, GlSprintf,
ValueStreamForm, ValueStreamForm,
...@@ -155,27 +153,28 @@ export default { ...@@ -155,27 +153,28 @@ export default {
@click="onSelect(id)" @click="onSelect(id)"
>{{ streamName }}</gl-dropdown-item >{{ streamName }}</gl-dropdown-item
> >
<gl-dropdown-divider /> <template #footer>
<gl-dropdown-item <gl-dropdown-item
v-gl-modal-directive="'value-stream-form-modal'" v-gl-modal-directive="'value-stream-form-modal'"
data-testid="create-value-stream" data-testid="create-value-stream"
data-track-action="click_dropdown" data-track-action="click_dropdown"
data-track-label="create_value_stream_form_open" data-track-label="create_value_stream_form_open"
@click="onCreate" @click="onCreate"
>{{ $options.i18n.CREATE_VALUE_STREAM }}</gl-dropdown-item >{{ $options.i18n.CREATE_VALUE_STREAM }}</gl-dropdown-item
> >
<gl-dropdown-item <gl-dropdown-item
v-if="isCustomValueStream" v-if="isCustomValueStream"
v-gl-modal-directive="'delete-value-stream-modal'" v-gl-modal-directive="'delete-value-stream-modal'"
variant="danger" variant="danger"
data-testid="delete-value-stream" data-testid="delete-value-stream"
data-track-action="click_dropdown" data-track-action="click_dropdown"
data-track-label="delete_value_stream_form_open" data-track-label="delete_value_stream_form_open"
> >
<gl-sprintf :message="$options.i18n.DELETE_NAME"> <gl-sprintf :message="$options.i18n.DELETE_NAME">
<template #name>{{ selectedValueStreamName }}</template> <template #name>{{ selectedValueStreamName }}</template>
</gl-sprintf> </gl-sprintf>
</gl-dropdown-item> </gl-dropdown-item>
</template>
</gl-dropdown> </gl-dropdown>
<gl-button <gl-button
v-else v-else
......
import { GlDropdown } from '@gitlab/ui'; import { GlDropdown } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { mount, shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import ValueStreamSelect from 'ee/analytics/cycle_analytics/components/value_stream_select.vue'; import ValueStreamSelect from 'ee/analytics/cycle_analytics/components/value_stream_select.vue';
import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
...@@ -38,9 +38,9 @@ describe('ValueStreamSelect', () => { ...@@ -38,9 +38,9 @@ describe('ValueStreamSelect', () => {
}, },
}); });
const createComponent = ({ data = {}, initialState = {} } = {}) => const createComponent = ({ data = {}, initialState = {}, mountFn = shallowMount } = {}) =>
extendedWrapper( extendedWrapper(
shallowMount(ValueStreamSelect, { mountFn(ValueStreamSelect, {
localVue, localVue,
store: fakeStore({ initialState }), store: fakeStore({ initialState }),
data() { data() {
...@@ -59,44 +59,48 @@ describe('ValueStreamSelect', () => { ...@@ -59,44 +59,48 @@ describe('ValueStreamSelect', () => {
const findModal = (modal) => wrapper.find(`[data-testid="${modal}-value-stream-modal"]`); const findModal = (modal) => wrapper.find(`[data-testid="${modal}-value-stream-modal"]`);
const submitModal = (modal) => findModal(modal).vm.$emit('primary', mockEvent); const submitModal = (modal) => findModal(modal).vm.$emit('primary', mockEvent);
const findSelectValueStreamDropdown = () => wrapper.findComponent(GlDropdown); const findSelectValueStreamDropdown = () => wrapper.findComponent(GlDropdown);
const findSelectValueStreamDropdownOptions = (_wrapper) => findDropdownItemText(_wrapper); const findSelectValueStreamDropdownOptions = () => findDropdownItemText(wrapper);
const findCreateValueStreamButton = () => wrapper.findByTestId('create-value-stream-button'); const findCreateValueStreamButton = () => wrapper.findByTestId('create-value-stream-button');
const findEditValueStreamButton = () => wrapper.findByTestId('edit-value-stream'); const findEditValueStreamButton = () => wrapper.findByTestId('edit-value-stream');
const findDeleteValueStreamButton = () => wrapper.findByTestId('delete-value-stream'); const findDeleteValueStreamButton = () => wrapper.findByTestId('delete-value-stream');
beforeEach(() => {
wrapper = createComponent({
initialState: {
valueStreams,
},
});
trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn);
});
afterEach(() => { afterEach(() => {
unmockTracking(); unmockTracking();
wrapper.destroy(); wrapper.destroy();
}); });
describe('with value streams available', () => { describe('with value streams available', () => {
it('does not display the create value stream button', () => { describe('default behaviour', () => {
expect(findCreateValueStreamButton().exists()).toBe(false); beforeEach(() => {
}); wrapper = createComponent({
mountFn: mount,
initialState: {
valueStreams,
},
});
trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn);
});
it('displays the select value stream dropdown', () => { it('does not display the create value stream button', () => {
expect(findSelectValueStreamDropdown().exists()).toBe(true); expect(findCreateValueStreamButton().exists()).toBe(false);
}); });
it('renders each value stream including a create button', () => { it('displays the select value stream dropdown', () => {
const opts = findSelectValueStreamDropdownOptions(wrapper); expect(findSelectValueStreamDropdown().exists()).toBe(true);
[...valueStreams.map((v) => v.name), 'Create new Value Stream'].forEach((vs) => { });
expect(opts).toContain(vs);
it('renders each value stream including a create button', () => {
const opts = findSelectValueStreamDropdownOptions(wrapper);
[...valueStreams.map((v) => v.name), 'Create new Value Stream'].forEach((vs) => {
expect(opts).toContain(vs);
});
}); });
}); });
describe('with a selected value stream', () => { describe('with a selected value stream', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createComponent({ wrapper = createComponent({
mountFn: mount,
initialState: { initialState: {
valueStreams, valueStreams,
selectedValueStream: { selectedValueStream: {
...@@ -189,6 +193,8 @@ describe('ValueStreamSelect', () => { ...@@ -189,6 +193,8 @@ describe('ValueStreamSelect', () => {
}, },
}); });
trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn);
submitModal('delete'); submitModal('delete');
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment