Skip to content

Commit

Permalink
change new setting value on existing EE tests to match old behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-lehnen-rc committed Oct 21, 2024
1 parent 0ae0f31 commit 8f66997
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ 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));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ test.describe('OC - Livechat API', () => {
let agent: Awaited<ReturnType<typeof createAgent>>;

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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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';
Expand Down Expand Up @@ -30,6 +31,10 @@ 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 }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ test.describe('OC - Livechat - Department Flow', () => {
let agent2: Awaited<ReturnType<typeof createAgent>>['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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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';
Expand All @@ -24,6 +25,9 @@ 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ 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);
Expand Down
4 changes: 0 additions & 4 deletions apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ describe('LIVECHAT - rooms', () => {
room = await createLivechatRoom(visitor.token);
});

after(async () => {
await updateEESetting('Livechat_Require_Contact_Verification', 'always');
});

describe('livechat/room', () => {
it('should fail when token is not passed as query parameter', async () => {
await request.get(api('livechat/room')).expect(400);
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/tests/end-to-end/api/livechat/01-agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
moveBackToQueue,
closeOmnichannelRoom,
} from '../../../data/livechat/rooms';
import { updatePermission, updateSetting } from '../../../data/permissions.helper';
import { updateEESetting, updatePermission, updateSetting } from '../../../data/permissions.helper';
import { password } from '../../../data/user';
import { createUser, deleteUser, getMe, login, setUserStatus } from '../../../data/users.helper';
import { IS_EE } from '../../../e2e/config/constants';
Expand All @@ -36,6 +36,7 @@ describe('LIVECHAT - Agents', () => {
before(async () => {
await updateSetting('Livechat_enabled', true);
await updateSetting('Livechat_Routing_Method', 'Manual_Selection');
await updateEESetting('Livechat_Require_Contact_Verification', 'never');
agent = await createAgent();
manager = await createManager();
});
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/tests/end-to-end/api/livechat/04-dashboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '../../../data/livechat/rooms';
import { createAnOnlineAgent } from '../../../data/livechat/users';
import { sleep } from '../../../data/livechat/utils';
import { removePermissionFromAllRoles, restorePermissionToRoles, updateSetting } from '../../../data/permissions.helper';
import { removePermissionFromAllRoles, restorePermissionToRoles, updateEESetting, updateSetting } from '../../../data/permissions.helper';
import { deleteUser } from '../../../data/users.helper';
import { IS_EE } from '../../../e2e/config/constants';

Expand All @@ -30,6 +30,7 @@ describe('LIVECHAT - dashboards', function () {

before(async () => {
await updateSetting('Livechat_enabled', true);
await updateEESetting('Livechat_Require_Contact_Verification', 'never');
});

let department: ILivechatDepartment;
Expand Down
9 changes: 8 additions & 1 deletion apps/meteor/tests/end-to-end/api/livechat/05-inquiries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ import {
takeInquiry,
} from '../../../data/livechat/rooms';
import { parseMethodResponse } from '../../../data/livechat/utils';
import { removePermissionFromAllRoles, restorePermissionToRoles, updatePermission, updateSetting } from '../../../data/permissions.helper';
import {
removePermissionFromAllRoles,
restorePermissionToRoles,
updateEESetting,
updatePermission,
updateSetting,
} from '../../../data/permissions.helper';
import { password } from '../../../data/user';
import { createUser, login, deleteUser } from '../../../data/users.helper';
import { IS_EE } from '../../../e2e/config/constants';
Expand All @@ -28,6 +34,7 @@ describe('LIVECHAT - inquiries', () => {
before(async () => {
await updateSetting('Livechat_enabled', true);
await updateSetting('Livechat_Routing_Method', 'Manual_Selection');
await updateEESetting('Livechat_Require_Contact_Verification', 'never');
});

describe('livechat/inquiries.list', () => {
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/tests/end-to-end/api/livechat/07-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getCredentials, api, request, credentials } from '../../../data/api-dat
import { createDepartmentWithAnOnlineAgent, deleteDepartment, addOrRemoveAgentFromDepartment } from '../../../data/livechat/department';
import { createVisitor, createLivechatRoom, closeOmnichannelRoom, deleteVisitor } from '../../../data/livechat/rooms';
import { createAnOnlineAgent } from '../../../data/livechat/users';
import { updatePermission, updateSetting } from '../../../data/permissions.helper';
import { updateEESetting, updatePermission, updateSetting } from '../../../data/permissions.helper';
import { deleteUser } from '../../../data/users.helper';
import { IS_EE } from '../../../e2e/config/constants';

Expand Down Expand Up @@ -39,6 +39,7 @@ describe('LIVECHAT - Queue', () => {
Promise.all([
updateSetting('Livechat_enabled', true),
updateSetting('Livechat_Routing_Method', 'Auto_Selection'),
updateEESetting('Livechat_Require_Contact_Verification', 'never'),

// this cleanup is required since previous tests left the DB dirty
cleanupRooms(),
Expand Down
9 changes: 8 additions & 1 deletion apps/meteor/tests/end-to-end/api/livechat/09-visitors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ import {
} from '../../../data/livechat/rooms';
import { getRandomVisitorToken } from '../../../data/livechat/users';
import { getLivechatVisitorByToken } from '../../../data/livechat/visitor';
import { updatePermission, updateSetting, removePermissionFromAllRoles, restorePermissionToRoles } from '../../../data/permissions.helper';
import {
updatePermission,
updateSetting,
removePermissionFromAllRoles,
restorePermissionToRoles,
updateEESetting,
} from '../../../data/permissions.helper';
import { adminUsername } from '../../../data/user';
import { IS_EE } from '../../../e2e/config/constants';

Expand All @@ -33,6 +39,7 @@ describe('LIVECHAT - visitors', () => {
before(async () => {
await updateSetting('Livechat_enabled', true);
await updatePermission('view-livechat-manager', ['admin']);
await updateEESetting('Livechat_Require_Contact_Verification', 'never');
await createAgent();
await makeAgentAvailable();
visitor = await createVisitor();
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/tests/end-to-end/api/livechat/12-priorites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { generateRandomSLAData } from '../../../e2e/utils/omnichannel/sla';
before(async () => {
await updateSetting('Livechat_enabled', true);
await updateSetting('Livechat_Routing_Method', 'Manual_Selection');
await updateEESetting('Livechat_Require_Contact_Verification', 'never');
});

after(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import {
sendMessage,
fetchInquiry,
} from '../../../data/livechat/rooms';
import { updatePermission, updateSetting } from '../../../data/permissions.helper';
import { updateEESetting, updatePermission, updateSetting } from '../../../data/permissions.helper';
import { IS_EE } from '../../../e2e/config/constants';

(IS_EE ? describe : describe.skip)('[EE] LIVECHAT - dashboards', () => {
before((done) => getCredentials(done));

before(async () => {
await updateSetting('Livechat_enabled', true);
await updateEESetting('Livechat_Require_Contact_Verification', 'never');
await createAgent();
});

Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/tests/end-to-end/api/livechat/18-rooms-ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
fetchMessages,
} from '../../../data/livechat/rooms';
import { sleep } from '../../../data/livechat/utils';
import { updatePermission, updateSetting } from '../../../data/permissions.helper';
import { updateEESetting, updatePermission, updateSetting } from '../../../data/permissions.helper';
import { password } from '../../../data/user';
import { createUser, deleteUser, login } from '../../../data/users.helper';
import { IS_EE } from '../../../e2e/config/constants';
Expand All @@ -31,6 +31,7 @@ import { IS_EE } from '../../../e2e/config/constants';
before(async () => {
await updateSetting('Livechat_enabled', true);
await updateSetting('Livechat_Routing_Method', 'Manual_Selection');
await updateEESetting('Livechat_Require_Contact_Verification', 'never');
await createAgent();
await makeAgentAvailable();
});
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/tests/end-to-end/api/livechat/20-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
closeOmnichannelRoom,
} from '../../../data/livechat/rooms';
import { removeAgent } from '../../../data/livechat/users';
import { updateSetting } from '../../../data/permissions.helper';
import { updateEESetting, updateSetting } from '../../../data/permissions.helper';
import { createRoom, deleteRoom } from '../../../data/rooms.helper';

describe('LIVECHAT - messages', () => {
Expand All @@ -26,6 +26,7 @@ describe('LIVECHAT - messages', () => {
agent = await createAgent();
await makeAgentAvailable();
await updateSetting('Livechat_Routing_Method', 'Manual_Selection');
await updateEESetting('Livechat_Require_Contact_Verification', 'never');
});

after(() => Promise.all([updateSetting('Livechat_Routing_Method', 'Auto_Selection'), removeAgent(agent._id)]));
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/tests/end-to-end/api/livechat/21-reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { api, request, credentials, getCredentials } from '../../../data/api-dat
import { createDepartment, addOrRemoveAgentFromDepartment } from '../../../data/livechat/department';
import { startANewLivechatRoomAndTakeIt, createAgent } from '../../../data/livechat/rooms';
import { createMonitor, createUnit } from '../../../data/livechat/units';
import { restorePermissionToRoles, updatePermission } from '../../../data/permissions.helper';
import { restorePermissionToRoles, updateEESetting, updatePermission } from '../../../data/permissions.helper';
import { password } from '../../../data/user';
import { createUser, deleteUser, login } from '../../../data/users.helper';
import { IS_EE } from '../../../e2e/config/constants';
Expand All @@ -19,6 +19,7 @@ import { IS_EE } from '../../../e2e/config/constants';
let agent3: { user: IUser; credentials: Credentials };

before(async () => {
await updateEESetting('Livechat_Require_Contact_Verification', 'never');
const user = await createUser();
const userCredentials = await login(user.username, password);
if (!user.username) {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/tests/end-to-end/api/livechat/contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ describe('LIVECHAT - contacts', () => {
expect(res.body).to.have.property('success', false);
expect(res.body).to.have.property('error');
expect(res.body.error).to.be.equal(
"must have required property 'email'\n must have required property 'phone'\n must have required property 'contactId'\n must match a schema in anyOf [invalid-params]",
"must have required property 'email'\n must have required property 'phone'\n must have required property 'contactId'\n must match exactly one schema in oneOf [invalid-params]",
);
expect(res.body.errorType).to.be.equal('invalid-params');
});
Expand All @@ -715,7 +715,7 @@ describe('LIVECHAT - contacts', () => {
expect(res.body).to.have.property('success', false);
expect(res.body).to.have.property('error');
expect(res.body.error).to.be.equal(
'must NOT have additional properties\n must NOT have additional properties\n must NOT have additional properties\n must match a schema in anyOf [invalid-params]',
'must NOT have additional properties\n must NOT have additional properties\n must NOT have additional properties\n must match exactly one schema in oneOf [invalid-params]',
);
expect(res.body.errorType).to.be.equal('invalid-params');
});
Expand Down

0 comments on commit 8f66997

Please sign in to comment.