Merge branch 'develop' into deploy-apr-15

This commit is contained in:
Pranav
2024-07-10 20:28:53 -07:00
144 changed files with 1683 additions and 2820 deletions
@@ -3,7 +3,7 @@ import { actions } from '../actions';
import * as types from '../../../mutation-types';
import { uploadFile } from 'dashboard/helper/uploadHelper';
jest.mock('dashboard/helper/uploadHelper');
vi.mock('dashboard/helper/uploadHelper');
const articleList = [
{
@@ -12,10 +12,10 @@ const articleList = [
title: 'Documents are required to complete KYC',
},
];
const commit = jest.fn();
const dispatch = jest.fn();
const commit = vi.fn();
const dispatch = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#index', () => {
@@ -2,9 +2,9 @@ import axios from 'axios';
import { actions } from '../actions';
import * as types from '../../../mutation-types';
import { categoriesPayload } from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#index', () => {
@@ -3,10 +3,10 @@ import { actions } from '../actions';
import { types } from '../mutations';
import { apiResponse } from './fixtures';
const commit = jest.fn();
const dispatch = jest.fn();
const commit = vi.fn();
const dispatch = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#index', () => {
@@ -12,9 +12,9 @@ const newAccountInfo = {
accountName: 'Company two',
};
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -5,7 +5,7 @@ const accountData = {
name: 'Company one',
locale: 'en',
features: {
auto_resolve_conversations: false,
auto_resolve_conversations: true,
agent_management: false,
},
};
@@ -38,17 +38,11 @@ describe('#getters', () => {
const state = {
records: [accountData],
};
const rootGetters = {
getCurrentUser: {
type: 'SuperAdmin',
},
};
expect(
getters.isFeatureEnabledonAccount(
state,
null,
null,
rootGetters
null
)(1, 'auto_resolve_conversations')
).toEqual(true);
});
@@ -3,9 +3,9 @@ import { actions } from '../../agentBots';
import types from '../../../mutation-types';
import { agentBotRecords } from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -3,10 +3,10 @@ import { actions } from '../../agents';
import * as types from '../../../mutation-types';
import agentList from './fixtures';
const commit = jest.fn();
const dispatch = jest.fn();
const commit = vi.fn();
const dispatch = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -3,9 +3,9 @@ import { actions } from '../../attributes';
import * as types from '../../../mutation-types';
import attributesList from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -2,23 +2,18 @@ import axios from 'axios';
import Cookies from 'js-cookie';
import { actions } from '../../auth';
import * as types from '../../../mutation-types';
import { setUser, clearCookiesOnLogout } from '../../../utils/api';
import * as APIHelpers from '../../../utils/api';
import '../../../../routes';
jest.mock('../../../../routes', () => {});
jest.mock('../../../utils/api', () => ({
setUser: jest.fn(),
clearCookiesOnLogout: jest.fn(),
getHeaderExpiry: jest.fn(),
}));
jest.mock('js-cookie', () => ({
get: jest.fn(),
}));
vi.spyOn(APIHelpers, 'setUser');
vi.spyOn(APIHelpers, 'clearCookiesOnLogout');
vi.spyOn(APIHelpers, 'getHeaderExpiry');
vi.spyOn(Cookies, 'get');
const commit = jest.fn();
const dispatch = jest.fn();
const commit = vi.fn();
const dispatch = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#validityCheck', () => {
@@ -28,7 +23,7 @@ describe('#actions', () => {
headers: { expiry: 581842904 },
});
await actions.validityCheck({ commit });
expect(setUser).toHaveBeenCalledTimes(1);
expect(APIHelpers.setUser).toHaveBeenCalledTimes(1);
expect(commit.mock.calls).toEqual([
[types.default.SET_CURRENT_USER, { id: 1, name: 'John' }],
]);
@@ -38,7 +33,7 @@ describe('#actions', () => {
response: { status: 401 },
});
await actions.validityCheck({ commit });
expect(clearCookiesOnLogout);
expect(APIHelpers.clearCookiesOnLogout);
});
});
@@ -1,8 +1,5 @@
import { getters } from '../../auth';
import '../../../../routes';
jest.mock('../../../../routes', () => {});
describe('#getters', () => {
describe('#isLoggedIn', () => {
it('return correct value if user data is available', () => {
@@ -3,9 +3,9 @@ import { actions } from '../../automations';
import * as types from '../../../mutation-types';
import automationsList from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -2,9 +2,9 @@ import axios from 'axios';
import { actions } from '../../bulkActions';
import * as types from '../../../mutation-types';
import payload from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#create', () => {
@@ -3,9 +3,9 @@ import { actions } from '../../campaigns';
import * as types from '../../../mutation-types';
import campaignList from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -8,9 +8,9 @@ import {
import * as types from '../../../mutation-types';
import conversationList from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -2,9 +2,9 @@ import axios from 'axios';
import { actions } from '../../contactLabels';
import * as types from '../../../mutation-types';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -3,9 +3,9 @@ import { actions } from '../../contactNotes';
import * as types from '../../../mutation-types';
import notesData from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -21,9 +21,9 @@ const filterQueryData = {
],
};
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -2,9 +2,9 @@ import axios from 'axios';
import { actions } from '../../conversationLabels';
import * as types from '../../../mutation-types';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -1,7 +1,7 @@
import { actions } from '../../conversationPage';
import * as types from '../../../mutation-types';
const commit = jest.fn();
const commit = vi.fn();
describe('#actions', () => {
describe('#setCurrentPage', () => {
@@ -1,9 +1,9 @@
import { actions } from '../../conversationSearch';
import types from '../../../mutation-types';
import axios from 'axios';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -2,9 +2,9 @@ import axios from 'axios';
import { actions } from '../../conversationStats';
import * as types from '../../../mutation-types';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -1,7 +1,7 @@
import { actions } from '../../conversationTypingStatus';
import * as types from '../../../mutation-types';
const commit = jest.fn();
const commit = vi.fn();
describe('#actions', () => {
describe('#create', () => {
@@ -2,9 +2,9 @@ import axios from 'axios';
import { actions } from '../../conversationWatchers';
import types from '../../../mutation-types';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -15,10 +15,10 @@ const dataToSend = {
};
import { dataReceived } from './testConversationResponse';
const commit = jest.fn();
const dispatch = jest.fn();
const commit = vi.fn();
const dispatch = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#hasMessageFailedWithExternalError', () => {
it('returns false if message is sent', () => {
@@ -292,7 +292,7 @@ describe('#actions', () => {
describe('#markMessagesRead', () => {
beforeEach(() => {
jest.useFakeTimers();
vi.useFakeTimers();
});
it('sends correct mutations if api is successful', async () => {
@@ -301,7 +301,7 @@ describe('#actions', () => {
data: { id: 1, agent_last_seen_at: lastSeen },
});
await actions.markMessagesRead({ commit }, { id: 1 });
jest.runAllTimers();
vi.runAllTimers();
expect(commit).toHaveBeenCalledTimes(1);
expect(commit.mock.calls).toEqual([
[types.UPDATE_MESSAGE_UNREAD_COUNT, { id: 1, lastSeen }],
@@ -321,7 +321,7 @@ describe('#actions', () => {
data: { id: 1, agent_last_seen_at: lastSeen, unread_count: 1 },
});
await actions.markMessagesUnread({ commit }, { id: 1 });
jest.runAllTimers();
vi.runAllTimers();
expect(commit).toHaveBeenCalledTimes(1);
expect(commit.mock.calls).toEqual([
[
@@ -1,11 +1,11 @@
import types from '../../../mutation-types';
import { mutations } from '../../conversations';
jest.mock('shared/helpers/mitt', () => ({
vi.mock('shared/helpers/mitt', () => ({
emitter: {
emit: jest.fn(),
on: jest.fn(),
off: jest.fn(),
emit: vi.fn(),
on: vi.fn(),
off: vi.fn(),
},
}));
@@ -116,7 +116,7 @@ describe('#mutations', () => {
});
it('add message to the conversation if it does not exist in the store', () => {
global.bus = { $emit: jest.fn() };
global.bus = { $emit: vi.fn() };
const state = {
allConversations: [{ id: 1, messages: [] }],
selectedChatId: -1,
@@ -144,7 +144,7 @@ describe('#mutations', () => {
});
it('add message to the conversation and emit scrollToMessage if it does not exist in the store', () => {
global.bus = { $emit: jest.fn() };
global.bus = { $emit: vi.fn() };
const state = {
allConversations: [{ id: 1, messages: [] }],
selectedChatId: 1,
@@ -172,7 +172,7 @@ describe('#mutations', () => {
});
it('update message if it exist in the store', () => {
global.bus = { $emit: jest.fn() };
global.bus = { $emit: vi.fn() };
const state = {
allConversations: [
{
@@ -2,9 +2,9 @@ import axios from 'axios';
import { actions } from '../../csat';
import types from '../../../mutation-types';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -3,9 +3,9 @@ import { actions } from '../../customViews';
import * as types from '../../../mutation-types';
import { customViewList, updateCustomViewList } from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -2,9 +2,9 @@ import axios from 'axios';
import { actions } from '../../dashboardApps';
import types from '../../../mutation-types';
import { payload, automationsList } from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -2,9 +2,9 @@ import axios from 'axios';
import { actions } from '../../draftMessages';
import types from '../../../mutation-types';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#set', () => {
@@ -2,9 +2,9 @@ import axios from 'axios';
import { actions, types } from '../../inboxAssignableAgents';
import agentsData from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#fetch', () => {
@@ -3,14 +3,14 @@ import { actions } from '../../inboxes';
import * as types from '../../../mutation-types';
import inboxList from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
it('sends correct actions if API is success', async () => {
const mockedGet = jest.fn(url => {
const mockedGet = vi.fn(url => {
if (url === '/api/v1/inboxes') {
return Promise.resolve({ data: { payload: inboxList } });
}
@@ -3,9 +3,9 @@ import { actions } from '../../integrations';
import types from '../../../mutation-types';
import integrationsList from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
const errorMessage = { message: 'Incorrect header' };
describe('#actions', () => {
@@ -3,14 +3,14 @@ import { actions } from '../../labels';
import * as types from '../../../mutation-types';
import labelsList from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
it('sends correct actions if API is success', async () => {
const mockedGet = jest.fn(url => {
const mockedGet = vi.fn(url => {
if (url === '/api/v1/labels') {
return Promise.resolve({ data: { payload: labelsList } });
}
@@ -3,9 +3,9 @@ import { actions } from '../../macros';
import * as types from '../../../mutation-types';
import macrosList from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -1,9 +1,9 @@
import axios from 'axios';
import { actions } from '../../notifications/actions';
import types from '../../../mutation-types';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -1,13 +1,12 @@
import axios from 'axios';
import { actions } from '../../reports';
import DownloadHelper from 'dashboard/helper/downloadHelper';
global.open = jest.fn();
global.axios = axios;
jest.mock('axios');
import * as DownloadHelper from 'dashboard/helper/downloadHelper';
jest.mock('dashboard/helper/downloadHelper', () => ({
downloadCsvFile: jest.fn(),
}));
global.open = vi.fn();
global.axios = axios;
vi.mock('axios');
vi.spyOn(DownloadHelper, 'downloadCsvFile');
describe('#actions', () => {
describe('#downloadAgentReports', () => {
@@ -3,13 +3,13 @@ import { actions } from '../../sla';
import * as types from '../../../mutation-types';
import SLAList from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
beforeEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
});
describe('#get', () => {
@@ -3,9 +3,9 @@ import { actions } from '../../SLAReports';
import appliedSlas from './fixtures';
import types from '../../../mutation-types';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -6,9 +6,9 @@ import {
} from '../../teamMembers';
import teamMembers from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -10,14 +10,14 @@ import {
} from '../../teams/types';
import teamsList from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
it('sends correct actions if API is success', async () => {
const mockedGet = jest.fn(url => {
const mockedGet = vi.fn(url => {
if (url === '/api/v1/teams') {
return Promise.resolve({ data: teamsList[1] });
}
@@ -2,9 +2,9 @@ import axios from 'axios';
import { actions } from '../../userNotificationSettings';
import * as types from '../../../mutation-types';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {
@@ -3,9 +3,9 @@ import { actions } from '../../webhooks';
import * as types from '../../../mutation-types';
import webhooks from './fixtures';
const commit = jest.fn();
const commit = vi.fn();
global.axios = axios;
jest.mock('axios');
vi.mock('axios');
describe('#actions', () => {
describe('#get', () => {