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 { ...@@ -33,7 +33,7 @@ export default {
props: { props: {
events: { events: {
type: Array, type: Array,
required: true, required: true,
}, },
labels: { labels: {
type: Array, type: Array,
...@@ -105,7 +105,7 @@ export default { ...@@ -105,7 +105,7 @@ export default {
}, },
stopEventError() { stopEventError() {
return !this.hasValidStartAndStopEventPair 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; : null;
}, },
}, },
......
...@@ -22,14 +22,14 @@ export default { ...@@ -22,14 +22,14 @@ export default {
}, },
data() { data() {
return { 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: [], events: [],
labels: [], labels: [],
isLoading: false, isLoading: false,
}; };
}, },
created() { 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; this.isLoading = true;
Api.groupLabels(this.namespace) Api.groupLabels(this.namespace)
.then(labels => { .then(labels => {
......
...@@ -2,7 +2,7 @@ import Vue from 'vue'; ...@@ -2,7 +2,7 @@ import Vue from 'vue';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import CustomStageForm from 'ee/analytics/cycle_analytics/components/custom_stage_form.vue'; 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 { 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 })); const labels = mockLabels.map(({ title, ...rest }) => ({ ...rest, name: title }));
...@@ -159,7 +159,7 @@ describe('CustomStageForm', () => { ...@@ -159,7 +159,7 @@ describe('CustomStageForm', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createComponent( wrapper = createComponent(
{ {
events: rawEvents, events,
}, },
false, false,
); );
...@@ -192,7 +192,7 @@ describe('CustomStageForm', () => { ...@@ -192,7 +192,7 @@ describe('CustomStageForm', () => {
Vue.nextTick(() => { Vue.nextTick(() => {
stopOptions = wrapper.find(sel.stopEvent).findAll('option'); stopOptions = wrapper.find(sel.stopEvent).findAll('option');
expect(stopOptions.length).toEqual(3); expect(stopOptions.length).toEqual(2);
}); });
}); });
...@@ -206,8 +206,10 @@ describe('CustomStageForm', () => { ...@@ -206,8 +206,10 @@ describe('CustomStageForm', () => {
stopOptions = wrapper.find(sel.stopEvent).findAll('option'); stopOptions = wrapper.find(sel.stopEvent).findAll('option');
[ [
{ name: 'Select stop event', identifier: '' }, { 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) => { ].forEach(({ name, identifier }, i) => {
expect(stopOptions.at(i).html()).toEqual( expect(stopOptions.at(i).html()).toEqual(
`<option value="${identifier}">${name}</option>`, `<option value="${identifier}">${name}</option>`,
......
...@@ -52,7 +52,9 @@ export const testEvents = stageFixtures.test; ...@@ -52,7 +52,9 @@ export const testEvents = stageFixtures.test;
export const stagingEvents = stageFixtures.staging; export const stagingEvents = stageFixtures.staging;
export const productionEvents = stageFixtures.production; 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: [ events: [
{ {
name: 'Issue created', name: 'Issue created',
...@@ -75,7 +77,6 @@ const apiResponse = { ...@@ -75,7 +77,6 @@ const apiResponse = {
canBeStartEvent: true, canBeStartEvent: true,
allowedEndEvents: ['merge_request_merged'], allowedEndEvents: ['merge_request_merged'],
}, },
{ {
name: 'Merge request first deployed to production', name: 'Merge request first deployed to production',
identifier: 'merge_request_first_deployed_to_production', identifier: 'merge_request_first_deployed_to_production',
...@@ -244,52 +245,6 @@ const apiResponse = { ...@@ -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 { export default {
apiResponse, apiResponse,
rawEvents,
}; };
...@@ -6,12 +6,14 @@ import { ...@@ -6,12 +6,14 @@ import {
eventsByIdentifier, eventsByIdentifier,
getLabelEventsIdentifiers, getLabelEventsIdentifiers,
} from 'ee/analytics/cycle_analytics/utils'; } from 'ee/analytics/cycle_analytics/utils';
import { rawEvents } from './mock_data'; import { apiResponse } from './mock_data';
const startEvent = rawEvents[0]; const { events } = apiResponse;
const endEvent = rawEvents[1];
const labelEvent = rawEvents[5]; const startEvent = events[0];
const labelEvents = [rawEvents[4], rawEvents[5]].map(i => i.identifier); const endEvent = events[1];
const labelEvent = events[11];
const labelEvents = [events[10], events[11]].map(i => i.identifier);
describe('Cycle analytics utils', () => { describe('Cycle analytics utils', () => {
describe('isStartEvent', () => { describe('isStartEvent', () => {
...@@ -46,14 +48,14 @@ describe('Cycle analytics utils', () => { ...@@ -46,14 +48,14 @@ describe('Cycle analytics utils', () => {
}); });
it('will set the "value" property to the events identifier', () => { it('will set the "value" property to the events identifier', () => {
rawEvents.forEach(ev => { events.forEach(ev => {
const res = eventToOption(ev); const res = eventToOption(ev);
expect(res.value).toEqual(ev.identifier); expect(res.value).toEqual(ev.identifier);
}); });
}); });
it('will set the "text" property to the events name', () => { it('will set the "text" property to the events name', () => {
rawEvents.forEach(ev => { events.forEach(ev => {
const res = eventToOption(ev); const res = eventToOption(ev);
expect(res.text).toEqual(ev.name); expect(res.text).toEqual(ev.name);
}); });
...@@ -62,7 +64,7 @@ describe('Cycle analytics utils', () => { ...@@ -62,7 +64,7 @@ describe('Cycle analytics utils', () => {
describe('getLabelEventsIdentifiers', () => { describe('getLabelEventsIdentifiers', () => {
it('will return an array of identifiers for the label events', () => { 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.length).toEqual(labelEvents.length);
expect(res).toEqual(labelEvents); expect(res).toEqual(labelEvents);
}); });
...@@ -75,25 +77,25 @@ describe('Cycle analytics utils', () => { ...@@ -75,25 +77,25 @@ describe('Cycle analytics utils', () => {
describe('getAllowedEndEvents', () => { describe('getAllowedEndEvents', () => {
it('will return the relevant end events for a given start event identifier', () => { it('will return the relevant end events for a given start event identifier', () => {
const se = rawEvents[4].allowedEndEvents; const se = events[10].allowedEndEvents;
expect(getAllowedEndEvents(rawEvents, 'issue_label_added')).toEqual(se); expect(getAllowedEndEvents(events, 'issue_label_added')).toEqual(se);
}); });
it('will return an empty array if there are no end events available', () => { it('will return an empty array if there are no end events available', () => {
['cool_issue_label_added', [], {}, null, undefined].forEach(ev => { ['cool_issue_label_added', [], {}, null, undefined].forEach(ev => {
expect(getAllowedEndEvents(rawEvents, ev)).toEqual([]); expect(getAllowedEndEvents(events, ev)).toEqual([]);
}); });
}); });
}); });
describe('eventsByIdentifier', () => { describe('eventsByIdentifier', () => {
it('will return the events with an identifier in the provided array', () => { 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', () => { it('will return an empty array if there are no matching events', () => {
[['lol', 'bad'], [], {}, null, undefined].forEach(items => { [['lol', 'bad'], [], {}, null, undefined].forEach(items => {
expect(eventsByIdentifier(rawEvents, items)).toEqual([]); expect(eventsByIdentifier(events, items)).toEqual([]);
}); });
expect(eventsByIdentifier([], labelEvents)).toEqual([]); expect(eventsByIdentifier([], labelEvents)).toEqual([]);
}); });
......
...@@ -4532,9 +4532,6 @@ msgstr "" ...@@ -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." 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 "" msgstr ""
msgid "CustomCycleAnalyticsStart event changed, please select a valid stop event"
msgstr ""
msgid "CustomCycleAnalytics|Add a stage" msgid "CustomCycleAnalytics|Add a stage"
msgstr "" msgstr ""
...@@ -4562,6 +4559,9 @@ msgstr "" ...@@ -4562,6 +4559,9 @@ msgstr ""
msgid "CustomCycleAnalytics|Start event" msgid "CustomCycleAnalytics|Start event"
msgstr "" msgstr ""
msgid "CustomCycleAnalytics|Start event changed, please select a valid stop event"
msgstr ""
msgid "CustomCycleAnalytics|Start event label" msgid "CustomCycleAnalytics|Start event label"
msgstr "" 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