feat: Add a view for mentions (#3505)

- Added a new table mentions for saving user mentions
- Added a filter conversation_type in the API
- Added a view to see the mentions
This commit is contained in:
Pranav Raj S
2021-12-08 21:50:14 -08:00
committed by GitHub
parent 1db82f235d
commit 2be71e73dc
28 changed files with 389 additions and 98 deletions

View File

@@ -59,7 +59,10 @@ describe('#actions', () => {
messages: [],
meta: { sender: { id: 1, name: 'john-doe' } },
};
actions.updateConversation({ commit, dispatch }, conversation);
actions.updateConversation(
{ commit, rootState: { route: { name: 'home' } }, dispatch },
conversation
);
expect(commit.mock.calls).toEqual([
[types.UPDATE_CONVERSATION, conversation],
]);
@@ -86,6 +89,7 @@ describe('#actions', () => {
actions.addConversation(
{
commit,
rootState: { route: { name: 'home' } },
dispatch,
state: { currentInbox: 1, appliedFilters: [] },
},
@@ -105,6 +109,27 @@ describe('#actions', () => {
actions.addConversation(
{
commit,
rootState: { route: { name: 'home' } },
dispatch,
state: { currentInbox: 1, appliedFilters: [{ id: 'random-filter' }] },
},
conversation
);
expect(commit.mock.calls).toEqual([]);
expect(dispatch.mock.calls).toEqual([]);
});
it('doesnot send mutation if the view is conversation mentions', () => {
const conversation = {
id: 1,
messages: [],
meta: { sender: { id: 1, name: 'john-doe' } },
inbox_id: 1,
};
actions.addConversation(
{
commit,
rootState: { route: { name: 'conversation_mentions' } },
dispatch,
state: { currentInbox: 1, appliedFilters: [{ id: 'random-filter' }] },
},
@@ -124,6 +149,7 @@ describe('#actions', () => {
actions.addConversation(
{
commit,
rootState: { route: { name: 'home' } },
dispatch,
state: { currentInbox: 1, appliedFilters: [] },
},
@@ -151,7 +177,12 @@ describe('#actions', () => {
inbox_id: 1,
};
actions.addConversation(
{ commit, dispatch, state: { appliedFilters: [] } },
{
commit,
rootState: { route: { name: 'home' } },
dispatch,
state: { appliedFilters: [] },
},
conversation
);
expect(commit.mock.calls).toEqual([
@@ -379,3 +410,27 @@ describe('#deleteMessage', () => {
});
});
});
describe('#addMentions', () => {
it('does not send mutations if the view is not mentions', () => {
actions.addMentions(
{ commit, dispatch, rootState: { route: { name: 'home' } } },
{ id: 1 }
);
expect(commit.mock.calls).toEqual([]);
expect(dispatch.mock.calls).toEqual([]);
});
it('send mutations if the view is mentions', () => {
actions.addMentions(
{
dispatch,
rootState: { route: { name: 'conversation_mentions' } },
},
{ id: 1, meta: { sender: { id: 1 } } }
);
expect(dispatch.mock.calls).toEqual([
['updateConversation', { id: 1, meta: { sender: { id: 1 } } }],
]);
});
});