Commit e64975e8 authored by Fatih Acet's avatar Fatih Acet

Merge branch '208470_01-geo-replicable-mutations' into 'master'

Geo Replicable - Generalize Mutations

See merge request gitlab-org/gitlab!26697
parents ed6dbb83 163c5764
...@@ -10,17 +10,17 @@ import { ...@@ -10,17 +10,17 @@ import {
import * as types from './mutation_types'; import * as types from './mutation_types';
import { FILTER_STATES } from './constants'; import { FILTER_STATES } from './constants';
// Fetch Designs // Fetch Replicable Items
export const requestDesigns = ({ commit }) => commit(types.REQUEST_DESIGNS); export const requestReplicableItems = ({ commit }) => commit(types.REQUEST_REPLICABLE_ITEMS);
export const receiveDesignsSuccess = ({ commit }, data) => export const receiveReplicableItemsSuccess = ({ commit }, data) =>
commit(types.RECEIVE_DESIGNS_SUCCESS, data); commit(types.RECEIVE_REPLICABLE_ITEMS_SUCCESS, data);
export const receiveDesignsError = ({ commit }) => { export const receiveReplicableItemsError = ({ commit }) => {
createFlash(__('There was an error fetching the Designs')); createFlash(__('There was an error fetching the designs'));
commit(types.RECEIVE_DESIGNS_ERROR); commit(types.RECEIVE_REPLICABLE_ITEMS_ERROR);
}; };
export const fetchDesigns = ({ state, dispatch }) => { export const fetchDesigns = ({ state, dispatch }) => {
dispatch('requestDesigns'); dispatch('requestReplicableItems');
const statusFilterName = state.filterOptions[state.currentFilterIndex] const statusFilterName = state.filterOptions[state.currentFilterIndex]
? state.filterOptions[state.currentFilterIndex] ? state.filterOptions[state.currentFilterIndex]
...@@ -37,59 +37,60 @@ export const fetchDesigns = ({ state, dispatch }) => { ...@@ -37,59 +37,60 @@ export const fetchDesigns = ({ state, dispatch }) => {
const paginationInformation = parseIntPagination(normalizedHeaders); const paginationInformation = parseIntPagination(normalizedHeaders);
const camelCaseData = convertObjectPropsToCamelCase(res.data, { deep: true }); const camelCaseData = convertObjectPropsToCamelCase(res.data, { deep: true });
dispatch('receiveDesignsSuccess', { dispatch('receiveReplicableItemsSuccess', {
data: camelCaseData, data: camelCaseData,
perPage: paginationInformation.perPage, perPage: paginationInformation.perPage,
total: paginationInformation.total, total: paginationInformation.total,
}); });
}) })
.catch(() => { .catch(() => {
dispatch('receiveDesignsError'); dispatch('receiveReplicableItemsError');
}); });
}; };
// Initiate All Design Syncs // Initiate All Replicable Syncs
export const requestInitiateAllDesignSyncs = ({ commit }) => export const requestInitiateAllReplicableSyncs = ({ commit }) =>
commit(types.REQUEST_INITIATE_ALL_DESIGN_SYNCS); commit(types.REQUEST_INITIATE_ALL_REPLICABLE_SYNCS);
export const receiveInitiateAllDesignSyncsSuccess = ({ commit, dispatch }, { action }) => { export const receiveInitiateAllReplicableSyncsSuccess = ({ commit, dispatch }, { action }) => {
toast(__(`All designs are being scheduled for ${action}`)); toast(__(`All designs are being scheduled for ${action}`));
commit(types.RECEIVE_INITIATE_ALL_DESIGN_SYNCS_SUCCESS); commit(types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS);
dispatch('fetchDesigns'); dispatch('fetchReplicableItems');
}; };
export const receiveInitiateAllDesignSyncsError = ({ commit }) => { export const receiveInitiateAllReplicableSyncsError = ({ commit }) => {
createFlash(__(`There was an error syncing the Design Repositories.`)); createFlash(__('There was an error syncing the designs.'));
commit(types.RECEIVE_INITIATE_ALL_DESIGN_SYNCS_ERROR); commit(types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_ERROR);
}; };
export const initiateAllDesignSyncs = ({ dispatch }, action) => { export const initiateAllDesignSyncs = ({ dispatch }, action) => {
dispatch('requestInitiateAllDesignSyncs'); dispatch('requestInitiateAllReplicableSyncs');
Api.initiateAllGeoDesignSyncs(action) Api.initiateAllGeoDesignSyncs(action)
.then(() => dispatch('receiveInitiateAllDesignSyncsSuccess', { action })) .then(() => dispatch('receiveInitiateAllReplicableSyncsSuccess', { action }))
.catch(() => { .catch(() => {
dispatch('receiveInitiateAllDesignSyncsError'); dispatch('receiveInitiateAllReplicableSyncsError');
}); });
}; };
// Initiate Design Sync // Initiate Replicable Sync
export const requestInitiateDesignSync = ({ commit }) => commit(types.REQUEST_INITIATE_DESIGN_SYNC); export const requestInitiateReplicableSync = ({ commit }) =>
export const receiveInitiateDesignSyncSuccess = ({ commit, dispatch }, { name, action }) => { commit(types.REQUEST_INITIATE_REPLICABLE_SYNC);
export const receiveInitiateReplicableSyncSuccess = ({ commit, dispatch }, { name, action }) => {
toast(__(`${name} is scheduled for ${action}`)); toast(__(`${name} is scheduled for ${action}`));
commit(types.RECEIVE_INITIATE_DESIGN_SYNC_SUCCESS); commit(types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS);
dispatch('fetchDesigns'); dispatch('fetchReplicableItems');
}; };
export const receiveInitiateDesignSyncError = ({ commit }, { name }) => { export const receiveInitiateReplicableSyncError = ({ commit }, { name }) => {
createFlash(__(`There was an error syncing project '${name}'`)); createFlash(__(`There was an error syncing project '${name}'`));
commit(types.RECEIVE_INITIATE_DESIGN_SYNC_ERROR); commit(types.RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR);
}; };
export const initiateDesignSync = ({ dispatch }, { projectId, name, action }) => { export const initiateDesignSync = ({ dispatch }, { projectId, name, action }) => {
dispatch('requestInitiateDesignSync'); dispatch('requestInitiateReplicableSync');
Api.initiateGeoDesignSync({ projectId, action }) Api.initiateGeoDesignSync({ projectId, action })
.then(() => dispatch('receiveInitiateDesignSyncSuccess', { name, action })) .then(() => dispatch('receiveInitiateReplicableSyncSuccess', { name, action }))
.catch(() => { .catch(() => {
dispatch('receiveInitiateDesignSyncError', { name }); dispatch('receiveInitiateReplicableSyncError', { name });
}); });
}; };
......
...@@ -2,15 +2,16 @@ export const SET_FILTER = 'SET_FILTER'; ...@@ -2,15 +2,16 @@ export const SET_FILTER = 'SET_FILTER';
export const SET_SEARCH = 'SET_SEARCH'; export const SET_SEARCH = 'SET_SEARCH';
export const SET_PAGE = 'SET_PAGE'; export const SET_PAGE = 'SET_PAGE';
export const REQUEST_DESIGNS = 'REQUEST_DESIGNS'; export const REQUEST_REPLICABLE_ITEMS = 'REQUEST_REPLICABLE_ITEMS';
export const RECEIVE_DESIGNS_SUCCESS = 'RECEIVE_DESIGNS_SUCCESS'; export const RECEIVE_REPLICABLE_ITEMS_SUCCESS = 'RECEIVE_REPLICABLE_ITEMS_SUCCESS';
export const RECEIVE_DESIGNS_ERROR = 'RECEIVE_DESIGNS_ERROR'; export const RECEIVE_REPLICABLE_ITEMS_ERROR = 'RECEIVE_REPLICABLE_ITEMS_ERROR';
export const REQUEST_INITIATE_ALL_DESIGN_SYNCS = 'REQUEST_INITIATE_ALL_DESIGN_SYNCS'; export const REQUEST_INITIATE_ALL_REPLICABLE_SYNCS = 'REQUEST_INITIATE_ALL_REPLICABLE_SYNCS';
export const RECEIVE_INITIATE_ALL_DESIGN_SYNCS_SUCCESS = export const RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS =
'RECEIVE_INITIATE_ALL_DESIGN_SYNCS_SUCCESS'; 'RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS';
export const RECEIVE_INITIATE_ALL_DESIGN_SYNCS_ERROR = 'RECEIVE_INITIATE_ALL_DESIGN_SYNCS_ERROR'; export const RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_ERROR =
'RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_ERROR';
export const REQUEST_INITIATE_DESIGN_SYNC = 'REQUEST_INITIATE_DESIGN_SYNC'; export const REQUEST_INITIATE_REPLICABLE_SYNC = 'REQUEST_INITIATE_REPLICABLE_SYNC';
export const RECEIVE_INITIATE_DESIGN_SYNC_SUCCESS = 'RECEIVE_INITIATE_DESIGN_SYNC_SUCCESS'; export const RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS = 'RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS';
export const RECEIVE_INITIATE_DESIGN_SYNC_ERROR = 'RECEIVE_INITIATE_DESIGN_SYNC_ERROR'; export const RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR = 'RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR';
...@@ -12,37 +12,37 @@ export default { ...@@ -12,37 +12,37 @@ export default {
[types.SET_PAGE](state, page) { [types.SET_PAGE](state, page) {
state.currentPage = page; state.currentPage = page;
}, },
[types.REQUEST_DESIGNS](state) { [types.REQUEST_REPLICABLE_ITEMS](state) {
state.isLoading = true; state.isLoading = true;
}, },
[types.RECEIVE_DESIGNS_SUCCESS](state, { data, perPage, total }) { [types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, { data, perPage, total }) {
state.isLoading = false; state.isLoading = false;
state.designs = data; state.designs = data;
state.pageSize = perPage; state.pageSize = perPage;
state.totalDesigns = total; state.totalDesigns = total;
}, },
[types.RECEIVE_DESIGNS_ERROR](state) { [types.RECEIVE_REPLICABLE_ITEMS_ERROR](state) {
state.isLoading = false; state.isLoading = false;
state.designs = []; state.designs = [];
state.pageSize = 0; state.pageSize = 0;
state.totalDesigns = 0; state.totalDesigns = 0;
}, },
[types.REQUEST_INITIATE_ALL_DESIGN_SYNCS](state) { [types.REQUEST_INITIATE_ALL_REPLICABLE_SYNCS](state) {
state.isLoading = true; state.isLoading = true;
}, },
[types.RECEIVE_INITIATE_ALL_DESIGN_SYNCS_SUCCESS](state) { [types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS](state) {
state.isLoading = false; state.isLoading = false;
}, },
[types.RECEIVE_INITIATE_ALL_DESIGN_SYNCS_ERROR](state) { [types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_ERROR](state) {
state.isLoading = false; state.isLoading = false;
}, },
[types.REQUEST_INITIATE_DESIGN_SYNC](state) { [types.REQUEST_INITIATE_REPLICABLE_SYNC](state) {
state.isLoading = true; state.isLoading = true;
}, },
[types.RECEIVE_INITIATE_DESIGN_SYNC_SUCCESS](state) { [types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS](state) {
state.isLoading = false; state.isLoading = false;
}, },
[types.RECEIVE_INITIATE_DESIGN_SYNC_ERROR](state) { [types.RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR](state) {
state.isLoading = false; state.isLoading = false;
}, },
}; };
...@@ -29,32 +29,39 @@ describe('GeoDesigns Store Actions', () => { ...@@ -29,32 +29,39 @@ describe('GeoDesigns Store Actions', () => {
mock.restore(); mock.restore();
}); });
describe('requestDesigns', () => { describe('requestReplicableItems', () => {
it('should commit mutation REQUEST_DESIGNS', done => { it('should commit mutation REQUEST_REPLICABLE_ITEMS', done => {
testAction(actions.requestDesigns, null, state, [{ type: types.REQUEST_DESIGNS }], [], done); testAction(
actions.requestReplicableItems,
null,
state,
[{ type: types.REQUEST_REPLICABLE_ITEMS }],
[],
done,
);
}); });
}); });
describe('receiveDesignsSuccess', () => { describe('receiveReplicableItemsSuccess', () => {
it('should commit mutation RECEIVE_DESIGNS_SUCCESS', done => { it('should commit mutation RECEIVE_REPLICABLE_ITEMS_SUCCESS', done => {
testAction( testAction(
actions.receiveDesignsSuccess, actions.receiveReplicableItemsSuccess,
MOCK_BASIC_FETCH_DATA_MAP, MOCK_BASIC_FETCH_DATA_MAP,
state, state,
[{ type: types.RECEIVE_DESIGNS_SUCCESS, payload: MOCK_BASIC_FETCH_DATA_MAP }], [{ type: types.RECEIVE_REPLICABLE_ITEMS_SUCCESS, payload: MOCK_BASIC_FETCH_DATA_MAP }],
[], [],
done, done,
); );
}); });
}); });
describe('receiveDesignsError', () => { describe('receiveReplicableItemsError', () => {
it('should commit mutation RECEIVE_DESIGNS_ERROR', () => { it('should commit mutation RECEIVE_REPLICABLE_ITEMS_ERROR', () => {
testAction( testAction(
actions.receiveDesignsError, actions.receiveReplicableItemsError,
null, null,
state, state,
[{ type: types.RECEIVE_DESIGNS_ERROR }], [{ type: types.RECEIVE_REPLICABLE_ITEMS_ERROR }],
[], [],
() => { () => {
expect(flash).toHaveBeenCalledTimes(1); expect(flash).toHaveBeenCalledTimes(1);
...@@ -79,8 +86,8 @@ describe('GeoDesigns Store Actions', () => { ...@@ -79,8 +86,8 @@ describe('GeoDesigns Store Actions', () => {
state, state,
[], [],
[ [
{ type: 'requestDesigns' }, { type: 'requestReplicableItems' },
{ type: 'receiveDesignsSuccess', payload: MOCK_BASIC_FETCH_DATA_MAP }, { type: 'receiveReplicableItemsSuccess', payload: MOCK_BASIC_FETCH_DATA_MAP },
], ],
done, done,
); );
...@@ -98,7 +105,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -98,7 +105,7 @@ describe('GeoDesigns Store Actions', () => {
{}, {},
state, state,
[], [],
[{ type: 'requestDesigns' }, { type: 'receiveDesignsError' }], [{ type: 'requestReplicableItems' }, { type: 'receiveReplicableItemsError' }],
done, done,
); );
}); });
...@@ -130,8 +137,8 @@ describe('GeoDesigns Store Actions', () => { ...@@ -130,8 +137,8 @@ describe('GeoDesigns Store Actions', () => {
state, state,
[], [],
[ [
{ type: 'requestDesigns' }, { type: 'requestReplicableItems' },
{ type: 'receiveDesignsSuccess', payload: MOCK_BASIC_FETCH_DATA_MAP }, { type: 'receiveReplicableItemsSuccess', payload: MOCK_BASIC_FETCH_DATA_MAP },
], ],
fetchDesignsCall, fetchDesignsCall,
); );
...@@ -161,8 +168,8 @@ describe('GeoDesigns Store Actions', () => { ...@@ -161,8 +168,8 @@ describe('GeoDesigns Store Actions', () => {
state, state,
[], [],
[ [
{ type: 'requestDesigns' }, { type: 'requestReplicableItems' },
{ type: 'receiveDesignsSuccess', payload: MOCK_BASIC_FETCH_DATA_MAP }, { type: 'receiveReplicableItemsSuccess', payload: MOCK_BASIC_FETCH_DATA_MAP },
], ],
fetchDesignsCall, fetchDesignsCall,
); );
...@@ -170,27 +177,27 @@ describe('GeoDesigns Store Actions', () => { ...@@ -170,27 +177,27 @@ describe('GeoDesigns Store Actions', () => {
}); });
}); });
describe('requestInitiateAllDesignSyncs', () => { describe('requestInitiateAllReplicableSyncs', () => {
it('should commit mutation REQUEST_INITIATE_ALL_DESIGN_SYNCS', done => { it('should commit mutation REQUEST_INITIATE_ALL_REPLICABLE_SYNCS', done => {
testAction( testAction(
actions.requestInitiateAllDesignSyncs, actions.requestInitiateAllReplicableSyncs,
null, null,
state, state,
[{ type: types.REQUEST_INITIATE_ALL_DESIGN_SYNCS }], [{ type: types.REQUEST_INITIATE_ALL_REPLICABLE_SYNCS }],
[], [],
done, done,
); );
}); });
}); });
describe('receiveInitiateAllDesignSyncsSuccess', () => { describe('receiveInitiateAllReplicableSyncsSuccess', () => {
it('should commit mutation RECEIVE_INITIATE_ALL_DESIGN_SYNCS_SUCCESS and call fetchDesigns and toast', () => { it('should commit mutation RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS and call fetchReplicableItems and toast', () => {
testAction( testAction(
actions.receiveInitiateAllDesignSyncsSuccess, actions.receiveInitiateAllReplicableSyncsSuccess,
{ action: ACTION_TYPES.RESYNC }, { action: ACTION_TYPES.RESYNC },
state, state,
[{ type: types.RECEIVE_INITIATE_ALL_DESIGN_SYNCS_SUCCESS }], [{ type: types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS }],
[{ type: 'fetchDesigns' }], [{ type: 'fetchReplicableItems' }],
() => { () => {
expect(toast).toHaveBeenCalledTimes(1); expect(toast).toHaveBeenCalledTimes(1);
toast.mockClear(); toast.mockClear();
...@@ -199,13 +206,13 @@ describe('GeoDesigns Store Actions', () => { ...@@ -199,13 +206,13 @@ describe('GeoDesigns Store Actions', () => {
}); });
}); });
describe('receiveInitiateAllDesignSyncsError', () => { describe('receiveInitiateAllReplicableSyncsError', () => {
it('should commit mutation RECEIVE_INITIATE_ALL_DESIGN_SYNCS_ERROR', () => { it('should commit mutation RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_ERROR', () => {
testAction( testAction(
actions.receiveInitiateAllDesignSyncsError, actions.receiveInitiateAllReplicableSyncsError,
ACTION_TYPES.RESYNC, ACTION_TYPES.RESYNC,
state, state,
[{ type: types.RECEIVE_INITIATE_ALL_DESIGN_SYNCS_ERROR }], [{ type: types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_ERROR }],
[], [],
() => { () => {
expect(flash).toHaveBeenCalledTimes(1); expect(flash).toHaveBeenCalledTimes(1);
...@@ -232,8 +239,8 @@ describe('GeoDesigns Store Actions', () => { ...@@ -232,8 +239,8 @@ describe('GeoDesigns Store Actions', () => {
state, state,
[], [],
[ [
{ type: 'requestInitiateAllDesignSyncs' }, { type: 'requestInitiateAllReplicableSyncs' },
{ type: 'receiveInitiateAllDesignSyncsSuccess', payload: { action } }, { type: 'receiveInitiateAllReplicableSyncsSuccess', payload: { action } },
], ],
done, done,
); );
...@@ -254,8 +261,8 @@ describe('GeoDesigns Store Actions', () => { ...@@ -254,8 +261,8 @@ describe('GeoDesigns Store Actions', () => {
state, state,
[], [],
[ [
{ type: 'requestInitiateAllDesignSyncs' }, { type: 'requestInitiateAllReplicableSyncs' },
{ type: 'receiveInitiateAllDesignSyncsError' }, { type: 'receiveInitiateAllReplicableSyncsError' },
], ],
done, done,
); );
...@@ -263,27 +270,27 @@ describe('GeoDesigns Store Actions', () => { ...@@ -263,27 +270,27 @@ describe('GeoDesigns Store Actions', () => {
}); });
}); });
describe('requestInitiateDesignSync', () => { describe('requestInitiateReplicableSync', () => {
it('should commit mutation REQUEST_INITIATE_DESIGN_SYNC', done => { it('should commit mutation REQUEST_INITIATE_REPLICABLE_SYNC', done => {
testAction( testAction(
actions.requestInitiateDesignSync, actions.requestInitiateReplicableSync,
null, null,
state, state,
[{ type: types.REQUEST_INITIATE_DESIGN_SYNC }], [{ type: types.REQUEST_INITIATE_REPLICABLE_SYNC }],
[], [],
done, done,
); );
}); });
}); });
describe('receiveInitiateDesignSyncSuccess', () => { describe('receiveInitiateReplicableSyncSuccess', () => {
it('should commit mutation RECEIVE_INITIATE_DESIGN_SYNC_SUCCESS and call fetchDesigns and toast', () => { it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS and call fetchReplicableItems and toast', () => {
testAction( testAction(
actions.receiveInitiateDesignSyncSuccess, actions.receiveInitiateReplicableSyncSuccess,
{ action: ACTION_TYPES.RESYNC, projectName: 'test' }, { action: ACTION_TYPES.RESYNC, projectName: 'test' },
state, state,
[{ type: types.RECEIVE_INITIATE_DESIGN_SYNC_SUCCESS }], [{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS }],
[{ type: 'fetchDesigns' }], [{ type: 'fetchReplicableItems' }],
() => { () => {
expect(toast).toHaveBeenCalledTimes(1); expect(toast).toHaveBeenCalledTimes(1);
toast.mockClear(); toast.mockClear();
...@@ -292,13 +299,13 @@ describe('GeoDesigns Store Actions', () => { ...@@ -292,13 +299,13 @@ describe('GeoDesigns Store Actions', () => {
}); });
}); });
describe('receiveInitiateDesignSyncError', () => { describe('receiveInitiateReplicableSyncError', () => {
it('should commit mutation RECEIVE_INITIATE_DESIGN_SYNC_ERROR', () => { it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR', () => {
testAction( testAction(
actions.receiveInitiateDesignSyncError, actions.receiveInitiateReplicableSyncError,
{ action: ACTION_TYPES.RESYNC, projectId: 1, projectName: 'test' }, { action: ACTION_TYPES.RESYNC, projectId: 1, projectName: 'test' },
state, state,
[{ type: types.RECEIVE_INITIATE_DESIGN_SYNC_ERROR }], [{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR }],
[], [],
() => { () => {
expect(flash).toHaveBeenCalledTimes(1); expect(flash).toHaveBeenCalledTimes(1);
...@@ -329,8 +336,8 @@ describe('GeoDesigns Store Actions', () => { ...@@ -329,8 +336,8 @@ describe('GeoDesigns Store Actions', () => {
state, state,
[], [],
[ [
{ type: 'requestInitiateDesignSync' }, { type: 'requestInitiateReplicableSync' },
{ type: 'receiveInitiateDesignSyncSuccess', payload: { name, action } }, { type: 'receiveInitiateReplicableSyncSuccess', payload: { name, action } },
], ],
done, done,
); );
...@@ -353,9 +360,9 @@ describe('GeoDesigns Store Actions', () => { ...@@ -353,9 +360,9 @@ describe('GeoDesigns Store Actions', () => {
state, state,
[], [],
[ [
{ type: 'requestInitiateDesignSync' }, { type: 'requestInitiateReplicableSync' },
{ {
type: 'receiveInitiateDesignSyncError', type: 'receiveInitiateReplicableSyncError',
payload: { name: 'test' }, payload: { name: 'test' },
}, },
], ],
......
...@@ -3,7 +3,7 @@ import createState from 'ee/geo_designs/store/state'; ...@@ -3,7 +3,7 @@ import createState from 'ee/geo_designs/store/state';
import * as types from 'ee/geo_designs/store/mutation_types'; import * as types from 'ee/geo_designs/store/mutation_types';
import { MOCK_BASIC_FETCH_DATA_MAP } from '../mock_data'; import { MOCK_BASIC_FETCH_DATA_MAP } from '../mock_data';
describe('GeoDesigns Store Mutations', () => { describe('GeoReplicable Store Mutations', () => {
let state; let state;
beforeEach(() => { beforeEach(() => {
state = createState(); state = createState();
...@@ -55,14 +55,14 @@ describe('GeoDesigns Store Mutations', () => { ...@@ -55,14 +55,14 @@ describe('GeoDesigns Store Mutations', () => {
}); });
}); });
describe('REQUEST_DESIGNS', () => { describe('REQUEST_REPLICABLE_ITEMS', () => {
it('sets isLoading to true', () => { it('sets isLoading to true', () => {
mutations[types.REQUEST_DESIGNS](state); mutations[types.REQUEST_REPLICABLE_ITEMS](state);
expect(state.isLoading).toEqual(true); expect(state.isLoading).toEqual(true);
}); });
}); });
describe('RECEIVE_DESIGNS_SUCCESS', () => { describe('RECEIVE_REPLICABLE_ITEMS_SUCCESS', () => {
let mockData = {}; let mockData = {};
beforeEach(() => { beforeEach(() => {
...@@ -72,23 +72,23 @@ describe('GeoDesigns Store Mutations', () => { ...@@ -72,23 +72,23 @@ describe('GeoDesigns Store Mutations', () => {
it('sets isLoading to false', () => { it('sets isLoading to false', () => {
state.isLoading = true; state.isLoading = true;
mutations[types.RECEIVE_DESIGNS_SUCCESS](state, mockData); mutations[types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, mockData);
expect(state.isLoading).toEqual(false); expect(state.isLoading).toEqual(false);
}); });
it('sets designs array with design data', () => { it('sets designs array with data', () => {
mutations[types.RECEIVE_DESIGNS_SUCCESS](state, mockData); mutations[types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, mockData);
expect(state.designs).toBe(mockData.data); expect(state.designs).toBe(mockData.data);
}); });
it('sets pageSize and totalDesigns', () => { it('sets pageSize and totalDesigns', () => {
mutations[types.RECEIVE_DESIGNS_SUCCESS](state, mockData); mutations[types.RECEIVE_REPLICABLE_ITEMS_SUCCESS](state, mockData);
expect(state.pageSize).toEqual(mockData.perPage); expect(state.pageSize).toEqual(mockData.perPage);
expect(state.totalDesigns).toEqual(mockData.total); expect(state.totalDesigns).toEqual(mockData.total);
}); });
}); });
describe('RECEIVE_DESIGNS_ERROR', () => { describe('RECEIVE_REPLICABLE_ITEMS_ERROR', () => {
let mockData = {}; let mockData = {};
beforeEach(() => { beforeEach(() => {
...@@ -98,14 +98,14 @@ describe('GeoDesigns Store Mutations', () => { ...@@ -98,14 +98,14 @@ describe('GeoDesigns Store Mutations', () => {
it('sets isLoading to false', () => { it('sets isLoading to false', () => {
state.isLoading = true; state.isLoading = true;
mutations[types.RECEIVE_DESIGNS_ERROR](state); mutations[types.RECEIVE_REPLICABLE_ITEMS_ERROR](state);
expect(state.isLoading).toEqual(false); expect(state.isLoading).toEqual(false);
}); });
it('resets designs array', () => { it('resets designs array', () => {
state.designs = mockData.data; state.designs = mockData.data;
mutations[types.RECEIVE_DESIGNS_ERROR](state); mutations[types.RECEIVE_REPLICABLE_ITEMS_ERROR](state);
expect(state.designs).toEqual([]); expect(state.designs).toEqual([]);
}); });
...@@ -113,20 +113,20 @@ describe('GeoDesigns Store Mutations', () => { ...@@ -113,20 +113,20 @@ describe('GeoDesigns Store Mutations', () => {
state.pageSize = mockData.perPage; state.pageSize = mockData.perPage;
state.totalDesigns = mockData.total; state.totalDesigns = mockData.total;
mutations[types.RECEIVE_DESIGNS_ERROR](state); mutations[types.RECEIVE_REPLICABLE_ITEMS_ERROR](state);
expect(state.pageSize).toEqual(0); expect(state.pageSize).toEqual(0);
expect(state.totalDesigns).toEqual(0); expect(state.totalDesigns).toEqual(0);
}); });
}); });
describe.each` describe.each`
mutation | loadingBefore | loadingAfter mutation | loadingBefore | loadingAfter
${types.REQUEST_INITIATE_ALL_DESIGN_SYNCS} | ${false} | ${true} ${types.REQUEST_INITIATE_ALL_REPLICABLE_SYNCS} | ${false} | ${true}
${types.RECEIVE_INITIATE_ALL_DESIGN_SYNCS_SUCCESS} | ${true} | ${false} ${types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS} | ${true} | ${false}
${types.RECEIVE_INITIATE_ALL_DESIGN_SYNCS_ERROR} | ${true} | ${false} ${types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_ERROR} | ${true} | ${false}
${types.REQUEST_INITIATE_DESIGN_SYNC} | ${false} | ${true} ${types.REQUEST_INITIATE_REPLICABLE_SYNC} | ${false} | ${true}
${types.RECEIVE_INITIATE_DESIGN_SYNC_SUCCESS} | ${true} | ${false} ${types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS} | ${true} | ${false}
${types.RECEIVE_INITIATE_DESIGN_SYNC_ERROR} | ${true} | ${false} ${types.RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR} | ${true} | ${false}
`(`Sync Mutations: `, ({ mutation, loadingBefore, loadingAfter }) => { `(`Sync Mutations: `, ({ mutation, loadingBefore, loadingAfter }) => {
describe(`${mutation}`, () => { describe(`${mutation}`, () => {
it(`sets isLoading to ${loadingAfter}`, () => { it(`sets isLoading to ${loadingAfter}`, () => {
......
...@@ -19914,10 +19914,10 @@ msgstr "" ...@@ -19914,10 +19914,10 @@ msgstr ""
msgid "There was an error fetching median data for stages" msgid "There was an error fetching median data for stages"
msgstr "" msgstr ""
msgid "There was an error fetching the Designs" msgid "There was an error fetching the Node's Groups"
msgstr "" msgstr ""
msgid "There was an error fetching the Node's Groups" msgid "There was an error fetching the designs"
msgstr "" msgstr ""
msgid "There was an error fetching the environments information." msgid "There was an error fetching the environments information."
...@@ -19962,7 +19962,7 @@ msgstr "" ...@@ -19962,7 +19962,7 @@ msgstr ""
msgid "There was an error subscribing to this label." msgid "There was an error subscribing to this label."
msgstr "" msgstr ""
msgid "There was an error syncing the Design Repositories." msgid "There was an error syncing the designs."
msgstr "" msgstr ""
msgid "There was an error trying to validate your query" msgid "There was an error trying to validate your query"
......
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