From 3454423d182c2e58bd14709f4d871610b8c03dde Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Wed, 27 Nov 2024 18:17:03 -0300 Subject: [PATCH] test: updated test files to use setting util --- ...account-forgetSessionOnWindowClose.spec.ts | 7 +- apps/meteor/tests/e2e/e2e-encryption.spec.ts | 52 +++++++------- apps/meteor/tests/e2e/homepage.spec.ts | 47 ++++++++----- .../omnichannel/omnichannel-agents.spec.ts | 5 +- .../omnichannel-appearance.spec.ts | 5 +- ...nichannel-auto-onhold-chat-closing.spec.ts | 11 +-- ...nnel-auto-transfer-unanswered-chat.spec.ts | 7 +- .../omnichannel-business-hours.spec.ts | 13 ++-- ...nel-changing-room-priority-and-sla.spec.ts | 6 +- .../omnichannel-close-inquiry.spec.ts | 5 +- .../omnichannel-current-chats.spec.ts | 18 +++-- .../omnichannel-departaments.spec.ts | 11 ++- .../omnichannel-livechat-api.spec.ts | 9 +-- .../omnichannel-livechat-background.spec.ts | 7 +- .../omnichannel-livechat-department.spec.ts | 5 +- .../omnichannel-livechat-fileupload.spec.ts | 13 ++-- ...hat-queue-management-autoselection.spec.ts | 13 ++-- ...ichannel-livechat-queue-management.spec.ts | 13 ++-- .../omnichannel-livechat-watermark.spec.ts | 4 +- .../omnichannel/omnichannel-livechat.spec.ts | 16 +++-- .../omnichannel-manager-role.spec.ts | 12 ++-- ...mnichannel-manual-selection-logout.spec.ts | 6 +- .../omnichannel-manual-selection.spec.ts | 9 +-- .../omnichannel-monitor-role.spec.ts | 12 ++-- .../omnichannel-priorities-sidebar.spec.ts | 14 ++-- .../omnichannel/omnichannel-takeChat.spec.ts | 13 ++-- ...channel-transfer-to-another-agents.spec.ts | 5 +- ...hannel-triggers-after-registration.spec.ts | 5 +- ...nichannel-triggers-open-by-visitor.spec.ts | 3 +- ...omnichannel-triggers-setDepartment.spec.ts | 9 +-- .../omnichannel-triggers-time-on-site.spec.ts | 3 +- .../omnichannel/omnichannel-triggers.spec.ts | 5 +- apps/meteor/tests/e2e/permissions.spec.ts | 69 +++++-------------- apps/meteor/tests/e2e/register.spec.ts | 39 +++++------ 34 files changed, 232 insertions(+), 239 deletions(-) diff --git a/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts b/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts index a820e04f88dd9..9c20b2b7f530d 100644 --- a/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts +++ b/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts @@ -1,5 +1,6 @@ import { DEFAULT_USER_CREDENTIALS } from './config/constants'; import { Registration } from './page-objects'; +import { setSettingValueById } from './utils'; import { test, expect } from './utils/test'; test.describe.serial('Forget session on window close setting', () => { @@ -13,7 +14,7 @@ test.describe.serial('Forget session on window close setting', () => { test.describe('Setting off', async () => { test.beforeAll(async ({ api }) => { - await api.post('/settings/Accounts_ForgetUserSessionOnWindowClose', { value: false }); + await setSettingValueById(api, 'Accounts_ForgetUserSessionOnWindowClose', false); }); test('Login using credentials and reload to stay logged in', async ({ page, context }) => { @@ -33,11 +34,11 @@ test.describe.serial('Forget session on window close setting', () => { // TODO: Fix this test test.describe.skip('Setting on', async () => { test.beforeAll(async ({ api }) => { - await api.post('/settings/Accounts_ForgetUserSessionOnWindowClose', { value: true }); + await setSettingValueById(api, 'Accounts_ForgetUserSessionOnWindowClose', true); }); test.afterAll(async ({ api }) => { - await api.post('/settings/Accounts_ForgetUserSessionOnWindowClose', { value: false }); + await setSettingValueById(api, 'Accounts_ForgetUserSessionOnWindowClose', false); }); test('Login using credentials and reload to get logged out', async ({ page, context }) => { diff --git a/apps/meteor/tests/e2e/e2e-encryption.spec.ts b/apps/meteor/tests/e2e/e2e-encryption.spec.ts index 04d01d5a7c711..55d1110d9c279 100644 --- a/apps/meteor/tests/e2e/e2e-encryption.spec.ts +++ b/apps/meteor/tests/e2e/e2e-encryption.spec.ts @@ -6,6 +6,7 @@ import { createAuxContext } from './fixtures/createAuxContext'; import injectInitialData from './fixtures/inject-initial-data'; import { Users, storeState, restoreState } from './fixtures/userStates'; import { AccountProfile, HomeChannel } from './page-objects'; +import { setSettingValueById } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -22,13 +23,11 @@ test.describe.serial('e2e-encryption initial setup', () => { }); test.beforeAll(async ({ api }) => { - await api.post('/settings/E2E_Enable', { value: true }); - await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: true }); + await Promise.all([setSettingValueById(api, 'E2E_Enable', true), setSettingValueById(api, 'E2E_Allow_Unencrypted_Messages', true)]); }); test.afterAll(async ({ api }) => { - await api.post('/settings/E2E_Enable', { value: false }); - await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: false }); + await Promise.all([setSettingValueById(api, 'E2E_Enable', false), setSettingValueById(api, 'E2E_Allow_Unencrypted_Messages', false)]); }); test.afterEach(async ({ api }) => { @@ -239,19 +238,18 @@ test.describe.serial('e2e-encryption', () => { test.use({ storageState: Users.userE2EE.state }); test.beforeEach(async ({ page, api }) => { - await api.post('/settings/E2E_Enable', { value: true }); + await setSettingValueById(api, 'E2E_Enable', true); poHomeChannel = new HomeChannel(page); await page.goto('/home'); }); test.beforeAll(async ({ api }) => { - await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: true }); + await setSettingValueById(api, 'E2E_Allow_Unencrypted_Messages', true); }); test.afterAll(async ({ api }) => { - await api.post('/settings/E2E_Enable', { value: false }); - await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: false }); + await Promise.all([setSettingValueById(api, 'E2E_Enable', false), setSettingValueById(api, 'E2E_Allow_Unencrypted_Messages', false)]); }); test('expect create a private channel encrypted and send an encrypted message', async ({ page }) => { @@ -504,8 +502,10 @@ test.describe.serial('e2e-encryption', () => { test.describe('File Encryption', async () => { test.afterAll(async ({ api }) => { - await api.post('/settings/FileUpload_MediaTypeWhiteList', { value: '' }); - await api.post('/settings/FileUpload_MediaTypeBlackList', { value: 'image/svg+xml' }); + await Promise.all([ + setSettingValueById(api, 'FileUpload_MediaTypeWhiteList', ''), + setSettingValueById(api, 'FileUpload_MediaTypeBlackList', 'image/svg+xml'), + ]); }); test('File and description encryption', async ({ page }) => { @@ -566,7 +566,7 @@ test.describe.serial('e2e-encryption', () => { }); await test.step('set whitelisted media type setting', async () => { - await api.post('/settings/FileUpload_MediaTypeWhiteList', { value: 'text/plain' }); + await setSettingValueById(api, 'FileUpload_MediaTypeWhiteList', 'text/plain'); }); await test.step('send text file again with whitelist setting set', async () => { @@ -581,7 +581,7 @@ test.describe.serial('e2e-encryption', () => { }); await test.step('set blacklisted media type setting to not accept application/octet-stream media type', async () => { - await api.post('/settings/FileUpload_MediaTypeBlackList', { value: 'application/octet-stream' }); + await setSettingValueById(api, 'FileUpload_MediaTypeBlackList', 'application/octet-stream'); }); await test.step('send text file again with blacklisted setting set, file upload should fail', async () => { @@ -598,13 +598,17 @@ test.describe.serial('e2e-encryption', () => { test.describe('File encryption setting disabled', async () => { test.beforeAll(async ({ api }) => { - await api.post('/settings/E2E_Enable_Encrypt_Files', { value: false }); - await api.post('/settings/FileUpload_MediaTypeBlackList', { value: 'application/octet-stream' }); + await Promise.all([ + setSettingValueById(api, 'E2E_Enable_Encrypt_Files', false), + setSettingValueById(api, 'FileUpload_MediaTypeBlackList', 'application/octet-stream'), + ]); }); test.afterAll(async ({ api }) => { - await api.post('/settings/E2E_Enable_Encrypt_Files', { value: true }); - await api.post('/settings/FileUpload_MediaTypeBlackList', { value: 'image/svg+xml' }); + await Promise.all([ + setSettingValueById(api, 'E2E_Enable_Encrypt_Files', true), + setSettingValueById(api, 'FileUpload_MediaTypeBlackList', 'image/svg+xml'), + ]); }); test('Upload file without encryption in e2ee room', async ({ page }) => { @@ -682,11 +686,11 @@ test.describe.serial('e2e-encryption', () => { await page.goto('/home'); }); test.beforeAll(async ({ api }) => { - await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: false }); + await setSettingValueById(api, 'E2E_Allow_Unencrypted_Messages', false); }); test.afterAll(async ({ api }) => { - await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: true }); + await setSettingValueById(api, 'E2E_Allow_Unencrypted_Messages', true); }); test('expect slash commands to be disabled in an e2ee room', async ({ page }) => { @@ -845,13 +849,11 @@ test.describe.serial('e2ee room setup', () => { }); test.beforeAll(async ({ api }) => { - await api.post('/settings/E2E_Enable', { value: true }); - await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: false }); + await Promise.all([setSettingValueById(api, 'E2E_Enable', true), setSettingValueById(api, 'E2E_Allow_Unencrypted_Messages', false)]); }); test.afterAll(async ({ api }) => { - await api.post('/settings/E2E_Enable', { value: false }); - await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: false }); + await Promise.all([setSettingValueById(api, 'E2E_Enable', false), setSettingValueById(api, 'E2E_Allow_Unencrypted_Messages', false)]); }); test.afterEach(async ({ api }) => { @@ -1034,13 +1036,11 @@ test.describe('e2ee support legacy formats', () => { }); test.beforeAll(async ({ api }) => { - await api.post('/settings/E2E_Enable', { value: true }); - await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: false }); + await Promise.all([setSettingValueById(api, 'E2E_Enable', true), setSettingValueById(api, 'E2E_Allow_Unencrypted_Messages', false)]); }); test.afterAll(async ({ api }) => { - await api.post('/settings/E2E_Enable', { value: false }); - await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: false }); + await Promise.all([setSettingValueById(api, 'E2E_Enable', false), setSettingValueById(api, 'E2E_Allow_Unencrypted_Messages', false)]); }); // ->>>>>>>>>>>Not testing upload since it was not implemented in the legacy format diff --git a/apps/meteor/tests/e2e/homepage.spec.ts b/apps/meteor/tests/e2e/homepage.spec.ts index 72291785bd09c..fef575b2e1021 100644 --- a/apps/meteor/tests/e2e/homepage.spec.ts +++ b/apps/meteor/tests/e2e/homepage.spec.ts @@ -2,6 +2,7 @@ import type { Page } from '@playwright/test'; import { IS_EE } from './config/constants'; import { Users } from './fixtures/userStates'; +import { setSettingValueById } from './utils'; import { expect, test } from './utils/test'; const CardIds = { @@ -27,8 +28,11 @@ test.describe.serial('homepage', () => { }); test.afterAll(async ({ api }) => { - expect((await api.post('/settings/Layout_Home_Custom_Block_Visible', { value: false })).status()).toBe(200); - expect((await api.post('/settings/Layout_Custom_Body_Only', { value: false })).status()).toBe(200); + await Promise.all([ + setSettingValueById(api, 'Layout_Home_Custom_Block_Visible', false), + setSettingValueById(api, 'Layout_Custom_Body_Only', false), + ]); + await adminPage.close(); }); @@ -44,7 +48,7 @@ test.describe.serial('homepage', () => { test.describe('custom body with empty custom content', async () => { test.beforeAll(async ({ api }) => { - await expect((await api.post('/settings/Layout_Home_Body', { value: '' })).status()).toBe(200); + await setSettingValueById(api, 'Layout_Home_Body', ''); }); test('visibility and button functionality in custom body with empty custom content', async () => { @@ -65,7 +69,7 @@ test.describe.serial('homepage', () => { test.describe('custom body with custom content', () => { test.beforeAll(async ({ api }) => { - await expect((await api.post('/settings/Layout_Home_Body', { value: 'Hello admin' })).status()).toBe(200); + await setSettingValueById(api, 'Layout_Home_Body', { value: 'Hello admin' }); }); test('visibility and button functionality in custom body with custom content', async () => { @@ -83,9 +87,11 @@ test.describe.serial('homepage', () => { test.skip(!IS_EE, 'Enterprise Only'); test.beforeAll(async ({ api }) => { - await expect((await api.post('/settings/Layout_Home_Body', { value: 'Hello admin' })).status()).toBe(200); - await expect((await api.post('/settings/Layout_Home_Custom_Block_Visible', { value: true })).status()).toBe(200); - await expect((await api.post('/settings/Layout_Custom_Body_Only', { value: true })).status()).toBe(200); + await Promise.all([ + setSettingValueById(api, 'Layout_Home_Body', 'Hello admin'), + setSettingValueById(api, 'Layout_Home_Custom_Block_Visible', true), + setSettingValueById(api, 'Layout_Custom_Body_Only', true), + ]); }); test('display custom content only', async () => { @@ -110,7 +116,7 @@ test.describe.serial('homepage', () => { const notVisibleCards = [CardIds.Users, CardIds.Custom]; test.beforeAll(async ({ api, browser }) => { - expect((await api.post('/settings/Layout_Home_Body', { value: '' })).status()).toBe(200); + await setSettingValueById(api, 'Layout_Home_Body', { value: '' }); regularUserPage = await browser.newPage({ storageState: Users.user2.state }); await regularUserPage.goto('/home'); await regularUserPage.waitForSelector('[data-qa-id="home-header"]'); @@ -148,16 +154,17 @@ test.describe.serial('homepage', () => { test.describe('custom values', () => { test.beforeAll(async ({ api }) => { - expect((await api.post('/settings/Site_Name', { value: 'NewSiteName' })).status()).toBe(200); - expect((await api.post('/settings/Layout_Home_Title', { value: 'NewTitle' })).status()).toBe(200); + await Promise.all([ + setSettingValueById(api, 'Site_Name', 'NewSiteName'), + setSettingValueById(api, 'Layout_Home_Title', 'NewTitle'), + ]); await regularUserPage.goto('/home'); await regularUserPage.waitForSelector('[data-qa-id="home-header"]'); }); test.afterAll(async ({ api }) => { - expect((await api.post('/settings/Site_Name', { value: 'Rocket.Chat' })).status()).toBe(200); - expect((await api.post('/settings/Layout_Home_Title', { value: 'Home' })).status()).toBe(200); + await Promise.all([setSettingValueById(api, 'Site_Name', 'Rocket.Chat'), setSettingValueById(api, 'Layout_Home_Title', 'Home')]); }); test('expect welcome text and header text to be correct', async () => { @@ -173,16 +180,20 @@ test.describe.serial('homepage', () => { test.describe('custom body with content', () => { test.beforeAll(async ({ api }) => { - expect((await api.post('/settings/Layout_Home_Body', { value: 'Hello' })).status()).toBe(200); - expect((await api.post('/settings/Layout_Home_Custom_Block_Visible', { value: true })).status()).toBe(200); + await Promise.all([ + setSettingValueById(api, 'Layout_Home_Body', 'Hello'), + setSettingValueById(api, 'Layout_Home_Custom_Block_Visible', true), + ]); await regularUserPage.goto('/home'); await regularUserPage.waitForSelector('[data-qa-id="home-header"]'); }); test.afterAll(async ({ api }) => { - expect((await api.post('/settings/Layout_Home_Body', { value: '' })).status()).toBe(200); - expect((await api.post('/settings/Layout_Home_Custom_Block_Visible', { value: false })).status()).toBe(200); + await Promise.all([ + setSettingValueById(api, 'Layout_Home_Body', ''), + setSettingValueById(api, 'Layout_Home_Custom_Block_Visible', false), + ]); }); test('expect custom body to be visible', async () => { @@ -193,11 +204,11 @@ test.describe.serial('homepage', () => { test.skip(!IS_EE, 'Enterprise Only'); test.beforeAll(async ({ api }) => { - expect((await api.post('/settings/Layout_Custom_Body_Only', { value: true })).status()).toBe(200); + await setSettingValueById(api, 'Layout_Custom_Body_Only', true); }); test.afterAll(async ({ api }) => { - expect((await api.post('/settings/Layout_Custom_Body_Only', { value: false })).status()).toBe(200); + await setSettingValueById(api, 'Layout_Custom_Body_Only', false); }); test('expect default layout not be visible and custom body visible', async () => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts index 239978928126e..e4a923b32d811 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts @@ -1,6 +1,7 @@ import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { OmnichannelAgents } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createDepartment } from '../utils/omnichannel/departments'; import { test, expect } from '../utils/test'; @@ -26,9 +27,9 @@ test.describe.serial('OC - Manage Agents', () => { // Ensure that there is no leftover data even if test fails test.afterEach(async ({ api }) => { await api.delete('/livechat/users/agent/user1'); - await api.post('/settings/Omnichannel_enable_department_removal', { value: true }).then((res) => expect(res.status()).toBe(200)); + await setSettingValueById(api, 'Omnichannel_enable_department_removal', true); await department.delete(); - await api.post('/settings/Omnichannel_enable_department_removal', { value: false }).then((res) => expect(res.status()).toBe(200)); + await setSettingValueById(api, 'Omnichannel_enable_department_removal', false); }); test('OC - Manage Agents - Add, search and remove using table', async ({ page }) => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-appearance.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-appearance.spec.ts index a67e45b01ce6c..cbdc04e0b55eb 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-appearance.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-appearance.spec.ts @@ -1,6 +1,7 @@ import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { OmnichannelLivechatAppearance } from '../page-objects/omnichannel-livechat-appearance'; +import { setSettingValueById } from '../utils'; import { test, expect } from '../utils/test'; test.use({ storageState: Users.admin.state }); @@ -19,8 +20,8 @@ test.describe.serial('OC - Livechat Appearance', () => { test.afterAll(async ({ api }) => { const res = await Promise.all([ - api.post('/settings/Livechat_hide_system_messages', { value: ['uj', 'ul', 'livechat-close'] }), - api.post('/settings/Livechat_background', { value: '' }), + setSettingValueById(api, 'Livechat_hide_system_messages', ['uj', 'ul', 'livechat-close']), + setSettingValueById(api, 'Livechat_background', ''), ]); if (res.some((r) => r.status() !== 200)) { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-auto-onhold-chat-closing.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-auto-onhold-chat-closing.spec.ts index 255ac0d3ed091..f4341d341b3b4 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-auto-onhold-chat-closing.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-auto-onhold-chat-closing.spec.ts @@ -5,6 +5,7 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeChannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { test, expect } from '../utils/test'; test.describe('omnichannel-auto-onhold-chat-closing', () => { @@ -18,9 +19,9 @@ test.describe('omnichannel-auto-onhold-chat-closing', () => { test.beforeAll(async ({ api, browser }) => { await Promise.all([ api.post('/livechat/users/agent', { username: 'user1' }).then((res) => expect(res.status()).toBe(200)), - api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }).then((res) => expect(res.status()).toBe(200)), - api.post('/settings/Livechat_auto_close_on_hold_chats_timeout', { value: 5 }).then((res) => expect(res.status()).toBe(200)), - api.post('/settings/Livechat_allow_manual_on_hold', { value: true }).then((res) => expect(res.status()).toBe(200)), + setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection'), + setSettingValueById(api, 'Livechat_auto_close_on_hold_chats_timeout', 5), + setSettingValueById(api, 'Livechat_allow_manual_on_hold', true), ]); const { page } = await createAuxContext(browser, Users.user1); @@ -31,8 +32,8 @@ test.describe('omnichannel-auto-onhold-chat-closing', () => { await Promise.all([ api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)), - api.post('/settings/Livechat_auto_close_on_hold_chats_timeout', { value: 3600 }).then((res) => expect(res.status()).toBe(200)), - api.post('/settings/Livechat_allow_manual_on_hold', { value: false }).then((res) => expect(res.status()).toBe(200)), + setSettingValueById(api, 'Livechat_auto_close_on_hold_chats_timeout', 3600), + setSettingValueById(api, 'Livechat_allow_manual_on_hold', false), ]); }); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-auto-transfer-unanswered-chat.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-auto-transfer-unanswered-chat.spec.ts index 285fdaef828a5..7689a4038fb1c 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-auto-transfer-unanswered-chat.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-auto-transfer-unanswered-chat.spec.ts @@ -5,6 +5,7 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeChannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { test, expect } from '../utils/test'; test.describe('omnichannel-auto-transfer-unanswered-chat', () => { @@ -20,8 +21,8 @@ test.describe('omnichannel-auto-transfer-unanswered-chat', () => { await Promise.all([ api.post('/livechat/users/agent', { username: 'user1' }).then((res) => expect(res.status()).toBe(200)), api.post('/livechat/users/agent', { username: 'user2' }).then((res) => expect(res.status()).toBe(200)), - api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }).then((res) => expect(res.status()).toBe(200)), - api.post('/settings/Livechat_auto_transfer_chat_timeout', { value: 5 }).then((res) => expect(res.status()).toBe(200)), + setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection'), + setSettingValueById(api, 'Livechat_auto_transfer_chat_timeout', 5), ]); const { page } = await createAuxContext(browser, Users.user1); @@ -38,7 +39,7 @@ test.describe('omnichannel-auto-transfer-unanswered-chat', () => { await Promise.all([ api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)), api.delete('/livechat/users/agent/user2').then((res) => expect(res.status()).toBe(200)), - api.post('/settings/Livechat_auto_transfer_chat_timeout', { value: 0 }).then((res) => expect(res.status()).toBe(200)), + setSettingValueById(api, 'Livechat_auto_transfer_chat_timeout', 0), ]); }); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-business-hours.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-business-hours.spec.ts index 2c5dc162e509c..3cfcaea23c926 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-business-hours.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-business-hours.spec.ts @@ -4,6 +4,7 @@ import type { Page } from '@playwright/test'; import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { OmnichannelBusinessHours } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { createBusinessHour } from '../utils/omnichannel/businessHours'; import { createDepartment } from '../utils/omnichannel/departments'; @@ -23,16 +24,20 @@ test.describe('OC - Business Hours', () => { department = await createDepartment(api); department2 = await createDepartment(api); agent = await createAgent(api, 'user2'); - await api.post('/settings/Livechat_enable_business_hours', { value: true }).then((res) => expect(res.status()).toBe(200)); - await api.post('/settings/Livechat_business_hour_type', { value: 'Multiple' }).then((res) => expect(res.status()).toBe(200)); + await Promise.all([ + setSettingValueById(api, 'Livechat_enable_business_hours', true), + setSettingValueById(api, 'Livechat_business_hour_type', 'Multiple'), + ]); }); test.afterAll(async ({ api }) => { await department.delete(); await department2.delete(); await agent.delete(); - await api.post('/settings/Livechat_enable_business_hours', { value: false }).then((res) => expect(res.status()).toBe(200)); - await api.post('/settings/Livechat_business_hour_type', { value: 'Single' }).then((res) => expect(res.status()).toBe(200)); + await Promise.all([ + setSettingValueById(api, 'Livechat_enable_business_hours', false), + setSettingValueById(api, 'Livechat_business_hour_type', 'Single'), + ]); }); test.beforeEach(async ({ page }: { page: Page }) => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-changing-room-priority-and-sla.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-changing-room-priority-and-sla.spec.ts index ee32eb4efe0de..90565ea423fc1 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-changing-room-priority-and-sla.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-changing-room-priority-and-sla.spec.ts @@ -5,6 +5,7 @@ import { ADMIN_CREDENTIALS, IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeChannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { getPriorityByi18nLabel } from '../utils/omnichannel/priority'; import { createSLA } from '../utils/omnichannel/sla'; import { test, expect } from '../utils/test'; @@ -35,8 +36,7 @@ test.describe.serial('omnichannel-changing-room-priority-and-sla', () => { statusCode = (await api.post('/livechat/users/manager', { username: ADMIN_CREDENTIALS.username })).status(); expect(statusCode).toBe(200); - statusCode = (await api.post('/settings/Livechat_Routing_Method', { value: 'Manual_Selection' })).status(); - expect(statusCode).toBe(200); + await setSettingValueById(api, 'Livechat_Routing_Method', 'Manual_Selection'); const { page } = await createAuxContext(browser, Users.admin); agent = { page, poHomeChannel: new HomeChannel(page) }; @@ -50,7 +50,7 @@ test.describe.serial('omnichannel-changing-room-priority-and-sla', () => { await Promise.all([ api.delete(`/livechat/users/agent/${ADMIN_CREDENTIALS.username}`), api.delete(`/livechat/users/manager/${ADMIN_CREDENTIALS.username}`), - api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }), + setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection'), ]); }); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-close-inquiry.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-close-inquiry.spec.ts index b37a34ba861e7..b99e473af9293 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-close-inquiry.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-close-inquiry.spec.ts @@ -4,6 +4,7 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeOmnichannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { test, expect } from '../utils/test'; test.describe('Omnichannel close inquiry', () => { @@ -15,7 +16,7 @@ test.describe('Omnichannel close inquiry', () => { test.beforeAll(async ({ api }) => { newVisitor = createFakeVisitor(); - await api.post('/settings/Livechat_Routing_Method', { value: 'Manual_Selection' }).then((res) => expect(res.status()).toBe(200)); + await setSettingValueById(api, 'Livechat_Routing_Method', 'Manual_Selection'); await api.post('/livechat/users/manager', { username: 'user1' }); await api.post('/livechat/users/agent', { username: 'user1' }); }); @@ -33,7 +34,7 @@ test.describe('Omnichannel close inquiry', () => { test.afterAll(async ({ api }) => { await Promise.all([ - await api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }).then((res) => expect(res.status()).toBe(200)), + await setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection'), await api.delete('/livechat/users/agent/user1'), await api.delete('/livechat/users/manager/user1'), ]); 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 8e121b36ddb04..7a0bf01f320a2 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-current-chats.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-current-chats.spec.ts @@ -4,6 +4,7 @@ import type { Page } from '@playwright/test'; import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { OmnichannelCurrentChats } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments'; import { createConversation, updateRoom } from '../utils/omnichannel/rooms'; @@ -27,11 +28,10 @@ test.describe('OC - Current Chats [Auto Selection]', async () => { // Allow manual on hold test.beforeAll(async ({ api }) => { - 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 }), + await Promise.all([ + setSettingValueById(api, 'Livechat_allow_manual_on_hold', true), + setSettingValueById(api, 'Livechat_allow_manual_on_hold_upon_agent_engagement_only', false), ]); - responses.forEach((res) => expect(res.status()).toBe(200)); }); // Create departments @@ -124,8 +124,8 @@ test.describe('OC - Current Chats [Auto Selection]', async () => { // Delete tags ...tags.map((tag) => tag.delete()), // Reset setting - api.post('/settings/Livechat_allow_manual_on_hold', { value: false }), - api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: true }), + setSettingValueById(api, 'Livechat_allow_manual_on_hold', false), + setSettingValueById(api, 'Livechat_allow_manual_on_hold_upon_agent_engagement_only', true), ]); }); @@ -289,8 +289,7 @@ test.describe('OC - Current Chats [Manual Selection]', () => { let agent: Awaited>; test.beforeAll(async ({ api }) => { - const res = await api.post('/settings/Livechat_Routing_Method', { value: 'Manual_Selection' }); - expect(res.status()).toBe(200); + await setSettingValueById(api, 'Livechat_Routing_Method', 'Manual_Selection'); }); test.beforeAll(async ({ api }) => { @@ -323,8 +322,7 @@ test.describe('OC - Current Chats [Manual Selection]', () => { }); test.afterAll(async ({ api }) => { - const res = await api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }); - expect(res.status()).toBe(200); + await setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection'); }); test.afterAll(async () => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts index 023d11de47570..45880c9745da8 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts @@ -4,6 +4,7 @@ import type { Page } from '@playwright/test'; import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { OmnichannelDepartments } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createDepartment, deleteDepartment } from '../utils/omnichannel/departments'; import { test, expect } from '../utils/test'; @@ -22,12 +23,12 @@ test.describe('OC - Manage Departments', () => { test.beforeAll(async ({ api }) => { // turn on department removal - await api.post('/settings/Omnichannel_enable_department_removal', { value: true }); + await setSettingValueById(api, 'Omnichannel_enable_department_removal', true); }); test.afterAll(async ({ api }) => { // turn off department removal - await api.post('/settings/Omnichannel_enable_department_removal', { value: false }); + await setSettingValueById(api, 'Omnichannel_enable_department_removal', false); }); test.describe('Create first department', async () => { @@ -258,8 +259,7 @@ test.describe('OC - Manage Departments', () => { }); await test.step('expect to disable department removal setting', async () => { - const statusCode = (await api.post('/settings/Omnichannel_enable_department_removal', { value: false })).status(); - expect(statusCode).toBe(200); + await setSettingValueById(api, 'Omnichannel_enable_department_removal', false); }); await test.step('expect not to be able to delete department', async () => { @@ -269,8 +269,7 @@ test.describe('OC - Manage Departments', () => { }); await test.step('expect to enable department removal setting', async () => { - const statusCode = (await api.post('/settings/Omnichannel_enable_department_removal', { value: true })).status(); - expect(statusCode).toBe(200); + await setSettingValueById(api, 'Omnichannel_enable_department_removal', true); }); await test.step('expect to delete department', async () => { 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 e14e3b43fbe30..f97857e21c550 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-api.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-api.spec.ts @@ -6,6 +6,7 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChatEmbedded } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments'; import { test, expect } from '../utils/test'; @@ -232,7 +233,7 @@ test.describe('OC - Livechat API', () => { await addAgentToDepartment(api, { department: departmentA, agentId: agent.data._id }); await addAgentToDepartment(api, { department: departmentB, agentId: agent2.data._id }); - expect((await api.post('/settings/Livechat_offline_email', { value: 'test@testing.com' })).status()).toBe(200); + await setSettingValueById(api, 'Livechat_offline_email', 'test@testing.com'); }); test.beforeEach(async ({ browser }, testInfo) => { @@ -263,9 +264,9 @@ test.describe('OC - Livechat API', () => { await agent.delete(); await agent2.delete(); - await expect((await api.post('/settings/Omnichannel_enable_department_removal', { value: true })).status()).toBe(200); + await setSettingValueById(api, 'Omnichannel_enable_department_removal', true); await Promise.all([...departments.map((department) => department.delete())]); - await expect((await api.post('/settings/Omnichannel_enable_department_removal', { value: false })).status()).toBe(200); + await setSettingValueById(api, 'Omnichannel_enable_department_removal', false); }); // clearBusinessUnit @@ -697,7 +698,7 @@ test.describe('OC - Livechat API', () => { test.beforeAll(async ({ api }) => { agent = await createAgent(api, 'user1'); - expect((await api.post('/settings/Livechat_offline_email', { value: 'test@testing.com' })).status()).toBe(200); + await setSettingValueById(api, 'Livechat_offline_email', 'test@testing.com'); }); test.beforeEach(async ({ browser }, testInfo) => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-background.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-background.spec.ts index b7a058e719ee1..ef947b523ea1f 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-background.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-background.spec.ts @@ -2,6 +2,7 @@ import { createFakeVisitor } from '../../mocks/data'; import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChatEmbedded } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { test, expect } from '../utils/test'; @@ -61,8 +62,7 @@ test.describe('OC - Livechat - Message list background', async () => { }); await test.step('expect to change message list background', async () => { - const res = await api.post('/settings/Livechat_background', { value: 'rgb(186, 1, 85)' }); - await expect(res.status()).toBe(200); + await setSettingValueById(api, 'Livechat_background', 'rgb(186, 1, 85)'); await page.reload(); await poLiveChat.openLiveChat(); @@ -81,8 +81,7 @@ test.describe('OC - Livechat - Message list background', async () => { }); await test.step('expect to reset message list background to default', async () => { - const res = await api.post('/settings/Livechat_background', { value: '' }); - await expect(res.status()).toBe(200); + await setSettingValueById(api, 'Livechat_background', ''); await page.reload(); await poLiveChat.openLiveChat(); 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 0c72c8894cc40..1127c0e3cc822 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-department.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-department.spec.ts @@ -3,6 +3,7 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChat } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments'; import { test, expect } from '../utils/test'; @@ -54,10 +55,10 @@ test.describe('OC - Livechat - Department Flow', () => { }); test.afterAll(async ({ api }) => { - await expect((await api.post('/settings/Omnichannel_enable_department_removal', { value: true })).status()).toBe(200); + await setSettingValueById(api, 'Omnichannel_enable_department_removal', true); await Promise.all([...agents.map((agent) => agent.delete())]); await Promise.all([...departments.map((department) => department.delete())]); - await expect((await api.post('/settings/Omnichannel_enable_department_removal', { value: false })).status()).toBe(200); + await setSettingValueById(api, 'Omnichannel_enable_department_removal', false); }); test('OC - Livechat - Chat with Department', async () => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-fileupload.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-fileupload.spec.ts index d96aa4006bc4b..2c2fc66852899 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-fileupload.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-fileupload.spec.ts @@ -2,6 +2,7 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChat } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { test, expect } from '../utils/test'; @@ -45,8 +46,10 @@ test.describe('OC - Livechat - OC - File Upload', () => { }); test.afterAll(async ({ api }) => { - await api.post('/settings/FileUpload_Enabled', { value: true }); - await api.post('/settings/Livechat_fileupload_enabled', { value: true }); + await Promise.all([ + setSettingValueById(api, 'FileUpload_Enabled', true), + setSettingValueById(api, 'Livechat_fileupload_enabled', true), + ]); await poHomeOmnichannel.page.close(); await agent.delete(); @@ -85,8 +88,10 @@ test.describe('OC - Livechat - OC - File Upload - Disabled', () => { }); test.afterAll(async ({ api }) => { - await api.post('/settings/FileUpload_Enabled', { value: true }); - await api.post('/settings/Livechat_fileupload_enabled', { value: true }); + await Promise.all([ + setSettingValueById(api, 'FileUpload_Enabled', true), + setSettingValueById(api, 'Livechat_fileupload_enabled', true), + ]); await poHomeOmnichannel.page?.close(); await agent.delete(); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-queue-management-autoselection.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-queue-management-autoselection.spec.ts index 62bf3111cab76..cb7b1e3d9c871 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-queue-management-autoselection.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-queue-management-autoselection.spec.ts @@ -3,6 +3,7 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChat } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { test, expect } from '../utils/test'; const firstVisitor = createFakeVisitor(); @@ -21,10 +22,10 @@ test.describe('OC - Livechat - Queue Management', () => { test.beforeAll(async ({ api, browser }) => { await Promise.all([ - api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }), - api.post('/settings/Livechat_accept_chats_with_no_agents', { value: true }), - api.post('/settings/Livechat_waiting_queue', { value: true }), - api.post('/settings/Livechat_waiting_queue_message', { value: waitingQueueMessage }), + setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection'), + setSettingValueById(api, 'Livechat_accept_chats_with_no_agents', true), + setSettingValueById(api, 'Livechat_waiting_queue', true), + setSettingValueById(api, 'Livechat_waiting_queue_message', waitingQueueMessage), api.post('/livechat/users/agent', { username: 'user1' }), ]); @@ -45,8 +46,8 @@ test.describe('OC - Livechat - Queue Management', () => { test.afterAll(async ({ api }) => { await Promise.all([ - api.post('/settings/Livechat_waiting_queue', { value: false }), - api.post('/settings/Livechat_waiting_queue_message', { value: '' }), + setSettingValueById(api, 'Livechat_waiting_queue', false), + setSettingValueById(api, 'Livechat_waiting_queue_message', ''), api.delete('/livechat/users/agent/user1'), ]); await poHomeOmnichannel.page.close(); 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 ee91c49bfb16e..583702273b3f1 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 @@ -3,6 +3,7 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChat } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { test, expect } from '../utils/test'; const firstVisitor = createFakeVisitor(); @@ -23,9 +24,9 @@ test.describe('OC - Livechat - Queue Management', () => { test.beforeAll(async ({ api, browser }) => { await Promise.all([ - api.post('/settings/Livechat_Routing_Method', { value: 'Manual_Selection' }), - api.post('/settings/Livechat_waiting_queue', { value: true }), - api.post('/settings/Livechat_waiting_queue_message', { value: waitingQueueMessage }), + setSettingValueById(api, 'Livechat_Routing_Method', 'Manual_Selection'), + setSettingValueById(api, 'Livechat_waiting_queue', true), + setSettingValueById(api, 'Livechat_waiting_queue_message', waitingQueueMessage), api.post('/livechat/users/agent', { username: 'user1' }), ]); @@ -43,9 +44,9 @@ test.describe('OC - Livechat - Queue Management', () => { test.afterAll(async ({ api }) => { await Promise.all([ - api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }), - api.post('/settings/Livechat_waiting_queue', { value: false }), - api.post('/settings/Livechat_waiting_queue_message', { value: '' }), + setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection'), + setSettingValueById(api, 'Livechat_waiting_queue', false), + setSettingValueById(api, 'Livechat_waiting_queue_message', ''), api.delete('/livechat/users/agent/user1'), ]); await poHomeOmnichannel.page.close(); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-watermark.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-watermark.spec.ts index 09883da3c16b6..0367c2c76f03c 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-watermark.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-watermark.spec.ts @@ -3,6 +3,7 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, OmnichannelSettings } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { test, expect } from '../utils/test'; @@ -42,8 +43,7 @@ test.describe('OC - Livechat - Hide watermark', async () => { }); test.afterAll(async ({ api }) => { - const res = await api.post('/settings/Livechat_hide_watermark', { value: false }); - await expect(res.status()).toBe(200); + await setSettingValueById(api, 'Livechat_hide_watermark', false); }); test('OC - Livechat - Hide watermark', async () => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts index 6d8f7f2c624cf..e40f149a610f4 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts @@ -169,7 +169,7 @@ test.describe.serial('OC - Livechat - Resub after close room', () => { }); test.beforeAll(async ({ browser, api }) => { - await api.post('/settings/Livechat_clear_local_storage_when_chat_ended', { value: true }); + await setSettingValueById(api, 'Livechat_clear_local_storage_when_chat_ended', true); const { page: omniPage } = await createAuxContext(browser, Users.user1, '/', true); poHomeOmnichannel = new HomeOmnichannel(omniPage); @@ -180,7 +180,7 @@ test.describe.serial('OC - Livechat - Resub after close room', () => { }); test.afterAll(async ({ api }) => { - await api.post('/settings/Livechat_clear_local_storage_when_chat_ended', { value: false }); + await setSettingValueById(api, 'Livechat_clear_local_storage_when_chat_ended', false); await api.delete('/livechat/users/agent/user1'); await poLiveChat.page.close(); await poHomeOmnichannel.page.close(); @@ -322,8 +322,10 @@ test.describe('OC - Livechat - Livechat_Display_Offline_Form', () => { const message = 'This form is not available'; test.beforeAll(async ({ api }) => { - await api.post('/settings/Livechat_display_offline_form', { value: false }); - await api.post('/settings/Livechat_offline_form_unavailable', { value: message }); + await Promise.all([ + setSettingValueById(api, 'Livechat_display_offline_form', false), + setSettingValueById(api, 'Livechat_offline_form_unavailable', message), + ]); }); test.beforeEach(async ({ page, api }) => { @@ -332,8 +334,10 @@ test.describe('OC - Livechat - Livechat_Display_Offline_Form', () => { }); test.afterAll(async ({ api }) => { - await api.post('/settings/Livechat_display_offline_form', { value: true }); - await api.post('/settings/Livechat_offline_form_unavailable', { value: '' }); + await Promise.all([ + setSettingValueById(api, 'Livechat_display_offline_form', true), + setSettingValueById(api, 'Livechat_offline_form_unavailable', ''), + ]); }); test('OC - Livechat - Livechat_Display_Offline_Form false', async () => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-manager-role.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-manager-role.spec.ts index a9c0de65cdff4..426cf0a24cf16 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-manager-role.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-manager-role.spec.ts @@ -4,6 +4,7 @@ import type { Page } from '@playwright/test'; import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { createDepartment } from '../utils/omnichannel/departments'; import { createManager } from '../utils/omnichannel/managers'; @@ -29,11 +30,10 @@ test.describe('OC - Manager Role', () => { // Allow manual on hold test.beforeAll(async ({ api }) => { - 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 }), + await Promise.all([ + setSettingValueById(api, 'Livechat_allow_manual_on_hold', true), + setSettingValueById(api, 'Livechat_allow_manual_on_hold_upon_agent_engagement_only', false), ]); - responses.forEach((res) => expect(res.status()).toBe(200)); }); // Create agents @@ -88,8 +88,8 @@ test.describe('OC - Manager Role', () => { ...conversations.map((conversation) => conversation.delete()), manager.delete(), // Reset setting - api.post('/settings/Livechat_allow_manual_on_hold', { value: false }), - api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: true }), + setSettingValueById(api, 'Livechat_allow_manual_on_hold', false), + setSettingValueById(api, 'Livechat_allow_manual_on_hold_upon_agent_engagement_only', true), ]); }); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-manual-selection-logout.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-manual-selection-logout.spec.ts index 9fbb567e3a87c..481e85b16023f 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-manual-selection-logout.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-manual-selection-logout.spec.ts @@ -4,6 +4,7 @@ import { DEFAULT_USER_CREDENTIALS } from '../config/constants'; import injectInitialData from '../fixtures/inject-initial-data'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { createConversation } from '../utils/omnichannel/rooms'; import { test, expect } from '../utils/test'; @@ -16,8 +17,7 @@ test.describe('OC - Manual Selection After Relogin', () => { // Change routing method to manual selection test.beforeAll(async ({ api }) => { - const res = await api.post('/settings/Livechat_Routing_Method', { value: 'Manual_Selection' }); - expect(res.status()).toBe(200); + await setSettingValueById(api, 'Livechat_Routing_Method', 'Manual_Selection'); }); // Create agent and make it available @@ -43,7 +43,7 @@ test.describe('OC - Manual Selection After Relogin', () => { // Delete all data test.afterAll(async ({ api }) => { await agent.delete(); - await api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }); + await setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection'); await injectInitialData(); }); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-manual-selection.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-manual-selection.spec.ts index ff7245e0b5324..b0f2f6d58ae6b 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-manual-selection.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-manual-selection.spec.ts @@ -3,6 +3,7 @@ import type { Page } from '@playwright/test'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { createConversation } from '../utils/omnichannel/rooms'; import { test, expect } from '../utils/test'; @@ -16,8 +17,7 @@ test.describe('OC - Manual Selection', () => { // Change routing method to manual selection test.beforeAll(async ({ api }) => { - const res = await api.post('/settings/Livechat_Routing_Method', { value: 'Manual_Selection' }); - expect(res.status()).toBe(200); + await setSettingValueById(api, 'Livechat_Routing_Method', 'Manual_Selection'); }); // Create agent and make it available @@ -44,10 +44,7 @@ test.describe('OC - Manual Selection', () => { }); // Delete all data test.afterAll(async ({ api }) => { - await Promise.all([ - ...agents.map((agent) => agent.delete()), - api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }), - ]); + await Promise.all([...agents.map((agent) => agent.delete()), setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection')]); }); test('OC - Manual Selection - Queue', async ({ page, api }) => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-monitor-role.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-monitor-role.spec.ts index 25a5336742a34..be5f502dbf827 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-monitor-role.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-monitor-role.spec.ts @@ -4,6 +4,7 @@ import type { Page } from '@playwright/test'; import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { createDepartment } from '../utils/omnichannel/departments'; import { createMonitor } from '../utils/omnichannel/monitors'; @@ -41,11 +42,10 @@ test.describe('OC - Monitor Role', () => { // Allow manual on hold test.beforeAll(async ({ api }) => { - 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 }), + await Promise.all([ + setSettingValueById(api, 'Livechat_allow_manual_on_hold', true), + setSettingValueById(api, 'Livechat_allow_manual_on_hold_upon_agent_engagement_only', false), ]); - responses.forEach((res) => expect(res.status()).toBe(200)); }); // Create agents @@ -118,8 +118,8 @@ test.describe('OC - Monitor Role', () => { ...units.map((unit) => unit.delete()), ...monitors.map((monitor) => monitor.delete()), // Reset setting - api.post('/settings/Livechat_allow_manual_on_hold', { value: false }), - api.post('/settings/Livechat_allow_manual_on_hold_upon_agent_engagement_only', { value: true }), + setSettingValueById(api, 'Livechat_allow_manual_on_hold', false), + setSettingValueById(api, 'Livechat_allow_manual_on_hold_upon_agent_engagement_only', true), ]); }); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-priorities-sidebar.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-priorities-sidebar.spec.ts index 10fe89818fe2f..63a1607a5a122 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-priorities-sidebar.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-priorities-sidebar.spec.ts @@ -3,6 +3,7 @@ import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel } from '../page-objects'; import { OmnichannelRoomInfo } from '../page-objects/omnichannel-room-info'; +import { setSettingValueById } from '../utils'; import { createConversation } from '../utils/omnichannel/rooms'; import { test, expect } from '../utils/test'; @@ -20,11 +21,11 @@ test.describe.serial('OC - Priorities [Sidebar]', () => { let poRoomInfo: OmnichannelRoomInfo; test.beforeAll(async ({ api }) => { + await setSettingValueById(api, 'Livechat_Routing_Method', 'Manual_Selection'); ( await Promise.all([ api.post('/livechat/users/agent', { username: 'user1' }), api.post('/livechat/users/manager', { username: 'user1' }), - api.post('/settings/Livechat_Routing_Method', { value: 'Manual_Selection' }), ]) ).every((res) => expect(res.status()).toBe(200)); }); @@ -44,13 +45,10 @@ test.describe.serial('OC - Priorities [Sidebar]', () => { }); test.afterAll(async ({ api }) => { - ( - await Promise.all([ - api.delete('/livechat/users/agent/user1'), - api.delete('/livechat/users/manager/user1'), - api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }), - ]) - ).every((res) => expect(res.status()).toBe(200)); + await setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection'); + (await Promise.all([api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/manager/user1')])).every((res) => + expect(res.status()).toBe(200), + ); }); test('OC - Priorities [Sidebar] - Update conversation priority', async ({ page }) => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-takeChat.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-takeChat.spec.ts index 92a06ffb061a7..c27e7281c678a 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-takeChat.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-takeChat.spec.ts @@ -4,6 +4,7 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeOmnichannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { test, expect } from '../utils/test'; test.describe('omnichannel-takeChat', () => { @@ -21,9 +22,9 @@ test.describe('omnichannel-takeChat', () => { test.beforeAll(async ({ api, browser }) => { await Promise.all([ - await api.post('/livechat/users/agent', { username: 'user1' }).then((res) => expect(res.status()).toBe(200)), - await api.post('/settings/Livechat_Routing_Method', { value: 'Manual_Selection' }).then((res) => expect(res.status()).toBe(200)), - await api.post('/settings/Livechat_enabled_when_agent_idle', { value: false }).then((res) => expect(res.status()).toBe(200)), + api.post('/livechat/users/agent', { username: 'user1' }).then((res) => expect(res.status()).toBe(200)), + setSettingValueById(api, 'Livechat_Routing_Method', 'Manual_Selection'), + setSettingValueById(api, 'Livechat_enabled_when_agent_idle', false), ]); const { page } = await createAuxContext(browser, Users.user1); @@ -36,9 +37,9 @@ test.describe('omnichannel-takeChat', () => { await agent.page.close(); await Promise.all([ - await api.delete('/livechat/users/agent/user1'), - await api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }), - await api.post('/settings/Livechat_enabled_when_agent_idle', { value: true }), + api.delete('/livechat/users/agent/user1'), + setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection'), + setSettingValueById(api, 'Livechat_enabled_when_agent_idle', true), ]); }); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-transfer-to-another-agents.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-transfer-to-another-agents.spec.ts index 5be6c4181460b..492a779174f2c 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-transfer-to-another-agents.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-transfer-to-another-agents.spec.ts @@ -3,6 +3,7 @@ import type { Page } from '@playwright/test'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { createManager } from '../utils/omnichannel/managers'; import { createConversation } from '../utils/omnichannel/rooms'; @@ -23,7 +24,7 @@ test.describe('OC - Chat transfers [Agent role]', () => { // Livechat when agent idle test.beforeAll(async ({ api }) => { - await api.post('/settings/Livechat_enabled_when_agent_idle', { value: false }).then((res) => expect(res.status()).toBe(200)); + await setSettingValueById(api, 'Livechat_enabled_when_agent_idle', false); }); // Create agent sessions @@ -40,7 +41,7 @@ test.describe('OC - Chat transfers [Agent role]', () => { ...conversations.map((conversation) => conversation.delete()), ...agents.map((agent) => agent.delete()), ...managers.map((manager) => manager.delete()), - api.post('/settings/Livechat_enabled_when_agent_idle', { value: true }).then((res) => expect(res.status()).toBe(200)), + setSettingValueById(api, 'Livechat_enabled_when_agent_idle', true), ]); }); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-after-registration.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-after-registration.spec.ts index 75d104cf02dcc..255652cfc12e1 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-after-registration.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-after-registration.spec.ts @@ -5,6 +5,7 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeOmnichannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { test, expect } from '../utils/test'; test.describe('OC - Livechat New Chat Triggers - After Registration', () => { @@ -66,7 +67,7 @@ test.describe('OC - Livechat New Chat Triggers - After Registration', () => { }); test.afterAll(async ({ api }) => { - await api.post('/settings/Livechat_clear_local_storage_when_chat_ended', { value: false }); + await setSettingValueById(api, 'Livechat_clear_local_storage_when_chat_ended', false); }); test.describe('OC - Livechat New Chat Triggers - After Registration', async () => { @@ -114,7 +115,7 @@ test.describe('OC - Livechat New Chat Triggers - After Registration', () => { test.describe('OC - Livechat New Chat Triggers - After Registration, clear Local storage', async () => { test.beforeAll(async ({ api }) => { - await api.post('/settings/Livechat_clear_local_storage_when_chat_ended', { value: true }); + await setSettingValueById(api, 'Livechat_clear_local_storage_when_chat_ended', true); }); test('expect trigger message after registration not be visible after local storage clear', async () => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-open-by-visitor.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-open-by-visitor.spec.ts index 1045036a926c5..6afd59bb75e3a 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-open-by-visitor.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-open-by-visitor.spec.ts @@ -4,6 +4,7 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeOmnichannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { test, expect } from '../utils/test'; test.use({ storageState: Users.admin.state }); @@ -67,7 +68,7 @@ test.describe('OC - Livechat Triggers - Open by Visitor', () => { await Promise.all([ api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/manager/user1'), - api.post('/settings/Livechat_clear_local_storage_when_chat_ended', { value: false }), + setSettingValueById(api, 'Livechat_clear_local_storage_when_chat_ended', false), ]); await agent.page.close(); }); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-setDepartment.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-setDepartment.spec.ts index 0c6415dd058ed..e4713f18e52b2 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-setDepartment.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-setDepartment.spec.ts @@ -2,6 +2,7 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChatEmbedded } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments'; import { test, expect } from '../utils/test'; @@ -88,11 +89,11 @@ test.describe('OC - Livechat Triggers - SetDepartment', () => { ) as unknown as string[]; await Promise.all(ids.map((id) => api.delete(`/livechat/triggers/${id}`))); - expect((await api.post('/settings/Omnichannel_enable_department_removal', { value: true })).status()).toBe(200); + await setSettingValueById(api, 'Omnichannel_enable_department_removal', true); await Promise.all([...agents.map((agent) => agent.delete())]); await Promise.all([...departments.map((department) => department.delete())]); - expect((await api.post('/settings/Omnichannel_enable_department_removal', { value: false })).status()).toBe(200); - await api.post('/settings/Livechat_registration_form', { value: true }); + await setSettingValueById(api, 'Omnichannel_enable_department_removal', false); + await setSettingValueById(api, 'Livechat_registration_form', true); }); test('OC - Livechat Triggers - setDepartment should affect agent.next call', async () => { @@ -110,7 +111,7 @@ test.describe('OC - Livechat Triggers - SetDepartment', () => { }); test('OC - Livechat Triggers - setDepartment should affect agent.next call - Register Form Disabled', async ({ api }) => { - await api.post('/settings/Livechat_registration_form', { value: false }); + await setSettingValueById(api, 'Livechat_registration_form', false); await poLiveChat.page.goto('/packages/rocketchat_livechat/assets/demo.html'); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-time-on-site.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-time-on-site.spec.ts index 66bf1058ebfa6..538f2430456ff 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-time-on-site.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-time-on-site.spec.ts @@ -4,6 +4,7 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeOmnichannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { test, expect } from '../utils/test'; test.use({ storageState: Users.admin.state }); @@ -53,7 +54,7 @@ test.describe('OC - Livechat Triggers - Time on site', () => { await Promise.all([ api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/manager/user1'), - api.post('/settings/Livechat_clear_local_storage_when_chat_ended', { value: false }), + setSettingValueById(api, 'Livechat_clear_local_storage_when_chat_ended', false), ]); await agent.page.close(); }); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers.spec.ts index 8add05c7c1e68..59c56ea2316d5 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers.spec.ts @@ -5,6 +5,7 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeOmnichannel } from '../page-objects'; +import { setSettingValueById } from '../utils'; import { test, expect } from '../utils/test'; test.describe.serial('OC - Livechat Triggers', () => { @@ -21,7 +22,7 @@ test.describe.serial('OC - Livechat Triggers', () => { const requests = await Promise.all([ api.post('/livechat/users/agent', { username: 'user1' }), api.post('/livechat/users/manager', { username: 'user1' }), - api.post('/settings/Livechat_clear_local_storage_when_chat_ended', { value: true }), + setSettingValueById(api, 'Livechat_clear_local_storage_when_chat_ended', true), ]); requests.every((e) => expect(e.status()).toBe(200)); @@ -44,7 +45,7 @@ test.describe.serial('OC - Livechat Triggers', () => { await Promise.all([ api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/manager/user1'), - api.post('/settings/Livechat_clear_local_storage_when_chat_ended', { value: false }), + setSettingValueById(api, 'Livechat_clear_local_storage_when_chat_ended', false), ]); await agent.page.close(); }); diff --git a/apps/meteor/tests/e2e/permissions.spec.ts b/apps/meteor/tests/e2e/permissions.spec.ts index 75bf44a159e20..ef331561628fa 100644 --- a/apps/meteor/tests/e2e/permissions.spec.ts +++ b/apps/meteor/tests/e2e/permissions.spec.ts @@ -1,6 +1,6 @@ import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { createTargetChannel } from './utils'; +import { createTargetChannel, setSettingValueById } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.user2.state }); @@ -21,9 +21,7 @@ test.describe.serial('permissions', () => { test.describe.serial('Edit message', () => { test.beforeAll(async ({ api }) => { - const statusCode = (await api.post('/settings/Message_AllowEditing', { value: false })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'Message_AllowEditing', false); }); test('expect option(edit) not be visible', async ({ page }) => { @@ -40,17 +38,13 @@ test.describe.serial('permissions', () => { }); test.afterAll(async ({ api }) => { - const statusCode = (await api.post('/settings/Message_AllowEditing', { value: true })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'Message_AllowEditing', true); }); }); test.describe.serial('Delete message', () => { test.beforeAll(async ({ api }) => { - const statusCode = (await api.post('/settings/Message_AllowDeleting', { value: false })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'Message_AllowDeleting', false); }); test('expect option(delete) not be visible', async ({ page }) => { @@ -68,9 +62,7 @@ test.describe.serial('permissions', () => { }); test.afterAll(async ({ api }) => { - const statusCode = (await api.post('/settings/Message_AllowDeleting', { value: true })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'Message_AllowDeleting', true); }); }); @@ -78,9 +70,7 @@ test.describe.serial('permissions', () => { test.use({ storageState: Users.admin.state }); test.beforeAll(async ({ api }) => { - const statusCode = (await api.post('/settings/Message_AllowPinning', { value: false })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'Message_AllowPinning', false); }); test('expect option(pin) not be visible', async ({ page }) => { @@ -94,9 +84,7 @@ test.describe.serial('permissions', () => { }); test.afterAll(async ({ api }) => { - const statusCode = (await api.post('/settings/Message_AllowPinning', { value: true })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'Message_AllowPinning', true); }); }); @@ -104,9 +92,7 @@ test.describe.serial('permissions', () => { // and after a click a "not allowed" alert pops up test.describe.skip('Star message', () => { test.beforeAll(async ({ api }) => { - const statusCode = (await api.post('/settings/Message_AllowStarring', { value: false })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'Message_AllowStarring', false); }); test('expect option(star) not be visible', async ({ page }) => { @@ -123,17 +109,13 @@ test.describe.serial('permissions', () => { }); test.afterAll(async ({ api }) => { - const statusCode = (await api.post('/settings/Message_AllowStarring', { value: true })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'Message_AllowStarring', true); }); }); test.describe.serial('Upload file', () => { test.beforeAll(async ({ api }) => { - const statusCode = (await api.post('/settings/FileUpload_Enabled', { value: false })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'FileUpload_Enabled', false); }); test('expect option (upload file) not be visible', async () => { @@ -142,17 +124,13 @@ test.describe.serial('permissions', () => { }); test.afterAll(async ({ api }) => { - const statusCode = (await api.post('/settings/FileUpload_Enabled', { value: true })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'FileUpload_Enabled', true); }); }); test.describe.serial('Upload audio', () => { test.beforeAll(async ({ api }) => { - const statusCode = (await api.post('/settings/Message_AudioRecorderEnabled', { value: false })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'Message_AudioRecorderEnabled', false); }); test('expect option (upload audio) not be visible', async () => { @@ -161,17 +139,13 @@ test.describe.serial('permissions', () => { }); test.afterAll(async ({ api }) => { - const statusCode = (await api.post('/settings/Message_AudioRecorderEnabled', { value: true })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'Message_AudioRecorderEnabled', true); }); }); test.describe.serial('Upload video', () => { test.beforeAll(async ({ api }) => { - const statusCode = (await api.post('/settings/Message_VideoRecorderEnabled', { value: false })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'Message_VideoRecorderEnabled', false); }); test('expect option (upload video) not be visible', async () => { @@ -180,19 +154,14 @@ test.describe.serial('permissions', () => { }); test.afterAll(async ({ api }) => { - const statusCode = (await api.post('/settings/Message_VideoRecorderEnabled', { value: true })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'Message_VideoRecorderEnabled', true); }); }); test.describe.serial('Filter words', () => { test.beforeAll(async ({ api }) => { - const statusCode1 = (await api.post('/settings/Message_AllowBadWordsFilter', { value: true })).status(); - const statusCode2 = (await api.post('/settings/Message_BadWordsFilterList', { value: 'badword' })).status(); - - await expect(statusCode1).toBe(200); - await expect(statusCode2).toBe(200); + await setSettingValueById(api, 'Message_AllowBadWordsFilter', true); + await setSettingValueById(api, 'Message_BadWordsFilterList', 'badword'); }); test('expect badword be censored', async () => { @@ -203,9 +172,7 @@ test.describe.serial('permissions', () => { }); test.afterAll(async ({ api }) => { - const statusCode = (await api.post('/settings/Message_AllowBadWordsFilter', { value: false })).status(); - - await expect(statusCode).toBe(200); + await setSettingValueById(api, 'Message_AllowBadWordsFilter', false); }); }); }); diff --git a/apps/meteor/tests/e2e/register.spec.ts b/apps/meteor/tests/e2e/register.spec.ts index 0e371aa25d972..80e7b1397bc02 100644 --- a/apps/meteor/tests/e2e/register.spec.ts +++ b/apps/meteor/tests/e2e/register.spec.ts @@ -1,6 +1,7 @@ import { faker } from '@faker-js/faker'; import { Utils, Registration } from './page-objects'; +import { setSettingValueById } from './utils'; import { test, expect } from './utils/test'; test.describe.parallel('register', () => { @@ -12,6 +13,7 @@ test.describe.parallel('register', () => { poRegistration = new Registration(page); poUtils = new Utils(page); }); + test('Successfully Registration flow', async ({ page }) => { await test.step('expect trigger a validation error if no data is provided on register', async () => { await page.goto('/home'); @@ -45,19 +47,16 @@ test.describe.parallel('register', () => { test.describe('Registration without Account confirmation password set', async () => { test.beforeEach(async ({ api }) => { - const result = await api.post('/settings/Accounts_RequirePasswordConfirmation', { value: false }); - - await expect(result.ok()).toBeTruthy(); + await setSettingValueById(api, 'Accounts_RequirePasswordConfirmation', false); }); + test.beforeEach(async ({ page }) => { await page.goto('/home'); await poRegistration.goToRegister.click(); }); + test.afterEach(async ({ api }) => { - const result = await api.post('/settings/Accounts_RequirePasswordConfirmation', { - value: true, - }); - await expect(result.ok()).toBeTruthy(); + await setSettingValueById(api, 'Accounts_RequirePasswordConfirmation', true); }); test('expect to register a user without password confirmation', async () => { @@ -79,10 +78,11 @@ test.describe.parallel('register', () => { test.describe('Registration with manually confirmation enabled', async () => { test.beforeEach(async ({ api }) => { - const result = await api.post('/settings/Accounts_ManuallyApproveNewUsers', { value: true }); + const result = await await setSettingValueById(api, 'Accounts_ManuallyApproveNewUsers', { value: true }); await expect(result.ok()).toBeTruthy(); }); + test.beforeEach(async ({ page }) => { poRegistration = new Registration(page); @@ -91,10 +91,7 @@ test.describe.parallel('register', () => { }); test.afterEach(async ({ api }) => { - const result = await api.post('/settings/Accounts_ManuallyApproveNewUsers', { - value: false, - }); - await expect(result.ok()).toBeTruthy(); + await setSettingValueById(api, 'Accounts_ManuallyApproveNewUsers', false); }); test('it should expect to have a textbox asking the reason for the registration', async () => { @@ -111,12 +108,11 @@ test.describe.parallel('register', () => { test.describe('Registration form Disabled', async () => { test.beforeEach(async ({ api }) => { - const result = await api.post('/settings/Accounts_RegistrationForm', { value: 'Disabled' }); - await expect(result.ok()).toBeTruthy(); + await setSettingValueById(api, 'Accounts_RegistrationForm', 'Disabled'); }); test.afterEach(async ({ api }) => { - await api.post('/settings/Accounts_RegistrationForm', { value: 'Public' }); + await setSettingValueById(api, 'Accounts_RegistrationForm', 'Public'); }); test('It should expect a message warning that registration is disabled', async ({ page }) => { @@ -140,14 +136,12 @@ test.describe.parallel('register', () => { test.beforeEach(async ({ api, page }) => { poRegistration = new Registration(page); poUtils = new Utils(page); - const result = await api.post('/settings/Accounts_RegistrationForm', { value: 'Secret URL' }); - await api.post('/settings/Accounts_RegistrationForm_SecretURL', { value: 'secret' }); - await expect(result.ok()).toBeTruthy(); + await setSettingValueById(api, 'Accounts_RegistrationForm', 'Secret URL'); + await setSettingValueById(api, 'Accounts_RegistrationForm_SecretURL', 'secret'); }); test.afterAll(async ({ api }) => { - const result = await api.post('/settings/Accounts_RegistrationForm', { value: 'Public' }); - await expect(result.ok()).toBeTruthy(); + await setSettingValueById(api, 'Accounts_RegistrationForm', 'Public'); }); test('It should expect a message warning that registration is disabled', async ({ page }) => { @@ -182,9 +176,8 @@ test.describe.parallel('register', () => { test.describe('Registration by Secret is disabled url should fail', async () => { test.beforeAll(async ({ api }) => { - const result = await api.post('/settings/Accounts_RegistrationForm', { value: 'Public' }); - await api.post('/settings/Accounts_RegistrationForm_SecretURL', { value: 'secret' }); - await expect(result.ok()).toBeTruthy(); + await setSettingValueById(api, 'Accounts_RegistrationForm', 'Public'); + await setSettingValueById(api, 'Accounts_RegistrationForm_SecretURL', 'secret'); }); test('It should show an invalid page informing that the url is not valid', async ({ page }) => {