* feat: group configurations - index page * feat: [AXIMST-63] Index group configurations page * fix: resolve discussions * fix: resolve second round discussions * feat: group configurations - content group actions * feat: [AXIMST-75, AXIMST-69, AXIMST-81] Content group actions * fix: resolve conversations * feat: group configurations - sidebar * feat: [AXIMST-87] group-configuration page sidebar * refactor: [AXIMST-87] add changes after review * refactor: [AXIMST-87] add changes after review * refactor: [AXIMST-87] add changes ater review --------- Co-authored-by: Kyrylo Hudym-Levkovych <kyr.hudym@kyrs-MacBook-Pro.local> * fix: group configurations - the page reloads after the user saves changes * feat: group configurations - experiment groups * feat: [AXIMST-93, 99, 105] Group configuration - Experiment Groups * fix: [AXIMST-518, 537] Group configuration - resolve bugs * fix: review discussions * fix: revert classname case * fix: group configurations - resolve discussions fix: [AXIMST-714] icon is aligned with text (#210) * fix: add hook tests * fix: add thunk tests * fix: add slice tests * chore: group configurations - messages * fix: group configurations - remove delete in edit mode --------- Co-authored-by: Kyr <40792129+khudym@users.noreply.github.com> Co-authored-by: Kyrylo Hudym-Levkovych <kyr.hudym@kyrs-MacBook-Pro.local> Co-authored-by: monteri <lansevermore>
79 lines
2.8 KiB
JavaScript
79 lines
2.8 KiB
JavaScript
import {
|
|
reducer,
|
|
fetchGroupConfigurations,
|
|
updateGroupConfigurationsSuccess,
|
|
deleteGroupConfigurationsSuccess,
|
|
updateExperimentConfigurationSuccess,
|
|
deleteExperimentConfigurationSuccess,
|
|
} from './slice';
|
|
import { RequestStatus } from '../../data/constants';
|
|
|
|
describe('groupConfigurations slice', () => {
|
|
let initialState;
|
|
|
|
beforeEach(() => {
|
|
initialState = {
|
|
savingStatus: '',
|
|
loadingStatus: RequestStatus.IN_PROGRESS,
|
|
groupConfigurations: {
|
|
allGroupConfigurations: [{ id: 1, name: 'Group 1', groups: [{ id: 1, name: 'inner group' }] }],
|
|
experimentGroupConfigurations: [],
|
|
},
|
|
};
|
|
});
|
|
|
|
it('should update group configurations with fetchGroupConfigurations', () => {
|
|
const payload = {
|
|
groupConfigurations: {
|
|
allGroupConfigurations: [{ id: 2, name: 'Group 2' }],
|
|
experimentGroupConfigurations: [],
|
|
},
|
|
};
|
|
|
|
const newState = reducer(initialState, fetchGroupConfigurations(payload));
|
|
|
|
expect(newState.groupConfigurations).toEqual(payload.groupConfigurations);
|
|
});
|
|
|
|
it('should update an existing group configuration with updateGroupConfigurationsSuccess', () => {
|
|
const payload = { data: { id: 1, name: 'Updated Group' } };
|
|
|
|
const newState = reducer(initialState, updateGroupConfigurationsSuccess(payload));
|
|
|
|
expect(newState.groupConfigurations.allGroupConfigurations[0]).toEqual(payload.data);
|
|
});
|
|
|
|
it('should delete a group configuration with deleteGroupConfigurationsSuccess', () => {
|
|
const payload = { parentGroupId: 1, groupId: 1 };
|
|
|
|
const newState = reducer(initialState, deleteGroupConfigurationsSuccess(payload));
|
|
|
|
expect(newState.groupConfigurations.allGroupConfigurations[0].groups.length).toEqual(0);
|
|
});
|
|
|
|
it('should update experiment configuration with updateExperimentConfigurationSuccess', () => {
|
|
const payload = { configuration: { id: 1, name: 'Experiment Config' } };
|
|
|
|
const newState = reducer(initialState, updateExperimentConfigurationSuccess(payload));
|
|
|
|
expect(newState.groupConfigurations.experimentGroupConfigurations.length).toEqual(1);
|
|
expect(newState.groupConfigurations.experimentGroupConfigurations[0]).toEqual(payload.configuration);
|
|
});
|
|
|
|
it('should delete an experiment configuration with deleteExperimentConfigurationSuccess', () => {
|
|
const initialStateWithExperiment = {
|
|
savingStatus: '',
|
|
loadingStatus: RequestStatus.IN_PROGRESS,
|
|
groupConfigurations: {
|
|
allGroupConfigurations: [],
|
|
experimentGroupConfigurations: [{ id: 1, name: 'Experiment Config' }],
|
|
},
|
|
};
|
|
const payload = { configurationId: 1 };
|
|
|
|
const newState = reducer(initialStateWithExperiment, deleteExperimentConfigurationSuccess(payload));
|
|
|
|
expect(newState.groupConfigurations.experimentGroupConfigurations.length).toEqual(0);
|
|
});
|
|
});
|