fix: Resolve conversation with id instead of current conversation (#2731)
This commit is contained in:
parent
9f3f238cb5
commit
d88e3e3596
5 changed files with 54 additions and 8 deletions
|
@ -145,10 +145,10 @@ const actions = {
|
||||||
status,
|
status,
|
||||||
snoozedUntil,
|
snoozedUntil,
|
||||||
});
|
});
|
||||||
commit(
|
commit(types.default.RESOLVE_CONVERSATION, {
|
||||||
types.default.RESOLVE_CONVERSATION,
|
conversationId,
|
||||||
response.data.payload.current_status
|
status: response.data.payload.current_status,
|
||||||
);
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Handle error
|
// Handle error
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,9 @@ const getters = {
|
||||||
getChatStatusFilter: ({ chatStatusFilter }) => chatStatusFilter,
|
getChatStatusFilter: ({ chatStatusFilter }) => chatStatusFilter,
|
||||||
getSelectedInbox: ({ currentInbox }) => currentInbox,
|
getSelectedInbox: ({ currentInbox }) => currentInbox,
|
||||||
getConversationById: _state => conversationId => {
|
getConversationById: _state => conversationId => {
|
||||||
return _state.allConversations.find(value => value.id === conversationId);
|
return _state.allConversations.find(
|
||||||
|
value => value.id === Number(conversationId)
|
||||||
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -69,9 +69,10 @@ export const mutations = {
|
||||||
Vue.set(chat.meta, 'team', team);
|
Vue.set(chat.meta, 'team', team);
|
||||||
},
|
},
|
||||||
|
|
||||||
[types.default.RESOLVE_CONVERSATION](_state, status) {
|
[types.default.RESOLVE_CONVERSATION](_state, { conversationId, status }) {
|
||||||
const [chat] = getSelectedChatConversation(_state);
|
const conversation =
|
||||||
chat.status = status;
|
getters.getConversationById(_state)(conversationId) || {};
|
||||||
|
Vue.set(conversation, 'status', status);
|
||||||
},
|
},
|
||||||
|
|
||||||
[types.default.MUTE_CONVERSATION](_state) {
|
[types.default.MUTE_CONVERSATION](_state) {
|
||||||
|
|
|
@ -214,6 +214,22 @@ describe('#actions', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#toggleStatus', () => {
|
||||||
|
it('sends correct mutations if toggle status is successful', async () => {
|
||||||
|
axios.post.mockResolvedValue({
|
||||||
|
data: { payload: { conversation_id: 1, current_status: 'resolved' } },
|
||||||
|
});
|
||||||
|
await actions.toggleStatus(
|
||||||
|
{ commit },
|
||||||
|
{ conversationId: 1, status: 'resolved' }
|
||||||
|
);
|
||||||
|
expect(commit).toHaveBeenCalledTimes(1);
|
||||||
|
expect(commit.mock.calls).toEqual([
|
||||||
|
['RESOLVE_CONVERSATION', { conversationId: 1, status: 'resolved' }],
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#assignTeam', () => {
|
describe('#assignTeam', () => {
|
||||||
it('sends correct mutations if assignment is successful', async () => {
|
it('sends correct mutations if assignment is successful', async () => {
|
||||||
axios.post.mockResolvedValue({
|
axios.post.mockResolvedValue({
|
||||||
|
|
|
@ -160,4 +160,31 @@ describe('#mutations', () => {
|
||||||
expect(global.bus.$emit).not.toHaveBeenCalled();
|
expect(global.bus.$emit).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#RESOLVE_CONVERSATION', () => {
|
||||||
|
it('updates the conversation status correctly', () => {
|
||||||
|
const state = {
|
||||||
|
allConversations: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
messages: [],
|
||||||
|
status: 'open',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
mutations[types.RESOLVE_CONVERSATION](state, {
|
||||||
|
conversationId: '1',
|
||||||
|
status: 'resolved',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(state.allConversations).toEqual([
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
messages: [],
|
||||||
|
status: 'resolved',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue