-
diff --git a/app/javascript/dashboard/routes/index.js b/app/javascript/dashboard/routes/index.js
index e2245e20f..70d870700 100644
--- a/app/javascript/dashboard/routes/index.js
+++ b/app/javascript/dashboard/routes/index.js
@@ -5,33 +5,12 @@ import dashboard from './dashboard/dashboard.routes';
import store from '../store';
import { validateLoggedInRoutes } from '../helper/routeHelpers';
import AnalyticsHelper from '../helper/AnalyticsHelper';
+import { buildPermissionsFromRouter } from '../helper/permissionsHelper';
const routes = [...dashboard.routes];
-window.roleWiseRoutes = {
- agent: [],
- administrator: [],
-};
-
-// generateRoleWiseRoute - updates window object with agent/admin route
-const generateRoleWiseRoute = route => {
- route.forEach(element => {
- if (element.children) {
- generateRoleWiseRoute(element.children);
- }
- if (element.roles) {
- element.roles.forEach(roleEl => {
- window.roleWiseRoutes[roleEl].push(element.name);
- });
- }
- });
-};
-// Create a object of routes
-// accessible by each role.
-// returns an object with roles as keys and routeArr as values
-generateRoleWiseRoute(routes);
-
export const router = new VueRouter({ mode: 'history', routes });
+export const routesWithPermissions = buildPermissionsFromRouter(routes);
export const validateAuthenticateRoutePermission = (to, next, { getters }) => {
const { isLoggedIn, getCurrentUser: user } = getters;
@@ -45,11 +24,7 @@ export const validateAuthenticateRoutePermission = (to, next, { getters }) => {
return next(frontendURL(`accounts/${user.account_id}/dashboard`));
}
- const nextRoute = validateLoggedInRoutes(
- to,
- getters.getCurrentUser,
- window.roleWiseRoutes
- );
+ const nextRoute = validateLoggedInRoutes(to, getters.getCurrentUser);
return nextRoute ? next(frontendURL(nextRoute)) : next();
};
diff --git a/app/javascript/dashboard/routes/index.spec.js b/app/javascript/dashboard/routes/index.spec.js
index 21ec30191..a169f8b76 100644
--- a/app/javascript/dashboard/routes/index.spec.js
+++ b/app/javascript/dashboard/routes/index.spec.js
@@ -1,18 +1,11 @@
-import 'expect-more-jest';
import { validateAuthenticateRoutePermission } from './index';
-jest.mock('./dashboard/dashboard.routes', () => ({
- routes: [],
-}));
-window.roleWiseRoutes = {};
-
describe('#validateAuthenticateRoutePermission', () => {
describe(`when route is protected`, () => {
describe(`when user not logged in`, () => {
it(`should redirect to login`, () => {
- // Arrange
const to = { name: 'some-protected-route', params: { accountId: 1 } };
- const next = jest.fn();
+ const next = vi.fn();
const getters = {
isLoggedIn: false,
getCurrentUser: {
@@ -30,14 +23,18 @@ describe('#validateAuthenticateRoutePermission', () => {
describe(`when user is logged in`, () => {
describe(`when route is not accessible to current user`, () => {
it(`should redirect to dashboard`, () => {
- window.roleWiseRoutes.agent = ['dashboard'];
- const to = { name: 'admin', params: { accountId: 1 } };
- const next = jest.fn();
+ const to = {
+ name: 'general_settings_index',
+ params: { accountId: 1 },
+ meta: { permissions: ['administrator'] },
+ };
+ const next = vi.fn();
const getters = {
isLoggedIn: true,
getCurrentUser: {
account_id: 1,
id: 1,
+ permissions: ['agent'],
accounts: [{ id: 1, role: 'agent', status: 'active' }],
},
};
@@ -47,15 +44,19 @@ describe('#validateAuthenticateRoutePermission', () => {
});
describe(`when route is accessible to current user`, () => {
it(`should go there`, () => {
- window.roleWiseRoutes.agent = ['dashboard', 'admin'];
- const to = { name: 'admin', params: { accountId: 1 } };
- const next = jest.fn();
+ const to = {
+ name: 'general_settings_index',
+ params: { accountId: 1 },
+ meta: { permissions: ['administrator'] },
+ };
+ const next = vi.fn();
const getters = {
isLoggedIn: true,
getCurrentUser: {
account_id: 1,
id: 1,
- accounts: [{ id: 1, role: 'agent', status: 'active' }],
+ permissions: ['administrator'],
+ accounts: [{ id: 1, role: 'administrator', status: 'active' }],
},
};
validateAuthenticateRoutePermission(to, next, { getters });
diff --git a/app/javascript/dashboard/store/modules/cannedResponse.js b/app/javascript/dashboard/store/modules/cannedResponse.js
index 7b24d1171..568150392 100644
--- a/app/javascript/dashboard/store/modules/cannedResponse.js
+++ b/app/javascript/dashboard/store/modules/cannedResponse.js
@@ -18,6 +18,15 @@ const getters = {
getCannedResponses(_state) {
return _state.records;
},
+ getSortedCannedResponses(_state) {
+ return sortOrder =>
+ [..._state.records].sort((a, b) => {
+ if (sortOrder === 'asc') {
+ return a.short_code.localeCompare(b.short_code);
+ }
+ return b.short_code.localeCompare(a.short_code);
+ });
+ },
getUIFlags(_state) {
return _state.uiFlags;
},
diff --git a/app/javascript/dashboard/store/modules/conversations/actions.js b/app/javascript/dashboard/store/modules/conversations/actions.js
index 6a8b94e1e..eaf385372 100644
--- a/app/javascript/dashboard/store/modules/conversations/actions.js
+++ b/app/javascript/dashboard/store/modules/conversations/actions.js
@@ -12,6 +12,7 @@ import {
} from './helpers/actionHelpers';
import messageReadActions from './actions/messageReadActions';
import messageTranslateActions from './actions/messageTranslateActions';
+import * as Sentry from '@sentry/browser';
export const hasMessageFailedWithExternalError = pendingMessage => {
// This helper is used to check if the message has failed with an external error.
@@ -100,14 +101,24 @@ const actions = {
},
fetchAllAttachments: async ({ commit }, conversationId) => {
+ let attachments = null;
+
try {
const { data } = await ConversationApi.getAllAttachments(conversationId);
+ attachments = data.payload;
+ } catch (error) {
+ // in case of error, log the error and continue
+ Sentry.setContext('Conversation', {
+ id: conversationId,
+ });
+ Sentry.captureException(error);
+ } finally {
+ // we run the commit even if the request fails
+ // this ensures that the `attachment` variable is always present on chat
commit(types.SET_ALL_ATTACHMENTS, {
id: conversationId,
- data: data.payload,
+ data: attachments,
});
- } catch (error) {
- // Handle error
}
},
diff --git a/app/javascript/dashboard/store/modules/conversations/getters.js b/app/javascript/dashboard/store/modules/conversations/getters.js
index 8c2070963..1a905c3c5 100644
--- a/app/javascript/dashboard/store/modules/conversations/getters.js
+++ b/app/javascript/dashboard/store/modules/conversations/getters.js
@@ -18,9 +18,8 @@ const getters = {
);
return selectedChat || {};
},
- getSelectedChatAttachments: (_state, _getters) => {
- const selectedChat = _getters.getSelectedChat;
- return selectedChat.attachments || [];
+ getSelectedChatAttachments: ({ selectedChatId, attachments }) => {
+ return attachments[selectedChatId] || [];
},
getChatListFilters: ({ conversationFilters }) => conversationFilters,
getLastEmailInSelectedChat: (stage, _getters) => {
diff --git a/app/javascript/dashboard/store/modules/conversations/index.js b/app/javascript/dashboard/store/modules/conversations/index.js
index 769354ed2..b3e39d397 100644
--- a/app/javascript/dashboard/store/modules/conversations/index.js
+++ b/app/javascript/dashboard/store/modules/conversations/index.js
@@ -10,6 +10,7 @@ import { emitter } from 'shared/helpers/mitt';
const state = {
allConversations: [],
+ attachments: {},
listLoadingStatus: true,
chatStatusFilter: wootConstants.STATUS_TYPE.OPEN,
chatSortFilter: wootConstants.SORT_BY_TYPE.LATEST,
@@ -48,7 +49,6 @@ export const mutations = {
allMessagesLoaded: existingConversation.allMessagesLoaded,
messages: existingConversation.messages,
dataFetched: existingConversation.dataFetched,
- attachments: existingConversation.attachments,
};
}
});
@@ -78,10 +78,10 @@ export const mutations = {
}
},
[types.SET_ALL_ATTACHMENTS](_state, { id, data }) {
- const [chat] = _state.allConversations.filter(c => c.id === id);
- if (!chat) return;
- Vue.set(chat, 'attachments', []);
- chat.attachments.push(...data);
+ const attachments = _state.attachments[id] || [];
+
+ attachments.push(...data);
+ _state.attachments[id] = [...attachments];
},
[types.SET_MISSING_MESSAGES](_state, { id, data }) {
const [chat] = _state.allConversations.filter(c => c.id === id);
@@ -144,42 +144,40 @@ export const mutations = {
Vue.set(chat, 'muted', false);
},
- [types.ADD_CONVERSATION_ATTACHMENTS]({ allConversations }, message) {
- const { conversation_id: conversationId } = message;
- const [chat] = getSelectedChatConversation({
- allConversations,
- selectedChatId: conversationId,
+ [types.ADD_CONVERSATION_ATTACHMENTS](_state, message) {
+ // early return if the message has not been sent, or has no attachments
+ if (
+ message.status !== MESSAGE_STATUS.SENT ||
+ !message.attachments?.length
+ ) {
+ return;
+ }
+
+ const id = message.conversation_id;
+ const existingAttachments = _state.attachments[id] || [];
+
+ const attachmentsToAdd = message.attachments.filter(attachment => {
+ // if the attachment is not already in the store, add it
+ // this is to prevent duplicates
+ return !existingAttachments.some(
+ existingAttachment => existingAttachment.id === attachment.id
+ );
});
- if (!chat) return;
-
- const isMessageSent =
- message.status === MESSAGE_STATUS.SENT && message.attachments;
- if (isMessageSent) {
- message.attachments.forEach(attachment => {
- if (!chat.attachments.some(a => a.id === attachment.id)) {
- chat.attachments.push(attachment);
- }
- });
- }
+ // replace the attachments in the store
+ _state.attachments[id] = [...existingAttachments, ...attachmentsToAdd];
},
- [types.DELETE_CONVERSATION_ATTACHMENTS]({ allConversations }, message) {
- const { conversation_id: conversationId } = message;
- const [chat] = getSelectedChatConversation({
- allConversations,
- selectedChatId: conversationId,
+ [types.DELETE_CONVERSATION_ATTACHMENTS](_state, message) {
+ if (message.status !== MESSAGE_STATUS.SENT) return;
+
+ const { conversation_id: id } = message;
+ const existingAttachments = _state.attachments[id] || [];
+ if (!existingAttachments.length) return;
+
+ _state.attachments[id] = existingAttachments.filter(attachment => {
+ return attachment.message_id !== message.id;
});
-
- if (!chat) return;
-
- const isMessageSent = message.status === MESSAGE_STATUS.SENT;
- if (isMessageSent) {
- const attachmentIndex = chat.attachments.findIndex(
- a => a.message_id === message.id
- );
- if (attachmentIndex !== -1) chat.attachments.splice(attachmentIndex, 1);
- }
},
[types.ADD_MESSAGE]({ allConversations, selectedChatId }, message) {
diff --git a/app/javascript/dashboard/store/modules/helpCenterArticles/specs/action.spec.js b/app/javascript/dashboard/store/modules/helpCenterArticles/specs/action.spec.js
index 378c4809d..bbd4f933b 100644
--- a/app/javascript/dashboard/store/modules/helpCenterArticles/specs/action.spec.js
+++ b/app/javascript/dashboard/store/modules/helpCenterArticles/specs/action.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/helpCenterCategories/specs/actions.spec.js b/app/javascript/dashboard/store/modules/helpCenterCategories/specs/actions.spec.js
index b5f62a328..528f2ebb5 100644
--- a/app/javascript/dashboard/store/modules/helpCenterCategories/specs/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/helpCenterCategories/specs/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/helpCenterPortals/specs/actions.spec.js b/app/javascript/dashboard/store/modules/helpCenterPortals/specs/actions.spec.js
index 6fdd054b3..9acbbb0b5 100644
--- a/app/javascript/dashboard/store/modules/helpCenterPortals/specs/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/helpCenterPortals/specs/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/integrations.js b/app/javascript/dashboard/store/modules/integrations.js
index 3183afbe3..add8f022f 100644
--- a/app/javascript/dashboard/store/modules/integrations.js
+++ b/app/javascript/dashboard/store/modules/integrations.js
@@ -20,28 +20,18 @@ const state = {
},
};
-const isAValidAppIntegration = integration => {
- return [
- 'dialogflow',
- 'dyte',
- 'google_translate',
- 'openai',
- 'linear',
- ].includes(integration.id);
-};
export const getters = {
- getIntegrations($state) {
- return $state.records.filter(item => !isAValidAppIntegration(item));
- },
getAppIntegrations($state) {
- return $state.records.filter(item => isAValidAppIntegration(item));
- },
- getIntegration: $state => integrationId => {
- const [integration] = $state.records.filter(
- record => record.id === integrationId
- );
- return integration || {};
+ return $state.records;
},
+ getIntegration:
+ $state =>
+ (integrationId, defaultValue = {}) => {
+ const [integration] = $state.records.filter(
+ record => record.id === integrationId
+ );
+ return integration || defaultValue;
+ },
getUIFlags($state) {
return $state.uiFlags;
},
diff --git a/app/javascript/dashboard/store/modules/specs/account/actions.spec.js b/app/javascript/dashboard/store/modules/specs/account/actions.spec.js
index b45e2ba1b..92f1328a5 100644
--- a/app/javascript/dashboard/store/modules/specs/account/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/account/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/account/getters.spec.js b/app/javascript/dashboard/store/modules/specs/account/getters.spec.js
index e7eec6101..676720c29 100644
--- a/app/javascript/dashboard/store/modules/specs/account/getters.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/account/getters.spec.js
@@ -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);
});
diff --git a/app/javascript/dashboard/store/modules/specs/agentBots/agentBots.spec.js b/app/javascript/dashboard/store/modules/specs/agentBots/agentBots.spec.js
index 46c97311a..90cae45d9 100644
--- a/app/javascript/dashboard/store/modules/specs/agentBots/agentBots.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/agentBots/agentBots.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/agents/actions.spec.js b/app/javascript/dashboard/store/modules/specs/agents/actions.spec.js
index 104d75501..1a43e9200 100644
--- a/app/javascript/dashboard/store/modules/specs/agents/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/agents/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/attributes/actions.spec.js b/app/javascript/dashboard/store/modules/specs/attributes/actions.spec.js
index 9579ff268..d3df969ac 100644
--- a/app/javascript/dashboard/store/modules/specs/attributes/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/attributes/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/auth/actions.spec.js b/app/javascript/dashboard/store/modules/specs/auth/actions.spec.js
index 59ef88f4c..f5206a8a6 100644
--- a/app/javascript/dashboard/store/modules/specs/auth/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/auth/actions.spec.js
@@ -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);
});
});
diff --git a/app/javascript/dashboard/store/modules/specs/auth/getters.spec.js b/app/javascript/dashboard/store/modules/specs/auth/getters.spec.js
index 6032189c9..e89386af3 100644
--- a/app/javascript/dashboard/store/modules/specs/auth/getters.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/auth/getters.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/automations/actions.spec.js b/app/javascript/dashboard/store/modules/specs/automations/actions.spec.js
index 035681ce7..e2eb55f11 100644
--- a/app/javascript/dashboard/store/modules/specs/automations/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/automations/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/bulkActions/actions.spec.js b/app/javascript/dashboard/store/modules/specs/bulkActions/actions.spec.js
index 91190c1a2..650bcac58 100644
--- a/app/javascript/dashboard/store/modules/specs/bulkActions/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/bulkActions/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/campaigns/actions.spec.js b/app/javascript/dashboard/store/modules/specs/campaigns/actions.spec.js
index 413d86793..a80f70e80 100644
--- a/app/javascript/dashboard/store/modules/specs/campaigns/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/campaigns/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/cannedResponses/getters.spec.js b/app/javascript/dashboard/store/modules/specs/cannedResponses/getters.spec.js
new file mode 100644
index 000000000..7a80aed8c
--- /dev/null
+++ b/app/javascript/dashboard/store/modules/specs/cannedResponses/getters.spec.js
@@ -0,0 +1,43 @@
+import CannedResponses from '../../cannedResponse';
+
+const CANNED_RESPONSES = [
+ { short_code: 'hello', content: 'Hi ' },
+ { short_code: 'ask', content: 'Ask questions' },
+ { short_code: 'greet', content: 'Good morning' },
+];
+
+const getters = CannedResponses.getters;
+
+describe('#getCannedResponses', () => {
+ it('returns canned responses', () => {
+ const state = { records: CANNED_RESPONSES };
+ expect(getters.getCannedResponses(state)).toEqual(CANNED_RESPONSES);
+ });
+});
+
+describe('#getSortedCannedResponses', () => {
+ it('returns sort canned responses in ascending order', () => {
+ const state = { records: CANNED_RESPONSES };
+ expect(getters.getSortedCannedResponses(state)('asc')).toEqual([
+ CANNED_RESPONSES[1],
+ CANNED_RESPONSES[2],
+ CANNED_RESPONSES[0],
+ ]);
+ });
+
+ it('returns sort canned responses in descending order', () => {
+ const state = { records: CANNED_RESPONSES };
+ expect(getters.getSortedCannedResponses(state)('desc')).toEqual([
+ CANNED_RESPONSES[0],
+ CANNED_RESPONSES[2],
+ CANNED_RESPONSES[1],
+ ]);
+ });
+});
+
+describe('#getUIFlags', () => {
+ it('returns uiFlags', () => {
+ const state = { uiFlags: { isFetching: true } };
+ expect(getters.getUIFlags(state)).toEqual({ isFetching: true });
+ });
+});
diff --git a/app/javascript/dashboard/store/modules/specs/contactConversations/actions.spec.js b/app/javascript/dashboard/store/modules/specs/contactConversations/actions.spec.js
index 9a36dd321..b403c0d4a 100644
--- a/app/javascript/dashboard/store/modules/specs/contactConversations/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/contactConversations/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/contactLabels/actions.spec.js b/app/javascript/dashboard/store/modules/specs/contactLabels/actions.spec.js
index 0f5222603..49e5edfd5 100644
--- a/app/javascript/dashboard/store/modules/specs/contactLabels/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/contactLabels/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/contactNotes/actions.spec.js b/app/javascript/dashboard/store/modules/specs/contactNotes/actions.spec.js
index 166d723c2..d732279e2 100644
--- a/app/javascript/dashboard/store/modules/specs/contactNotes/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/contactNotes/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/contacts/actions.spec.js b/app/javascript/dashboard/store/modules/specs/contacts/actions.spec.js
index cec9db143..ec75ec968 100644
--- a/app/javascript/dashboard/store/modules/specs/contacts/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/contacts/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/conversationLabels/actions.spec.js b/app/javascript/dashboard/store/modules/specs/conversationLabels/actions.spec.js
index e37d5d644..a79544414 100644
--- a/app/javascript/dashboard/store/modules/specs/conversationLabels/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/conversationLabels/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/conversationPage/actions.spec.js b/app/javascript/dashboard/store/modules/specs/conversationPage/actions.spec.js
index 48e502d0c..0c38abf3e 100644
--- a/app/javascript/dashboard/store/modules/specs/conversationPage/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/conversationPage/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/conversationSearch/actions.spec.js b/app/javascript/dashboard/store/modules/specs/conversationSearch/actions.spec.js
index 449e699c2..0fdcae458 100644
--- a/app/javascript/dashboard/store/modules/specs/conversationSearch/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/conversationSearch/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/conversationStats/actions.spec.js b/app/javascript/dashboard/store/modules/specs/conversationStats/actions.spec.js
index e357204d2..33d927103 100644
--- a/app/javascript/dashboard/store/modules/specs/conversationStats/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/conversationStats/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/conversationTypingStatus/actions.spec.js b/app/javascript/dashboard/store/modules/specs/conversationTypingStatus/actions.spec.js
index f9e62940c..c47e582dd 100644
--- a/app/javascript/dashboard/store/modules/specs/conversationTypingStatus/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/conversationTypingStatus/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/conversationWatchers/actions.spec.js b/app/javascript/dashboard/store/modules/specs/conversationWatchers/actions.spec.js
index 25b28a5bb..b3cfabeba 100644
--- a/app/javascript/dashboard/store/modules/specs/conversationWatchers/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/conversationWatchers/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/conversations/actions.spec.js b/app/javascript/dashboard/store/modules/specs/conversations/actions.spec.js
index ddbbe54b0..b0c9d2480 100644
--- a/app/javascript/dashboard/store/modules/specs/conversations/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/conversations/actions.spec.js
@@ -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([
[
diff --git a/app/javascript/dashboard/store/modules/specs/conversations/getters.spec.js b/app/javascript/dashboard/store/modules/specs/conversations/getters.spec.js
index 3c3bf79de..cded29329 100644
--- a/app/javascript/dashboard/store/modules/specs/conversations/getters.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/conversations/getters.spec.js
@@ -245,30 +245,18 @@ describe('#getters', () => {
describe('#getSelectedChatAttachments', () => {
it('Returns attachments in selected chat', () => {
- const state = {};
- const getSelectedChat = {
- attachments: [
- {
- id: 1,
- file_name: 'test1',
- },
- {
- id: 2,
- file_name: 'test2',
- },
+ const attachments = {
+ 1: [
+ { id: 1, file_name: 'test1' },
+ { id: 2, file_name: 'test2' },
],
};
+ const selectedChatId = 1;
expect(
- getters.getSelectedChatAttachments(state, { getSelectedChat })
+ getters.getSelectedChatAttachments({ selectedChatId, attachments })
).toEqual([
- {
- id: 1,
- file_name: 'test1',
- },
- {
- id: 2,
- file_name: 'test2',
- },
+ { id: 1, file_name: 'test1' },
+ { id: 2, file_name: 'test2' },
]);
});
});
diff --git a/app/javascript/dashboard/store/modules/specs/conversations/mutations.spec.js b/app/javascript/dashboard/store/modules/specs/conversations/mutations.spec.js
index b10a24ea0..6340e4de9 100644
--- a/app/javascript/dashboard/store/modules/specs/conversations/mutations.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/conversations/mutations.spec.js
@@ -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: [
{
@@ -313,7 +313,6 @@ describe('#mutations', () => {
{
id: 1,
messages: [{ id: 1, content: 'test' }],
- attachments: [{ id: 1, name: 'test1.png' }],
dataFetched: true,
allMessagesLoaded: true,
},
@@ -325,7 +324,6 @@ describe('#mutations', () => {
id: 1,
name: 'test',
messages: [{ id: 1, content: 'updated message' }],
- attachments: [{ id: 1, name: 'test.png' }],
dataFetched: true,
allMessagesLoaded: true,
},
@@ -335,7 +333,6 @@ describe('#mutations', () => {
id: 1,
name: 'test',
messages: [{ id: 1, content: 'test' }],
- attachments: [{ id: 1, name: 'test1.png' }],
dataFetched: true,
allMessagesLoaded: true,
},
@@ -371,25 +368,28 @@ describe('#mutations', () => {
it('set all attachments', () => {
const state = {
allConversations: [{ id: 1 }],
+ attachments: {},
};
const data = [{ id: 1, name: 'test' }];
mutations[types.SET_ALL_ATTACHMENTS](state, { id: 1, data });
- expect(state.allConversations[0].attachments).toEqual(data);
+ expect(state.attachments[1]).toEqual(data);
});
it('set attachments key even if the attachments are empty', () => {
const state = {
allConversations: [{ id: 1 }],
+ attachments: {},
};
const data = [];
mutations[types.SET_ALL_ATTACHMENTS](state, { id: 1, data });
- expect(state.allConversations[0].attachments).toEqual([]);
+ expect(state.attachments[1]).toEqual([]);
});
});
describe('#ADD_CONVERSATION_ATTACHMENTS', () => {
it('add conversation attachments', () => {
const state = {
- allConversations: [{ id: 1, attachments: [] }],
+ allConversations: [{ id: 1 }],
+ attachments: {},
};
const message = {
conversation_id: 1,
@@ -398,19 +398,13 @@ describe('#mutations', () => {
};
mutations[types.ADD_CONVERSATION_ATTACHMENTS](state, message);
- expect(state.allConversations[0].attachments).toEqual(
- message.attachments
- );
+ expect(state.attachments[1]).toEqual(message.attachments);
});
it('should not add duplicate attachments', () => {
const state = {
- allConversations: [
- {
- id: 1,
- attachments: [{ id: 1, name: 'existing' }],
- },
- ],
+ allConversations: [{ id: 1 }],
+ attachments: { 1: [{ id: 1, name: 'existing' }] },
};
const message = {
conversation_id: 1,
@@ -422,12 +416,12 @@ describe('#mutations', () => {
};
mutations[types.ADD_CONVERSATION_ATTACHMENTS](state, message);
- expect(state.allConversations[0].attachments).toHaveLength(2);
- expect(state.allConversations[0].attachments).toContainEqual({
+ expect(state.attachments[1]).toHaveLength(2);
+ expect(state.attachments[1]).toContainEqual({
id: 1,
name: 'existing',
});
- expect(state.allConversations[0].attachments).toContainEqual({
+ expect(state.attachments[1]).toContainEqual({
id: 2,
name: 'new',
});
@@ -436,6 +430,9 @@ describe('#mutations', () => {
it('should not add attachments if chat not found', () => {
const state = {
allConversations: [{ id: 1, attachments: [] }],
+ attachments: {
+ 1: [],
+ },
};
const message = {
conversation_id: 2,
@@ -444,14 +441,17 @@ describe('#mutations', () => {
};
mutations[types.ADD_CONVERSATION_ATTACHMENTS](state, message);
- expect(state.allConversations[0].attachments).toHaveLength(0);
+ expect(state.attachments[1]).toHaveLength(0);
});
});
describe('#DELETE_CONVERSATION_ATTACHMENTS', () => {
it('delete conversation attachments', () => {
const state = {
- allConversations: [{ id: 1, attachments: [{ id: 1, message_id: 1 }] }],
+ allConversations: [{ id: 1 }],
+ attachments: {
+ 1: [{ id: 1, message_id: 1 }],
+ },
};
const message = {
conversation_id: 1,
@@ -460,12 +460,15 @@ describe('#mutations', () => {
};
mutations[types.DELETE_CONVERSATION_ATTACHMENTS](state, message);
- expect(state.allConversations[0].attachments).toHaveLength(0);
+ expect(state.attachments[1]).toHaveLength(0);
});
it('should not delete attachments for non-matching message id', () => {
const state = {
- allConversations: [{ id: 1, attachments: [{ id: 1, message_id: 1 }] }],
+ allConversations: [{ id: 1 }],
+ attachments: {
+ 1: [{ id: 1, message_id: 1 }],
+ },
};
const message = {
conversation_id: 1,
@@ -474,12 +477,13 @@ describe('#mutations', () => {
};
mutations[types.DELETE_CONVERSATION_ATTACHMENTS](state, message);
- expect(state.allConversations[0].attachments).toHaveLength(1);
+ expect(state.attachments[1]).toHaveLength(1);
});
it('should not delete attachments if chat not found', () => {
const state = {
- allConversations: [{ id: 1, attachments: [{ id: 1, message_id: 1 }] }],
+ allConversations: [{ id: 1 }],
+ attachments: { 1: [{ id: 1, message_id: 1 }] },
};
const message = {
conversation_id: 2,
@@ -488,7 +492,7 @@ describe('#mutations', () => {
};
mutations[types.DELETE_CONVERSATION_ATTACHMENTS](state, message);
- expect(state.allConversations[0].attachments).toHaveLength(1);
+ expect(state.attachments[1]).toHaveLength(1);
});
});
diff --git a/app/javascript/dashboard/store/modules/specs/csat/actions.spec.js b/app/javascript/dashboard/store/modules/specs/csat/actions.spec.js
index 475559b34..d29d79a54 100644
--- a/app/javascript/dashboard/store/modules/specs/csat/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/csat/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/customViews/actions.spec.js b/app/javascript/dashboard/store/modules/specs/customViews/actions.spec.js
index 8fe3c96aa..ff04206c6 100644
--- a/app/javascript/dashboard/store/modules/specs/customViews/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/customViews/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/dashboardApps/actions.spec.js b/app/javascript/dashboard/store/modules/specs/dashboardApps/actions.spec.js
index 0a214108f..ee39ea881 100644
--- a/app/javascript/dashboard/store/modules/specs/dashboardApps/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/dashboardApps/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/draftMessages/actions.spec.js b/app/javascript/dashboard/store/modules/specs/draftMessages/actions.spec.js
index 6260c6cef..c9f763792 100644
--- a/app/javascript/dashboard/store/modules/specs/draftMessages/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/draftMessages/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/inboxAssignableMembers/actions.spec.js b/app/javascript/dashboard/store/modules/specs/inboxAssignableMembers/actions.spec.js
index 39b21b3c0..eac8e7d08 100644
--- a/app/javascript/dashboard/store/modules/specs/inboxAssignableMembers/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/inboxAssignableMembers/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/inboxes/actions.spec.js b/app/javascript/dashboard/store/modules/specs/inboxes/actions.spec.js
index fb8ce3abf..8e917467a 100644
--- a/app/javascript/dashboard/store/modules/specs/inboxes/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/inboxes/actions.spec.js
@@ -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 } });
}
diff --git a/app/javascript/dashboard/store/modules/specs/integrations/actions.spec.js b/app/javascript/dashboard/store/modules/specs/integrations/actions.spec.js
index b6dbcca96..561ebb4fe 100644
--- a/app/javascript/dashboard/store/modules/specs/integrations/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/integrations/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/integrations/getters.spec.js b/app/javascript/dashboard/store/modules/specs/integrations/getters.spec.js
index 43080a7d8..feb358684 100644
--- a/app/javascript/dashboard/store/modules/specs/integrations/getters.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/integrations/getters.spec.js
@@ -1,60 +1,9 @@
import { getters } from '../../integrations';
describe('#getters', () => {
- it('getIntegrations', () => {
- const state = {
- records: [
- {
- id: 'test1',
- name: 'test1',
- logo: 'test',
- enabled: true,
- },
- {
- id: 'test2',
- name: 'test2',
- logo: 'test',
- enabled: true,
- },
- {
- id: 'dyte',
- name: 'dyte',
- logo: 'test',
- enabled: true,
- },
- {
- id: 'dialogflow',
- name: 'dialogflow',
- logo: 'test',
- enabled: true,
- },
- ],
- };
- expect(getters.getIntegrations(state)).toEqual([
- {
- id: 'test1',
- name: 'test1',
- logo: 'test',
- enabled: true,
- },
- {
- id: 'test2',
- name: 'test2',
- logo: 'test',
- enabled: true,
- },
- ]);
- });
-
it('getAppIntegrations', () => {
const state = {
records: [
- {
- id: 'test1',
- name: 'test1',
- logo: 'test',
- enabled: true,
- },
{
id: 'dyte',
name: 'dyte',
diff --git a/app/javascript/dashboard/store/modules/specs/labels/actions.spec.js b/app/javascript/dashboard/store/modules/specs/labels/actions.spec.js
index 0918949ef..9ffefc276 100644
--- a/app/javascript/dashboard/store/modules/specs/labels/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/labels/actions.spec.js
@@ -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 } });
}
diff --git a/app/javascript/dashboard/store/modules/specs/macros/actions.spec.js b/app/javascript/dashboard/store/modules/specs/macros/actions.spec.js
index 95bba8e1d..435d30cf4 100644
--- a/app/javascript/dashboard/store/modules/specs/macros/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/macros/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/notifications/actions.spec.js b/app/javascript/dashboard/store/modules/specs/notifications/actions.spec.js
index 7b772634c..b81d9c68d 100644
--- a/app/javascript/dashboard/store/modules/specs/notifications/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/notifications/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/reports/actions.spec.js b/app/javascript/dashboard/store/modules/specs/reports/actions.spec.js
index a6e87e1a1..da3c715c4 100644
--- a/app/javascript/dashboard/store/modules/specs/reports/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/reports/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/sla/actions.spec.js b/app/javascript/dashboard/store/modules/specs/sla/actions.spec.js
index 12895ec2f..55bd5a3ed 100644
--- a/app/javascript/dashboard/store/modules/specs/sla/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/sla/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/slaReports/actions.spec.js b/app/javascript/dashboard/store/modules/specs/slaReports/actions.spec.js
index fb350c937..41797cded 100644
--- a/app/javascript/dashboard/store/modules/specs/slaReports/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/slaReports/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/teamMembers/actions.spec.js b/app/javascript/dashboard/store/modules/specs/teamMembers/actions.spec.js
index d293a19eb..b4d4b0a93 100644
--- a/app/javascript/dashboard/store/modules/specs/teamMembers/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/teamMembers/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/teams/actions.spec.js b/app/javascript/dashboard/store/modules/specs/teams/actions.spec.js
index 909f54e6f..7359f82b6 100644
--- a/app/javascript/dashboard/store/modules/specs/teams/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/teams/actions.spec.js
@@ -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] });
}
diff --git a/app/javascript/dashboard/store/modules/specs/userNotificationSettings/actions.spec.js b/app/javascript/dashboard/store/modules/specs/userNotificationSettings/actions.spec.js
index eca5e9d83..e8707cdc5 100644
--- a/app/javascript/dashboard/store/modules/specs/userNotificationSettings/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/userNotificationSettings/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/dashboard/store/modules/specs/webhooks/actions.spec.js b/app/javascript/dashboard/store/modules/specs/webhooks/actions.spec.js
index 0cb8b8787..bacdac1e9 100644
--- a/app/javascript/dashboard/store/modules/specs/webhooks/actions.spec.js
+++ b/app/javascript/dashboard/store/modules/specs/webhooks/actions.spec.js
@@ -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', () => {
diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js
index bbf36fa9a..81e62b950 100644
--- a/app/javascript/packs/application.js
+++ b/app/javascript/packs/application.js
@@ -9,7 +9,6 @@ import VueFormulate from '@braid/vue-formulate';
import WootSwitch from 'components/ui/Switch';
import WootWizard from 'components/ui/Wizard';
import { sync } from 'vuex-router-sync';
-import Vuelidate from 'vuelidate';
import VTooltip from 'v-tooltip';
import WootUiKit from '../dashboard/components';
import App from '../dashboard/App';
@@ -65,7 +64,6 @@ Vue.use(VueDOMPurifyHTML, domPurifyConfig);
Vue.use(VueRouter);
Vue.use(VueI18n);
Vue.use(WootUiKit);
-Vue.use(Vuelidate);
Vue.use(VueFormulate, {
rules: {
JSON: ({ value }) => isJSONValid(value),
diff --git a/app/javascript/packs/survey.js b/app/javascript/packs/survey.js
index 031767052..fdcaec106 100644
--- a/app/javascript/packs/survey.js
+++ b/app/javascript/packs/survey.js
@@ -1,5 +1,4 @@
import Vue from 'vue';
-import Vuelidate from 'vuelidate';
import VueI18n from 'vue-i18n';
import App from '../survey/App.vue';
import i18n from '../survey/i18n';
@@ -7,7 +6,6 @@ import store from '../survey/store';
import { emitter } from 'shared/helpers/mitt';
Vue.use(VueI18n);
-Vue.use(Vuelidate);
const i18nConfig = new VueI18n({
locale: 'en',
diff --git a/app/javascript/packs/v3app.js b/app/javascript/packs/v3app.js
index 5807ff60f..d5180675c 100644
--- a/app/javascript/packs/v3app.js
+++ b/app/javascript/packs/v3app.js
@@ -1,7 +1,6 @@
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import VueRouter from 'vue-router';
-import Vuelidate from 'vuelidate';
import i18n from 'dashboard/i18n';
import * as Sentry from '@sentry/vue';
import { Integrations } from '@sentry/tracing';
@@ -44,7 +43,7 @@ if (window.errorLoggingConfig) {
Vue.use(VueRouter);
Vue.use(VueI18n);
-Vue.use(Vuelidate);
+
Vue.use(AnalyticsPlugin);
Vue.prototype.$emitter = emitter;
Vue.component('fluent-icon', FluentIcon);
diff --git a/app/javascript/packs/widget.js b/app/javascript/packs/widget.js
index ea3bb8200..a6c873c55 100644
--- a/app/javascript/packs/widget.js
+++ b/app/javascript/packs/widget.js
@@ -1,5 +1,4 @@
import Vue from 'vue';
-import Vuelidate from 'vuelidate';
import VueI18n from 'vue-i18n';
import VueDOMPurifyHTML from 'vue-dompurify-html';
import VueFormulate from '@braid/vue-formulate';
@@ -18,7 +17,7 @@ import { domPurifyConfig } from '../shared/helpers/HTMLSanitizer';
const PhoneInput = () => import('../widget/components/Form/PhoneInput');
Vue.use(VueI18n);
-Vue.use(Vuelidate);
+
Vue.use(VueDOMPurifyHTML, domPurifyConfig);
Vue.directive('on-clickaway', onClickaway);
diff --git a/app/javascript/portal/components/PublicArticleSearch.vue b/app/javascript/portal/components/PublicArticleSearch.vue
index 1174c636c..3e4be5ba9 100644
--- a/app/javascript/portal/components/PublicArticleSearch.vue
+++ b/app/javascript/portal/components/PublicArticleSearch.vue
@@ -1,27 +1,3 @@
-
-
-
-
+
+
+
+
diff --git a/app/javascript/portal/components/PublicSearchInput.vue b/app/javascript/portal/components/PublicSearchInput.vue
index ffa0f99a7..08dd5e1cf 100644
--- a/app/javascript/portal/components/PublicSearchInput.vue
+++ b/app/javascript/portal/components/PublicSearchInput.vue
@@ -1,25 +1,3 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/app/javascript/portal/components/SearchSuggestions.vue b/app/javascript/portal/components/SearchSuggestions.vue
index 2c9697e14..68abe44f5 100644
--- a/app/javascript/portal/components/SearchSuggestions.vue
+++ b/app/javascript/portal/components/SearchSuggestions.vue
@@ -1,60 +1,10 @@
-
-
-
- {{ loadingPlaceholder }}
-
-
-
-
- {{ emptyPlaceholder }}
-
-
-
-
+
+
+
+
+ {{ loadingPlaceholder }}
+
+
+
+
+ {{ emptyPlaceholder }}
+
+
+
diff --git a/app/javascript/portal/components/TableOfContents.vue b/app/javascript/portal/components/TableOfContents.vue
index d7b3bb021..d907bc49e 100644
--- a/app/javascript/portal/components/TableOfContents.vue
+++ b/app/javascript/portal/components/TableOfContents.vue
@@ -1,33 +1,3 @@
-
-
-
+
+
+
+
diff --git a/app/javascript/portal/portalHelpers.js b/app/javascript/portal/portalHelpers.js
index 3e9690b20..dfe2951f0 100644
--- a/app/javascript/portal/portalHelpers.js
+++ b/app/javascript/portal/portalHelpers.js
@@ -33,7 +33,7 @@ export const openExternalLinksInNewTab = () => {
const isOnArticlePage =
isSameHost && document.querySelector('#cw-article-content') !== null;
- document.addEventListener('click', function (event) {
+ document.addEventListener('click', event => {
if (!isOnArticlePage) return;
// Some of the links come wrapped in strong tag through prosemirror
diff --git a/app/javascript/portal/specs/portal.spec.js b/app/javascript/portal/specs/portal.spec.js
index cd4347bad..13edd3718 100644
--- a/app/javascript/portal/specs/portal.spec.js
+++ b/app/javascript/portal/specs/portal.spec.js
@@ -1,21 +1,44 @@
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
+import { JSDOM } from 'jsdom';
import { InitializationHelpers } from '../portalHelpers';
-describe('#navigateToLocalePage', () => {
- it('returns correct cookie name', () => {
- const elemDiv = document.createElement('div');
- elemDiv.classList.add('locale-switcher');
- document.body.appendChild(elemDiv);
+describe('InitializationHelpers.navigateToLocalePage', () => {
+ let dom;
+ let document;
+ let window;
- const allLocaleSwitcher = document.querySelector('.locale-switcher');
+ beforeEach(() => {
+ dom = new JSDOM(
+ '
',
+ { url: 'http://localhost/' }
+ );
+ document = dom.window.document;
+ window = dom.window;
+ global.document = document;
+ global.window = window;
+ });
- allLocaleSwitcher.addEventListener = jest
- .fn()
- .mockImplementationOnce((event, callback) => {
- callback({ target: { value: 1 } });
- });
+ afterEach(() => {
+ dom = null;
+ document = null;
+ window = null;
+ delete global.document;
+ delete global.window;
+ });
+
+ it('should return false if .locale-switcher is not found', () => {
+ document.querySelector('.locale-switcher').remove();
+ const result = InitializationHelpers.navigateToLocalePage();
+ expect(result).toBe(false);
+ });
+
+ it('should add change event listener to .locale-switcher', () => {
+ const localeSwitcher = document.querySelector('.locale-switcher');
+ const addEventListenerSpy = vi.spyOn(localeSwitcher, 'addEventListener');
InitializationHelpers.navigateToLocalePage();
- expect(allLocaleSwitcher.addEventListener).toBeCalledWith(
+
+ expect(addEventListenerSpy).toHaveBeenCalledWith(
'change',
expect.any(Function)
);
diff --git a/app/javascript/portal/specs/portalTheme.spec.js b/app/javascript/portal/specs/portalTheme.spec.js
index cc4a766e0..e87999242 100644
--- a/app/javascript/portal/specs/portalTheme.spec.js
+++ b/app/javascript/portal/specs/portalTheme.spec.js
@@ -23,17 +23,17 @@ describe('portalThemeHelper', () => {
appearanceDropdown.id = 'appearance-dropdown';
document.body.appendChild(appearanceDropdown);
- window.matchMedia = jest.fn().mockImplementation(query => ({
+ window.matchMedia = vi.fn().mockImplementation(query => ({
matches: query === '(prefers-color-scheme: dark)',
- addEventListener: jest.fn(),
- removeEventListener: jest.fn(),
+ addEventListener: vi.fn(),
+ removeEventListener: vi.fn(),
}));
window.portalConfig = { portalColor: '#ff5733' };
- document.documentElement.style.setProperty = jest.fn();
+ document.documentElement.style.setProperty = vi.fn();
document.documentElement.classList.remove('dark', 'light');
- jest.clearAllMocks();
+ vi.clearAllMocks();
});
afterEach(() => {
@@ -72,7 +72,7 @@ describe('portalThemeHelper', () => {
originalLocation = window.location;
delete window.location;
window.location = new URL('http://localhost:3000/');
- window.history.replaceState = jest.fn();
+ window.history.replaceState = vi.fn();
});
afterEach(() => {
@@ -123,7 +123,7 @@ describe('portalThemeHelper', () => {
describe('#switchTheme', () => {
it('should set theme to system theme and update classes', () => {
- window.matchMedia = jest.fn().mockReturnValue({ matches: true });
+ window.matchMedia = vi.fn().mockReturnValue({ matches: true });
switchTheme('system');
expect(localStorage.theme).toBeUndefined();
expect(document.documentElement.classList).toContain('dark');
@@ -198,10 +198,10 @@ describe('portalThemeHelper', () => {
beforeEach(() => {
mediaQuery = {
- addEventListener: jest.fn(),
+ addEventListener: vi.fn(),
matches: false,
};
- window.matchMedia = jest.fn().mockReturnValue(mediaQuery);
+ window.matchMedia = vi.fn().mockReturnValue(mediaQuery);
});
it('adds a listener to the media query', () => {
diff --git a/app/javascript/sdk/IFrameHelper.js b/app/javascript/sdk/IFrameHelper.js
index 275d082f5..8f6716f1c 100644
--- a/app/javascript/sdk/IFrameHelper.js
+++ b/app/javascript/sdk/IFrameHelper.js
@@ -14,7 +14,6 @@ import {
chatBubble,
closeBubble,
bubbleHolder,
- createNotificationBubble,
onClickChatBubble,
onBubbleClick,
setBubbleText,
@@ -315,7 +314,6 @@ export const IFrameHelper = {
bubbleHolder.appendChild(chatIcon);
bubbleHolder.appendChild(closeBubble);
- bubbleHolder.appendChild(createNotificationBubble());
onClickChatBubble();
},
toggleCloseButton: () => {
diff --git a/app/javascript/sdk/bubbleHelpers.js b/app/javascript/sdk/bubbleHelpers.js
index 600c1444a..609fe04da 100644
--- a/app/javascript/sdk/bubbleHelpers.js
+++ b/app/javascript/sdk/bubbleHelpers.js
@@ -65,11 +65,6 @@ export const createBubbleHolder = hideMessageBubble => {
body.appendChild(bubbleHolder);
};
-export const createNotificationBubble = () => {
- addClasses(notificationBubble, 'woot--notification');
- return notificationBubble;
-};
-
export const onBubbleClick = (props = {}) => {
const { toggleValue } = props;
const { isOpen } = window.$chatwoot;
diff --git a/app/javascript/sdk/specs/cookieHelpers.spec.js b/app/javascript/sdk/specs/cookieHelpers.spec.js
index 6ede978fc..746a35f99 100644
--- a/app/javascript/sdk/specs/cookieHelpers.spec.js
+++ b/app/javascript/sdk/specs/cookieHelpers.spec.js
@@ -51,28 +51,24 @@ describe('#hasUserKeys', () => {
});
// Mock the 'set' method of the 'Cookies' object
-jest.mock('js-cookie', () => ({
- set: jest.fn(),
-}));
describe('setCookieWithDomain', () => {
+ beforeEach(() => {
+ vi.spyOn(Cookies, 'set');
+ });
+
afterEach(() => {
- // Clear mock calls after each test
- Cookies.set.mockClear();
+ vi.restoreAllMocks();
});
it('should set a cookie with default parameters', () => {
setCookieWithDomain('myCookie', 'cookieValue');
- expect(Cookies.set).toHaveBeenCalledWith(
- 'myCookie',
- 'cookieValue',
- expect.objectContaining({
- expires: 365,
- sameSite: 'Lax',
- domain: undefined,
- })
- );
+ expect(Cookies.set).toHaveBeenCalledWith('myCookie', 'cookieValue', {
+ expires: 365,
+ sameSite: 'Lax',
+ domain: undefined,
+ });
});
it('should set a cookie with custom expiration and sameSite attribute', () => {
@@ -80,15 +76,11 @@ describe('setCookieWithDomain', () => {
expires: 30,
});
- expect(Cookies.set).toHaveBeenCalledWith(
- 'myCookie',
- 'cookieValue',
- expect.objectContaining({
- expires: 30,
- sameSite: 'Lax',
- domain: undefined,
- })
- );
+ expect(Cookies.set).toHaveBeenCalledWith('myCookie', 'cookieValue', {
+ expires: 30,
+ sameSite: 'Lax',
+ domain: undefined,
+ });
});
it('should set a cookie with a specific base domain', () => {
@@ -96,18 +88,14 @@ describe('setCookieWithDomain', () => {
baseDomain: 'example.com',
});
- expect(Cookies.set).toHaveBeenCalledWith(
- 'myCookie',
- 'cookieValue',
- expect.objectContaining({
- expires: 365,
- sameSite: 'Lax',
- domain: 'example.com',
- })
- );
+ expect(Cookies.set).toHaveBeenCalledWith('myCookie', 'cookieValue', {
+ expires: 365,
+ sameSite: 'Lax',
+ domain: 'example.com',
+ });
});
- it('should stringify the cookie value when setting', () => {
+ it('should stringify the cookie value when setting the value', () => {
setCookieWithDomain(
'myCookie',
{ value: 'cookieValue' },
@@ -119,11 +107,11 @@ describe('setCookieWithDomain', () => {
expect(Cookies.set).toHaveBeenCalledWith(
'myCookie',
JSON.stringify({ value: 'cookieValue' }),
- expect.objectContaining({
+ {
expires: 365,
sameSite: 'Lax',
domain: 'example.com',
- })
+ }
);
});
@@ -133,14 +121,10 @@ describe('setCookieWithDomain', () => {
baseDomain: 'example.com',
});
- expect(Cookies.set).toHaveBeenCalledWith(
- 'myCookie',
- 'cookieValue',
- expect.objectContaining({
- expires: 7,
- sameSite: 'Lax',
- domain: 'example.com',
- })
- );
+ expect(Cookies.set).toHaveBeenCalledWith('myCookie', 'cookieValue', {
+ expires: 7,
+ sameSite: 'Lax',
+ domain: 'example.com',
+ });
});
});
diff --git a/app/javascript/shared/components/Branding.vue b/app/javascript/shared/components/Branding.vue
index bbeb578e9..8034e3506 100644
--- a/app/javascript/shared/components/Branding.vue
+++ b/app/javascript/shared/components/Branding.vue
@@ -1,27 +1,3 @@
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/app/javascript/survey/components/Banner.vue b/app/javascript/survey/components/Banner.vue
index b178b6797..f2a907bf6 100644
--- a/app/javascript/survey/components/Banner.vue
+++ b/app/javascript/survey/components/Banner.vue
@@ -1,16 +1,3 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/app/javascript/survey/components/Feedback.vue b/app/javascript/survey/components/Feedback.vue
index 2b870cc47..fcae0cb31 100644
--- a/app/javascript/survey/components/Feedback.vue
+++ b/app/javascript/survey/components/Feedback.vue
@@ -1,22 +1,3 @@
-
-
-
-
-
-
-
- {{ $t('SURVEY.FEEDBACK.BUTTON_TEXT') }}
-
-
-
-
-
+
+
+
+
+
+
+
+
+ {{ $t('SURVEY.FEEDBACK.BUTTON_TEXT') }}
+
+
+
+
diff --git a/app/javascript/survey/components/Rating.vue b/app/javascript/survey/components/Rating.vue
index 530bc6c21..8d1e84bcf 100644
--- a/app/javascript/survey/components/Rating.vue
+++ b/app/javascript/survey/components/Rating.vue
@@ -1,18 +1,3 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/app/javascript/widget/api/specs/endPoints.spec.js b/app/javascript/widget/api/specs/endPoints.spec.js
index 13e57a034..0216caed9 100644
--- a/app/javascript/widget/api/specs/endPoints.spec.js
+++ b/app/javascript/widget/api/specs/endPoints.spec.js
@@ -2,22 +2,21 @@ import endPoints from '../endPoints';
describe('#sendMessage', () => {
it('returns correct payload', () => {
- const spy = jest.spyOn(global, 'Date').mockImplementation(() => ({
+ const spy = vi.spyOn(global, 'Date').mockImplementation(() => ({
toString: () => 'mock date',
}));
- const windowSpy = jest.spyOn(window, 'window', 'get');
- windowSpy.mockImplementation(() => ({
- WOOT_WIDGET: {
- $root: {
- $i18n: {
- locale: 'ar',
- },
+ vi.spyOn(window, 'location', 'get').mockReturnValue({
+ ...window.location,
+ search: '?param=1',
+ });
+
+ window.WOOT_WIDGET = {
+ $root: {
+ $i18n: {
+ locale: 'ar',
},
},
- location: {
- search: '?param=1',
- },
- }));
+ };
expect(endPoints.sendMessage('hello')).toEqual({
url: `/api/v1/widget/messages?param=1&locale=ar`,
@@ -29,13 +28,16 @@ describe('#sendMessage', () => {
},
},
});
- windowSpy.mockRestore();
spy.mockRestore();
});
});
describe('#getConversation', () => {
it('returns correct payload', () => {
+ vi.spyOn(window, 'location', 'get').mockReturnValue({
+ ...window.location,
+ search: '',
+ });
expect(endPoints.getConversation({ before: 123 })).toEqual({
url: `/api/v1/widget/messages`,
params: {
@@ -47,10 +49,13 @@ describe('#getConversation', () => {
describe('#triggerCampaign', () => {
it('should returns correct payload', () => {
- const spy = jest.spyOn(global, 'Date').mockImplementation(() => ({
+ const spy = vi.spyOn(global, 'Date').mockImplementation(() => ({
toString: () => 'mock date',
}));
- const windowSpy = jest.spyOn(window, 'window', 'get');
+ vi.spyOn(window, 'location', 'get').mockReturnValue({
+ ...window.location,
+ search: '',
+ });
const websiteToken = 'ADSDJ2323MSDSDFMMMASDM';
const campaignId = 12;
expect(
@@ -74,7 +79,6 @@ describe('#triggerCampaign', () => {
website_token: websiteToken,
},
});
- windowSpy.mockRestore();
spy.mockRestore();
});
@@ -82,10 +86,13 @@ describe('#triggerCampaign', () => {
describe('#getConversation', () => {
it('should returns correct payload', () => {
- const spy = jest.spyOn(global, 'Date').mockImplementation(() => ({
+ const spy = vi.spyOn(global, 'Date').mockImplementation(() => ({
toString: () => 'mock date',
}));
- const windowSpy = jest.spyOn(window, 'window', 'get');
+ vi.spyOn(window, 'location', 'get').mockReturnValue({
+ ...window.location,
+ search: '',
+ });
expect(
endPoints.getConversation({
after: 123,
@@ -97,7 +104,6 @@ describe('#getConversation', () => {
before: undefined,
},
});
- windowSpy.mockRestore();
spy.mockRestore();
});
diff --git a/app/javascript/widget/components/AgentMessage.vue b/app/javascript/widget/components/AgentMessage.vue
index eb64e0c36..3296d5128 100755
--- a/app/javascript/widget/components/AgentMessage.vue
+++ b/app/javascript/widget/components/AgentMessage.vue
@@ -1,89 +1,10 @@
-
-
-
-
+
+
+
+
diff --git a/app/javascript/widget/components/AgentMessageBubble.vue b/app/javascript/widget/components/AgentMessageBubble.vue
index f5bad52fc..c1c0cc8d0 100755
--- a/app/javascript/widget/components/AgentMessageBubble.vue
+++ b/app/javascript/widget/components/AgentMessageBubble.vue
@@ -1,64 +1,3 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/javascript/widget/components/AgentTypingBubble.vue b/app/javascript/widget/components/AgentTypingBubble.vue
index e8f8e7b09..a84d8fc7b 100644
--- a/app/javascript/widget/components/AgentTypingBubble.vue
+++ b/app/javascript/widget/components/AgentTypingBubble.vue
@@ -1,3 +1,11 @@
+
+
@@ -17,14 +25,6 @@
-
-
+
+
+
diff --git a/app/javascript/widget/components/ArticleList.vue b/app/javascript/widget/components/ArticleList.vue
index 4043bf060..5aef7e265 100644
--- a/app/javascript/widget/components/ArticleList.vue
+++ b/app/javascript/widget/components/ArticleList.vue
@@ -1,15 +1,3 @@
-
-
-
-
+
+
+
+
diff --git a/app/javascript/widget/components/ArticleListItem.vue b/app/javascript/widget/components/ArticleListItem.vue
index f16afa5e1..a7e828649 100644
--- a/app/javascript/widget/components/ArticleListItem.vue
+++ b/app/javascript/widget/components/ArticleListItem.vue
@@ -1,18 +1,3 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/app/javascript/widget/components/ArticleSearch.vue b/app/javascript/widget/components/ArticleSearch.vue
index 8ce663321..275d44ec1 100644
--- a/app/javascript/widget/components/ArticleSearch.vue
+++ b/app/javascript/widget/components/ArticleSearch.vue
@@ -1,29 +1,3 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+ {{ '⌘K' }}
+
+
+
+
diff --git a/app/javascript/widget/components/AvailableAgents.vue b/app/javascript/widget/components/AvailableAgents.vue
index 7e51b887b..10ecd7afb 100644
--- a/app/javascript/widget/components/AvailableAgents.vue
+++ b/app/javascript/widget/components/AvailableAgents.vue
@@ -1,7 +1,3 @@
-
-
-
-
+
+
+
+
diff --git a/app/javascript/widget/components/Banner.vue b/app/javascript/widget/components/Banner.vue
index 173dfabb2..bdd11a5b7 100644
--- a/app/javascript/widget/components/Banner.vue
+++ b/app/javascript/widget/components/Banner.vue
@@ -1,11 +1,3 @@
-
-
-
- {{ bannerMessage }}
-
-
-
-
+
+
+
+ {{ bannerMessage }}
+
+
+
+