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,7 +153,7 @@ export default { ...@@ -155,7 +153,7 @@ 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"
...@@ -176,6 +174,7 @@ export default { ...@@ -176,6 +174,7 @@ export default {
<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,13 +59,21 @@ describe('ValueStreamSelect', () => { ...@@ -59,13 +59,21 @@ 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');
afterEach(() => {
unmockTracking();
wrapper.destroy();
});
describe('with value streams available', () => {
describe('default behaviour', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createComponent({ wrapper = createComponent({
mountFn: mount,
initialState: { initialState: {
valueStreams, valueStreams,
}, },
...@@ -73,12 +81,6 @@ describe('ValueStreamSelect', () => { ...@@ -73,12 +81,6 @@ describe('ValueStreamSelect', () => {
trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn); trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn);
}); });
afterEach(() => {
unmockTracking();
wrapper.destroy();
});
describe('with value streams available', () => {
it('does not display the create value stream button', () => { it('does not display the create value stream button', () => {
expect(findCreateValueStreamButton().exists()).toBe(false); expect(findCreateValueStreamButton().exists()).toBe(false);
}); });
...@@ -93,10 +95,12 @@ describe('ValueStreamSelect', () => { ...@@ -93,10 +95,12 @@ describe('ValueStreamSelect', () => {
expect(opts).toContain(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