Refactor: Inbox store, remove inboxes from sidebar (#387)
* Refactor: Inbox store, remove inboxes from sidebar * Add a new page for inbox settings * Show inboxes on sidebar * Add inbox_members API * Disable similar-code check * Fix codeclimate scss issues * Add widget_color update API and actions * Add specs for inbox store * Fix Facebook auth flow * Fix agent loading, inbox name
This commit is contained in:
24
app/javascript/dashboard/store/modules/inboxMembers.js
Normal file
24
app/javascript/dashboard/store/modules/inboxMembers.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import InboxMembersAPI from '../../api/inboxMembers';
|
||||
|
||||
const state = {};
|
||||
|
||||
const getters = {};
|
||||
|
||||
const actions = {
|
||||
get(_, { inboxId }) {
|
||||
return InboxMembersAPI.show(inboxId);
|
||||
},
|
||||
create(_, { inboxId, agentList }) {
|
||||
return InboxMembersAPI.create({ inboxId, agentList });
|
||||
},
|
||||
};
|
||||
|
||||
const mutations = {};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations,
|
||||
};
|
||||
109
app/javascript/dashboard/store/modules/inboxes.js
Normal file
109
app/javascript/dashboard/store/modules/inboxes.js
Normal file
@@ -0,0 +1,109 @@
|
||||
import * as MutationHelpers from 'shared/helpers/vuex/mutationHelpers';
|
||||
import * as types from '../mutation-types';
|
||||
import InboxesAPI from '../../api/inboxes';
|
||||
import WebChannel from '../../api/channel/webChannel';
|
||||
import FBChannel from '../../api/channel/fbChannel';
|
||||
|
||||
export const state = {
|
||||
records: [],
|
||||
uiFlags: {
|
||||
isFetching: false,
|
||||
isFetchingItem: false,
|
||||
isCreating: false,
|
||||
isUpdating: false,
|
||||
isDeleting: false,
|
||||
},
|
||||
};
|
||||
|
||||
export const getters = {
|
||||
getInboxes($state) {
|
||||
return $state.records;
|
||||
},
|
||||
getInbox: $state => inboxId => {
|
||||
const [inbox] = $state.records.filter(
|
||||
record => record.id === Number(inboxId)
|
||||
);
|
||||
return inbox || {};
|
||||
},
|
||||
getUIFlags($state) {
|
||||
return $state.uiFlags;
|
||||
},
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
get: async ({ commit }) => {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isFetching: true });
|
||||
try {
|
||||
const response = await InboxesAPI.get();
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isFetching: false });
|
||||
commit(types.default.SET_INBOXES, response.data.payload);
|
||||
} catch (error) {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isFetching: false });
|
||||
}
|
||||
},
|
||||
createWebsiteChannel: async ({ commit }, params) => {
|
||||
try {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isCreating: true });
|
||||
const response = await WebChannel.create(params);
|
||||
commit(types.default.ADD_INBOXES, response.data);
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isCreating: false });
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isCreating: false });
|
||||
throw new Error(error);
|
||||
}
|
||||
},
|
||||
createFBChannel: async ({ commit }, params) => {
|
||||
try {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isCreating: true });
|
||||
const response = await FBChannel.create(params);
|
||||
commit(types.default.ADD_INBOXES, response.data);
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isCreating: false });
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isCreating: false });
|
||||
throw new Error(error);
|
||||
}
|
||||
},
|
||||
updateWebsiteChannel: async ({ commit }, { id, ...inboxParams }) => {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isUpdating: true });
|
||||
try {
|
||||
const response = await WebChannel.update(id, inboxParams);
|
||||
commit(types.default.EDIT_INBOXES, response.data);
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isUpdating: false });
|
||||
} catch (error) {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isUpdating: false });
|
||||
throw new Error(error);
|
||||
}
|
||||
},
|
||||
delete: async ({ commit }, inboxId) => {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isDeleting: true });
|
||||
try {
|
||||
await InboxesAPI.delete(inboxId);
|
||||
commit(types.default.DELETE_INBOXES, inboxId);
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isDeleting: false });
|
||||
} catch (error) {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isDeleting: false });
|
||||
throw new Error(error);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const mutations = {
|
||||
[types.default.SET_INBOXES_UI_FLAG]($state, uiFlag) {
|
||||
$state.uiFlags = { ...$state.uiFlags, ...uiFlag };
|
||||
},
|
||||
[types.default.SET_INBOXES]: MutationHelpers.set,
|
||||
[types.default.SET_INBOXES_ITEM]: MutationHelpers.setSingleRecord,
|
||||
[types.default.ADD_INBOXES]: MutationHelpers.create,
|
||||
[types.default.EDIT_INBOXES]: MutationHelpers.update,
|
||||
[types.default.DELETE_INBOXES]: MutationHelpers.destroy,
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations,
|
||||
};
|
||||
@@ -1,195 +0,0 @@
|
||||
/* eslint no-console: 0 */
|
||||
/* eslint-env browser */
|
||||
/* eslint no-param-reassign: 0 */
|
||||
/* global bus */
|
||||
// import * as types from '../mutation-types';
|
||||
import defaultState from '../../i18n/default-sidebar';
|
||||
import * as types from '../mutation-types';
|
||||
import Account from '../../api/account';
|
||||
import ChannelApi from '../../api/channels';
|
||||
import { frontendURL } from '../../helper/URLHelper';
|
||||
import WebChannel from '../../api/channel/webChannel';
|
||||
|
||||
const state = defaultState;
|
||||
// inboxes fetch flag
|
||||
state.inboxesLoading = false;
|
||||
|
||||
const getters = {
|
||||
getMenuItems(_state) {
|
||||
return _state.menuGroup;
|
||||
},
|
||||
getInboxesList(_state) {
|
||||
return _state.menuGroup.common.menuItems.inbox.children;
|
||||
},
|
||||
getInboxLoadingStatus(_state) {
|
||||
return _state.inboxesLoading;
|
||||
},
|
||||
};
|
||||
|
||||
const actions = {
|
||||
// Fetch Labels
|
||||
fetchLabels({ commit }) {
|
||||
Account.getLabels()
|
||||
.then(response => {
|
||||
commit(types.default.SET_LABELS, response.data);
|
||||
})
|
||||
.catch();
|
||||
},
|
||||
// Fetch Inboxes
|
||||
fetchInboxes({ commit }) {
|
||||
commit(types.default.INBOXES_LOADING, true);
|
||||
return new Promise((resolve, reject) => {
|
||||
Account.getInboxes()
|
||||
.then(response => {
|
||||
commit(types.default.INBOXES_LOADING, false);
|
||||
commit(types.default.SET_INBOXES, response.data);
|
||||
resolve();
|
||||
})
|
||||
.catch(error => {
|
||||
commit(types.default.INBOXES_LOADING, false);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
deleteInbox({ commit }, id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Account.deleteInbox(id)
|
||||
.then(response => {
|
||||
if (response.status === 200) {
|
||||
commit(types.default.DELETE_INBOX, id);
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
addWebsiteChannel: async ({ commit }, params) => {
|
||||
try {
|
||||
const response = await WebChannel.create(params);
|
||||
commit(types.default.SET_INBOX_ITEM, response);
|
||||
bus.$emit('new_website_channel', {
|
||||
inboxId: response.data.id,
|
||||
websiteToken: response.data.website_token,
|
||||
});
|
||||
} catch (error) {
|
||||
// Handle error
|
||||
}
|
||||
},
|
||||
addInboxItem({ commit }, { channel, params }) {
|
||||
const donePromise = new Promise(resolve => {
|
||||
ChannelApi.createChannel(channel, params)
|
||||
.then(response => {
|
||||
commit(types.default.SET_INBOX_ITEM, response);
|
||||
resolve(response);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
});
|
||||
return donePromise;
|
||||
},
|
||||
listInboxAgents(_, { inboxId }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Account.listInboxAgents(inboxId)
|
||||
.then(response => {
|
||||
if (response.status === 200) {
|
||||
resolve(response.data);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
updateInboxAgents(_, { inboxId, agentList }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Account.updateInboxAgents(inboxId, agentList)
|
||||
.then(response => {
|
||||
if (response.status === 200) {
|
||||
resolve(response.data);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
// Set Labels
|
||||
[types.default.SET_LABELS](_state, data) {
|
||||
let payload = data.data.payload.labels;
|
||||
payload = payload.map(item => ({
|
||||
label: item,
|
||||
toState: `/#/${item}`,
|
||||
}));
|
||||
// Identify menuItem to update
|
||||
// May have more than one object to update
|
||||
// Iterate it accordingly. Updating commmon sidebar now.
|
||||
const { menuItems } = _state.menuGroup.common;
|
||||
// Update children for key `label`
|
||||
menuItems.labels.children = payload;
|
||||
},
|
||||
|
||||
[types.default.INBOXES_LOADING](_state, flag) {
|
||||
_state.inboxesLoading = flag;
|
||||
},
|
||||
// Set Inboxes
|
||||
[types.default.SET_INBOXES](_state, data) {
|
||||
let { payload } = data.data;
|
||||
payload = payload.map(item => ({
|
||||
channel_id: item.id,
|
||||
label: item.name,
|
||||
toState: frontendURL(`inbox/${item.id}`),
|
||||
channelType: item.channel_type,
|
||||
avatarUrl: item.avatar_url,
|
||||
pageId: item.page_id,
|
||||
websiteToken: item.website_token,
|
||||
widgetColor: item.widget_color,
|
||||
}));
|
||||
// Identify menuItem to update
|
||||
// May have more than one object to update
|
||||
// Iterate it accordingly. Updating commmon sidebar now.
|
||||
const { menuItems } = _state.menuGroup.common;
|
||||
// Update children for key `inbox`
|
||||
menuItems.inbox.children = payload;
|
||||
},
|
||||
|
||||
[types.default.SET_INBOX_ITEM](_state, { data }) {
|
||||
const { menuItems } = _state.menuGroup.common;
|
||||
// Update children for key `inbox`
|
||||
menuItems.inbox.children.push({
|
||||
channel_id: data.id,
|
||||
label: data.name,
|
||||
toState: frontendURL(`inbox/${data.id}`),
|
||||
channelType: data.channel_type,
|
||||
avatarUrl: data.avatar_url === undefined ? null : data.avatar_url,
|
||||
pageId: data.page_id,
|
||||
websiteToken: data.website_token,
|
||||
widgetColor: data.widget_color,
|
||||
});
|
||||
},
|
||||
|
||||
[types.default.DELETE_INBOX](_state, id) {
|
||||
const { menuItems } = _state.menuGroup.common;
|
||||
let inboxList = menuItems.inbox.children;
|
||||
inboxList = inboxList.filter(inbox => inbox.channel_id !== id);
|
||||
menuItems.inbox.children = inboxList;
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations,
|
||||
};
|
||||
@@ -0,0 +1,116 @@
|
||||
import axios from 'axios';
|
||||
import { actions } from '../../inboxes';
|
||||
import * as types from '../../../mutation-types';
|
||||
import inboxList from './fixtures';
|
||||
|
||||
const commit = jest.fn();
|
||||
global.axios = axios;
|
||||
jest.mock('axios');
|
||||
|
||||
describe('#actions', () => {
|
||||
describe('#get', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
axios.get.mockResolvedValue({ data: { payload: inboxList } });
|
||||
await actions.get({ commit });
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isFetching: true }],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isFetching: false }],
|
||||
[types.default.SET_INBOXES, inboxList],
|
||||
]);
|
||||
});
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.get.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await actions.get({ commit });
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isFetching: true }],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isFetching: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#createWebsiteChannel', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
axios.post.mockResolvedValue({ data: inboxList[0] });
|
||||
await actions.createWebsiteChannel({ commit }, inboxList[0]);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isCreating: true }],
|
||||
[types.default.ADD_INBOXES, inboxList[0]],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isCreating: false }],
|
||||
]);
|
||||
});
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.post.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await expect(actions.createWebsiteChannel({ commit })).rejects.toThrow(
|
||||
Error
|
||||
);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isCreating: true }],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isCreating: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#createFBChannel', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
axios.post.mockResolvedValue({ data: inboxList[0] });
|
||||
await actions.createFBChannel({ commit }, inboxList[0]);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isCreating: true }],
|
||||
[types.default.ADD_INBOXES, inboxList[0]],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isCreating: false }],
|
||||
]);
|
||||
});
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.post.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await expect(actions.createFBChannel({ commit })).rejects.toThrow(Error);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isCreating: true }],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isCreating: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#updateWebsiteChannel', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
axios.patch.mockResolvedValue({ data: inboxList[0] });
|
||||
await actions.updateWebsiteChannel({ commit }, inboxList[0]);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdating: true }],
|
||||
[types.default.EDIT_INBOXES, inboxList[0]],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdating: false }],
|
||||
]);
|
||||
});
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.patch.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await expect(
|
||||
actions.updateWebsiteChannel({ commit }, inboxList[0])
|
||||
).rejects.toThrow(Error);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdating: true }],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdating: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#delete', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
axios.delete.mockResolvedValue({ data: inboxList[0] });
|
||||
await actions.delete({ commit }, inboxList[0].id);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isDeleting: true }],
|
||||
[types.default.DELETE_INBOXES, inboxList[0].id],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isDeleting: false }],
|
||||
]);
|
||||
});
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.delete.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await expect(actions.delete({ commit }, inboxList[0].id)).rejects.toThrow(
|
||||
Error
|
||||
);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isDeleting: true }],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isDeleting: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
export default [
|
||||
{
|
||||
id: 1,
|
||||
channel_id: 1,
|
||||
name: 'Test FacebookPage 1',
|
||||
channel_type: 'Channel::FacebookPage',
|
||||
avatar_url: 'random_image.png',
|
||||
page_id: '12345',
|
||||
widget_color: null,
|
||||
website_token: null,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
channel_id: 2,
|
||||
name: 'Test Widget 1',
|
||||
channel_type: 'Channel::WebWidget',
|
||||
avatar_url: null,
|
||||
page_id: null,
|
||||
widget_color: '#7B64FF',
|
||||
website_token: 'randomid123',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
channel_id: 3,
|
||||
name: 'Test Widget 2',
|
||||
channel_type: 'Channel::WebWidget',
|
||||
avatar_url: null,
|
||||
page_id: null,
|
||||
widget_color: '#68BC00',
|
||||
website_token: 'randomid124',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
channel_id: 4,
|
||||
name: 'Test Widget 3',
|
||||
channel_type: 'Channel::WebWidget',
|
||||
avatar_url: null,
|
||||
page_id: null,
|
||||
widget_color: '#68BC00',
|
||||
website_token: 'randomid125',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,46 @@
|
||||
import { getters } from '../../inboxes';
|
||||
import inboxList from './fixtures';
|
||||
|
||||
describe('#getters', () => {
|
||||
it('getInboxes', () => {
|
||||
const state = {
|
||||
records: inboxList,
|
||||
};
|
||||
expect(getters.getInboxes(state)).toEqual(inboxList);
|
||||
});
|
||||
|
||||
it('getInbox', () => {
|
||||
const state = {
|
||||
records: inboxList,
|
||||
};
|
||||
expect(getters.getInbox(state)(1)).toEqual({
|
||||
id: 1,
|
||||
channel_id: 1,
|
||||
name: 'Test FacebookPage 1',
|
||||
channel_type: 'Channel::FacebookPage',
|
||||
avatar_url: 'random_image.png',
|
||||
page_id: '12345',
|
||||
widget_color: null,
|
||||
website_token: null,
|
||||
});
|
||||
});
|
||||
|
||||
it('getUIFlags', () => {
|
||||
const state = {
|
||||
uiFlags: {
|
||||
isFetching: true,
|
||||
isFetchingItem: false,
|
||||
isCreating: false,
|
||||
isUpdating: false,
|
||||
isDeleting: false,
|
||||
},
|
||||
};
|
||||
expect(getters.getUIFlags(state)).toEqual({
|
||||
isFetching: true,
|
||||
isFetchingItem: false,
|
||||
isCreating: false,
|
||||
isUpdating: false,
|
||||
isDeleting: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,94 @@
|
||||
import * as types from '../../../mutation-types';
|
||||
import { mutations } from '../../inboxes';
|
||||
import inboxList from './fixtures';
|
||||
|
||||
describe('#mutations', () => {
|
||||
describe('#SET_INBOXES', () => {
|
||||
it('set inbox records', () => {
|
||||
const state = { records: [] };
|
||||
mutations[types.default.SET_INBOXES](state, inboxList);
|
||||
expect(state.records).toEqual(inboxList);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#SET_INBOXES_ITEM', () => {
|
||||
it('push inbox if inbox doesnot exist to the store', () => {
|
||||
const state = {
|
||||
records: [],
|
||||
};
|
||||
mutations[types.default.SET_INBOXES_ITEM](state, inboxList[0]);
|
||||
expect(state.records).toEqual([inboxList[0]]);
|
||||
});
|
||||
|
||||
it('update inbox if it exists to the store', () => {
|
||||
const state = {
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
channel_id: 1,
|
||||
name: 'Test FacebookPage',
|
||||
channel_type: 'Channel::FacebookPage',
|
||||
avatar_url: 'random_image1.png',
|
||||
page_id: '1235',
|
||||
widget_color: null,
|
||||
website_token: null,
|
||||
},
|
||||
],
|
||||
};
|
||||
mutations[types.default.SET_INBOXES_ITEM](state, inboxList[0]);
|
||||
expect(state.records).toEqual([inboxList[0]]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#ADD_INBOXES', () => {
|
||||
it('push new record in the inbox store', () => {
|
||||
const state = {
|
||||
records: [],
|
||||
};
|
||||
mutations[types.default.ADD_INBOXES](state, inboxList[0]);
|
||||
expect(state.records).toEqual([inboxList[0]]);
|
||||
});
|
||||
});
|
||||
describe('#EDIT_INBOXES', () => {
|
||||
it('update inbox in the store', () => {
|
||||
const state = {
|
||||
records: [
|
||||
{
|
||||
id: 1,
|
||||
channel_id: 1,
|
||||
name: 'Test FacebookPage',
|
||||
channel_type: 'Channel::FacebookPage',
|
||||
avatar_url: 'random_image1.png',
|
||||
page_id: '1235',
|
||||
widget_color: null,
|
||||
website_token: null,
|
||||
},
|
||||
],
|
||||
};
|
||||
mutations[types.default.EDIT_INBOXES](state, inboxList[0]);
|
||||
expect(state.records).toEqual([inboxList[0]]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#DELETE_INBOXES', () => {
|
||||
it('delete inbox from store', () => {
|
||||
const state = {
|
||||
records: [inboxList[0]],
|
||||
};
|
||||
mutations[types.default.DELETE_INBOXES](state, 1);
|
||||
expect(state.records).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#DELETE_INBOXES', () => {
|
||||
it('delete inbox from store', () => {
|
||||
const state = {
|
||||
uiFlags: { isFetchingItem: false },
|
||||
};
|
||||
mutations[types.default.SET_INBOXES_UI_FLAG](state, {
|
||||
isFetchingItem: true,
|
||||
});
|
||||
expect(state.uiFlags).toEqual({ isFetchingItem: true });
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user