Commit 1c899c8e authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Fix show add stage form event

Updates the listening event for
the custom stage form

Adds additional jest specs
parent 4a0c6ab9
......@@ -102,7 +102,7 @@ export default {
<add-stage-button
:class="$options.noDragClass"
:active="isCreatingCustomStage"
@showform="$emit('show-add-stage-form')"
@showform="$emit($options.STAGE_ACTIONS.ADD_STAGE)"
/>
</ul>
</template>
......@@ -56,6 +56,7 @@ export const STAGE_ACTIONS = {
HIDE: 'hideStage',
CREATE: 'createStage',
UPDATE: 'updateStage',
ADD_STAGE: 'showAddStageForm',
};
export const STAGE_NAME = {
......
......@@ -13,6 +13,7 @@ import StageTable from 'ee/analytics/cycle_analytics/components/stage_table.vue'
import StageTableNav from 'ee/analytics/cycle_analytics/components/stage_table_nav.vue';
import StageNavItem from 'ee/analytics/cycle_analytics/components/stage_nav_item.vue';
import AddStageButton from 'ee/analytics/cycle_analytics/components/add_stage_button.vue';
import CustomStageForm from 'ee/analytics/cycle_analytics/components/custom_stage_form.vue';
import FilterBar from 'ee/analytics/cycle_analytics/components/filter_bar.vue';
import DurationChart from 'ee/analytics/cycle_analytics/components/duration_chart.vue';
import Daterange from 'ee/analytics/shared/components/daterange.vue';
......@@ -137,6 +138,8 @@ describe('Cycle Analytics component', () => {
.findAll(StageNavItem)
.at(index);
const findAddStageButton = () => wrapper.find(AddStageButton);
const displaysProjectsDropdownFilter = flag => {
expect(wrapper.find(ProjectsDropdownFilter).exists()).toBe(flag);
};
......@@ -429,6 +432,31 @@ describe('Cycle Analytics component', () => {
expect(first.props('isActive')).toBe(false);
});
});
describe('Add stage button', () => {
beforeEach(() => {
wrapper = createComponent({
opts: {
stubs: {
StageTable,
StageTableNav,
AddStageButton,
},
},
withStageSelected: true,
});
});
it('can navigate to the custom stage form', () => {
expect(wrapper.find(CustomStageForm).exists()).toBe(false);
findAddStageButton().trigger('click');
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(CustomStageForm).exists()).toBe(true);
});
});
});
});
});
......
......@@ -60,9 +60,18 @@ describe('StageTableNav', () => {
});
});
it('will render the add a stage button', () => {
wrapper = createComponent();
expect(wrapper.find(AddStageButton).exists()).toBe(true);
describe('Add stage button', () => {
it('will render', () => {
wrapper = createComponent();
expect(wrapper.find(AddStageButton).exists()).toBe(true);
});
it('will emit showAddStageForm action when clicked', () => {
wrapper = createComponent({ mountFn: mount });
wrapper.find(AddStageButton).trigger('click');
expect(wrapper.emitted('showAddStageForm')).toHaveLength(1);
});
});
describe.each`
......
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