From 04e7f06bacf6ad9c6f37c03197d2d75b6dd094fd Mon Sep 17 00:00:00 2001 From: dougfabris Date: Mon, 21 Oct 2024 16:53:05 -0300 Subject: [PATCH 1/2] test: ignore require contact verification --- apps/meteor/tests/e2e/fixtures/inject-initial-data.ts | 4 ++++ .../tests/e2e/omnichannel/omnichannel-current-chats.spec.ts | 1 - .../tests/e2e/omnichannel/omnichannel-livechat-api.spec.ts | 4 ---- .../omnichannel-livechat-avatar-visibility.spec.ts | 5 ----- .../e2e/omnichannel/omnichannel-livechat-department.spec.ts | 2 -- .../omnichannel-livechat-message-bubble-color.spec.ts | 4 ---- .../omnichannel-livechat-queue-management.spec.ts | 1 - 7 files changed, 4 insertions(+), 17 deletions(-) diff --git a/apps/meteor/tests/e2e/fixtures/inject-initial-data.ts b/apps/meteor/tests/e2e/fixtures/inject-initial-data.ts index 192b0ea66937..38659303903c 100644 --- a/apps/meteor/tests/e2e/fixtures/inject-initial-data.ts +++ b/apps/meteor/tests/e2e/fixtures/inject-initial-data.ts @@ -66,6 +66,10 @@ export default async function injectInitialData() { _id: 'Accounts_OAuth_Google', value: false, }, + { + _id: 'Livechat_Require_Contact_Verification', + value: 'never', + }, ].map((setting) => connection .db() diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-current-chats.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-current-chats.spec.ts index 7ad9005533d3..8e121b36ddb0 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-current-chats.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-current-chats.spec.ts @@ -30,7 +30,6 @@ test.describe('OC - Current Chats [Auto Selection]', async () => { const responses = await Promise.all([ api.post('/settings/Livechat_allow_manual_on_hold', { value: true }), api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: false }), - api.post('/settings/Livechat_Require_Contact_Verification', { value: 'never' }), ]); responses.forEach((res) => expect(res.status()).toBe(200)); }); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-api.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-api.spec.ts index 85d1f45ad981..e529746def9e 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-api.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-api.spec.ts @@ -75,10 +75,6 @@ test.describe('OC - Livechat API', () => { let agent: Awaited>; test.beforeAll(async ({ browser, api }) => { - if (IS_EE) { - await api.post('/settings/Livechat_Require_Contact_Verification', { value: 'never' }); - } - agent = await createAgent(api, 'user1'); page = await browser.newPage(); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-avatar-visibility.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-avatar-visibility.spec.ts index 54d83299fd4b..7729b5684228 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-avatar-visibility.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-avatar-visibility.spec.ts @@ -1,7 +1,6 @@ import type { Page } from '@playwright/test'; import { createFakeVisitor } from '../../mocks/data'; -import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChatEmbedded } from '../page-objects'; @@ -31,10 +30,6 @@ test.describe('OC - Livechat - Avatar visibility', async () => { if (res.status() !== 200) { throw new Error('Failed to make agent available'); } - - if (IS_EE) { - await api.post('/settings/Livechat_Require_Contact_Verification', { value: 'never' }); - } }); test.beforeEach(async ({ browser }) => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-department.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-department.spec.ts index 37d7932a7c43..0c72c8894cc4 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-department.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-department.spec.ts @@ -24,8 +24,6 @@ test.describe('OC - Livechat - Department Flow', () => { let agent2: Awaited>['data']; test.beforeAll(async ({ api }) => { - await api.post('/settings/Livechat_Require_Contact_Verification', { value: 'never' }); - // Assign agents & departments agents = await Promise.all([createAgent(api, 'user1'), createAgent(api, 'user2')]); [agent1, agent2] = agents.map(({ data }) => data); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-message-bubble-color.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-message-bubble-color.spec.ts index e3a124a4f2de..70d0441db5e1 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-message-bubble-color.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-message-bubble-color.spec.ts @@ -1,7 +1,6 @@ import type { Page } from '@playwright/test'; import { createFakeVisitor } from '../../mocks/data'; -import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChatEmbedded } from '../page-objects'; @@ -25,9 +24,6 @@ test.describe('OC - Livechat - Bubble background color', async () => { test.beforeAll(async ({ api }) => { agent = await createAgent(api, 'user1'); - if (IS_EE) { - await api.post('/settings/Livechat_Require_Contact_Verification', { value: 'never' }); - } const res = await makeAgentAvailable(api, agent.data._id); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-queue-management.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-queue-management.spec.ts index ce33f8bc1e58..ee91c49bfb16 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-queue-management.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-queue-management.spec.ts @@ -27,7 +27,6 @@ test.describe('OC - Livechat - Queue Management', () => { api.post('/settings/Livechat_waiting_queue', { value: true }), api.post('/settings/Livechat_waiting_queue_message', { value: waitingQueueMessage }), api.post('/livechat/users/agent', { username: 'user1' }), - api.post('/settings/Livechat_Require_Contact_Verification', { value: 'never' }), ]); const { page: omniPage } = await createAuxContext(browser, Users.user1, '/', true); From c790f8663678e8967cee75ae621d2484a7548e94 Mon Sep 17 00:00:00 2001 From: gustrb Date: Tue, 22 Oct 2024 09:12:45 -0300 Subject: [PATCH 2/2] fix: throw Meteor.Error instead of Error --- apps/meteor/app/livechat/server/methods/takeInquiry.ts | 4 ++-- packages/i18n/src/locales/en.i18n.json | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/meteor/app/livechat/server/methods/takeInquiry.ts b/apps/meteor/app/livechat/server/methods/takeInquiry.ts index 98dab4e1ed6b..bca805237d65 100644 --- a/apps/meteor/app/livechat/server/methods/takeInquiry.ts +++ b/apps/meteor/app/livechat/server/methods/takeInquiry.ts @@ -52,12 +52,12 @@ export const takeInquiry = async ( const room = await LivechatRooms.findOneById(inquiry.rid); if (!room || !(await Omnichannel.isWithinMACLimit(room))) { - throw new Error('error-mac-limit-reached'); + throw new Meteor.Error('error-mac-limit-reached'); } const contactId = await migrateVisitorIfMissingContact(inquiry.v._id, room.source); if (contactId && (await shouldTriggerVerificationApp(contactId, room.source))) { - throw new Error('error-unverified-contact'); + throw new Meteor.Error('error-unverified-contact'); } const agent = { diff --git a/packages/i18n/src/locales/en.i18n.json b/packages/i18n/src/locales/en.i18n.json index f30a89b45480..e482f17bbd2f 100644 --- a/packages/i18n/src/locales/en.i18n.json +++ b/packages/i18n/src/locales/en.i18n.json @@ -2183,6 +2183,7 @@ "error-max-number-simultaneous-chats-reached": "The maximum number of simultaneous chats per agent has been reached.", "error-max-rooms-per-guest-reached": "The maximum number of rooms per guest has been reached.", "error-mac-limit-reached": "The maximum number of monthly active contacts for this workspace has been reached.", + "error-unverified-contact": "The contact must be verified.", "error-message-deleting-blocked": "Message deleting is blocked", "error-message-editing-blocked": "Message editing is blocked", "error-message-size-exceeded": "Message size exceeds Message_MaxAllowedSize",