Merge branch 'develop' into feat/expand-idb-coverage
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import axios from 'axios';
|
||||
import { actions } from '../../customViews';
|
||||
import * as types from '../../../mutation-types';
|
||||
import { customViewList, updateCustomViewList } from './fixtures';
|
||||
import { actions } from '../../customViews';
|
||||
import {
|
||||
contactFilterView,
|
||||
customViewList,
|
||||
updateCustomViewList,
|
||||
} from './fixtures';
|
||||
|
||||
const commit = vi.fn();
|
||||
global.axios = axios;
|
||||
@@ -106,5 +110,27 @@ describe('#actions', () => {
|
||||
[types.default.SET_ACTIVE_CONVERSATION_FOLDER, customViewList[0]],
|
||||
]);
|
||||
});
|
||||
|
||||
it('prefetches the contact of a contact filter', async () => {
|
||||
const dispatch = vi.fn();
|
||||
await actions.setActiveConversationFolder(
|
||||
{ commit, dispatch },
|
||||
contactFilterView
|
||||
);
|
||||
expect(dispatch).toHaveBeenCalledWith(
|
||||
'contacts/show',
|
||||
{ id: 42 },
|
||||
{ root: true }
|
||||
);
|
||||
});
|
||||
|
||||
it('does not prefetch without a contact filter', async () => {
|
||||
const dispatch = vi.fn();
|
||||
await actions.setActiveConversationFolder(
|
||||
{ commit, dispatch },
|
||||
customViewList[0]
|
||||
);
|
||||
expect(dispatch).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,6 +15,21 @@ export const contactViewList = [
|
||||
},
|
||||
];
|
||||
|
||||
export const contactFilterView = {
|
||||
name: 'Contact view',
|
||||
filter_type: 0,
|
||||
query: {
|
||||
payload: [
|
||||
{
|
||||
attribute_key: 'contact_id',
|
||||
filter_operator: 'equal_to',
|
||||
values: [42],
|
||||
query_operator: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const customViewList = [
|
||||
{
|
||||
name: 'Custom view',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getters } from '../../customViews';
|
||||
import { contactViewList, customViewList } from './fixtures';
|
||||
import { contactFilterView, contactViewList, customViewList } from './fixtures';
|
||||
|
||||
describe('#getters', () => {
|
||||
it('getCustomViewsByFilterType', () => {
|
||||
@@ -43,4 +43,20 @@ describe('#getters', () => {
|
||||
customViewList[0]
|
||||
);
|
||||
});
|
||||
|
||||
it('getActiveFolderContactId', () => {
|
||||
expect(
|
||||
getters.getActiveFolderContactId({
|
||||
activeConversationFolder: contactFilterView,
|
||||
})
|
||||
).toEqual(42);
|
||||
});
|
||||
|
||||
it('getActiveFolderContactId returns undefined without a contact filter', () => {
|
||||
expect(
|
||||
getters.getActiveFolderContactId({
|
||||
activeConversationFolder: customViewList[0],
|
||||
})
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user