Commit 3e99ee37 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Fix namespaced translation

Remove extra mock data

Removed some extra mock data we do not
need and added a note to migrate mocks
to fixture specs.
parent db5a6bbc
......@@ -33,7 +33,7 @@ export default {
props: {
events: {
type: Array,
required: true,
required: true,
},
labels: {
type: Array,
......@@ -105,7 +105,7 @@ export default {
},
stopEventError() {
return !this.hasValidStartAndStopEventPair
? s__('CustomCycleAnalyticsStart event changed, please select a valid stop event')
? s__('CustomCycleAnalytics|Start event changed, please select a valid stop event')
: null;
},
},
......
......@@ -22,14 +22,14 @@ export default {
},
data() {
return {
// NOTE: events will be part of the response from the new cycle analytics backend
// https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31535
events: [],
labels: [],
isLoading: false,
};
},
created() {
// NOTE: events will be part of the response from the new cycle analytics backend
// https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/31535
this.isLoading = true;
Api.groupLabels(this.namespace)
.then(labels => {
......
......@@ -2,7 +2,7 @@ import Vue from 'vue';
import { mount } from '@vue/test-utils';
import CustomStageForm from 'ee/analytics/cycle_analytics/components/custom_stage_form.vue';
import { mockLabels } from '../../../../../../spec/javascripts/vue_shared/components/sidebar/labels_select/mock_data';
import { apiResponse, rawEvents } from '../mock_data';
import { apiResponse } from '../mock_data';
const labels = mockLabels.map(({ title, ...rest }) => ({ ...rest, name: title }));
......@@ -159,7 +159,7 @@ describe('CustomStageForm', () => {
beforeEach(() => {
wrapper = createComponent(
{
events: rawEvents,
events,
},
false,
);
......@@ -192,7 +192,7 @@ describe('CustomStageForm', () => {
Vue.nextTick(() => {
stopOptions = wrapper.find(sel.stopEvent).findAll('option');
expect(stopOptions.length).toEqual(3);
expect(stopOptions.length).toEqual(2);
});
});
......@@ -206,8 +206,10 @@ describe('CustomStageForm', () => {
stopOptions = wrapper.find(sel.stopEvent).findAll('option');
[
{ name: 'Select stop event', identifier: '' },
{ name: 'Issue closed', identifier: 'issue_closed' },
{ name: 'Issue merged', identifier: 'issue_merged' },
{
name: 'Issue first associated with a milestone or issue first added to a board',
identifier: 'issue_stage_end',
},
].forEach(({ name, identifier }, i) => {
expect(stopOptions.at(i).html()).toEqual(
`<option value="${identifier}">${name}</option>`,
......
......@@ -52,7 +52,9 @@ export const testEvents = stageFixtures.test;
export const stagingEvents = stageFixtures.staging;
export const productionEvents = stageFixtures.production;
const apiResponse = {
// NOTE: once the backend is complete, we can generate this as a JSON fixture
// https://gitlab.com/gitlab-org/gitlab/issues/32112
export const apiResponse = {
events: [
{
name: 'Issue created',
......@@ -75,7 +77,6 @@ const apiResponse = {
canBeStartEvent: true,
allowedEndEvents: ['merge_request_merged'],
},
{
name: 'Merge request first deployed to production',
identifier: 'merge_request_first_deployed_to_production',
......@@ -244,52 +245,6 @@ const apiResponse = {
},
};
export const rawEvents = [
{
name: 'Issue created',
identifier: 'issue_created',
type: 'simple',
canBeStartEvent: true,
allowedEndEvents: ['issue_closed', 'issue_merged'],
},
{
name: 'Merge request closed',
identifier: 'merge_request_closed',
type: 'simple',
canBeStartEvent: false,
allowedEndEvents: [],
},
{
name: 'Issue closed',
identifier: 'issue_closed',
type: 'simple',
canBeStartEvent: false,
allowedEndEvents: [],
},
{
name: 'Issue merged',
identifier: 'issue_merged',
type: 'simple',
canBeStartEvent: false,
allowedEndEvents: [],
},
{
identifier: 'issue_label_added',
name: 'Issue Label Added',
type: 'label',
canBeStartEvent: true,
allowedEndEvents: ['issue_closed', 'issue_label_removed'],
},
{
identifier: 'issue_label_removed',
name: 'Issue Label Removed',
type: 'label',
canBeStartEvent: false,
allowedEndEvents: [],
},
];
export default {
apiResponse,
rawEvents,
};
......@@ -6,12 +6,14 @@ import {
eventsByIdentifier,
getLabelEventsIdentifiers,
} from 'ee/analytics/cycle_analytics/utils';
import { rawEvents } from './mock_data';
import { apiResponse } from './mock_data';
const startEvent = rawEvents[0];
const endEvent = rawEvents[1];
const labelEvent = rawEvents[5];
const labelEvents = [rawEvents[4], rawEvents[5]].map(i => i.identifier);
const { events } = apiResponse;
const startEvent = events[0];
const endEvent = events[1];
const labelEvent = events[11];
const labelEvents = [events[10], events[11]].map(i => i.identifier);
describe('Cycle analytics utils', () => {
describe('isStartEvent', () => {
......@@ -46,14 +48,14 @@ describe('Cycle analytics utils', () => {
});
it('will set the "value" property to the events identifier', () => {
rawEvents.forEach(ev => {
events.forEach(ev => {
const res = eventToOption(ev);
expect(res.value).toEqual(ev.identifier);
});
});
it('will set the "text" property to the events name', () => {
rawEvents.forEach(ev => {
events.forEach(ev => {
const res = eventToOption(ev);
expect(res.text).toEqual(ev.name);
});
......@@ -62,7 +64,7 @@ describe('Cycle analytics utils', () => {
describe('getLabelEventsIdentifiers', () => {
it('will return an array of identifiers for the label events', () => {
const res = getLabelEventsIdentifiers(rawEvents);
const res = getLabelEventsIdentifiers(events);
expect(res.length).toEqual(labelEvents.length);
expect(res).toEqual(labelEvents);
});
......@@ -75,25 +77,25 @@ describe('Cycle analytics utils', () => {
describe('getAllowedEndEvents', () => {
it('will return the relevant end events for a given start event identifier', () => {
const se = rawEvents[4].allowedEndEvents;
expect(getAllowedEndEvents(rawEvents, 'issue_label_added')).toEqual(se);
const se = events[10].allowedEndEvents;
expect(getAllowedEndEvents(events, 'issue_label_added')).toEqual(se);
});
it('will return an empty array if there are no end events available', () => {
['cool_issue_label_added', [], {}, null, undefined].forEach(ev => {
expect(getAllowedEndEvents(rawEvents, ev)).toEqual([]);
expect(getAllowedEndEvents(events, ev)).toEqual([]);
});
});
});
describe('eventsByIdentifier', () => {
it('will return the events with an identifier in the provided array', () => {
expect(eventsByIdentifier(rawEvents, labelEvents)).toEqual([rawEvents[4], rawEvents[5]]);
expect(eventsByIdentifier(events, labelEvents)).toEqual([events[10], events[11]]);
});
it('will return an empty array if there are no matching events', () => {
[['lol', 'bad'], [], {}, null, undefined].forEach(items => {
expect(eventsByIdentifier(rawEvents, items)).toEqual([]);
expect(eventsByIdentifier(events, items)).toEqual([]);
});
expect(eventsByIdentifier([], labelEvents)).toEqual([]);
});
......
......@@ -4532,9 +4532,6 @@ msgstr ""
msgid "Custom project templates have not been set up for groups that you are a member of. They are enabled from a group’s settings page. Contact your group’s Owner or Maintainer to setup custom project templates."
msgstr ""
msgid "CustomCycleAnalyticsStart event changed, please select a valid stop event"
msgstr ""
msgid "CustomCycleAnalytics|Add a stage"
msgstr ""
......@@ -4562,6 +4559,9 @@ msgstr ""
msgid "CustomCycleAnalytics|Start event"
msgstr ""
msgid "CustomCycleAnalytics|Start event changed, please select a valid stop event"
msgstr ""
msgid "CustomCycleAnalytics|Start event label"
msgstr ""
......
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