From c63cb5b5d0c707c81ad3905fa722d2f1538579f6 Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Wed, 9 Apr 2025 15:26:08 -0300 Subject: [PATCH 1/9] test: added status check to setSettingValueById util --- apps/meteor/tests/e2e/utils/setSettingValueById.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/meteor/tests/e2e/utils/setSettingValueById.ts b/apps/meteor/tests/e2e/utils/setSettingValueById.ts index f63593380993a..241db28bbe34d 100644 --- a/apps/meteor/tests/e2e/utils/setSettingValueById.ts +++ b/apps/meteor/tests/e2e/utils/setSettingValueById.ts @@ -2,5 +2,14 @@ import type { APIResponse } from '@playwright/test'; import type { BaseTest } from './test'; -export const setSettingValueById = (api: BaseTest['api'], settingId: string, value: unknown): Promise => - api.post(`/settings/${settingId}`, { value }); +export const setSettingValueById = async (api: BaseTest['api'], settingId: string, value: unknown): Promise => { + const response = await api.post(`/settings/${settingId}`, { value }); + + if (!response.ok()) { + throw new Error( + `Failed to update setting "${settingId}" with value "${value}" [http status: ${response.status()} ${response.statusText()}]`, + ); + } + + return response; +}; From be89548ebfe71a0c93d11b41fecf043f6f5f5afa Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Wed, 9 Apr 2025 15:40:28 -0300 Subject: [PATCH 2/9] test: added strict option to setSettingValueById --- apps/meteor/tests/e2e/utils/setSettingValueById.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/meteor/tests/e2e/utils/setSettingValueById.ts b/apps/meteor/tests/e2e/utils/setSettingValueById.ts index 241db28bbe34d..cfe22d587ce31 100644 --- a/apps/meteor/tests/e2e/utils/setSettingValueById.ts +++ b/apps/meteor/tests/e2e/utils/setSettingValueById.ts @@ -2,10 +2,10 @@ import type { APIResponse } from '@playwright/test'; import type { BaseTest } from './test'; -export const setSettingValueById = async (api: BaseTest['api'], settingId: string, value: unknown): Promise => { +export const setSettingValueById = async (api: BaseTest['api'], settingId: string, value: unknown, strict = true): Promise => { const response = await api.post(`/settings/${settingId}`, { value }); - if (!response.ok()) { + if (strict && !response.ok()) { throw new Error( `Failed to update setting "${settingId}" with value "${value}" [http status: ${response.status()} ${response.statusText()}]`, ); From 8259bffa46ead8cd2816200c3a78cdb7984c02e2 Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Wed, 9 Apr 2025 16:09:35 -0300 Subject: [PATCH 3/9] test: added updateSettings util --- apps/meteor/tests/e2e/utils/setSettingValueById.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/meteor/tests/e2e/utils/setSettingValueById.ts b/apps/meteor/tests/e2e/utils/setSettingValueById.ts index cfe22d587ce31..dc4a32fc3ddb1 100644 --- a/apps/meteor/tests/e2e/utils/setSettingValueById.ts +++ b/apps/meteor/tests/e2e/utils/setSettingValueById.ts @@ -1,4 +1,5 @@ import type { APIResponse } from '@playwright/test'; +import type { ISetting } from '@rocket.chat/core-typings'; import type { BaseTest } from './test'; @@ -13,3 +14,12 @@ export const setSettingValueById = async (api: BaseTest['api'], settingId: strin return response; }; + +export const updateSettings = async ( + api: BaseTest['api'], + settings: Record, + strict = true, +): Promise => { + const entries = Object.entries(settings); + return Promise.all(entries.map(([name, value]) => setSettingValueById(api, name, value, strict))); +}; From fe80cff37410a3a31e204f804eaa31918157a5a1 Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Wed, 9 Apr 2025 17:59:34 -0300 Subject: [PATCH 4/9] test: renamed setSettingValueById to updateSetting --- apps/meteor/tests/e2e/utils/index.ts | 2 +- .../e2e/utils/{setSettingValueById.ts => updateSetting.ts} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename apps/meteor/tests/e2e/utils/{setSettingValueById.ts => updateSetting.ts} (72%) diff --git a/apps/meteor/tests/e2e/utils/index.ts b/apps/meteor/tests/e2e/utils/index.ts index 7548171e8758d..8a31e0a819b01 100644 --- a/apps/meteor/tests/e2e/utils/index.ts +++ b/apps/meteor/tests/e2e/utils/index.ts @@ -1,4 +1,4 @@ export * from './create-target-channel'; -export * from './setSettingValueById'; +export * from './updateSetting'; export * from './getSettingValueById'; export * from './setUserPreferences'; diff --git a/apps/meteor/tests/e2e/utils/setSettingValueById.ts b/apps/meteor/tests/e2e/utils/updateSetting.ts similarity index 72% rename from apps/meteor/tests/e2e/utils/setSettingValueById.ts rename to apps/meteor/tests/e2e/utils/updateSetting.ts index dc4a32fc3ddb1..7537a3fa6506c 100644 --- a/apps/meteor/tests/e2e/utils/setSettingValueById.ts +++ b/apps/meteor/tests/e2e/utils/updateSetting.ts @@ -3,7 +3,7 @@ import type { ISetting } from '@rocket.chat/core-typings'; import type { BaseTest } from './test'; -export const setSettingValueById = async (api: BaseTest['api'], settingId: string, value: unknown, strict = true): Promise => { +export const updateSetting = async (api: BaseTest['api'], settingId: string, value: unknown, strict = true): Promise => { const response = await api.post(`/settings/${settingId}`, { value }); if (strict && !response.ok()) { @@ -21,5 +21,5 @@ export const updateSettings = async ( strict = true, ): Promise => { const entries = Object.entries(settings); - return Promise.all(entries.map(([name, value]) => setSettingValueById(api, name, value, strict))); + return Promise.all(entries.map(([name, value]) => updateSetting(api, name, value, strict))); }; From 119fe258bac211d33723a602fbc8851ac68df185 Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Wed, 9 Apr 2025 17:59:56 -0300 Subject: [PATCH 5/9] test: updated test files to use updateSetting util --- .../tests/e2e/access-security-page.spec.ts | 58 +++++++-------- ...account-forgetSessionOnWindowClose.spec.ts | 7 +- apps/meteor/tests/e2e/administration.spec.ts | 6 +- apps/meteor/tests/e2e/anonymous-user.spec.ts | 14 ++-- apps/meteor/tests/e2e/avatar-settings.ts | 15 ++-- apps/meteor/tests/e2e/e2e-encryption.spec.ts | 58 ++++++++------- apps/meteor/tests/e2e/feature-preview.spec.ts | 10 +-- apps/meteor/tests/e2e/file-upload.spec.ts | 9 ++- apps/meteor/tests/e2e/homepage.spec.ts | 50 ++++++++----- apps/meteor/tests/e2e/login.spec.ts | 6 +- apps/meteor/tests/e2e/oauth.spec.ts | 10 +-- .../omnichannel/omnichannel-agents.spec.ts | 5 +- .../omnichannel-appearance.spec.ts | 9 +-- ...nichannel-auto-onhold-chat-closing.spec.ts | 16 +++-- ...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 | 17 ++--- .../omnichannel-livechat-background.spec.ts | 7 +- .../omnichannel-livechat-department.spec.ts | 5 +- .../omnichannel-livechat-fileupload.spec.ts | 35 ++++----- ...hat-queue-management-autoselection.spec.ts | 19 +++-- ...ichannel-livechat-queue-management.spec.ts | 21 +++--- .../omnichannel-livechat-watermark.spec.ts | 4 +- .../omnichannel/omnichannel-livechat.spec.ts | 22 +++--- .../omnichannel-manager-role.spec.ts | 16 +++-- ...mnichannel-manual-selection-logout.spec.ts | 6 +- .../omnichannel-manual-selection.spec.ts | 9 +-- .../omnichannel-monitor-role.spec.ts | 13 ++-- .../omnichannel-priorities-sidebar.spec.ts | 14 ++-- .../omnichannel/omnichannel-takeChat.spec.ts | 11 ++- ...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 | 71 ++++++------------- apps/meteor/tests/e2e/presence.spec.ts | 8 +-- apps/meteor/tests/e2e/read-receipts.spec.ts | 14 ++-- apps/meteor/tests/e2e/register.spec.ts | 45 ++++++------ apps/meteor/tests/e2e/reset-password.spec.ts | 8 +-- .../meteor/tests/e2e/retention-policy.spec.ts | 29 ++++---- apps/meteor/tests/e2e/saml.spec.ts | 40 +++++------ .../tests/e2e/search-discussion.spec.ts | 9 ++- ...tings-persistence-on-ui-navigation.spec.ts | 6 +- apps/meteor/tests/e2e/system-messages.spec.ts | 8 +-- apps/meteor/tests/e2e/translations.spec.ts | 15 ++-- 51 files changed, 425 insertions(+), 390 deletions(-) diff --git a/apps/meteor/tests/e2e/access-security-page.spec.ts b/apps/meteor/tests/e2e/access-security-page.spec.ts index 590f41297ef2a..e6ae7661eefd3 100644 --- a/apps/meteor/tests/e2e/access-security-page.spec.ts +++ b/apps/meteor/tests/e2e/access-security-page.spec.ts @@ -1,6 +1,6 @@ import { Users } from './fixtures/userStates'; import { AccountProfile } from './page-objects'; -import { setSettingValueById } from './utils/setSettingValueById'; +import { updateSettings } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -9,11 +9,11 @@ test.describe.serial('access-security-page', () => { let poAccountProfile: AccountProfile; test.beforeAll(async ({ api }) => { - await Promise.all([ - setSettingValueById(api, 'Accounts_AllowPasswordChange', false), - setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', false), - setSettingValueById(api, 'E2E_Enable', false), - ]); + await updateSettings(api, { + Accounts_AllowPasswordChange: false, + Accounts_TwoFactorAuthentication_Enabled: false, + E2E_Enable: false, + }); }); test.beforeEach(async ({ page }) => { @@ -22,13 +22,13 @@ test.describe.serial('access-security-page', () => { await page.waitForSelector('.main-content'); }); - test.afterAll(async ({ api }) => - Promise.all([ - setSettingValueById(api, 'Accounts_AllowPasswordChange', true), - setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', true), - setSettingValueById(api, 'E2E_Enable', false), - ]), - ); + test.afterAll(async ({ api }) => { + await updateSettings(api, { + Accounts_AllowPasswordChange: true, + Accounts_TwoFactorAuthentication_Enabled: true, + E2E_Enable: false, + }); + }); test('security tab is invisible when password change, 2FA and E2E are disabled', async ({ page }) => { const securityTab = poAccountProfile.sidenav.linkSecurity; @@ -39,11 +39,11 @@ test.describe.serial('access-security-page', () => { test.describe.serial('can access account security sections', () => { test.beforeAll(async ({ api }) => { - await Promise.all([ - setSettingValueById(api, 'Accounts_AllowPasswordChange', true), - setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', false), - setSettingValueById(api, 'E2E_Enable', false), - ]); + await updateSettings(api, { + Accounts_AllowPasswordChange: true, + Accounts_TwoFactorAuthentication_Enabled: false, + E2E_Enable: false, + }); }); test.beforeEach(async () => { @@ -61,20 +61,22 @@ test.describe.serial('access-security-page', () => { }); test('can access 2FA setting when enabled but password change and E2E are disabled', async ({ api }) => { - await Promise.all([ - setSettingValueById(api, 'Accounts_AllowPasswordChange', false), - setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', true), - setSettingValueById(api, 'E2E_Enable', false), - ]); + await updateSettings(api, { + Accounts_AllowPasswordChange: false, + Accounts_TwoFactorAuthentication_Enabled: true, + E2E_Enable: false, + }); + await expect(poAccountProfile.security2FASection).toBeVisible(); }); test('can access E2E setting when enabled but password change and 2FA are disabled', async ({ api }) => { - await Promise.all([ - setSettingValueById(api, 'Accounts_AllowPasswordChange', false), - setSettingValueById(api, 'Accounts_TwoFactorAuthentication_Enabled', false), - setSettingValueById(api, 'E2E_Enable', true), - ]); + await updateSettings(api, { + Accounts_AllowPasswordChange: false, + Accounts_TwoFactorAuthentication_Enabled: false, + E2E_Enable: true, + }); + await expect(poAccountProfile.securityE2EEncryptionSection).toBeVisible(); }); }); diff --git a/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts b/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts index a820e04f88dd9..e483c3daf8deb 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 { updateSetting } 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 updateSetting(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 updateSetting(api, 'Accounts_ForgetUserSessionOnWindowClose', true); }); test.afterAll(async ({ api }) => { - await api.post('/settings/Accounts_ForgetUserSessionOnWindowClose', { value: false }); + await updateSetting(api, 'Accounts_ForgetUserSessionOnWindowClose', false); }); test('Login using credentials and reload to get logged out', async ({ page, context }) => { diff --git a/apps/meteor/tests/e2e/administration.spec.ts b/apps/meteor/tests/e2e/administration.spec.ts index dde8bfe392d06..bb3985cb4d2d6 100644 --- a/apps/meteor/tests/e2e/administration.spec.ts +++ b/apps/meteor/tests/e2e/administration.spec.ts @@ -3,7 +3,7 @@ import { faker } from '@faker-js/faker'; import { IS_EE } from './config/constants'; import { Users } from './fixtures/userStates'; import { Admin, Utils } from './page-objects'; -import { createTargetChannel, setSettingValueById } from './utils'; +import { createTargetChannel, updateSetting } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -283,7 +283,7 @@ test.describe.parallel('administration', () => { const incomingIntegrationName = faker.string.uuid(); test.beforeAll(async ({ api }) => { - await setSettingValueById(api, 'Message_Code_highlight', ''); + await updateSetting(api, 'Message_Code_highlight', ''); }); test.beforeEach(async ({ page }) => { @@ -291,7 +291,7 @@ test.describe.parallel('administration', () => { }); test.afterAll(async ({ api }) => { - await setSettingValueById(api, 'Message_Code_highlight', messageCodeHighlightDefault); + await updateSetting(api, 'Message_Code_highlight', messageCodeHighlightDefault); }); test('should display the example payload correctly', async () => { diff --git a/apps/meteor/tests/e2e/anonymous-user.spec.ts b/apps/meteor/tests/e2e/anonymous-user.spec.ts index 45fb03284a590..2ab13be74e332 100644 --- a/apps/meteor/tests/e2e/anonymous-user.spec.ts +++ b/apps/meteor/tests/e2e/anonymous-user.spec.ts @@ -1,20 +1,24 @@ import { faker } from '@faker-js/faker'; import { HomeChannel, Registration } from './page-objects'; -import { setSettingValueById } from './utils/setSettingValueById'; +import { updateSettings } from './utils'; import { expect, test } from './utils/test'; test.describe('anonymous-user', () => { let poHomeChannel: HomeChannel; test.beforeAll(async ({ api }) => { - await expect((await setSettingValueById(api, 'Accounts_AllowAnonymousRead', true)).status()).toBe(200); - await expect((await setSettingValueById(api, 'Accounts_AllowAnonymousWrite', true)).status()).toBe(200); + await updateSettings(api, { + Accounts_AllowAnonymousRead: true, + Accounts_AllowAnonymousWrite: true, + }); }); test.afterAll(async ({ api }) => { - await expect((await setSettingValueById(api, 'Accounts_AllowAnonymousRead', false)).status()).toBe(200); - await expect((await setSettingValueById(api, 'Accounts_AllowAnonymousWrite', false)).status()).toBe(200); + await updateSettings(api, { + Accounts_AllowAnonymousRead: false, + Accounts_AllowAnonymousWrite: false, + }); }); test.beforeEach(async ({ page }) => { diff --git a/apps/meteor/tests/e2e/avatar-settings.ts b/apps/meteor/tests/e2e/avatar-settings.ts index cba8c5ae63ba2..9ef1fe18c301e 100644 --- a/apps/meteor/tests/e2e/avatar-settings.ts +++ b/apps/meteor/tests/e2e/avatar-settings.ts @@ -1,7 +1,6 @@ import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { createTargetChannel, createTargetPrivateChannel, createDirectMessage } from './utils'; -import { setSettingValueById } from './utils/setSettingValueById'; +import { createTargetChannel, createTargetPrivateChannel, createDirectMessage, updateSettings } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -35,13 +34,17 @@ test.describe('avatar-settings', () => { const providerUrlPrefix = 'https://example.com/avatar/'; test.beforeAll(async ({ api }) => { - await setSettingValueById(api, 'Accounts_RoomAvatarExternalUrl', `${providerUrlPrefix}{username}`); - await setSettingValueById(api, 'Accounts_AvatarExternalUrl', `${providerUrlPrefix}{username}`); + await updateSettings(api, { + Accounts_RoomAvatarExternalUrl: `${providerUrlPrefix}{username}`, + Accounts_AvatarExternalUrl: `${providerUrlPrefix}{username}`, + }); }); test.afterAll(async ({ api }) => { - await setSettingValueById(api, 'Accounts_RoomAvatarExternalUrl', ''); - await setSettingValueById(api, 'Accounts_AvatarExternalUrl', ''); + await updateSettings(api, { + Accounts_RoomAvatarExternalUrl: '', + Accounts_AvatarExternalUrl: '', + }); }); test.describe('public channels', () => { diff --git a/apps/meteor/tests/e2e/e2e-encryption.spec.ts b/apps/meteor/tests/e2e/e2e-encryption.spec.ts index 39ba5fe64d015..70eda971e8d44 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 { updateSetting, updateSettings } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -22,13 +23,17 @@ 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 updateSettings(api, { + E2E_Enable: true, + 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 updateSettings(api, { + E2E_Enable: false, + E2E_Allow_Unencrypted_Messages: false, + }); }); test.afterEach(async ({ api }) => { @@ -253,19 +258,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 updateSetting(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 updateSetting(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 updateSettings(api, { E2E_Enable: false, E2E_Allow_Unencrypted_Messages: false }); }); test('expect create a private channel encrypted and send an encrypted message', async ({ page }) => { @@ -518,8 +522,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 updateSettings(api, { + FileUpload_MediaTypeWhiteList: '', + FileUpload_MediaTypeBlackList: 'image/svg+xml', + }); }); test('File and description encryption', async ({ page }) => { @@ -580,7 +586,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 updateSetting(api, 'FileUpload_MediaTypeWhiteList', 'text/plain'); }); await test.step('send text file again with whitelist setting set', async () => { @@ -595,7 +601,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 updateSetting(api, 'FileUpload_MediaTypeBlackList', 'application/octet-stream'); }); await test.step('send text file again with blacklisted setting set, file upload should fail', async () => { @@ -612,13 +618,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 updateSettings(api, { + E2E_Enable_Encrypt_Files: false, + 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 updateSettings(api, { + E2E_Enable_Encrypt_Files: true, + FileUpload_MediaTypeBlackList: 'image/svg+xml', + }); }); test('Upload file without encryption in e2ee room', async ({ page }) => { @@ -696,11 +706,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 updateSetting(api, 'E2E_Allow_Unencrypted_Messages', false); }); test.afterAll(async ({ api }) => { - await api.post('/settings/E2E_Allow_Unencrypted_Messages', { value: true }); + await updateSetting(api, 'E2E_Allow_Unencrypted_Messages', true); }); test('expect slash commands to be disabled in an e2ee room', async ({ page }) => { @@ -859,13 +869,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 updateSettings(api, { E2E_Enable: true, 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 updateSettings(api, { E2E_Enable: false, E2E_Allow_Unencrypted_Messages: false }); }); test.afterEach(async ({ api }) => { @@ -1047,13 +1055,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 updateSettings(api, { E2E_Enable: true, 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 updateSettings(api, { E2E_Enable: false, E2E_Allow_Unencrypted_Messages: false }); }); // ->>>>>>>>>>>Not testing upload since it was not implemented in the legacy format diff --git a/apps/meteor/tests/e2e/feature-preview.spec.ts b/apps/meteor/tests/e2e/feature-preview.spec.ts index a8b105222e4e3..4f6b89576a525 100644 --- a/apps/meteor/tests/e2e/feature-preview.spec.ts +++ b/apps/meteor/tests/e2e/feature-preview.spec.ts @@ -8,7 +8,7 @@ import { createTargetTeam, deleteChannel, deleteTeam, - setSettingValueById, + updateSetting, createTargetDiscussion, createChannelWithTeam, deleteRoom, @@ -27,13 +27,13 @@ test.describe.serial('feature preview', () => { const targetChannelNameInTeam = `channel-from-team-${faker.number.int()}`; test.beforeAll(async ({ api }) => { - await setSettingValueById(api, 'Accounts_AllowFeaturePreview', true); + await updateSetting(api, 'Accounts_AllowFeaturePreview', true); targetChannel = await createTargetChannel(api, { members: ['user1'] }); targetDiscussion = await createTargetDiscussion(api); }); test.afterAll(async ({ api }) => { - await setSettingValueById(api, 'Accounts_AllowFeaturePreview', false); + await updateSetting(api, 'Accounts_AllowFeaturePreview', false); await deleteChannel(api, targetChannel); await deleteRoom(api, targetDiscussion._id); }); @@ -216,7 +216,7 @@ test.describe.serial('feature preview', () => { let user1Page: Page; test.beforeAll(async ({ api, browser }) => { - await setSettingValueById(api, 'Accounts_Default_User_Preferences_featuresPreview', [{ name: 'newNavigation', value: true }]); + await updateSetting(api, 'Accounts_Default_User_Preferences_featuresPreview', [{ name: 'newNavigation', value: true }]); const { channelName, teamName } = await createChannelWithTeam(api); targetTeam = teamName; @@ -225,7 +225,7 @@ test.describe.serial('feature preview', () => { }); test.afterAll(async ({ api }) => { - await setSettingValueById(api, 'Accounts_Default_User_Preferences_featuresPreview', []); + await updateSetting(api, 'Accounts_Default_User_Preferences_featuresPreview', []); await deleteChannel(api, targetChannelWithTeam); await deleteTeam(api, targetTeam); diff --git a/apps/meteor/tests/e2e/file-upload.spec.ts b/apps/meteor/tests/e2e/file-upload.spec.ts index 626162df47d3f..c125a692592de 100644 --- a/apps/meteor/tests/e2e/file-upload.spec.ts +++ b/apps/meteor/tests/e2e/file-upload.spec.ts @@ -1,7 +1,6 @@ import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { createTargetChannel } from './utils'; -import { setSettingValueById } from './utils/setSettingValueById'; +import { createTargetChannel, updateSetting } from './utils'; import { expect, test } from './utils/test'; test.use({ storageState: Users.user1.state }); @@ -11,7 +10,7 @@ test.describe.serial('file-upload', () => { let targetChannel: string; test.beforeAll(async ({ api }) => { - await setSettingValueById(api, 'FileUpload_MediaTypeBlackList', 'image/svg+xml'); + await updateSetting(api, 'FileUpload_MediaTypeBlackList', 'image/svg+xml'); targetChannel = await createTargetChannel(api, { members: ['user1'] }); }); @@ -23,7 +22,7 @@ test.describe.serial('file-upload', () => { }); test.afterAll(async ({ api }) => { - await setSettingValueById(api, 'FileUpload_MediaTypeBlackList', 'image/svg+xml'); + await updateSetting(api, 'FileUpload_MediaTypeBlackList', 'image/svg+xml'); expect((await api.post('/channels.delete', { roomName: targetChannel })).status()).toBe(200); }); @@ -69,7 +68,7 @@ test.describe.serial('file-upload', () => { }); test('expect not to send drawio file (unknown media type) when the default media type is blocked', async ({ api, page }) => { - await setSettingValueById(api, 'FileUpload_MediaTypeBlackList', 'application/octet-stream'); + await updateSetting(api, 'FileUpload_MediaTypeBlackList', 'application/octet-stream'); await page.reload(); await poHomeChannel.content.sendFileMessage('diagram.drawio'); diff --git a/apps/meteor/tests/e2e/homepage.spec.ts b/apps/meteor/tests/e2e/homepage.spec.ts index 72291785bd09c..5eedcd48df294 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 { updateSetting, updateSettings } 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 updateSettings(api, { + Layout_Home_Custom_Block_Visible: false, + 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 updateSetting(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 updateSetting(api, 'Layout_Home_Body', '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 updateSettings(api, { + Layout_Home_Body: 'Hello admin', + Layout_Home_Custom_Block_Visible: true, + 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 updateSetting(api, 'Layout_Home_Body', ''); regularUserPage = await browser.newPage({ storageState: Users.user2.state }); await regularUserPage.goto('/home'); await regularUserPage.waitForSelector('[data-qa-id="home-header"]'); @@ -148,16 +154,20 @@ 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 updateSettings(api, { + Site_Name: 'NewSiteName', + 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 updateSettings(api, { + Site_Name: 'Rocket.Chat', + Layout_Home_Title: 'Home', + }); }); test('expect welcome text and header text to be correct', async () => { @@ -173,16 +183,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 updateSettings(api, { + Layout_Home_Body: 'Hello', + 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 updateSettings(api, { + Layout_Home_Body: '', + Layout_Home_Custom_Block_Visible: false, + }); }); test('expect custom body to be visible', async () => { @@ -193,11 +207,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 updateSetting(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 updateSetting(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/login.spec.ts b/apps/meteor/tests/e2e/login.spec.ts index 75340c64506b3..e4cc5c37674f2 100644 --- a/apps/meteor/tests/e2e/login.spec.ts +++ b/apps/meteor/tests/e2e/login.spec.ts @@ -2,7 +2,7 @@ import { faker } from '@faker-js/faker'; import { DEFAULT_USER_CREDENTIALS } from './config/constants'; import { Utils, Registration } from './page-objects'; -import { setSettingValueById } from './utils/setSettingValueById'; +import { updateSetting } from './utils'; import { test, expect } from './utils/test'; test.describe.parallel('Login', () => { @@ -17,7 +17,7 @@ test.describe.parallel('Login', () => { }); test.afterAll(async ({ api }) => { - await setSettingValueById(api, 'Language', 'en'); + await updateSetting(api, 'Language', 'en'); }); test('should not have any accessibility violations', async ({ makeAxeBuilder }) => { @@ -57,7 +57,7 @@ test.describe.parallel('Login', () => { }); test('Should correctly display switch language button', async ({ page, api }) => { - expect((await setSettingValueById(api, 'Language', 'pt-BR')).status()).toBe(200); + expect((await updateSetting(api, 'Language', 'pt-BR')).status()).toBe(200); const button = page.getByRole('button', { name: 'Change to português (Brasil)' }); await button.click(); diff --git a/apps/meteor/tests/e2e/oauth.spec.ts b/apps/meteor/tests/e2e/oauth.spec.ts index c93dc5a4f7dbe..53faa2ccb80dd 100644 --- a/apps/meteor/tests/e2e/oauth.spec.ts +++ b/apps/meteor/tests/e2e/oauth.spec.ts @@ -1,5 +1,5 @@ import { Registration } from './page-objects'; -import { setSettingValueById } from './utils/setSettingValueById'; +import { updateSetting } from './utils'; import { test, expect } from './utils/test'; test.describe('OAuth', () => { @@ -11,7 +11,7 @@ test.describe('OAuth', () => { test('Login Page', async ({ page, api }) => { await test.step('expect OAuth button to be visible', async () => { - await expect((await setSettingValueById(api, 'Accounts_OAuth_Google', true)).status()).toBe(200); + await updateSetting(api, 'Accounts_OAuth_Google', true); await page.waitForTimeout(5000); await page.goto('/home'); @@ -20,7 +20,7 @@ test.describe('OAuth', () => { }); await test.step('expect Custom OAuth button to be visible', async () => { - await expect((await setSettingValueById(api, 'Accounts_OAuth_Custom-Test', true)).status()).toBe(200); + await updateSetting(api, 'Accounts_OAuth_Custom-Test', true); await page.waitForTimeout(5000); await page.goto('/home'); @@ -33,7 +33,7 @@ test.describe('OAuth', () => { }); await test.step('expect OAuth button to not be visible', async () => { - await expect((await setSettingValueById(api, 'Accounts_OAuth_Google', false)).status()).toBe(200); + await updateSetting(api, 'Accounts_OAuth_Google', false); await page.waitForTimeout(5000); await page.goto('/home'); @@ -41,7 +41,7 @@ test.describe('OAuth', () => { }); await test.step('expect Custom OAuth button to not be visible', async () => { - await expect((await setSettingValueById(api, 'Accounts_OAuth_Custom-Test', false)).status()).toBe(200); + await updateSetting(api, 'Accounts_OAuth_Custom-Test', false); await page.waitForTimeout(5000); await page.goto('/home'); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts index 239978928126e..ac5c0857e0203 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 { updateSetting } 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 updateSetting(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 updateSetting(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 e0d9f92df2ea6..34e6551dda0b5 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 { updateSettings } from '../utils'; import { test, expect } from '../utils/test'; test.use({ storageState: Users.admin.state }); @@ -17,10 +18,10 @@ test.describe.serial('OC - Livechat Appearance - EE', () => { }); 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: '' }), - ]); + const res = await updateSettings(api, { + Livechat_hide_system_messages: ['uj', 'ul', 'livechat-close'], + Livechat_background: '', + }); if (res.some((r) => r.status() !== 200)) { throw new Error('Failed to reset settings'); 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..a541c42f8c846 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 { updateSettings } from '../utils'; import { test, expect } from '../utils/test'; test.describe('omnichannel-auto-onhold-chat-closing', () => { @@ -18,9 +19,11 @@ 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)), + updateSettings(api, { + Livechat_Routing_Method: 'Auto_Selection', + Livechat_auto_close_on_hold_chats_timeout: 5, + Livechat_allow_manual_on_hold: true, + }), ]); const { page } = await createAuxContext(browser, Users.user1); @@ -31,8 +34,11 @@ 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)), + updateSettings(api, { + Livechat_Routing_Method: 'Auto_Selection', + Livechat_auto_close_on_hold_chats_timeout: 3600, + 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..70c5376ea9f19 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 { updateSetting } 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)), + updateSetting(api, 'Livechat_Routing_Method', 'Auto_Selection'), + updateSetting(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)), + updateSetting(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..0cd818fa45da8 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 { updateSetting } 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([ + updateSetting(api, 'Livechat_enable_business_hours', true), + updateSetting(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([ + updateSetting(api, 'Livechat_enable_business_hours', false), + updateSetting(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..11f1da166cd04 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 { updateSetting } 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 updateSetting(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' }), + updateSetting(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..3f122edea1bef 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 { updateSetting } 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 updateSetting(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 updateSetting(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..6b891ff607b59 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 { updateSetting } 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([ + updateSetting(api, 'Livechat_allow_manual_on_hold', true), + updateSetting(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 }), + updateSetting(api, 'Livechat_allow_manual_on_hold', false), + updateSetting(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 updateSetting(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 updateSetting(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..7182b835007e0 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 { updateSetting } 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 updateSetting(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 updateSetting(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 updateSetting(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 updateSetting(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 ba86085435679..04ce8656faecf 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 { updateSetting } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments'; import { test, expect } from '../utils/test'; @@ -232,8 +233,8 @@ 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 api.post('/settings/Livechat_enabled_when_agent_idle', { value: false }); + await updateSetting(api, 'Livechat_offline_email', 'test@testing.com'); + await updateSetting(api, 'Livechat_enabled_when_agent_idle', false); }); test.beforeEach(async ({ browser }, testInfo) => { @@ -264,10 +265,10 @@ 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 updateSetting(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 api.post('/settings/Livechat_enabled_when_agent_idle', { value: true }); + await updateSetting(api, 'Omnichannel_enable_department_removal', false); + await updateSetting(api, 'Livechat_enabled_when_agent_idle', true); }); // clearBusinessUnit @@ -695,8 +696,8 @@ 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 api.post('/settings/Livechat_enabled_when_agent_idle', { value: false }); + await updateSetting(api, 'Livechat_offline_email', 'test@testing.com'); + await updateSetting(api, 'Livechat_enabled_when_agent_idle', false); }); test.beforeEach(async ({ browser }, testInfo) => { @@ -724,7 +725,7 @@ test.describe('OC - Livechat API', () => { test.afterAll(async ({ api }) => { await agent.delete(); - await api.post('/settings/Livechat_enabled_when_agent_idle', { value: true }); + await updateSetting(api, 'Livechat_enabled_when_agent_idle', true); }); test('OC - Livechat API - onChatMaximized & onChatMinimized', async () => { 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..db57d955a4942 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 { updateSetting } 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 updateSetting(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 updateSetting(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..8b7c3da5f0e3a 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 { updateSetting } 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 updateSetting(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 updateSetting(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..b5427a9513c96 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-fileupload.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-fileupload.spec.ts @@ -2,20 +2,21 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChat } from '../page-objects'; +import { updateSetting, updateSettings } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { test, expect } from '../utils/test'; const visitor = createFakeVisitor(); // Endpoint defaults are reset after each test, so if not in matrix assume is true -const endpointMatrix = [ - [{ url: '/settings/FileUpload_Enabled', value: false }], - [{ url: '/settings/Livechat_fileupload_enabled', value: false }], +const settingsMatrix = [ + [{ name: 'FileUpload_Enabled', value: false }], + [{ name: 'Livechat_fileupload_enabled', value: false }], [ - { url: '/settings/FileUpload_Enabled', value: false }, - { url: '/settings/Livechat_fileupload_enabled', value: false }, + { name: 'FileUpload_Enabled', value: false }, + { name: 'Livechat_fileupload_enabled', value: false }, ], -]; +] as const; const beforeTest = async (poLiveChat: OmnichannelLiveChat) => { await poLiveChat.page.goto('/livechat'); @@ -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 updateSettings(api, { + FileUpload_Enabled: true, + Livechat_fileupload_enabled: true, + }); await poHomeOmnichannel.page.close(); await agent.delete(); @@ -85,24 +88,22 @@ 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 updateSettings(api, { + FileUpload_Enabled: true, + Livechat_fileupload_enabled: true, + }); await poHomeOmnichannel.page?.close(); await agent.delete(); }); - endpointMatrix.forEach((endpoints) => { - const testName = endpoints.map((endpoint) => endpoint.url.split('/').pop()?.concat(`=${endpoint.value}`)).join(' '); + settingsMatrix.forEach((settings) => { + const testName = settings.map(({ name, value }) => `${name}=${value}`).join(' '); test(`OC - Livechat - txt Drag & Drop - ${testName}`, async ({ page, api }) => { poLiveChat = new OmnichannelLiveChat(page, api); - await Promise.all( - endpoints.map(async (endpoint: { url: string; value: boolean }) => { - await api.post(endpoint.url, { value: endpoint.value }); - }), - ); + await Promise.all(settings.map(({ name, value }) => updateSetting(api, name, value))); await poLiveChat.page.goto('/livechat'); 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 bb736b6fde4c0..ac9d5e42fed86 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 { updateSettings } from '../utils'; import { test, expect } from '../utils/test'; const firstVisitor = createFakeVisitor(); @@ -21,10 +22,12 @@ 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 }), + updateSettings(api, { + Livechat_Routing_Method: 'Auto_Selection', + Livechat_accept_chats_with_no_agents: true, + Livechat_waiting_queue: true, + Livechat_waiting_queue_message: waitingQueueMessage, + }), api.post('/livechat/users/agent', { username: 'user1' }), ]); @@ -45,9 +48,11 @@ test.describe('OC - Livechat - Queue Management', () => { test.afterAll(async ({ api }) => { await Promise.all([ - api.post('/settings/Livechat_accept_chats_with_no_agents', { value: false }), - api.post('/settings/Livechat_waiting_queue', { value: false }), - api.post('/settings/Livechat_waiting_queue_message', { value: '' }), + updateSettings(api, { + Livechat_accept_chats_with_no_agents: false, + Livechat_waiting_queue: false, + 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 1311ac01ab092..24c6f05f0ebfc 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 { updateSetting, updateSettings } from '../utils'; import { test, expect } from '../utils/test'; const firstVisitor = createFakeVisitor(); @@ -23,9 +24,11 @@ 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 }), + updateSettings(api, { + Livechat_Routing_Method: 'Manual_Selection', + Livechat_waiting_queue: true, + Livechat_waiting_queue_message: waitingQueueMessage, + }), api.post('/livechat/users/agent', { username: 'user1' }), ]); @@ -43,9 +46,11 @@ 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: '' }), + updateSettings(api, { + Livechat_Routing_Method: 'Auto_Selection', + Livechat_waiting_queue: false, + Livechat_waiting_queue_message: '', + }), api.delete('/livechat/users/agent/user1'), ]); await poHomeOmnichannel.page.close(); @@ -133,7 +138,7 @@ test.describe('OC - Contact Manager Routing', () => { test.beforeAll(async ({ api, browser }) => { await api.post('/livechat/users/agent', { username: 'user2' }); - await api.post('/settings/Livechat_Routing_Method', { value: 'Manual_Selection' }); + await updateSetting(api, 'Livechat_Routing_Method', 'Manual_Selection'); await api.post('/omnichannel/contact', { _id: contactId, name: visitorWithManager.name, @@ -160,7 +165,7 @@ test.describe('OC - Contact Manager Routing', () => { test.afterAll(async ({ api }) => { await Promise.all([ - api.post('/settings/Livechat_Routing_Method', { value: 'Auto_Selection' }), + updateSetting(api, 'Livechat_Routing_Method', 'Auto_Selection'), api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/agent/user2'), api.delete(`/omnichannel/contact/${contactId}`), 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..b9e1fd45cc1d2 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 { updateSetting } 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 updateSetting(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 cf805ca233dda..d100968aeeb3d 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts @@ -2,7 +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 { updateSetting, updateSettings } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { test, expect } from '../utils/test'; @@ -123,13 +123,13 @@ test.describe.serial('OC - Livechat - Visitors closing the room is disabled', () }); test.beforeAll(async ({ browser, api }) => { - await setSettingValueById(api, 'Livechat_allow_visitor_closing_chat', false); + await updateSetting(api, 'Omnichannel_allow_visitors_to_close_conversation', false); const { page: omniPage } = await createAuxContext(browser, Users.user1, '/', true); poHomeOmnichannel = new HomeOmnichannel(omniPage); }); test.afterAll(async ({ api }) => { - await setSettingValueById(api, 'Livechat_allow_visitor_closing_chat', true); + await updateSetting(api, 'Omnichannel_allow_visitors_to_close_conversation', true); await api.delete('/livechat/users/agent/user1'); await poLiveChat.page.close(); }); @@ -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 updateSetting(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 updateSetting(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 updateSettings(api, { + Livechat_display_offline_form: false, + 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 updateSettings(api, { + Livechat_display_offline_form: true, + 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..7171408e3f754 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 { updateSettings } 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 }), - ]); - responses.forEach((res) => expect(res.status()).toBe(200)); + await updateSettings(api, { + Livechat_allow_manual_on_hold: true, + Livechat_allow_manual_on_hold_upon_agent_engagement_only: false, + }); }); // Create agents @@ -88,8 +88,10 @@ 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 }), + updateSettings(api, { + Livechat_allow_manual_on_hold: false, + 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..288c67a3738a8 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 { updateSetting } 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 updateSetting(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 updateSetting(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..1a759e1bc352f 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 { updateSetting } 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 updateSetting(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()), updateSetting(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..14aee706430fd 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 { updateSettings } 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 }), - ]); - responses.forEach((res) => expect(res.status()).toBe(200)); + await updateSettings(api, { + Livechat_allow_manual_on_hold: true, + Livechat_allow_manual_on_hold_upon_agent_engagement_only: false, + }); }); // Create agents @@ -118,8 +118,7 @@ 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 }), + updateSettings(api, { Livechat_allow_manual_on_hold: false, 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..6b5f3d32579f8 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 { updateSetting } 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 updateSetting(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 updateSetting(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..0405c4bb616a9 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 { updateSettings } from '../utils'; import { test, expect } from '../utils/test'; test.describe('omnichannel-takeChat', () => { @@ -21,9 +22,8 @@ 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)), + updateSettings(api, { Livechat_Routing_Method: 'Manual_Selection', Livechat_enabled_when_agent_idle: false }), ]); const { page } = await createAuxContext(browser, Users.user1); @@ -36,9 +36,8 @@ 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'), + updateSettings(api, { Livechat_Routing_Method: 'Auto_Selection', 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..0ca1b73cd72ef 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 { updateSetting } 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 updateSetting(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)), + updateSetting(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..7292de5ae9dad 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 { updateSetting } 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 updateSetting(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 updateSetting(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..e2d14dbd13e5f 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 { updateSetting } 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 }), + updateSetting(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..dc8f5cc05b67b 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 { updateSetting } 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 updateSetting(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 updateSetting(api, 'Omnichannel_enable_department_removal', false); + await updateSetting(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 updateSetting(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..43bd94ca361c7 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 { updateSetting } 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 }), + updateSetting(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..68c3d7d29180c 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 { updateSetting } 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 }), + updateSetting(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 }), + updateSetting(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..68626adb2f563 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, updateSetting, updateSettings } 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 updateSetting(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 updateSetting(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 updateSetting(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 updateSetting(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 updateSetting(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 updateSetting(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 updateSetting(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 updateSetting(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 updateSetting(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 updateSetting(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 updateSetting(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 updateSetting(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 updateSetting(api, 'Message_VideoRecorderEnabled', false); }); test('expect option (upload video) not be visible', async () => { @@ -180,19 +154,16 @@ 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 updateSetting(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 updateSettings(api, { + Message_AllowBadWordsFilter: true, + Message_BadWordsFilterList: 'badword', + }); }); test('expect badword be censored', async () => { @@ -203,9 +174,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 updateSetting(api, 'Message_AllowBadWordsFilter', false); }); }); }); diff --git a/apps/meteor/tests/e2e/presence.spec.ts b/apps/meteor/tests/e2e/presence.spec.ts index 4f5dfe7a6db70..61cd0a6963688 100644 --- a/apps/meteor/tests/e2e/presence.spec.ts +++ b/apps/meteor/tests/e2e/presence.spec.ts @@ -1,7 +1,7 @@ import { DEFAULT_USER_CREDENTIALS, IS_EE } from './config/constants'; import { Users } from './fixtures/userStates'; import { Registration } from './page-objects'; -import { setSettingValueById } from './utils/setSettingValueById'; +import { updateSetting } from './utils'; import { test, expect } from './utils/test'; test.describe.serial('Presence', () => { @@ -14,11 +14,11 @@ test.describe.serial('Presence', () => { }); test.beforeAll(async ({ api }) => { - await expect((await setSettingValueById(api, 'API_Use_REST_For_DDP_Calls', true)).status()).toBe(200); + await updateSetting(api, 'API_Use_REST_For_DDP_Calls', true); }); test.afterAll(async ({ api }) => { - await expect((await setSettingValueById(api, 'API_Use_REST_For_DDP_Calls', true)).status()).toBe(200); + await updateSetting(api, 'API_Use_REST_For_DDP_Calls', true); }); test.describe('Login using default settings', () => { @@ -35,7 +35,7 @@ test.describe.serial('Presence', () => { test.skip(IS_EE, `Micro services don't support turning this setting off`); test.beforeAll(async ({ api }) => { - await expect((await setSettingValueById(api, 'API_Use_REST_For_DDP_Calls', false)).status()).toBe(200); + await updateSetting(api, 'API_Use_REST_For_DDP_Calls', false); }); test('expect user to be online after log in', async ({ page }) => { diff --git a/apps/meteor/tests/e2e/read-receipts.spec.ts b/apps/meteor/tests/e2e/read-receipts.spec.ts index f61e1b2e1d1f7..b93645ab323f6 100644 --- a/apps/meteor/tests/e2e/read-receipts.spec.ts +++ b/apps/meteor/tests/e2e/read-receipts.spec.ts @@ -4,7 +4,7 @@ import { IS_EE } from './config/constants'; import { createAuxContext } from './fixtures/createAuxContext'; import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { createTargetChannel, setSettingValueById } from './utils'; +import { createTargetChannel, updateSettings } from './utils'; import { expect, test } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -36,13 +36,17 @@ test.describe.serial('read-receipts', () => { test.describe('read receipts enabled', async () => { test.beforeAll(async ({ api }) => { - await setSettingValueById(api, 'Message_Read_Receipt_Enabled', true); - await setSettingValueById(api, 'Message_Read_Receipt_Store_Users', true); + await updateSettings(api, { + Message_Read_Receipt_Enabled: true, + Message_Read_Receipt_Store_Users: true, + }); }); test.afterAll(async ({ api }) => { - await setSettingValueById(api, 'Message_Read_Receipt_Enabled', false); - await setSettingValueById(api, 'Message_Read_Receipt_Store_Users', false); + await updateSettings(api, { + Message_Read_Receipt_Enabled: false, + Message_Read_Receipt_Store_Users: false, + }); }); let auxContext: { page: Page; poHomeChannel: HomeChannel } | undefined; diff --git a/apps/meteor/tests/e2e/register.spec.ts b/apps/meteor/tests/e2e/register.spec.ts index 0e371aa25d972..d8554d55aeeee 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 { updateSetting, updateSettings } 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 updateSetting(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 updateSetting(api, 'Accounts_RequirePasswordConfirmation', true); }); test('expect to register a user without password confirmation', async () => { @@ -79,10 +78,9 @@ 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 }); - - await expect(result.ok()).toBeTruthy(); + await updateSetting(api, 'Accounts_ManuallyApproveNewUsers', true); }); + test.beforeEach(async ({ page }) => { poRegistration = new Registration(page); @@ -91,10 +89,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 updateSetting(api, 'Accounts_ManuallyApproveNewUsers', false); }); test('it should expect to have a textbox asking the reason for the registration', async () => { @@ -111,12 +106,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 updateSetting(api, 'Accounts_RegistrationForm', 'Disabled'); }); test.afterEach(async ({ api }) => { - await api.post('/settings/Accounts_RegistrationForm', { value: 'Public' }); + await updateSetting(api, 'Accounts_RegistrationForm', 'Public'); }); test('It should expect a message warning that registration is disabled', async ({ page }) => { @@ -140,14 +134,14 @@ 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 updateSettings(api, { + Accounts_RegistrationForm: 'Secret URL', + Accounts_RegistrationForm_SecretURL: 'secret', + }); }); test.afterAll(async ({ api }) => { - const result = await api.post('/settings/Accounts_RegistrationForm', { value: 'Public' }); - await expect(result.ok()).toBeTruthy(); + await updateSetting(api, 'Accounts_RegistrationForm', 'Public'); }); test('It should expect a message warning that registration is disabled', async ({ page }) => { @@ -182,9 +176,10 @@ 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 updateSettings(api, { + Accounts_RegistrationForm: 'Public', + Accounts_RegistrationForm_SecretURL: 'secret', + }); }); test('It should show an invalid page informing that the url is not valid', async ({ page }) => { diff --git a/apps/meteor/tests/e2e/reset-password.spec.ts b/apps/meteor/tests/e2e/reset-password.spec.ts index fcd26eb4f355e..2ea78fd1f90fd 100644 --- a/apps/meteor/tests/e2e/reset-password.spec.ts +++ b/apps/meteor/tests/e2e/reset-password.spec.ts @@ -1,5 +1,5 @@ import { Registration } from './page-objects'; -import { setSettingValueById } from './utils/setSettingValueById'; +import { updateSetting } from './utils'; import { test, expect } from './utils/test'; test.describe.parallel('Reset Password', () => { @@ -7,13 +7,13 @@ test.describe.parallel('Reset Password', () => { test.beforeEach(async ({ api, page }) => { poRegistration = new Registration(page); - await setSettingValueById(api, 'Accounts_RequirePasswordConfirmation', true); + await updateSetting(api, 'Accounts_RequirePasswordConfirmation', true); await page.goto('/reset-password/someToken'); }); test.afterAll(async ({ api }) => { - await setSettingValueById(api, 'Accounts_RequirePasswordConfirmation', true); + await updateSetting(api, 'Accounts_RequirePasswordConfirmation', true); }); test('should confirm password be invalid', async () => { @@ -24,7 +24,7 @@ test.describe.parallel('Reset Password', () => { }); test('should confirm password not be visible', async ({ api }) => { - await setSettingValueById(api, 'Accounts_RequirePasswordConfirmation', false); + await updateSetting(api, 'Accounts_RequirePasswordConfirmation', false); await expect(poRegistration.inputPasswordConfirm).not.toBeVisible(); }); diff --git a/apps/meteor/tests/e2e/retention-policy.spec.ts b/apps/meteor/tests/e2e/retention-policy.spec.ts index 25962d2aae162..b48224a6b62c3 100644 --- a/apps/meteor/tests/e2e/retention-policy.spec.ts +++ b/apps/meteor/tests/e2e/retention-policy.spec.ts @@ -4,7 +4,7 @@ import type { Page } from '@playwright/test'; import { createAuxContext } from './fixtures/createAuxContext'; import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { createTargetTeam, createTargetPrivateChannel, getSettingValueById, setSettingValueById } from './utils'; +import { createTargetTeam, createTargetPrivateChannel, getSettingValueById, updateSetting, updateSettings } from './utils'; import { test, expect } from './utils/test'; import { timeUnitToMs, TIMEUNIT } from '../../client/lib/convertTimeUnit'; @@ -33,7 +33,7 @@ test.describe.serial('retention-policy', () => { test.describe('retention policy disabled', () => { test.beforeAll(async ({ api }) => { - await setSettingValueById(api, 'RetentionPolicy_Enabled', false); + await updateSetting(api, 'RetentionPolicy_Enabled', false); }); test('should not show prune banner in channel', async () => { @@ -59,14 +59,17 @@ test.describe.serial('retention-policy', () => { test.describe('retention policy enabled', () => { test.beforeAll(async ({ api }) => { - await setSettingValueById(api, 'RetentionPolicy_Enabled', true); + await updateSetting(api, 'RetentionPolicy_Enabled', true); }); + test.afterAll(async ({ api }) => { - await setSettingValueById(api, 'RetentionPolicy_Enabled', false); - await setSettingValueById(api, 'RetentionPolicy_AppliesToChannels', false); - await setSettingValueById(api, 'RetentionPolicy_AppliesToGroups', false); - await setSettingValueById(api, 'RetentionPolicy_AppliesToDMs', false); - await setSettingValueById(api, 'RetentionPolicy_TTL_Channels', timeUnitToMs(TIMEUNIT.days, 30)); + await updateSettings(api, { + RetentionPolicy_Enabled: false, + RetentionPolicy_AppliesToChannels: false, + RetentionPolicy_AppliesToGroups: false, + RetentionPolicy_AppliesToDMs: false, + RetentionPolicy_TTL_Channels: timeUnitToMs(TIMEUNIT.days, 30), + }); }); test('should not show prune banner even with retention policy setting enabled in any type of room', async () => { @@ -118,9 +121,11 @@ test.describe.serial('retention-policy', () => { test.describe('retention policy applies enabled by default', () => { test.beforeAll(async ({ api }) => { - await setSettingValueById(api, 'RetentionPolicy_AppliesToChannels', true); - await setSettingValueById(api, 'RetentionPolicy_AppliesToGroups', true); - await setSettingValueById(api, 'RetentionPolicy_AppliesToDMs', true); + await updateSettings(api, { + RetentionPolicy_AppliesToChannels: true, + RetentionPolicy_AppliesToGroups: true, + RetentionPolicy_AppliesToDMs: true, + }); }); test('should prune old messages checkbox enabled by default in channel and show retention policy banner', async () => { @@ -164,7 +169,7 @@ test.describe.serial('retention-policy', () => { test.beforeAll(async ({ api }) => { ignoreThreadsSetting = (await getSettingValueById(api, 'RetentionPolicy_DoNotPruneThreads')) as boolean; - expect((await setSettingValueById(api, 'RetentionPolicy_TTL_Channels', timeUnitToMs(TIMEUNIT.days, 15))).status()).toBe(200); + await updateSetting(api, 'RetentionPolicy_TTL_Channels', timeUnitToMs(TIMEUNIT.days, 15)); }); test.beforeEach(async () => { diff --git a/apps/meteor/tests/e2e/saml.spec.ts b/apps/meteor/tests/e2e/saml.spec.ts index d7e0904fc2cf4..59d30117f56cc 100644 --- a/apps/meteor/tests/e2e/saml.spec.ts +++ b/apps/meteor/tests/e2e/saml.spec.ts @@ -10,11 +10,11 @@ import * as constants from './config/constants'; import { createUserFixture } from './fixtures/collections/users'; import { Users } from './fixtures/userStates'; import { Registration } from './page-objects'; +import { updateSetting } from './utils'; import { convertHexToRGB } from './utils/convertHexToRGB'; import { createCustomRole, deleteCustomRole } from './utils/custom-role'; import { getUserInfo } from './utils/getUserInfo'; import { parseMeteorResponse } from './utils/parseMeteorResponse'; -import { setSettingValueById } from './utils/setSettingValueById'; import type { BaseTest } from './utils/test'; import { test, expect } from './utils/test'; @@ -55,8 +55,8 @@ const resetTestData = async ({ api, cleanupOnly = false }: { api?: any; cleanupO { _id: 'SAML_Custom_Default_mail_overwrite', value: false }, { _id: 'SAML_Custom_Default_name_overwrite', value: false }, { _id: 'SAML_Custom_Default', value: false }, - { _id: 'SAML_Custom_Default_role_attribute_sync', value: true }, - { _id: 'SAML_Custom_Default_role_attribute_name', value: 'role' }, + { _id: 'SAML_Custom_Default_role_attribute_sync', value: true, strict: false }, + { _id: 'SAML_Custom_Default_role_attribute_name', value: 'role', strict: false }, { _id: 'SAML_Custom_Default_user_data_fieldmap', value: '{"username":"username", "email":"email", "name": "cn"}' }, { _id: 'SAML_Custom_Default_provider', value: 'test-sp' }, { _id: 'SAML_Custom_Default_issuer', value: 'http://localhost:3000/_saml/metadata/test-sp' }, @@ -66,7 +66,7 @@ const resetTestData = async ({ api, cleanupOnly = false }: { api?: any; cleanupO { _id: 'SAML_Custom_Default_button_color', value: '#185925' }, ]; - await Promise.all(settings.map(({ _id, value }) => setSettingValueById(api, _id, value))); + await Promise.all(settings.map(({ _id, value, strict }) => updateSetting(api, _id, value, strict))); }; const setupCustomRole = async (api: BaseTest['api']) => { @@ -90,7 +90,7 @@ test.describe('SAML', () => { await resetTestData({ api }); // Only one setting updated through the API to avoid refreshing the service configurations several times - await expect((await setSettingValueById(api, 'SAML_Custom_Default', true)).status()).toBe(200); + await updateSetting(api, 'SAML_Custom_Default', true); // Create a new custom role if (constants.IS_EE) { @@ -188,7 +188,7 @@ test.describe('SAML', () => { test('Allow password change for OAuth users', async ({ api }) => { await test.step("should not send password reset mail if 'Allow Password Change for OAuth Users' setting is disabled", async () => { - expect((await setSettingValueById(api, 'Accounts_AllowPasswordChangeForOAuthUsers', false)).status()).toBe(200); + await updateSetting(api, 'Accounts_AllowPasswordChangeForOAuthUsers', false); const response = await api.post('/method.call/sendForgotPasswordEmail', { message: JSON.stringify({ msg: 'method', id: 'id', method: 'sendForgotPasswordEmail', params: ['samluser1@example.com'] }), @@ -199,7 +199,7 @@ test.describe('SAML', () => { }); await test.step("should send password reset mail if 'Allow Password Change for OAuth Users' setting is enabled", async () => { - expect((await setSettingValueById(api, 'Accounts_AllowPasswordChangeForOAuthUsers', true)).status()).toBe(200); + await updateSetting(api, 'Accounts_AllowPasswordChangeForOAuthUsers', true); const response = await api.post('/method.call/sendForgotPasswordEmail', { message: JSON.stringify({ msg: 'method', id: 'id', method: 'sendForgotPasswordEmail', params: ['samluser1@example.com'] }), @@ -241,7 +241,7 @@ test.describe('SAML', () => { test('Logout - Rocket.Chat only', async ({ page, api }) => { await test.step('Configure logout to only logout from Rocket.Chat', async () => { - await expect((await setSettingValueById(api, 'SAML_Custom_Default_logout_behaviour', 'Local')).status()).toBe(200); + await updateSetting(api, 'SAML_Custom_Default_logout_behaviour', 'Local'); }); await page.goto('/home'); @@ -257,7 +257,7 @@ test.describe('SAML', () => { test('Logout - Single Sign Out', async ({ page, api }) => { await test.step('Configure logout to terminate SAML session', async () => { - await expect((await setSettingValueById(api, 'SAML_Custom_Default_logout_behaviour', 'SAML')).status()).toBe(200); + await updateSetting(api, 'SAML_Custom_Default_logout_behaviour', 'SAML'); }); await page.goto('/home'); @@ -274,7 +274,7 @@ test.describe('SAML', () => { test('User Merge - By Email', async ({ page, api }) => { await test.step('Configure SAML to identify users by email', async () => { - await expect((await setSettingValueById(api, 'SAML_Custom_Default_immutable_property', 'EMail')).status()).toBe(200); + await updateSetting(api, 'SAML_Custom_Default_immutable_property', 'EMail'); }); await doLoginStep(page, 'samluser2'); @@ -293,8 +293,8 @@ test.describe('SAML', () => { test('User Merge - By Email with Name Override', async ({ page, api }) => { await test.step('Configure SAML to identify users by email', async () => { - expect((await setSettingValueById(api, 'SAML_Custom_Default_immutable_property', 'EMail')).status()).toBe(200); - expect((await setSettingValueById(api, 'SAML_Custom_Default_name_overwrite', true)).status()).toBe(200); + await updateSetting(api, 'SAML_Custom_Default_immutable_property', 'EMail'); + await updateSetting(api, 'SAML_Custom_Default_name_overwrite', true); }); await doLoginStep(page, 'samluser2'); @@ -313,9 +313,9 @@ test.describe('SAML', () => { test('User Merge - By Username', async ({ page, api }) => { await test.step('Configure SAML to identify users by username', async () => { - expect((await setSettingValueById(api, 'SAML_Custom_Default_immutable_property', 'Username')).status()).toBe(200); - expect((await setSettingValueById(api, 'SAML_Custom_Default_name_overwrite', false)).status()).toBe(200); - expect((await setSettingValueById(api, 'SAML_Custom_Default_mail_overwrite', false)).status()).toBe(200); + await updateSetting(api, 'SAML_Custom_Default_immutable_property', 'Username'); + await updateSetting(api, 'SAML_Custom_Default_name_overwrite', false); + await updateSetting(api, 'SAML_Custom_Default_mail_overwrite', false); }); await doLoginStep(page, 'samluser3'); @@ -334,9 +334,9 @@ test.describe('SAML', () => { test('User Merge - By Username with Email Override', async ({ page, api }) => { await test.step('Configure SAML to identify users by username', async () => { - expect((await setSettingValueById(api, 'SAML_Custom_Default_immutable_property', 'Username')).status()).toBe(200); - expect((await setSettingValueById(api, 'SAML_Custom_Default_name_overwrite', false)).status()).toBe(200); - expect((await setSettingValueById(api, 'SAML_Custom_Default_mail_overwrite', true)).status()).toBe(200); + await updateSetting(api, 'SAML_Custom_Default_immutable_property', 'Username'); + await updateSetting(api, 'SAML_Custom_Default_name_overwrite', false); + await updateSetting(api, 'SAML_Custom_Default_mail_overwrite', true); }); await doLoginStep(page, 'samluser3'); @@ -355,8 +355,8 @@ test.describe('SAML', () => { test('User Merge - By Username with Name Override', async ({ page, api }) => { await test.step('Configure SAML to identify users by username', async () => { - await expect((await setSettingValueById(api, 'SAML_Custom_Default_immutable_property', 'Username')).status()).toBe(200); - await expect((await setSettingValueById(api, 'SAML_Custom_Default_name_overwrite', true)).status()).toBe(200); + await updateSetting(api, 'SAML_Custom_Default_immutable_property', 'Username'); + await updateSetting(api, 'SAML_Custom_Default_name_overwrite', true); }); await doLoginStep(page, 'samluser3'); diff --git a/apps/meteor/tests/e2e/search-discussion.spec.ts b/apps/meteor/tests/e2e/search-discussion.spec.ts index a2ec674805296..50526e8bf4176 100644 --- a/apps/meteor/tests/e2e/search-discussion.spec.ts +++ b/apps/meteor/tests/e2e/search-discussion.spec.ts @@ -2,9 +2,8 @@ import type { Page } from '@playwright/test'; import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { createTargetDiscussion, deleteRoom } from './utils'; +import { createTargetDiscussion, deleteRoom, updateSetting } from './utils'; import { getSettingValueById } from './utils/getSettingValueById'; -import { setSettingValueById } from './utils/setSettingValueById'; import { test, expect } from './utils/test'; test.use({ storageState: Users.user1.state }); @@ -25,7 +24,7 @@ test.describe.serial('search-discussion', () => { }); test.afterAll(async ({ api }) => { - await setSettingValueById(api, 'UI_Allow_room_names_with_special_chars', settingDefaultValue); + await updateSetting(api, 'UI_Allow_room_names_with_special_chars', settingDefaultValue); await deleteRoom(api, discussion._id); }); @@ -37,12 +36,12 @@ test.describe.serial('search-discussion', () => { }; test('expect search discussion to show fname when UI_Allow_room_names_with_special_chars=true', async ({ page, api }) => { - await setSettingValueById(api, 'UI_Allow_room_names_with_special_chars', true); + await updateSetting(api, 'UI_Allow_room_names_with_special_chars', true); await testDiscussionSearch(page); }); test('expect search discussion to show fname when UI_Allow_room_names_with_special_chars=false', async ({ page, api }) => { - await setSettingValueById(api, 'UI_Allow_room_names_with_special_chars', false); + await updateSetting(api, 'UI_Allow_room_names_with_special_chars', false); await testDiscussionSearch(page); }); }); diff --git a/apps/meteor/tests/e2e/settings-persistence-on-ui-navigation.spec.ts b/apps/meteor/tests/e2e/settings-persistence-on-ui-navigation.spec.ts index f2610d54cd98d..d54b0c0a021a5 100644 --- a/apps/meteor/tests/e2e/settings-persistence-on-ui-navigation.spec.ts +++ b/apps/meteor/tests/e2e/settings-persistence-on-ui-navigation.spec.ts @@ -1,11 +1,11 @@ import { Users } from './fixtures/userStates'; -import { setSettingValueById } from './utils'; +import { updateSetting } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); test.describe.serial('settings-persistence-on-ui-navigation', () => { - test.beforeAll(({ api }) => setSettingValueById(api, 'Hide_System_Messages', [])); + test.beforeAll(({ api }) => updateSetting(api, 'Hide_System_Messages', [])); test.beforeEach(async ({ page }) => { await page.goto('/admin/settings/Message'); @@ -23,7 +23,7 @@ test.describe.serial('settings-persistence-on-ui-navigation', () => { }); }); - test.afterAll(({ api }) => setSettingValueById(api, 'Hide_System_Messages', [])); + test.afterAll(({ api }) => updateSetting(api, 'Hide_System_Messages', [])); test('expect settings to persist in ui when navigating back and forth', async ({ page }) => { const settingInput = await page.locator('[data-qa-setting-id="Hide_System_Messages"] input'); diff --git a/apps/meteor/tests/e2e/system-messages.spec.ts b/apps/meteor/tests/e2e/system-messages.spec.ts index b4820ab25ac7a..e269843387517 100644 --- a/apps/meteor/tests/e2e/system-messages.spec.ts +++ b/apps/meteor/tests/e2e/system-messages.spec.ts @@ -4,7 +4,7 @@ import type { IRoom, IUser } from '@rocket.chat/core-typings'; import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { setSettingValueById } from './utils/setSettingValueById'; +import { updateSetting } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -27,7 +27,7 @@ test.describe.serial('System Messages', () => { let group: IRoom; test.beforeAll(async ({ api }) => { - await expect((await setSettingValueById(api, 'Hide_System_Messages', [])).status()).toBe(200); + await updateSetting(api, 'Hide_System_Messages', []); const groupResult = await api.post('/groups.create', { name: faker.string.uuid() }); await expect(groupResult.status()).toBe(200); @@ -62,7 +62,7 @@ test.describe.serial('System Messages', () => { }); test('expect "User added" system message to be hidden', async ({ page, api }) => { - await expect((await setSettingValueById(api, 'Hide_System_Messages', ['au'])).status()).toBe(200); + await updateSetting(api, 'Hide_System_Messages', ['au']); await expect(findSysMes(page, 'au')).not.toBeVisible(); }); @@ -74,7 +74,7 @@ test.describe.serial('System Messages', () => { }); test('expect "User removed" system message to be hidden', async ({ page, api }) => { - await expect((await setSettingValueById(api, 'Hide_System_Messages', ['ru'])).status()).toBe(200); + await updateSetting(api, 'Hide_System_Messages', ['ru']); await expect(findSysMes(page, 'ru')).not.toBeVisible(); }); diff --git a/apps/meteor/tests/e2e/translations.spec.ts b/apps/meteor/tests/e2e/translations.spec.ts index 05854fcb71a51..62915b5236876 100644 --- a/apps/meteor/tests/e2e/translations.spec.ts +++ b/apps/meteor/tests/e2e/translations.spec.ts @@ -1,5 +1,5 @@ import { Users } from './fixtures/userStates'; -import { setSettingValueById } from './utils/setSettingValueById'; +import { updateSettings } from './utils'; import { setUserPreferences } from './utils/setUserPreferences'; import { test, expect } from './utils/test'; @@ -8,13 +8,18 @@ test.use({ storageState: Users.admin.state }); test.describe('Translations', () => { test.beforeAll(async ({ api }) => { expect((await setUserPreferences(api, { language: '' })).status()).toBe(200); - expect((await setSettingValueById(api, 'Language', 'en')).status()).toBe(200); - expect((await setSettingValueById(api, 'Site_Name', 'Rocket.Chat')).status()).toBe(200); + await updateSettings(api, { + Language: 'en', + Site_Name: 'Rocket.Chat', + }); }); test.afterAll(async ({ api }) => { - expect((await setUserPreferences(api, { language: '' })).status()).toBe(200); - expect((await setSettingValueById(api, 'Language', 'en')).status()).toBe(200); + await setUserPreferences(api, { language: '' }); + await updateSettings(api, { + Language: 'en', + Site_Name: 'Rocket.Chat', + }); }); test("expect to display text in the user's preference language", async ({ page, api }) => { From 228c3cfbade5940d4c6cbcf39cc228bed3f2885c Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Wed, 9 Apr 2025 14:49:28 -0300 Subject: [PATCH 6/9] test: added updateSetting fixture --- apps/meteor/tests/e2e/utils/test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/apps/meteor/tests/e2e/utils/test.ts b/apps/meteor/tests/e2e/utils/test.ts index 716c91d25aaf9..ea84c0ca5182c 100644 --- a/apps/meteor/tests/e2e/utils/test.ts +++ b/apps/meteor/tests/e2e/utils/test.ts @@ -5,8 +5,10 @@ import * as path from 'path'; import AxeBuilder from '@axe-core/playwright'; import type { Locator, APIResponse, APIRequestContext } from '@playwright/test'; import { test as baseTest, request as baseRequest } from '@playwright/test'; +import type { ISetting } from '@rocket.chat/core-typings'; import { v4 as uuid } from 'uuid'; +import { updateSetting, updateSettings } from './updateSetting'; import { BASE_API_URL, API_PREFIX, ADMIN_CREDENTIALS } from '../config/constants'; import { Users } from '../fixtures/userStates'; @@ -24,6 +26,8 @@ export type BaseTest = { delete(uri: string, params?: AnyObj, prefix?: string): Promise; }; makeAxeBuilder: () => AxeBuilder; + + updateSetting: (settingId: string, value: ISetting['value'], defaultValue?: ISetting['value']) => Promise; }; declare global { // eslint-disable-next-line @typescript-eslint/naming-convention @@ -119,6 +123,7 @@ export const test = baseTest.extend({ }, }); }, + makeAxeBuilder: async ({ page }, use) => { const SELECT_KNOW_ISSUES = ['aria-hidden-focus', 'nested-interactive']; @@ -129,6 +134,20 @@ export const test = baseTest.extend({ .disableRules([...SELECT_KNOW_ISSUES]); await use(makeAxeBuilder); }, + + updateSetting: async ({ api }, use) => { + const _defaultSettings: Record = {}; + + await use((settingId: ISetting['_id'], value: ISetting['value'], defaultValue: ISetting['value']) => { + if (defaultValue !== undefined) { + _defaultSettings[settingId] = defaultValue; + } + + return updateSetting(api, settingId, value); + }); + + await updateSettings(api, _defaultSettings); + }, }); export const { expect } = test; From 37b12ef52b45ba4fc039bc972dd408eefbb2bf8d Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Wed, 9 Apr 2025 14:49:49 -0300 Subject: [PATCH 7/9] test: updated test files to use updateSetting fixture --- .../tests/e2e/access-security-page.spec.ts | 57 ++++++------- ...account-forgetSessionOnWindowClose.spec.ts | 13 +-- .../tests/e2e/administration-settings.spec.ts | 8 +- apps/meteor/tests/e2e/administration.spec.ts | 10 +-- apps/meteor/tests/e2e/anonymous-user.spec.ts | 18 ++-- apps/meteor/tests/e2e/avatar-settings.ts | 19 ++--- apps/meteor/tests/e2e/e2e-encryption.spec.ts | 84 ++++++------------- apps/meteor/tests/e2e/feature-preview.spec.ts | 5 +- apps/meteor/tests/e2e/file-upload.spec.ts | 11 ++- apps/meteor/tests/e2e/homepage.spec.ts | 71 +++++----------- apps/meteor/tests/e2e/login.spec.ts | 9 +- apps/meteor/tests/e2e/oauth.spec.ts | 11 ++- .../omnichannel/omnichannel-agents.spec.ts | 7 +- .../omnichannel-appearance.spec.ts | 15 ++-- ...nichannel-auto-onhold-chat-closing.spec.ts | 20 ++--- ...nnel-auto-transfer-unanswered-chat.spec.ts | 8 +- .../omnichannel-business-hours.spec.ts | 13 +-- ...nel-changing-room-priority-and-sla.spec.ts | 6 +- .../omnichannel-close-inquiry.spec.ts | 11 +-- ...annel-contact-center-chats-filters.spec.ts | 8 +- .../omnichannel-current-chats.spec.ts | 20 ++--- .../omnichannel-departaments.spec.ts | 16 ++-- .../omnichannel-livechat-api.spec.ts | 27 +++--- .../omnichannel-livechat-background.spec.ts | 7 +- .../omnichannel-livechat-department.spec.ts | 7 +- .../omnichannel-livechat-fileupload.spec.ts | 19 ++--- ...hat-queue-management-autoselection.spec.ts | 22 ++--- ...ichannel-livechat-queue-management.spec.ts | 25 ++---- .../omnichannel-livechat-watermark.spec.ts | 5 +- .../omnichannel/omnichannel-livechat.spec.ts | 28 ++----- .../omnichannel-manager-role.spec.ts | 18 ++-- ...mnichannel-manual-selection-logout.spec.ts | 8 +- .../omnichannel-manual-selection.spec.ts | 9 +- .../omnichannel-monitor-role.spec.ts | 15 ++-- .../omnichannel-priorities-sidebar.spec.ts | 6 +- .../omnichannel/omnichannel-takeChat.spec.ts | 11 +-- ...channel-transfer-to-another-agents.spec.ts | 8 +- ...hannel-triggers-after-registration.spec.ts | 9 +- ...nichannel-triggers-open-by-visitor.spec.ts | 5 +- ...omnichannel-triggers-setDepartment.spec.ts | 13 ++- .../omnichannel-triggers-time-on-site.spec.ts | 5 +- .../omnichannel/omnichannel-triggers.spec.ts | 11 +-- apps/meteor/tests/e2e/permissions.spec.ts | 72 +++++----------- apps/meteor/tests/e2e/presence.spec.ts | 21 ++--- apps/meteor/tests/e2e/read-receipts.spec.ts | 19 ++--- apps/meteor/tests/e2e/register.spec.ts | 49 ++++------- apps/meteor/tests/e2e/reset-password.spec.ts | 13 +-- .../meteor/tests/e2e/retention-policy.spec.ts | 42 +++++----- apps/meteor/tests/e2e/saml.spec.ts | 58 +++++++------ .../tests/e2e/search-discussion.spec.ts | 17 ++-- ...tings-persistence-on-ui-navigation.spec.ts | 5 +- apps/meteor/tests/e2e/system-messages.spec.ts | 13 ++- apps/meteor/tests/e2e/translations.spec.ts | 12 +-- 53 files changed, 362 insertions(+), 657 deletions(-) diff --git a/apps/meteor/tests/e2e/access-security-page.spec.ts b/apps/meteor/tests/e2e/access-security-page.spec.ts index e6ae7661eefd3..b0b976941d0f1 100644 --- a/apps/meteor/tests/e2e/access-security-page.spec.ts +++ b/apps/meteor/tests/e2e/access-security-page.spec.ts @@ -1,6 +1,5 @@ import { Users } from './fixtures/userStates'; import { AccountProfile } from './page-objects'; -import { updateSettings } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -8,12 +7,12 @@ test.use({ storageState: Users.admin.state }); test.describe.serial('access-security-page', () => { let poAccountProfile: AccountProfile; - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - Accounts_AllowPasswordChange: false, - Accounts_TwoFactorAuthentication_Enabled: false, - E2E_Enable: false, - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Accounts_AllowPasswordChange', false, true), + updateSetting('Accounts_TwoFactorAuthentication_Enabled', false, true), + updateSetting('E2E_Enable', false, false), + ]); }); test.beforeEach(async ({ page }) => { @@ -22,14 +21,6 @@ test.describe.serial('access-security-page', () => { await page.waitForSelector('.main-content'); }); - test.afterAll(async ({ api }) => { - await updateSettings(api, { - Accounts_AllowPasswordChange: true, - Accounts_TwoFactorAuthentication_Enabled: true, - E2E_Enable: false, - }); - }); - test('security tab is invisible when password change, 2FA and E2E are disabled', async ({ page }) => { const securityTab = poAccountProfile.sidenav.linkSecurity; await expect(securityTab).not.toBeVisible(); @@ -38,12 +29,12 @@ test.describe.serial('access-security-page', () => { }); test.describe.serial('can access account security sections', () => { - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - Accounts_AllowPasswordChange: true, - Accounts_TwoFactorAuthentication_Enabled: false, - E2E_Enable: false, - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Accounts_AllowPasswordChange', true), + updateSetting('Accounts_TwoFactorAuthentication_Enabled', false), + updateSetting('E2E_Enable', false), + ]); }); test.beforeEach(async () => { @@ -60,22 +51,22 @@ test.describe.serial('access-security-page', () => { await expect(poAccountProfile.securityPasswordSection).toBeVisible(); }); - test('can access 2FA setting when enabled but password change and E2E are disabled', async ({ api }) => { - await updateSettings(api, { - Accounts_AllowPasswordChange: false, - Accounts_TwoFactorAuthentication_Enabled: true, - E2E_Enable: false, - }); + test('can access 2FA setting when enabled but password change and E2E are disabled', async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Accounts_AllowPasswordChange', false), + updateSetting('Accounts_TwoFactorAuthentication_Enabled', true), + updateSetting('E2E_Enable', false), + ]); await expect(poAccountProfile.security2FASection).toBeVisible(); }); - test('can access E2E setting when enabled but password change and 2FA are disabled', async ({ api }) => { - await updateSettings(api, { - Accounts_AllowPasswordChange: false, - Accounts_TwoFactorAuthentication_Enabled: false, - E2E_Enable: true, - }); + test('can access E2E setting when enabled but password change and 2FA are disabled', async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Accounts_AllowPasswordChange', false), + updateSetting('Accounts_TwoFactorAuthentication_Enabled', false), + updateSetting('E2E_Enable', true), + ]); await expect(poAccountProfile.securityE2EEncryptionSection).toBeVisible(); }); diff --git a/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts b/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts index e483c3daf8deb..facb61492d116 100644 --- a/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts +++ b/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts @@ -1,6 +1,5 @@ import { DEFAULT_USER_CREDENTIALS } from './config/constants'; import { Registration } from './page-objects'; -import { updateSetting } from './utils'; import { test, expect } from './utils/test'; test.describe.serial('Forget session on window close setting', () => { @@ -13,8 +12,8 @@ test.describe.serial('Forget session on window close setting', () => { }); test.describe('Setting off', async () => { - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Accounts_ForgetUserSessionOnWindowClose', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Accounts_ForgetUserSessionOnWindowClose', false, false); }); test('Login using credentials and reload to stay logged in', async ({ page, context }) => { @@ -33,12 +32,8 @@ test.describe.serial('Forget session on window close setting', () => { // TODO: Fix this test test.describe.skip('Setting on', async () => { - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Accounts_ForgetUserSessionOnWindowClose', true); - }); - - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Accounts_ForgetUserSessionOnWindowClose', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Accounts_ForgetUserSessionOnWindowClose', true); }); test('Login using credentials and reload to get logged out', async ({ page, context }) => { diff --git a/apps/meteor/tests/e2e/administration-settings.spec.ts b/apps/meteor/tests/e2e/administration-settings.spec.ts index 24ffa09d34c1c..a6d5a67b934f6 100644 --- a/apps/meteor/tests/e2e/administration-settings.spec.ts +++ b/apps/meteor/tests/e2e/administration-settings.spec.ts @@ -1,6 +1,6 @@ import { Users } from './fixtures/userStates'; import { Admin } from './page-objects'; -import { getSettingValueById, setSettingValueById } from './utils'; +import { getSettingValueById } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -42,9 +42,9 @@ test.describe.parallel('administration-settings', () => { await page.goto('/admin/settings/Layout'); }); - test.afterAll(async ({ api }) => setSettingValueById(api, 'theme-custom-css', '')); + test.afterAll(async ({ updateSetting }) => updateSetting('theme-custom-css', '')); - test('should display the code mirror correctly', async ({ page, api }) => { + test('should display the code mirror correctly', async ({ page, updateSetting }) => { await poAdmin.getAccordionBtnByName('Custom CSS').click(); await test.step('should render only one code mirror element', async () => { @@ -60,7 +60,7 @@ test.describe.parallel('administration-settings', () => { await test.step('should reflect updated value when valueProp changes after server update', async () => { const codeValue = `.test-class-${Date.now()} { background-color: red; }`; - await setSettingValueById(api, 'theme-custom-css', codeValue); + await updateSetting('theme-custom-css', codeValue); const codeMirrorParent = page.getByRole('code'); await expect(codeMirrorParent.locator('.CodeMirror-line')).toHaveText(codeValue); diff --git a/apps/meteor/tests/e2e/administration.spec.ts b/apps/meteor/tests/e2e/administration.spec.ts index bb3985cb4d2d6..65f4e909e6dd9 100644 --- a/apps/meteor/tests/e2e/administration.spec.ts +++ b/apps/meteor/tests/e2e/administration.spec.ts @@ -3,7 +3,7 @@ import { faker } from '@faker-js/faker'; import { IS_EE } from './config/constants'; import { Users } from './fixtures/userStates'; import { Admin, Utils } from './page-objects'; -import { createTargetChannel, updateSetting } from './utils'; +import { createTargetChannel } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -282,18 +282,14 @@ test.describe.parallel('administration', () => { 'javascript,css,markdown,dockerfile,json,go,rust,clean,bash,plaintext,powershell,scss,shell,yaml,vim'; const incomingIntegrationName = faker.string.uuid(); - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Message_Code_highlight', ''); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Message_Code_highlight', '', messageCodeHighlightDefault); }); test.beforeEach(async ({ page }) => { await page.goto('/admin/integrations'); }); - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Message_Code_highlight', messageCodeHighlightDefault); - }); - test('should display the example payload correctly', async () => { await poAdmin.btnNew.click(); await poAdmin.btnInstructions.click(); diff --git a/apps/meteor/tests/e2e/anonymous-user.spec.ts b/apps/meteor/tests/e2e/anonymous-user.spec.ts index 2ab13be74e332..5d19b55358700 100644 --- a/apps/meteor/tests/e2e/anonymous-user.spec.ts +++ b/apps/meteor/tests/e2e/anonymous-user.spec.ts @@ -1,24 +1,16 @@ import { faker } from '@faker-js/faker'; import { HomeChannel, Registration } from './page-objects'; -import { updateSettings } from './utils'; import { expect, test } from './utils/test'; test.describe('anonymous-user', () => { let poHomeChannel: HomeChannel; - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - Accounts_AllowAnonymousRead: true, - Accounts_AllowAnonymousWrite: true, - }); - }); - - test.afterAll(async ({ api }) => { - await updateSettings(api, { - Accounts_AllowAnonymousRead: false, - Accounts_AllowAnonymousWrite: false, - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Accounts_AllowAnonymousRead', true, false), + updateSetting('Accounts_AllowAnonymousWrite', true, false), + ]); }); test.beforeEach(async ({ page }) => { diff --git a/apps/meteor/tests/e2e/avatar-settings.ts b/apps/meteor/tests/e2e/avatar-settings.ts index 9ef1fe18c301e..1d902cda3b9b3 100644 --- a/apps/meteor/tests/e2e/avatar-settings.ts +++ b/apps/meteor/tests/e2e/avatar-settings.ts @@ -1,6 +1,6 @@ import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { createTargetChannel, createTargetPrivateChannel, createDirectMessage, updateSettings } from './utils'; +import { createTargetChannel, createTargetPrivateChannel, createDirectMessage } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -33,18 +33,11 @@ test.describe('avatar-settings', () => { test.describe('external avatar provider', () => { const providerUrlPrefix = 'https://example.com/avatar/'; - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - Accounts_RoomAvatarExternalUrl: `${providerUrlPrefix}{username}`, - Accounts_AvatarExternalUrl: `${providerUrlPrefix}{username}`, - }); - }); - - test.afterAll(async ({ api }) => { - await updateSettings(api, { - Accounts_RoomAvatarExternalUrl: '', - Accounts_AvatarExternalUrl: '', - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Accounts_RoomAvatarExternalUrl', `${providerUrlPrefix}{username}`, ''), + updateSetting('Accounts_AvatarExternalUrl', `${providerUrlPrefix}{username}`, ''), + ]); }); test.describe('public channels', () => { diff --git a/apps/meteor/tests/e2e/e2e-encryption.spec.ts b/apps/meteor/tests/e2e/e2e-encryption.spec.ts index 70eda971e8d44..a85968b4dd969 100644 --- a/apps/meteor/tests/e2e/e2e-encryption.spec.ts +++ b/apps/meteor/tests/e2e/e2e-encryption.spec.ts @@ -6,7 +6,6 @@ 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 { updateSetting, updateSettings } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -22,18 +21,8 @@ test.describe.serial('e2e-encryption initial setup', () => { poHomeChannel = new HomeChannel(page); }); - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - E2E_Enable: true, - E2E_Allow_Unencrypted_Messages: true, - }); - }); - - test.afterAll(async ({ api }) => { - await updateSettings(api, { - E2E_Enable: false, - E2E_Allow_Unencrypted_Messages: false, - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([updateSetting('E2E_Enable', true, false), updateSetting('E2E_Allow_Unencrypted_Messages', true, false)]); }); test.afterEach(async ({ api }) => { @@ -257,19 +246,15 @@ test.describe.serial('e2e-encryption', () => { test.use({ storageState: Users.userE2EE.state }); - test.beforeEach(async ({ page, api }) => { - await updateSetting(api, 'E2E_Enable', true); + test.beforeEach(async ({ page, updateSetting }) => { + await updateSetting('E2E_Enable', true, false); poHomeChannel = new HomeChannel(page); await page.goto('/home'); }); - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'E2E_Allow_Unencrypted_Messages', true); - }); - - test.afterAll(async ({ api }) => { - await updateSettings(api, { E2E_Enable: false, E2E_Allow_Unencrypted_Messages: false }); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('E2E_Allow_Unencrypted_Messages', true, false); }); test('expect create a private channel encrypted and send an encrypted message', async ({ page }) => { @@ -521,11 +506,11 @@ test.describe.serial('e2e-encryption', () => { }); test.describe('File Encryption', async () => { - test.afterAll(async ({ api }) => { - await updateSettings(api, { - FileUpload_MediaTypeWhiteList: '', - FileUpload_MediaTypeBlackList: 'image/svg+xml', - }); + test.afterAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('FileUpload_MediaTypeWhiteList', ''), + updateSetting('FileUpload_MediaTypeBlackList', 'image/svg+xml'), + ]); }); test('File and description encryption', async ({ page }) => { @@ -557,7 +542,7 @@ test.describe.serial('e2e-encryption', () => { }); }); - test('File encryption with whitelisted and blacklisted media types', async ({ page, api }) => { + test('File encryption with whitelisted and blacklisted media types', async ({ page, updateSetting }) => { await test.step('create an encrypted room', async () => { const channelName = faker.string.uuid(); @@ -586,7 +571,7 @@ test.describe.serial('e2e-encryption', () => { }); await test.step('set whitelisted media type setting', async () => { - await updateSetting(api, 'FileUpload_MediaTypeWhiteList', 'text/plain'); + await updateSetting('FileUpload_MediaTypeWhiteList', 'text/plain', ''); }); await test.step('send text file again with whitelist setting set', async () => { @@ -601,7 +586,7 @@ test.describe.serial('e2e-encryption', () => { }); await test.step('set blacklisted media type setting to not accept application/octet-stream media type', async () => { - await updateSetting(api, 'FileUpload_MediaTypeBlackList', 'application/octet-stream'); + await updateSetting('FileUpload_MediaTypeBlackList', 'application/octet-stream', 'image/svg+xml'); }); await test.step('send text file again with blacklisted setting set, file upload should fail', async () => { @@ -617,18 +602,11 @@ test.describe.serial('e2e-encryption', () => { }); test.describe('File encryption setting disabled', async () => { - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - E2E_Enable_Encrypt_Files: false, - FileUpload_MediaTypeBlackList: 'application/octet-stream', - }); - }); - - test.afterAll(async ({ api }) => { - await updateSettings(api, { - E2E_Enable_Encrypt_Files: true, - FileUpload_MediaTypeBlackList: 'image/svg+xml', - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('E2E_Enable_Encrypt_Files', false, true), + updateSetting('FileUpload_MediaTypeBlackList', 'application/octet-stream', 'image/svg+xml'), + ]); }); test('Upload file without encryption in e2ee room', async ({ page }) => { @@ -705,12 +683,8 @@ test.describe.serial('e2e-encryption', () => { poHomeChannel = new HomeChannel(page); await page.goto('/home'); }); - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'E2E_Allow_Unencrypted_Messages', false); - }); - - test.afterAll(async ({ api }) => { - await updateSetting(api, 'E2E_Allow_Unencrypted_Messages', true); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('E2E_Allow_Unencrypted_Messages', false, true); }); test('expect slash commands to be disabled in an e2ee room', async ({ page }) => { @@ -868,12 +842,8 @@ test.describe.serial('e2ee room setup', () => { poHomeChannel = new HomeChannel(page); }); - test.beforeAll(async ({ api }) => { - await updateSettings(api, { E2E_Enable: true, E2E_Allow_Unencrypted_Messages: false }); - }); - - test.afterAll(async ({ api }) => { - await updateSettings(api, { E2E_Enable: false, E2E_Allow_Unencrypted_Messages: false }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([updateSetting('E2E_Enable', true, false), updateSetting('E2E_Allow_Unencrypted_Messages', false, false)]); }); test.afterEach(async ({ api }) => { @@ -1054,12 +1024,8 @@ test.describe('e2ee support legacy formats', () => { poHomeChannel = new HomeChannel(page); }); - test.beforeAll(async ({ api }) => { - await updateSettings(api, { E2E_Enable: true, E2E_Allow_Unencrypted_Messages: false }); - }); - - test.afterAll(async ({ api }) => { - await updateSettings(api, { E2E_Enable: false, E2E_Allow_Unencrypted_Messages: false }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([updateSetting('E2E_Enable', true, false), updateSetting('E2E_Allow_Unencrypted_Messages', false, false)]); }); // ->>>>>>>>>>>Not testing upload since it was not implemented in the legacy format diff --git a/apps/meteor/tests/e2e/feature-preview.spec.ts b/apps/meteor/tests/e2e/feature-preview.spec.ts index 4f6b89576a525..bd02abe207909 100644 --- a/apps/meteor/tests/e2e/feature-preview.spec.ts +++ b/apps/meteor/tests/e2e/feature-preview.spec.ts @@ -26,14 +26,13 @@ test.describe.serial('feature preview', () => { let sidepanelTeam: string; const targetChannelNameInTeam = `channel-from-team-${faker.number.int()}`; - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Accounts_AllowFeaturePreview', true); + test.beforeAll(async ({ api, updateSetting }) => { + await updateSetting('Accounts_AllowFeaturePreview', true, false); targetChannel = await createTargetChannel(api, { members: ['user1'] }); targetDiscussion = await createTargetDiscussion(api); }); test.afterAll(async ({ api }) => { - await updateSetting(api, 'Accounts_AllowFeaturePreview', false); await deleteChannel(api, targetChannel); await deleteRoom(api, targetDiscussion._id); }); diff --git a/apps/meteor/tests/e2e/file-upload.spec.ts b/apps/meteor/tests/e2e/file-upload.spec.ts index c125a692592de..2ee2b53524339 100644 --- a/apps/meteor/tests/e2e/file-upload.spec.ts +++ b/apps/meteor/tests/e2e/file-upload.spec.ts @@ -1,6 +1,6 @@ import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { createTargetChannel, updateSetting } from './utils'; +import { createTargetChannel } from './utils'; import { expect, test } from './utils/test'; test.use({ storageState: Users.user1.state }); @@ -9,8 +9,8 @@ test.describe.serial('file-upload', () => { let poHomeChannel: HomeChannel; let targetChannel: string; - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'FileUpload_MediaTypeBlackList', 'image/svg+xml'); + test.beforeAll(async ({ api, updateSetting }) => { + await updateSetting('FileUpload_MediaTypeBlackList', 'image/svg+xml', 'image/svg+xml'); targetChannel = await createTargetChannel(api, { members: ['user1'] }); }); @@ -22,7 +22,6 @@ test.describe.serial('file-upload', () => { }); test.afterAll(async ({ api }) => { - await updateSetting(api, 'FileUpload_MediaTypeBlackList', 'image/svg+xml'); expect((await api.post('/channels.delete', { roomName: targetChannel })).status()).toBe(200); }); @@ -67,8 +66,8 @@ test.describe.serial('file-upload', () => { await expect(poHomeChannel.content.lastMessageFileName).toContainText('diagram.drawio'); }); - test('expect not to send drawio file (unknown media type) when the default media type is blocked', async ({ api, page }) => { - await updateSetting(api, 'FileUpload_MediaTypeBlackList', 'application/octet-stream'); + test('expect not to send drawio file (unknown media type) when the default media type is blocked', async ({ page, updateSetting }) => { + await updateSetting('FileUpload_MediaTypeBlackList', 'application/octet-stream', 'image/svg+xml'); await page.reload(); await poHomeChannel.content.sendFileMessage('diagram.drawio'); diff --git a/apps/meteor/tests/e2e/homepage.spec.ts b/apps/meteor/tests/e2e/homepage.spec.ts index 5eedcd48df294..be0d1ae5e52fa 100644 --- a/apps/meteor/tests/e2e/homepage.spec.ts +++ b/apps/meteor/tests/e2e/homepage.spec.ts @@ -2,7 +2,6 @@ import type { Page } from '@playwright/test'; import { IS_EE } from './config/constants'; import { Users } from './fixtures/userStates'; -import { updateSetting, updateSettings } from './utils'; import { expect, test } from './utils/test'; const CardIds = { @@ -27,11 +26,8 @@ test.describe.serial('homepage', () => { await adminPage.waitForSelector('[data-qa-id="home-header"]'); }); - test.afterAll(async ({ api }) => { - await updateSettings(api, { - Layout_Home_Custom_Block_Visible: false, - Layout_Custom_Body_Only: false, - }); + test.afterAll(async ({ updateSetting }) => { + await Promise.all([updateSetting('Layout_Home_Custom_Block_Visible', false), updateSetting('Layout_Custom_Body_Only', false)]); await adminPage.close(); }); @@ -47,8 +43,8 @@ test.describe.serial('homepage', () => { }); test.describe('custom body with empty custom content', async () => { - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Layout_Home_Body', ''); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Layout_Home_Body', '', ''); }); test('visibility and button functionality in custom body with empty custom content', async () => { @@ -68,8 +64,8 @@ test.describe.serial('homepage', () => { }); test.describe('custom body with custom content', () => { - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Layout_Home_Body', 'Hello admin'); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Layout_Home_Body', 'Hello admin', ''); }); test('visibility and button functionality in custom body with custom content', async () => { @@ -86,12 +82,12 @@ test.describe.serial('homepage', () => { test.describe('enterprise edition', () => { test.skip(!IS_EE, 'Enterprise Only'); - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - Layout_Home_Body: 'Hello admin', - Layout_Home_Custom_Block_Visible: true, - Layout_Custom_Body_Only: true, - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Layout_Home_Body', 'Hello admin'), + updateSetting('Layout_Home_Custom_Block_Visible', true), + updateSetting('Layout_Custom_Body_Only', true), + ]); }); test('display custom content only', async () => { @@ -115,8 +111,8 @@ test.describe.serial('homepage', () => { test.describe('for regular users', () => { const notVisibleCards = [CardIds.Users, CardIds.Custom]; - test.beforeAll(async ({ api, browser }) => { - await updateSetting(api, 'Layout_Home_Body', ''); + test.beforeAll(async ({ updateSetting, browser }) => { + await updateSetting('Layout_Home_Body', '', ''); regularUserPage = await browser.newPage({ storageState: Users.user2.state }); await regularUserPage.goto('/home'); await regularUserPage.waitForSelector('[data-qa-id="home-header"]'); @@ -153,23 +149,16 @@ test.describe.serial('homepage', () => { }); test.describe('custom values', () => { - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - Site_Name: 'NewSiteName', - Layout_Home_Title: 'NewTitle', - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Site_Name', 'NewSiteName', 'Rocket.Chat'), + updateSetting('Layout_Home_Title', 'NewTitle', 'Home'), + ]); await regularUserPage.goto('/home'); await regularUserPage.waitForSelector('[data-qa-id="home-header"]'); }); - test.afterAll(async ({ api }) => { - await updateSettings(api, { - Site_Name: 'Rocket.Chat', - Layout_Home_Title: 'Home', - }); - }); - test('expect welcome text and header text to be correct', async () => { await test.step('expect welcome text to be NewSiteName', async () => { await expect(regularUserPage.locator('role=heading[name="Welcome to NewSiteName"]')).toBeVisible(); @@ -182,23 +171,13 @@ test.describe.serial('homepage', () => { }); test.describe('custom body with content', () => { - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - Layout_Home_Body: 'Hello', - Layout_Home_Custom_Block_Visible: true, - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([updateSetting('Layout_Home_Body', 'Hello', ''), updateSetting('Layout_Home_Custom_Block_Visible', true, false)]); await regularUserPage.goto('/home'); await regularUserPage.waitForSelector('[data-qa-id="home-header"]'); }); - test.afterAll(async ({ api }) => { - await updateSettings(api, { - Layout_Home_Body: '', - Layout_Home_Custom_Block_Visible: false, - }); - }); - test('expect custom body to be visible', async () => { await expect(regularUserPage.locator('div >> text="Hello"')).toBeVisible(); }); @@ -206,12 +185,8 @@ test.describe.serial('homepage', () => { test.describe('enterprise edition', () => { test.skip(!IS_EE, 'Enterprise Only'); - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Layout_Custom_Body_Only', true); - }); - - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Layout_Custom_Body_Only', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Layout_Custom_Body_Only', true, false); }); test('expect default layout not be visible and custom body visible', async () => { diff --git a/apps/meteor/tests/e2e/login.spec.ts b/apps/meteor/tests/e2e/login.spec.ts index e4cc5c37674f2..89c3aa2811860 100644 --- a/apps/meteor/tests/e2e/login.spec.ts +++ b/apps/meteor/tests/e2e/login.spec.ts @@ -2,7 +2,6 @@ import { faker } from '@faker-js/faker'; import { DEFAULT_USER_CREDENTIALS } from './config/constants'; import { Utils, Registration } from './page-objects'; -import { updateSetting } from './utils'; import { test, expect } from './utils/test'; test.describe.parallel('Login', () => { @@ -16,10 +15,6 @@ test.describe.parallel('Login', () => { await page.goto('/home'); }); - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Language', 'en'); - }); - test('should not have any accessibility violations', async ({ makeAxeBuilder }) => { const results = await makeAxeBuilder().analyze(); expect(results.violations).toEqual([]); @@ -56,8 +51,8 @@ test.describe.parallel('Login', () => { }); }); - test('Should correctly display switch language button', async ({ page, api }) => { - expect((await updateSetting(api, 'Language', 'pt-BR')).status()).toBe(200); + test('Should correctly display switch language button', async ({ page, updateSetting }) => { + await updateSetting('Language', 'pt-BR', 'en'); const button = page.getByRole('button', { name: 'Change to português (Brasil)' }); await button.click(); diff --git a/apps/meteor/tests/e2e/oauth.spec.ts b/apps/meteor/tests/e2e/oauth.spec.ts index 53faa2ccb80dd..e3e5a6daee01e 100644 --- a/apps/meteor/tests/e2e/oauth.spec.ts +++ b/apps/meteor/tests/e2e/oauth.spec.ts @@ -1,5 +1,4 @@ import { Registration } from './page-objects'; -import { updateSetting } from './utils'; import { test, expect } from './utils/test'; test.describe('OAuth', () => { @@ -9,9 +8,9 @@ test.describe('OAuth', () => { poRegistration = new Registration(page); }); - test('Login Page', async ({ page, api }) => { + test('Login Page', async ({ page, updateSetting }) => { await test.step('expect OAuth button to be visible', async () => { - await updateSetting(api, 'Accounts_OAuth_Google', true); + await updateSetting('Accounts_OAuth_Google', true); await page.waitForTimeout(5000); await page.goto('/home'); @@ -20,7 +19,7 @@ test.describe('OAuth', () => { }); await test.step('expect Custom OAuth button to be visible', async () => { - await updateSetting(api, 'Accounts_OAuth_Custom-Test', true); + await updateSetting('Accounts_OAuth_Custom-Test', true); await page.waitForTimeout(5000); await page.goto('/home'); @@ -33,7 +32,7 @@ test.describe('OAuth', () => { }); await test.step('expect OAuth button to not be visible', async () => { - await updateSetting(api, 'Accounts_OAuth_Google', false); + await updateSetting('Accounts_OAuth_Google', false); await page.waitForTimeout(5000); await page.goto('/home'); @@ -41,7 +40,7 @@ test.describe('OAuth', () => { }); await test.step('expect Custom OAuth button to not be visible', async () => { - await updateSetting(api, 'Accounts_OAuth_Custom-Test', false); + await updateSetting('Accounts_OAuth_Custom-Test', false); await page.waitForTimeout(5000); await page.goto('/home'); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts index ac5c0857e0203..793ee87f7bab4 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts @@ -1,7 +1,6 @@ import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { OmnichannelAgents } from '../page-objects'; -import { updateSetting } from '../utils'; import { createDepartment } from '../utils/omnichannel/departments'; import { test, expect } from '../utils/test'; @@ -25,11 +24,11 @@ test.describe.serial('OC - Manage Agents', () => { }); // Ensure that there is no leftover data even if test fails - test.afterEach(async ({ api }) => { + test.afterEach(async ({ api, updateSetting }) => { await api.delete('/livechat/users/agent/user1'); - await updateSetting(api, 'Omnichannel_enable_department_removal', true); + await updateSetting('Omnichannel_enable_department_removal', true); await department.delete(); - await updateSetting(api, 'Omnichannel_enable_department_removal', false); + await updateSetting('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 34e6551dda0b5..e111dc933b508 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-appearance.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-appearance.spec.ts @@ -1,7 +1,6 @@ import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { OmnichannelLivechatAppearance } from '../page-objects/omnichannel-livechat-appearance'; -import { updateSettings } from '../utils'; import { test, expect } from '../utils/test'; test.use({ storageState: Users.admin.state }); @@ -17,15 +16,11 @@ test.describe.serial('OC - Livechat Appearance - EE', () => { await poLivechatAppearance.sidenav.linkLivechatAppearance.click(); }); - test.afterAll(async ({ api }) => { - const res = await updateSettings(api, { - Livechat_hide_system_messages: ['uj', 'ul', 'livechat-close'], - Livechat_background: '', - }); - - if (res.some((r) => r.status() !== 200)) { - throw new Error('Failed to reset settings'); - } + test.afterAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Livechat_hide_system_messages', ['uj', 'ul', 'livechat-close']), + updateSetting('Livechat_background', ''), + ]); }); test('OC - Livechat Appearance - Hide system messages', async ({ page }) => { 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 a541c42f8c846..f3ffe614536c3 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,7 +5,6 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeChannel } from '../page-objects'; -import { updateSettings } from '../utils'; import { test, expect } from '../utils/test'; test.describe('omnichannel-auto-onhold-chat-closing', () => { @@ -16,14 +15,12 @@ test.describe('omnichannel-auto-onhold-chat-closing', () => { let agent: { page: Page; poHomeChannel: HomeChannel }; - test.beforeAll(async ({ api, browser }) => { + test.beforeAll(async ({ api, browser, updateSetting }) => { await Promise.all([ api.post('/livechat/users/agent', { username: 'user1' }).then((res) => expect(res.status()).toBe(200)), - updateSettings(api, { - Livechat_Routing_Method: 'Auto_Selection', - Livechat_auto_close_on_hold_chats_timeout: 5, - Livechat_allow_manual_on_hold: true, - }), + updateSetting('Livechat_Routing_Method', 'Auto_Selection', 'Auto_Selection'), + updateSetting('Livechat_auto_close_on_hold_chats_timeout', 5, 3600), + updateSetting('Livechat_allow_manual_on_hold', true, false), ]); const { page } = await createAuxContext(browser, Users.user1); @@ -32,14 +29,7 @@ test.describe('omnichannel-auto-onhold-chat-closing', () => { test.afterAll(async ({ api }) => { await agent.page.close(); - await Promise.all([ - api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)), - updateSettings(api, { - Livechat_Routing_Method: 'Auto_Selection', - Livechat_auto_close_on_hold_chats_timeout: 3600, - Livechat_allow_manual_on_hold: false, - }), - ]); + await api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)); }); test.beforeEach(async ({ page, api }) => { 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 70c5376ea9f19..cdfd221ff2f5e 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,7 +5,6 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeChannel } from '../page-objects'; -import { updateSetting } from '../utils'; import { test, expect } from '../utils/test'; test.describe('omnichannel-auto-transfer-unanswered-chat', () => { @@ -17,12 +16,12 @@ test.describe('omnichannel-auto-transfer-unanswered-chat', () => { let agent1: { page: Page; poHomeChannel: HomeChannel }; let agent2: { page: Page; poHomeChannel: HomeChannel }; - test.beforeAll(async ({ api, browser }) => { + test.beforeAll(async ({ api, browser, updateSetting }) => { 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)), - updateSetting(api, 'Livechat_Routing_Method', 'Auto_Selection'), - updateSetting(api, 'Livechat_auto_transfer_chat_timeout', 5), + updateSetting('Livechat_Routing_Method', 'Auto_Selection', 'Auto_Selection'), + updateSetting('Livechat_auto_transfer_chat_timeout', 5, 0), ]); const { page } = await createAuxContext(browser, Users.user1); @@ -39,7 +38,6 @@ 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)), - updateSetting(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 0cd818fa45da8..fb2cca43bf613 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-business-hours.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-business-hours.spec.ts @@ -4,7 +4,6 @@ import type { Page } from '@playwright/test'; import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { OmnichannelBusinessHours } from '../page-objects'; -import { updateSetting } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { createBusinessHour } from '../utils/omnichannel/businessHours'; import { createDepartment } from '../utils/omnichannel/departments'; @@ -20,24 +19,20 @@ test.describe('OC - Business Hours', () => { let department2: Awaited>; let agent: Awaited>; - test.beforeAll(async ({ api }) => { + test.beforeAll(async ({ api, updateSetting }) => { department = await createDepartment(api); department2 = await createDepartment(api); agent = await createAgent(api, 'user2'); await Promise.all([ - updateSetting(api, 'Livechat_enable_business_hours', true), - updateSetting(api, 'Livechat_business_hour_type', 'Multiple'), + updateSetting('Livechat_enable_business_hours', true, false), + updateSetting('Livechat_business_hour_type', 'Multiple', 'Single'), ]); }); - test.afterAll(async ({ api }) => { + test.afterAll(async () => { await department.delete(); await department2.delete(); await agent.delete(); - await Promise.all([ - updateSetting(api, 'Livechat_enable_business_hours', false), - updateSetting(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 11f1da166cd04..5ab5190a40bc3 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,7 +5,6 @@ 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 { updateSetting } from '../utils'; import { getPriorityByi18nLabel } from '../utils/omnichannel/priority'; import { createSLA } from '../utils/omnichannel/sla'; import { test, expect } from '../utils/test'; @@ -29,14 +28,14 @@ test.describe.serial('omnichannel-changing-room-priority-and-sla', () => { let agent: { page: Page; poHomeChannel: HomeChannel }; - test.beforeAll(async ({ api, browser }) => { + test.beforeAll(async ({ api, browser, updateSetting }) => { let statusCode = (await api.post('/livechat/users/agent', { username: ADMIN_CREDENTIALS.username })).status(); expect(statusCode).toBe(200); statusCode = (await api.post('/livechat/users/manager', { username: ADMIN_CREDENTIALS.username })).status(); expect(statusCode).toBe(200); - await updateSetting(api, 'Livechat_Routing_Method', 'Manual_Selection'); + await updateSetting('Livechat_Routing_Method', 'Manual_Selection', 'Auto_Selection'); const { page } = await createAuxContext(browser, Users.admin); agent = { page, poHomeChannel: new HomeChannel(page) }; @@ -50,7 +49,6 @@ 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}`), - updateSetting(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 3f122edea1bef..3251e0dba2420 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-close-inquiry.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-close-inquiry.spec.ts @@ -4,7 +4,6 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeOmnichannel } from '../page-objects'; -import { updateSetting } from '../utils'; import { test, expect } from '../utils/test'; test.describe('Omnichannel close inquiry', () => { @@ -13,10 +12,10 @@ test.describe('Omnichannel close inquiry', () => { let agent: { page: Page; poHomeOmnichannel: HomeOmnichannel }; - test.beforeAll(async ({ api }) => { + test.beforeAll(async ({ api, updateSetting }) => { newVisitor = createFakeVisitor(); - await updateSetting(api, 'Livechat_Routing_Method', 'Manual_Selection'); + await updateSetting('Livechat_Routing_Method', 'Manual_Selection', 'Auto_Selection'); await api.post('/livechat/users/manager', { username: 'user1' }); await api.post('/livechat/users/agent', { username: 'user1' }); }); @@ -33,11 +32,7 @@ test.describe('Omnichannel close inquiry', () => { }); test.afterAll(async ({ api }) => { - await Promise.all([ - await updateSetting(api, 'Livechat_Routing_Method', 'Auto_Selection'), - await api.delete('/livechat/users/agent/user1'), - await api.delete('/livechat/users/manager/user1'), - ]); + await Promise.all([await api.delete('/livechat/users/agent/user1'), await api.delete('/livechat/users/manager/user1')]); }); test('Receiving a message from visitor', async ({ page }) => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center-chats-filters.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center-chats-filters.spec.ts index 9a62b6b376fac..a4862cd0cc4db 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center-chats-filters.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center-chats-filters.spec.ts @@ -2,7 +2,6 @@ import { faker } from '@faker-js/faker/locale/af_ZA'; import { Users } from '../fixtures/userStates'; import { OmnichannelChats } from '../page-objects/omnichannel-contact-center-chats'; -import { setSettingValueById } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { createConversation } from '../utils/omnichannel/rooms'; import { test, expect } from '../utils/test'; @@ -19,8 +18,8 @@ test.describe('OC - Contact Center - Chats', () => { const visitorA = `visitorA_${uuid}`; const visitorB = `visitorB_${uuid}`; - test.beforeAll(async ({ api }) => { - expect((await setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection')).status()).toBe(200); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Livechat_Routing_Method', 'Auto_Selection', 'Auto_Selection'); }); test.beforeAll(async ({ api }) => { @@ -46,9 +45,8 @@ test.describe('OC - Contact Center - Chats', () => { await page.close(); }); - test.afterAll(async ({ api }) => { + test.afterAll(async () => { await Promise.all([...conversations.map((conversation) => conversation.delete()), agent.delete()]); - expect((await setSettingValueById(api, 'Livechat_Routing_Method', 'Auto_Selection')).status()).toBe(200); }); test(`OC - Contact Center - Chats - Filter from and to same date`, async ({ page }) => { 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 6b891ff607b59..d00661ca83fcc 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-current-chats.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-current-chats.spec.ts @@ -4,7 +4,6 @@ import type { Page } from '@playwright/test'; import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { OmnichannelCurrentChats } from '../page-objects'; -import { updateSetting } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments'; import { createConversation, updateRoom } from '../utils/omnichannel/rooms'; @@ -27,10 +26,10 @@ test.describe('OC - Current Chats [Auto Selection]', async () => { let tags: Awaited>[]; // Allow manual on hold - test.beforeAll(async ({ api }) => { + test.beforeAll(async ({ updateSetting }) => { await Promise.all([ - updateSetting(api, 'Livechat_allow_manual_on_hold', true), - updateSetting(api, 'Livechat_allow_manual_on_hold_upon_agent_engagement_only', false), + updateSetting('Livechat_allow_manual_on_hold', true, false), + updateSetting('Livechat_allow_manual_on_hold_upon_agent_engagement_only', false, true), ]); }); @@ -113,7 +112,7 @@ test.describe('OC - Current Chats [Auto Selection]', async () => { await poCurrentChats.sidenav.linkCurrentChats.click(); }); - test.afterAll(async ({ api }) => { + test.afterAll(async () => { await Promise.all([ // Delete conversations ...conversations.map((conversation) => conversation.delete()), @@ -123,9 +122,6 @@ test.describe('OC - Current Chats [Auto Selection]', async () => { ...agents.map((agent) => agent.delete()), // Delete tags ...tags.map((tag) => tag.delete()), - // Reset setting - updateSetting(api, 'Livechat_allow_manual_on_hold', false), - updateSetting(api, 'Livechat_allow_manual_on_hold_upon_agent_engagement_only', true), ]); }); @@ -288,8 +284,8 @@ test.describe('OC - Current Chats [Manual Selection]', () => { let poCurrentChats: OmnichannelCurrentChats; let agent: Awaited>; - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Livechat_Routing_Method', 'Manual_Selection'); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Livechat_Routing_Method', 'Manual_Selection', 'Auto_Selection'); }); test.beforeAll(async ({ api }) => { @@ -321,10 +317,6 @@ test.describe('OC - Current Chats [Manual Selection]', () => { }); }); - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Livechat_Routing_Method', 'Auto_Selection'); - }); - test.afterAll(async () => { await queuedConversation.delete(); await agent.delete(); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts index 7182b835007e0..338eb83e880b9 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts @@ -4,7 +4,6 @@ import type { Page } from '@playwright/test'; import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { OmnichannelDepartments } from '../page-objects'; -import { updateSetting } from '../utils'; import { createDepartment, deleteDepartment } from '../utils/omnichannel/departments'; import { test, expect } from '../utils/test'; @@ -21,14 +20,9 @@ test.describe('OC - Manage Departments', () => { let poOmnichannelDepartments: OmnichannelDepartments; - test.beforeAll(async ({ api }) => { + test.beforeAll(async ({ updateSetting }) => { // turn on department removal - await updateSetting(api, 'Omnichannel_enable_department_removal', true); - }); - - test.afterAll(async ({ api }) => { - // turn off department removal - await updateSetting(api, 'Omnichannel_enable_department_removal', false); + await updateSetting('Omnichannel_enable_department_removal', true, false); }); test.describe('Create first department', async () => { @@ -246,7 +240,7 @@ test.describe('OC - Manage Departments', () => { }); }); - test('Toggle department removal', async ({ api }) => { + test('Toggle department removal', async ({ api, updateSetting }) => { await test.step('expect create new department', async () => { await poOmnichannelDepartments.search(department.name); await expect(poOmnichannelDepartments.firstRowInTable).toBeVisible(); @@ -259,7 +253,7 @@ test.describe('OC - Manage Departments', () => { }); await test.step('expect to disable department removal setting', async () => { - await updateSetting(api, 'Omnichannel_enable_department_removal', false); + await updateSetting('Omnichannel_enable_department_removal', false, false); }); await test.step('expect not to be able to delete department', async () => { @@ -269,7 +263,7 @@ test.describe('OC - Manage Departments', () => { }); await test.step('expect to enable department removal setting', async () => { - await updateSetting(api, 'Omnichannel_enable_department_removal', true); + await updateSetting('Omnichannel_enable_department_removal', true, false); }); 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 04ce8656faecf..2d1d5a99ea8bd 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-api.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-api.spec.ts @@ -6,7 +6,6 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChatEmbedded } from '../page-objects'; -import { updateSetting } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments'; import { test, expect } from '../utils/test'; @@ -224,7 +223,7 @@ test.describe('OC - Livechat API', () => { let departments: Awaited>[]; let pageContext: Page; - test.beforeAll(async ({ api }) => { + test.beforeAll(async ({ api, updateSetting }) => { agent = await createAgent(api, 'user1'); agent2 = await createAgent(api, 'user2'); @@ -233,8 +232,10 @@ test.describe('OC - Livechat API', () => { await addAgentToDepartment(api, { department: departmentA, agentId: agent.data._id }); await addAgentToDepartment(api, { department: departmentB, agentId: agent2.data._id }); - await updateSetting(api, 'Livechat_offline_email', 'test@testing.com'); - await updateSetting(api, 'Livechat_enabled_when_agent_idle', false); + await Promise.all([ + updateSetting('Livechat_offline_email', 'test@testing.com', ''), + updateSetting('Livechat_enabled_when_agent_idle', false, true), + ]); }); test.beforeEach(async ({ browser }, testInfo) => { @@ -261,14 +262,13 @@ test.describe('OC - Livechat API', () => { await pageContext?.close(); }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ updateSetting }) => { await agent.delete(); await agent2.delete(); - await updateSetting(api, 'Omnichannel_enable_department_removal', true); + await updateSetting('Omnichannel_enable_department_removal', true); await Promise.all([...departments.map((department) => department.delete())]); - await updateSetting(api, 'Omnichannel_enable_department_removal', false); - await updateSetting(api, 'Livechat_enabled_when_agent_idle', true); + await updateSetting('Omnichannel_enable_department_removal', false); }); // clearBusinessUnit @@ -694,10 +694,12 @@ test.describe('OC - Livechat API', () => { let page: Page; let agent: Awaited>; - test.beforeAll(async ({ api }) => { + test.beforeAll(async ({ api, updateSetting }) => { agent = await createAgent(api, 'user1'); - await updateSetting(api, 'Livechat_offline_email', 'test@testing.com'); - await updateSetting(api, 'Livechat_enabled_when_agent_idle', false); + await Promise.all([ + updateSetting('Livechat_offline_email', 'test@testing.com', ''), + updateSetting('Livechat_enabled_when_agent_idle', false, true), + ]); }); test.beforeEach(async ({ browser }, testInfo) => { @@ -723,9 +725,8 @@ test.describe('OC - Livechat API', () => { await page.close(); }); - test.afterAll(async ({ api }) => { + test.afterAll(async () => { await agent.delete(); - await updateSetting(api, 'Livechat_enabled_when_agent_idle', true); }); test('OC - Livechat API - onChatMaximized & onChatMinimized', async () => { 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 db57d955a4942..3ce61fe0ace36 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-background.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-background.spec.ts @@ -2,7 +2,6 @@ import { createFakeVisitor } from '../../mocks/data'; import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChatEmbedded } from '../page-objects'; -import { updateSetting } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { test, expect } from '../utils/test'; @@ -46,7 +45,7 @@ test.describe('OC - Livechat - Message list background', async () => { await agent.delete(); }); - test('OC - Livechat - Change message list background', async ({ api, page }) => { + test('OC - Livechat - Change message list background', async ({ page, updateSetting }) => { const visitor = createFakeVisitor(); await test.step('should initiate Livechat conversation', async () => { @@ -62,7 +61,7 @@ test.describe('OC - Livechat - Message list background', async () => { }); await test.step('expect to change message list background', async () => { - await updateSetting(api, 'Livechat_background', 'rgb(186, 1, 85)'); + await updateSetting('Livechat_background', 'rgb(186, 1, 85)', ''); await page.reload(); await poLiveChat.openLiveChat(); @@ -81,7 +80,7 @@ test.describe('OC - Livechat - Message list background', async () => { }); await test.step('expect to reset message list background to default', async () => { - await updateSetting(api, 'Livechat_background', ''); + await updateSetting('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 8b7c3da5f0e3a..a75e4eb5774df 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-department.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-department.spec.ts @@ -3,7 +3,6 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChat } from '../page-objects'; -import { updateSetting } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments'; import { test, expect } from '../utils/test'; @@ -54,11 +53,11 @@ test.describe('OC - Livechat - Department Flow', () => { await page.close(); }); - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Omnichannel_enable_department_removal', true); + test.afterAll(async ({ updateSetting }) => { + await updateSetting('Omnichannel_enable_department_removal', true); await Promise.all([...agents.map((agent) => agent.delete())]); await Promise.all([...departments.map((department) => department.delete())]); - await updateSetting(api, 'Omnichannel_enable_department_removal', false); + await updateSetting('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 b5427a9513c96..6325afe7498d6 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-fileupload.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-fileupload.spec.ts @@ -2,7 +2,6 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChat } from '../page-objects'; -import { updateSetting, updateSettings } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { test, expect } from '../utils/test'; @@ -45,11 +44,8 @@ test.describe('OC - Livechat - OC - File Upload', () => { poLiveChat = new OmnichannelLiveChat(page, api); }); - test.afterAll(async ({ api }) => { - await updateSettings(api, { - FileUpload_Enabled: true, - Livechat_fileupload_enabled: true, - }); + test.afterAll(async ({ updateSetting }) => { + await Promise.all([updateSetting('FileUpload_Enabled', true), updateSetting('Livechat_fileupload_enabled', true)]); await poHomeOmnichannel.page.close(); await agent.delete(); @@ -87,11 +83,8 @@ test.describe('OC - Livechat - OC - File Upload - Disabled', () => { poHomeOmnichannel = new HomeOmnichannel(page); }); - test.afterAll(async ({ api }) => { - await updateSettings(api, { - FileUpload_Enabled: true, - Livechat_fileupload_enabled: true, - }); + test.afterAll(async ({ updateSetting }) => { + await Promise.all([updateSetting('FileUpload_Enabled', true), updateSetting('Livechat_fileupload_enabled', true)]); await poHomeOmnichannel.page?.close(); await agent.delete(); @@ -100,10 +93,10 @@ test.describe('OC - Livechat - OC - File Upload - Disabled', () => { settingsMatrix.forEach((settings) => { const testName = settings.map(({ name, value }) => `${name}=${value}`).join(' '); - test(`OC - Livechat - txt Drag & Drop - ${testName}`, async ({ page, api }) => { + test(`OC - Livechat - txt Drag & Drop - ${testName}`, async ({ page, api, updateSetting }) => { poLiveChat = new OmnichannelLiveChat(page, api); - await Promise.all(settings.map(({ name, value }) => updateSetting(api, name, value))); + await Promise.all(settings.map(({ name, value }) => updateSetting(name, value))); await poLiveChat.page.goto('/livechat'); 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 ac9d5e42fed86..314fb8e45dcbc 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,7 +3,6 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChat } from '../page-objects'; -import { updateSettings } from '../utils'; import { test, expect } from '../utils/test'; const firstVisitor = createFakeVisitor(); @@ -20,14 +19,12 @@ test.describe('OC - Livechat - Queue Management', () => { const waitingQueueMessage = 'This is a message from Waiting Queue'; - test.beforeAll(async ({ api, browser }) => { + test.beforeAll(async ({ api, browser, updateSetting }) => { await Promise.all([ - updateSettings(api, { - Livechat_Routing_Method: 'Auto_Selection', - Livechat_accept_chats_with_no_agents: true, - Livechat_waiting_queue: true, - Livechat_waiting_queue_message: waitingQueueMessage, - }), + updateSetting('Livechat_Routing_Method', 'Auto_Selection', 'Auto_Selection'), + updateSetting('Livechat_accept_chats_with_no_agents', true, false), + updateSetting('Livechat_waiting_queue', true, false), + updateSetting('Livechat_waiting_queue_message', waitingQueueMessage, ''), api.post('/livechat/users/agent', { username: 'user1' }), ]); @@ -47,14 +44,7 @@ test.describe('OC - Livechat - Queue Management', () => { }); test.afterAll(async ({ api }) => { - await Promise.all([ - updateSettings(api, { - Livechat_accept_chats_with_no_agents: false, - Livechat_waiting_queue: false, - Livechat_waiting_queue_message: '', - }), - api.delete('/livechat/users/agent/user1'), - ]); + await 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 24c6f05f0ebfc..e4fea08c6b575 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,7 +3,6 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChat } from '../page-objects'; -import { updateSetting, updateSettings } from '../utils'; import { test, expect } from '../utils/test'; const firstVisitor = createFakeVisitor(); @@ -22,13 +21,11 @@ test.describe('OC - Livechat - Queue Management', () => { const queuePosition1 = 'Your spot is #1'; const queuePosition2 = 'Your spot is #2'; - test.beforeAll(async ({ api, browser }) => { + test.beforeAll(async ({ api, browser, updateSetting }) => { await Promise.all([ - updateSettings(api, { - Livechat_Routing_Method: 'Manual_Selection', - Livechat_waiting_queue: true, - Livechat_waiting_queue_message: waitingQueueMessage, - }), + updateSetting('Livechat_Routing_Method', 'Manual_Selection', 'Auto_Selection'), + updateSetting('Livechat_waiting_queue', true, false), + updateSetting('Livechat_waiting_queue_message', waitingQueueMessage, ''), api.post('/livechat/users/agent', { username: 'user1' }), ]); @@ -45,14 +42,7 @@ test.describe('OC - Livechat - Queue Management', () => { }); test.afterAll(async ({ api }) => { - await Promise.all([ - updateSettings(api, { - Livechat_Routing_Method: 'Auto_Selection', - Livechat_waiting_queue: false, - Livechat_waiting_queue_message: '', - }), - api.delete('/livechat/users/agent/user1'), - ]); + await api.delete('/livechat/users/agent/user1'); await poHomeOmnichannel.page.close(); }); @@ -136,9 +126,9 @@ test.describe('OC - Contact Manager Routing', () => { const visitorWithManager = createFakeVisitor(); const contactId = `contact-${Date.now()}`; - test.beforeAll(async ({ api, browser }) => { + test.beforeAll(async ({ api, browser, updateSetting }) => { await api.post('/livechat/users/agent', { username: 'user2' }); - await updateSetting(api, 'Livechat_Routing_Method', 'Manual_Selection'); + await updateSetting('Livechat_Routing_Method', 'Manual_Selection', 'Auto_Selection'); await api.post('/omnichannel/contact', { _id: contactId, name: visitorWithManager.name, @@ -165,7 +155,6 @@ test.describe('OC - Contact Manager Routing', () => { test.afterAll(async ({ api }) => { await Promise.all([ - updateSetting(api, 'Livechat_Routing_Method', 'Auto_Selection'), api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/agent/user2'), api.delete(`/omnichannel/contact/${contactId}`), 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 b9e1fd45cc1d2..047db947d0a8d 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-watermark.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-watermark.spec.ts @@ -3,7 +3,6 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, OmnichannelSettings } from '../page-objects'; -import { updateSetting } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { test, expect } from '../utils/test'; @@ -42,8 +41,8 @@ test.describe('OC - Livechat - Hide watermark', async () => { await page.goto('/admin/settings/Omnichannel'); }); - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Livechat_hide_watermark', false); + test.afterAll(async ({ updateSetting }) => { + await updateSetting('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 d100968aeeb3d..1a4d334651218 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts @@ -2,7 +2,6 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChat } from '../page-objects'; -import { updateSetting, updateSettings } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { test, expect } from '../utils/test'; @@ -122,14 +121,13 @@ test.describe.serial('OC - Livechat - Visitors closing the room is disabled', () poLiveChat = new OmnichannelLiveChat(livechatPage, api); }); - test.beforeAll(async ({ browser, api }) => { - await updateSetting(api, 'Omnichannel_allow_visitors_to_close_conversation', false); + test.beforeAll(async ({ browser, updateSetting }) => { + await updateSetting('Omnichannel_allow_visitors_to_close_conversation', false, true); const { page: omniPage } = await createAuxContext(browser, Users.user1, '/', true); poHomeOmnichannel = new HomeOmnichannel(omniPage); }); test.afterAll(async ({ api }) => { - await updateSetting(api, 'Omnichannel_allow_visitors_to_close_conversation', true); await api.delete('/livechat/users/agent/user1'); await poLiveChat.page.close(); }); @@ -168,8 +166,8 @@ test.describe.serial('OC - Livechat - Resub after close room', () => { expect(statusCode).toBe(200); }); - test.beforeAll(async ({ browser, api }) => { - await updateSetting(api, 'Livechat_clear_local_storage_when_chat_ended', true); + test.beforeAll(async ({ browser, api, updateSetting }) => { + await updateSetting('Livechat_clear_local_storage_when_chat_ended', true, false); const { page: omniPage } = await createAuxContext(browser, Users.user1, '/', true); poHomeOmnichannel = new HomeOmnichannel(omniPage); @@ -180,7 +178,6 @@ test.describe.serial('OC - Livechat - Resub after close room', () => { }); test.afterAll(async ({ api }) => { - await updateSetting(api, 'Livechat_clear_local_storage_when_chat_ended', false); await api.delete('/livechat/users/agent/user1'); await poLiveChat.page.close(); await poHomeOmnichannel.page.close(); @@ -321,11 +318,11 @@ test.describe('OC - Livechat - Livechat_Display_Offline_Form', () => { let poLiveChat: OmnichannelLiveChat; const message = 'This form is not available'; - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - Livechat_display_offline_form: false, - Livechat_offline_form_unavailable: message, - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Livechat_display_offline_form', false, true), + updateSetting('Livechat_offline_form_unavailable', message, ''), + ]); }); test.beforeEach(async ({ page, api }) => { @@ -333,13 +330,6 @@ test.describe('OC - Livechat - Livechat_Display_Offline_Form', () => { await poLiveChat.page.goto('/livechat'); }); - test.afterAll(async ({ api }) => { - await updateSettings(api, { - Livechat_display_offline_form: true, - Livechat_offline_form_unavailable: '', - }); - }); - test('OC - Livechat - Livechat_Display_Offline_Form false', async () => { await test.step('expect offline form to not be visible', async () => { await poLiveChat.openAnyLiveChat(); 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 7171408e3f754..9af3882d456f1 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-manager-role.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-manager-role.spec.ts @@ -4,7 +4,6 @@ import type { Page } from '@playwright/test'; import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel } from '../page-objects'; -import { updateSettings } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { createDepartment } from '../utils/omnichannel/departments'; import { createManager } from '../utils/omnichannel/managers'; @@ -29,11 +28,11 @@ test.describe('OC - Manager Role', () => { let manager: Awaited>; // Allow manual on hold - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - Livechat_allow_manual_on_hold: true, - Livechat_allow_manual_on_hold_upon_agent_engagement_only: false, - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Livechat_allow_manual_on_hold', true, false), + updateSetting('Livechat_allow_manual_on_hold_upon_agent_engagement_only', false, true), + ]); }); // Create agents @@ -81,17 +80,12 @@ test.describe('OC - Manager Role', () => { }); // Delete all created data - test.afterAll(async ({ api }) => { + test.afterAll(async () => { await Promise.all([ ...agents.map((agent) => agent.delete()), ...departments.map((department) => department.delete()), ...conversations.map((conversation) => conversation.delete()), manager.delete(), - // Reset setting - updateSettings(api, { - Livechat_allow_manual_on_hold: false, - 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 288c67a3738a8..e29206e103b8e 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,7 +4,6 @@ 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 { updateSetting } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { createConversation } from '../utils/omnichannel/rooms'; import { test, expect } from '../utils/test'; @@ -16,8 +15,8 @@ test.describe('OC - Manual Selection After Relogin', () => { let agent: Awaited>; // Change routing method to manual selection - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Livechat_Routing_Method', 'Manual_Selection'); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Livechat_Routing_Method', 'Manual_Selection', 'Auto_Selection'); }); // Create agent and make it available @@ -41,9 +40,8 @@ test.describe('OC - Manual Selection After Relogin', () => { }); // Delete all data - test.afterAll(async ({ api }) => { + test.afterAll(async () => { await agent.delete(); - await updateSetting(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 1a759e1bc352f..f5f0f60eb4dbe 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-manual-selection.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-manual-selection.spec.ts @@ -3,7 +3,6 @@ import type { Page } from '@playwright/test'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel } from '../page-objects'; -import { updateSetting } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { createConversation } from '../utils/omnichannel/rooms'; import { test, expect } from '../utils/test'; @@ -16,8 +15,8 @@ test.describe('OC - Manual Selection', () => { let agentB: { page: Page; poHomeOmnichannel: HomeOmnichannel }; // Change routing method to manual selection - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Livechat_Routing_Method', 'Manual_Selection'); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Livechat_Routing_Method', 'Manual_Selection', 'Auto_Selection'); }); // Create agent and make it available @@ -43,8 +42,8 @@ test.describe('OC - Manual Selection', () => { await agentB.page.close(); }); // Delete all data - test.afterAll(async ({ api }) => { - await Promise.all([...agents.map((agent) => agent.delete()), updateSetting(api, 'Livechat_Routing_Method', 'Auto_Selection')]); + test.afterAll(async () => { + await Promise.all(agents.map((agent) => agent.delete())); }); 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 14aee706430fd..e95851848ed24 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-monitor-role.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-monitor-role.spec.ts @@ -4,7 +4,6 @@ import type { Page } from '@playwright/test'; import { IS_EE } from '../config/constants'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel } from '../page-objects'; -import { updateSettings } from '../utils'; import { createAgent, makeAgentAvailable } from '../utils/omnichannel/agents'; import { createDepartment } from '../utils/omnichannel/departments'; import { createMonitor } from '../utils/omnichannel/monitors'; @@ -41,11 +40,11 @@ test.describe('OC - Monitor Role', () => { }); // Allow manual on hold - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - Livechat_allow_manual_on_hold: true, - Livechat_allow_manual_on_hold_upon_agent_engagement_only: false, - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Livechat_allow_manual_on_hold', true, false), + updateSetting('Livechat_allow_manual_on_hold_upon_agent_engagement_only', false, true), + ]); }); // Create agents @@ -110,15 +109,13 @@ test.describe('OC - Monitor Role', () => { }); // Delete all created data - test.afterAll(async ({ api }) => { + test.afterAll(async () => { await Promise.all([ ...agents.map((agent) => agent.delete()), ...departments.map((department) => department.delete()), ...conversations.map((conversation) => conversation.delete()), ...units.map((unit) => unit.delete()), ...monitors.map((monitor) => monitor.delete()), - // Reset setting - updateSettings(api, { Livechat_allow_manual_on_hold: false, 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 6b5f3d32579f8..93e5eb251770a 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-priorities-sidebar.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-priorities-sidebar.spec.ts @@ -3,7 +3,6 @@ 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 { updateSetting } from '../utils'; import { createConversation } from '../utils/omnichannel/rooms'; import { test, expect } from '../utils/test'; @@ -20,8 +19,8 @@ test.describe.serial('OC - Priorities [Sidebar]', () => { let poHomeChannel: HomeOmnichannel; let poRoomInfo: OmnichannelRoomInfo; - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Livechat_Routing_Method', 'Manual_Selection'); + test.beforeAll(async ({ api, updateSetting }) => { + await updateSetting('Livechat_Routing_Method', 'Manual_Selection', 'Auto_Selection'); ( await Promise.all([ api.post('/livechat/users/agent', { username: 'user1' }), @@ -45,7 +44,6 @@ test.describe.serial('OC - Priorities [Sidebar]', () => { }); test.afterAll(async ({ api }) => { - await updateSetting(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), ); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-takeChat.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-takeChat.spec.ts index 0405c4bb616a9..6330593cc8885 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-takeChat.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-takeChat.spec.ts @@ -4,7 +4,6 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeOmnichannel } from '../page-objects'; -import { updateSettings } from '../utils'; import { test, expect } from '../utils/test'; test.describe('omnichannel-takeChat', () => { @@ -20,10 +19,11 @@ test.describe('omnichannel-takeChat', () => { await poLiveChat.btnSendMessageToOnlineAgent.click(); }; - test.beforeAll(async ({ api, browser }) => { + test.beforeAll(async ({ api, browser, updateSetting }) => { await Promise.all([ api.post('/livechat/users/agent', { username: 'user1' }).then((res) => expect(res.status()).toBe(200)), - updateSettings(api, { Livechat_Routing_Method: 'Manual_Selection', Livechat_enabled_when_agent_idle: false }), + updateSetting('Livechat_Routing_Method', 'Manual_Selection', 'Auto_Selection'), + updateSetting('Livechat_enabled_when_agent_idle', false, true), ]); const { page } = await createAuxContext(browser, Users.user1); @@ -35,10 +35,7 @@ test.describe('omnichannel-takeChat', () => { await agent.poHomeChannel.sidenav.switchStatus('online'); await agent.page.close(); - await Promise.all([ - api.delete('/livechat/users/agent/user1'), - updateSettings(api, { Livechat_Routing_Method: 'Auto_Selection', Livechat_enabled_when_agent_idle: true }), - ]); + await api.delete('/livechat/users/agent/user1'); }); test.beforeEach('start a new livechat chat', async ({ page, api }) => { 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 0ca1b73cd72ef..bd8fa5db0ee24 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,7 +3,6 @@ import type { Page } from '@playwright/test'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel } from '../page-objects'; -import { updateSetting } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { createManager } from '../utils/omnichannel/managers'; import { createConversation } from '../utils/omnichannel/rooms'; @@ -23,8 +22,8 @@ test.describe('OC - Chat transfers [Agent role]', () => { }); // Livechat when agent idle - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Livechat_enabled_when_agent_idle', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Livechat_enabled_when_agent_idle', false, true); }); // Create agent sessions @@ -36,12 +35,11 @@ test.describe('OC - Chat transfers [Agent role]', () => { }); // Delete all data - test.afterAll(async ({ api }) => { + test.afterAll(async () => { await Promise.all([ ...conversations.map((conversation) => conversation.delete()), ...agents.map((agent) => agent.delete()), ...managers.map((manager) => manager.delete()), - updateSetting(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 7292de5ae9dad..37768d0abfddc 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,7 +5,6 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeOmnichannel } from '../page-objects'; -import { updateSetting } from '../utils'; import { test, expect } from '../utils/test'; test.describe('OC - Livechat New Chat Triggers - After Registration', () => { @@ -66,8 +65,8 @@ test.describe('OC - Livechat New Chat Triggers - After Registration', () => { await agent.page.close(); }); - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Livechat_clear_local_storage_when_chat_ended', false); + test.afterAll(async ({ updateSetting }) => { + await updateSetting('Livechat_clear_local_storage_when_chat_ended', false, false); }); test.describe('OC - Livechat New Chat Triggers - After Registration', async () => { @@ -114,8 +113,8 @@ 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 updateSetting(api, 'Livechat_clear_local_storage_when_chat_ended', true); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Livechat_clear_local_storage_when_chat_ended', true, false); }); 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 e2d14dbd13e5f..96cb9712aabb7 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,7 +4,6 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeOmnichannel } from '../page-objects'; -import { updateSetting } from '../utils'; import { test, expect } from '../utils/test'; test.use({ storageState: Users.admin.state }); @@ -58,7 +57,7 @@ test.describe('OC - Livechat Triggers - Open by Visitor', () => { await page.goto('/livechat'); }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ api, updateSetting }) => { const ids = (await (await api.get('/livechat/triggers')).json()).triggers.map( (trigger: { _id: string }) => trigger._id, ) as unknown as string[]; @@ -68,7 +67,7 @@ test.describe('OC - Livechat Triggers - Open by Visitor', () => { await Promise.all([ api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/manager/user1'), - updateSetting(api, 'Livechat_clear_local_storage_when_chat_ended', false), + updateSetting('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 dc8f5cc05b67b..9443e9585df16 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-setDepartment.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers-setDepartment.spec.ts @@ -2,7 +2,6 @@ import { IS_EE } from '../config/constants'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { HomeOmnichannel, OmnichannelLiveChatEmbedded } from '../page-objects'; -import { updateSetting } from '../utils'; import { createAgent } from '../utils/omnichannel/agents'; import { addAgentToDepartment, createDepartment } from '../utils/omnichannel/departments'; import { test, expect } from '../utils/test'; @@ -83,17 +82,17 @@ test.describe('OC - Livechat Triggers - SetDepartment', () => { await page.close(); }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ api, updateSetting }) => { const ids = (await (await api.get('/livechat/triggers')).json()).triggers.map( (trigger: { _id: string }) => trigger._id, ) as unknown as string[]; await Promise.all(ids.map((id) => api.delete(`/livechat/triggers/${id}`))); - await updateSetting(api, 'Omnichannel_enable_department_removal', true); + await updateSetting('Omnichannel_enable_department_removal', true); await Promise.all([...agents.map((agent) => agent.delete())]); await Promise.all([...departments.map((department) => department.delete())]); - await updateSetting(api, 'Omnichannel_enable_department_removal', false); - await updateSetting(api, 'Livechat_registration_form', true); + await updateSetting('Omnichannel_enable_department_removal', false); + await updateSetting('Livechat_registration_form', true); }); test('OC - Livechat Triggers - setDepartment should affect agent.next call', async () => { @@ -110,8 +109,8 @@ test.describe('OC - Livechat Triggers - SetDepartment', () => { await expect(poLiveChat.headerTitle).toContainText(agent2.username); }); - test('OC - Livechat Triggers - setDepartment should affect agent.next call - Register Form Disabled', async ({ api }) => { - await updateSetting(api, 'Livechat_registration_form', false); + test('OC - Livechat Triggers - setDepartment should affect agent.next call - Register Form Disabled', async ({ updateSetting }) => { + await updateSetting('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 43bd94ca361c7..7fcb14a282043 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,7 +4,6 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeOmnichannel } from '../page-objects'; -import { updateSetting } from '../utils'; import { test, expect } from '../utils/test'; test.use({ storageState: Users.admin.state }); @@ -44,7 +43,7 @@ test.describe('OC - Livechat Triggers - Time on site', () => { await page.goto('/livechat'); }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ api, updateSetting }) => { const ids = (await (await api.get('/livechat/triggers')).json()).triggers.map( (trigger: { _id: string }) => trigger._id, ) as unknown as string[]; @@ -54,7 +53,7 @@ test.describe('OC - Livechat Triggers - Time on site', () => { await Promise.all([ api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/manager/user1'), - updateSetting(api, 'Livechat_clear_local_storage_when_chat_ended', false), + updateSetting('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 68c3d7d29180c..81a42e5c46067 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-triggers.spec.ts @@ -5,7 +5,6 @@ import { createFakeVisitor } from '../../mocks/data'; import { createAuxContext } from '../fixtures/createAuxContext'; import { Users } from '../fixtures/userStates'; import { OmnichannelLiveChat, HomeOmnichannel } from '../page-objects'; -import { updateSetting } from '../utils'; import { test, expect } from '../utils/test'; test.describe.serial('OC - Livechat Triggers', () => { @@ -15,14 +14,14 @@ test.describe.serial('OC - Livechat Triggers', () => { let newVisitor: { email: string; name: string }; let agent: { page: Page; poHomeOmnichannel: HomeOmnichannel }; - test.beforeAll(async ({ api, browser }) => { + test.beforeAll(async ({ api, browser, updateSetting }) => { newVisitor = createFakeVisitor(); triggersName = faker.string.uuid(); triggerMessage = 'This is a trigger message'; const requests = await Promise.all([ api.post('/livechat/users/agent', { username: 'user1' }), api.post('/livechat/users/manager', { username: 'user1' }), - updateSetting(api, 'Livechat_clear_local_storage_when_chat_ended', true), + updateSetting('Livechat_clear_local_storage_when_chat_ended', true, false), ]); requests.every((e) => expect(e.status()).toBe(200)); @@ -42,11 +41,7 @@ test.describe.serial('OC - Livechat Triggers', () => { await Promise.all(ids.map((id) => api.delete(`/livechat/triggers/${id}`))); - await Promise.all([ - api.delete('/livechat/users/agent/user1'), - api.delete('/livechat/users/manager/user1'), - updateSetting(api, 'Livechat_clear_local_storage_when_chat_ended', false), - ]); + await Promise.all([api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/manager/user1')]); await agent.page.close(); }); diff --git a/apps/meteor/tests/e2e/permissions.spec.ts b/apps/meteor/tests/e2e/permissions.spec.ts index 68626adb2f563..90e86f5e823fd 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, updateSetting, updateSettings } from './utils'; +import { createTargetChannel } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.user2.state }); @@ -20,8 +20,8 @@ test.describe.serial('permissions', () => { }); test.describe.serial('Edit message', () => { - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Message_AllowEditing', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Message_AllowEditing', false, true); }); test('expect option(edit) not be visible', async ({ page }) => { @@ -36,15 +36,11 @@ test.describe.serial('permissions', () => { await poHomeChannel.content.openLastMessageMenu(); await expect(poHomeChannel.content.btnOptionEditMessage).toBeHidden(); }); - - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Message_AllowEditing', true); - }); }); test.describe.serial('Delete message', () => { - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Message_AllowDeleting', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Message_AllowDeleting', false, true); }); test('expect option(delete) not be visible', async ({ page }) => { @@ -60,17 +56,13 @@ test.describe.serial('permissions', () => { await expect(poHomeChannel.content.btnOptionDeleteMessage).toBeHidden(); }); - - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Message_AllowDeleting', true); - }); }); test.describe.serial('Pin message', () => { test.use({ storageState: Users.admin.state }); - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Message_AllowPinning', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Message_AllowPinning', false, true); }); test('expect option(pin) not be visible', async ({ page }) => { @@ -82,17 +74,13 @@ test.describe.serial('permissions', () => { await expect(poHomeChannel.content.btnOptionPinMessage).toBeHidden(); }); - - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Message_AllowPinning', true); - }); }); // FIXME: Wrong behavior in Rocket.chat, currently it shows the button // and after a click a "not allowed" alert pops up test.describe.skip('Star message', () => { - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Message_AllowStarring', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Message_AllowStarring', false, true); }); test('expect option(star) not be visible', async ({ page }) => { @@ -107,63 +95,47 @@ test.describe.serial('permissions', () => { await expect(poHomeChannel.content.btnOptionStarMessage).toBeHidden(); }); - - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Message_AllowStarring', true); - }); }); test.describe.serial('Upload file', () => { - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'FileUpload_Enabled', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('FileUpload_Enabled', false, true); }); test('expect option (upload file) not be visible', async () => { await poHomeChannel.sidenav.openChat(targetChannel); await expect(poHomeChannel.content.btnOptionFileUpload).toBeDisabled(); }); - - test.afterAll(async ({ api }) => { - await updateSetting(api, 'FileUpload_Enabled', true); - }); }); test.describe.serial('Upload audio', () => { - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Message_AudioRecorderEnabled', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Message_AudioRecorderEnabled', false, true); }); test('expect option (upload audio) not be visible', async () => { await poHomeChannel.sidenav.openChat(targetChannel); await expect(poHomeChannel.content.btnRecordAudio).toBeDisabled(); }); - - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Message_AudioRecorderEnabled', true); - }); }); test.describe.serial('Upload video', () => { - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Message_VideoRecorderEnabled', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Message_VideoRecorderEnabled', false, true); }); test('expect option (upload video) not be visible', async () => { await poHomeChannel.sidenav.openChat(targetChannel); await expect(poHomeChannel.content.btnVideoMessage).toBeDisabled(); }); - - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Message_VideoRecorderEnabled', true); - }); }); test.describe.serial('Filter words', () => { - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - Message_AllowBadWordsFilter: true, - Message_BadWordsFilterList: 'badword', - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Message_AllowBadWordsFilter', true, false), + updateSetting('Message_BadWordsFilterList', 'badword', ''), + ]); }); test('expect badword be censored', async () => { @@ -172,9 +144,5 @@ test.describe.serial('permissions', () => { await expect(poHomeChannel.content.lastUserMessage).toContainText('*'.repeat(7)); }); - - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Message_AllowBadWordsFilter', false); - }); }); }); diff --git a/apps/meteor/tests/e2e/presence.spec.ts b/apps/meteor/tests/e2e/presence.spec.ts index 61cd0a6963688..14cdde7d64ad9 100644 --- a/apps/meteor/tests/e2e/presence.spec.ts +++ b/apps/meteor/tests/e2e/presence.spec.ts @@ -1,7 +1,6 @@ import { DEFAULT_USER_CREDENTIALS, IS_EE } from './config/constants'; import { Users } from './fixtures/userStates'; import { Registration } from './page-objects'; -import { updateSetting } from './utils'; import { test, expect } from './utils/test'; test.describe.serial('Presence', () => { @@ -13,12 +12,8 @@ test.describe.serial('Presence', () => { await page.goto('/home'); }); - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'API_Use_REST_For_DDP_Calls', true); - }); - - test.afterAll(async ({ api }) => { - await updateSetting(api, 'API_Use_REST_For_DDP_Calls', true); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('API_Use_REST_For_DDP_Calls', true, true); }); test.describe('Login using default settings', () => { @@ -34,8 +29,8 @@ test.describe.serial('Presence', () => { test.describe('Login using with "Methods by REST" disabled', () => { test.skip(IS_EE, `Micro services don't support turning this setting off`); - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'API_Use_REST_For_DDP_Calls', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('API_Use_REST_For_DDP_Calls', false, true); }); test('expect user to be online after log in', async ({ page }) => { @@ -53,12 +48,8 @@ test.describe.serial('Presence', () => { test.describe.configure({ timeout: 1000 * 60 * 10 }); test.use({ storageState: Users.admin.state }); - test.beforeAll(async ({ api }) => { - await setSettingValueById(api, 'Calendar_BusyStatus_Enabled', true); - }); - - test.afterAll(async ({ api }) => { - await setSettingValueById(api, 'Calendar_BusyStatus_Enabled', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('Calendar_BusyStatus_Enabled', true, false); }); test('Should change user status to busy when there is an appointment', async ({ page, api }) => { diff --git a/apps/meteor/tests/e2e/read-receipts.spec.ts b/apps/meteor/tests/e2e/read-receipts.spec.ts index b93645ab323f6..3a64ec22d7b1e 100644 --- a/apps/meteor/tests/e2e/read-receipts.spec.ts +++ b/apps/meteor/tests/e2e/read-receipts.spec.ts @@ -4,7 +4,7 @@ import { IS_EE } from './config/constants'; import { createAuxContext } from './fixtures/createAuxContext'; import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { createTargetChannel, updateSettings } from './utils'; +import { createTargetChannel } from './utils'; import { expect, test } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -35,18 +35,11 @@ test.describe.serial('read-receipts', () => { }); test.describe('read receipts enabled', async () => { - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - Message_Read_Receipt_Enabled: true, - Message_Read_Receipt_Store_Users: true, - }); - }); - - test.afterAll(async ({ api }) => { - await updateSettings(api, { - Message_Read_Receipt_Enabled: false, - Message_Read_Receipt_Store_Users: false, - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Message_Read_Receipt_Enabled', true, false), + updateSetting('Message_Read_Receipt_Store_Users', true, false), + ]); }); let auxContext: { page: Page; poHomeChannel: HomeChannel } | undefined; diff --git a/apps/meteor/tests/e2e/register.spec.ts b/apps/meteor/tests/e2e/register.spec.ts index d8554d55aeeee..0f5edb18a8be0 100644 --- a/apps/meteor/tests/e2e/register.spec.ts +++ b/apps/meteor/tests/e2e/register.spec.ts @@ -1,7 +1,6 @@ import { faker } from '@faker-js/faker'; import { Utils, Registration } from './page-objects'; -import { updateSetting, updateSettings } from './utils'; import { test, expect } from './utils/test'; test.describe.parallel('register', () => { @@ -46,8 +45,8 @@ test.describe.parallel('register', () => { }); test.describe('Registration without Account confirmation password set', async () => { - test.beforeEach(async ({ api }) => { - await updateSetting(api, 'Accounts_RequirePasswordConfirmation', false); + test.beforeEach(async ({ updateSetting }) => { + await updateSetting('Accounts_RequirePasswordConfirmation', false, true); }); test.beforeEach(async ({ page }) => { @@ -55,10 +54,6 @@ test.describe.parallel('register', () => { await poRegistration.goToRegister.click(); }); - test.afterEach(async ({ api }) => { - await updateSetting(api, 'Accounts_RequirePasswordConfirmation', true); - }); - test('expect to register a user without password confirmation', async () => { await test.step('expect to not have password confirmation field', async () => { await expect(poRegistration.inputPasswordConfirm).toBeHidden(); @@ -77,8 +72,8 @@ test.describe.parallel('register', () => { }); test.describe('Registration with manually confirmation enabled', async () => { - test.beforeEach(async ({ api }) => { - await updateSetting(api, 'Accounts_ManuallyApproveNewUsers', true); + test.beforeEach(async ({ updateSetting }) => { + await updateSetting('Accounts_ManuallyApproveNewUsers', true, false); }); test.beforeEach(async ({ page }) => { @@ -88,10 +83,6 @@ test.describe.parallel('register', () => { await poRegistration.goToRegister.click(); }); - test.afterEach(async ({ api }) => { - await updateSetting(api, 'Accounts_ManuallyApproveNewUsers', false); - }); - test('it should expect to have a textbox asking the reason for the registration', async () => { await test.step('expect to have a textbox asking the reason for the registration', async () => { await expect(poRegistration.inputReason).toBeVisible(); @@ -105,12 +96,8 @@ test.describe.parallel('register', () => { }); test.describe('Registration form Disabled', async () => { - test.beforeEach(async ({ api }) => { - await updateSetting(api, 'Accounts_RegistrationForm', 'Disabled'); - }); - - test.afterEach(async ({ api }) => { - await updateSetting(api, 'Accounts_RegistrationForm', 'Public'); + test.beforeEach(async ({ updateSetting }) => { + await updateSetting('Accounts_RegistrationForm', 'Disabled', 'Public'); }); test('It should expect a message warning that registration is disabled', async ({ page }) => { @@ -131,17 +118,13 @@ test.describe.parallel('register', () => { }); test.describe('Registration for secret password', async () => { - test.beforeEach(async ({ api, page }) => { + test.beforeEach(async ({ updateSetting, page }) => { poRegistration = new Registration(page); poUtils = new Utils(page); - await updateSettings(api, { - Accounts_RegistrationForm: 'Secret URL', - Accounts_RegistrationForm_SecretURL: 'secret', - }); - }); - - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Accounts_RegistrationForm', 'Public'); + await Promise.all([ + updateSetting('Accounts_RegistrationForm', 'Secret URL', 'Public'), + updateSetting('Accounts_RegistrationForm_SecretURL', 'secret', faker.string.uuid()), + ]); }); test('It should expect a message warning that registration is disabled', async ({ page }) => { @@ -175,11 +158,11 @@ test.describe.parallel('register', () => { }); test.describe('Registration by Secret is disabled url should fail', async () => { - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - Accounts_RegistrationForm: 'Public', - Accounts_RegistrationForm_SecretURL: 'secret', - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('Accounts_RegistrationForm', 'Public', 'Public'), + updateSetting('Accounts_RegistrationForm_SecretURL', 'secret', faker.string.uuid()), + ]); }); test('It should show an invalid page informing that the url is not valid', async ({ page }) => { diff --git a/apps/meteor/tests/e2e/reset-password.spec.ts b/apps/meteor/tests/e2e/reset-password.spec.ts index 2ea78fd1f90fd..745aa630fe443 100644 --- a/apps/meteor/tests/e2e/reset-password.spec.ts +++ b/apps/meteor/tests/e2e/reset-password.spec.ts @@ -1,21 +1,16 @@ import { Registration } from './page-objects'; -import { updateSetting } from './utils'; import { test, expect } from './utils/test'; test.describe.parallel('Reset Password', () => { let poRegistration: Registration; - test.beforeEach(async ({ api, page }) => { + test.beforeEach(async ({ updateSetting, page }) => { poRegistration = new Registration(page); - await updateSetting(api, 'Accounts_RequirePasswordConfirmation', true); + await updateSetting('Accounts_RequirePasswordConfirmation', true, true); await page.goto('/reset-password/someToken'); }); - test.afterAll(async ({ api }) => { - await updateSetting(api, 'Accounts_RequirePasswordConfirmation', true); - }); - test('should confirm password be invalid', async () => { await poRegistration.inputPassword.fill('123456'); await poRegistration.inputPasswordConfirm.fill('123455'); @@ -23,8 +18,8 @@ test.describe.parallel('Reset Password', () => { await expect(poRegistration.inputPasswordConfirm).toBeInvalid(); }); - test('should confirm password not be visible', async ({ api }) => { - await updateSetting(api, 'Accounts_RequirePasswordConfirmation', false); + test('should confirm password not be visible', async ({ updateSetting }) => { + await updateSetting('Accounts_RequirePasswordConfirmation', false, true); await expect(poRegistration.inputPasswordConfirm).not.toBeVisible(); }); diff --git a/apps/meteor/tests/e2e/retention-policy.spec.ts b/apps/meteor/tests/e2e/retention-policy.spec.ts index b48224a6b62c3..266e06810e9c0 100644 --- a/apps/meteor/tests/e2e/retention-policy.spec.ts +++ b/apps/meteor/tests/e2e/retention-policy.spec.ts @@ -4,7 +4,7 @@ import type { Page } from '@playwright/test'; import { createAuxContext } from './fixtures/createAuxContext'; import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { createTargetTeam, createTargetPrivateChannel, getSettingValueById, updateSetting, updateSettings } from './utils'; +import { createTargetTeam, createTargetPrivateChannel, getSettingValueById } from './utils'; import { test, expect } from './utils/test'; import { timeUnitToMs, TIMEUNIT } from '../../client/lib/convertTimeUnit'; @@ -32,8 +32,8 @@ test.describe.serial('retention-policy', () => { }); test.describe('retention policy disabled', () => { - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'RetentionPolicy_Enabled', false); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('RetentionPolicy_Enabled', false, false); }); test('should not show prune banner in channel', async () => { @@ -58,18 +58,18 @@ test.describe.serial('retention-policy', () => { }); test.describe('retention policy enabled', () => { - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'RetentionPolicy_Enabled', true); + test.beforeAll(async ({ updateSetting }) => { + await updateSetting('RetentionPolicy_Enabled', true, false); }); - test.afterAll(async ({ api }) => { - await updateSettings(api, { - RetentionPolicy_Enabled: false, - RetentionPolicy_AppliesToChannels: false, - RetentionPolicy_AppliesToGroups: false, - RetentionPolicy_AppliesToDMs: false, - RetentionPolicy_TTL_Channels: timeUnitToMs(TIMEUNIT.days, 30), - }); + test.afterAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('RetentionPolicy_Enabled', false), + updateSetting('RetentionPolicy_AppliesToChannels', false), + updateSetting('RetentionPolicy_AppliesToGroups', false), + updateSetting('RetentionPolicy_AppliesToDMs', false), + updateSetting('RetentionPolicy_TTL_Channels', timeUnitToMs(TIMEUNIT.days, 30)), + ]); }); test('should not show prune banner even with retention policy setting enabled in any type of room', async () => { @@ -120,12 +120,12 @@ test.describe.serial('retention-policy', () => { }); test.describe('retention policy applies enabled by default', () => { - test.beforeAll(async ({ api }) => { - await updateSettings(api, { - RetentionPolicy_AppliesToChannels: true, - RetentionPolicy_AppliesToGroups: true, - RetentionPolicy_AppliesToDMs: true, - }); + test.beforeAll(async ({ updateSetting }) => { + await Promise.all([ + updateSetting('RetentionPolicy_AppliesToChannels', true, false), + updateSetting('RetentionPolicy_AppliesToGroups', true, false), + updateSetting('RetentionPolicy_AppliesToDMs', true, false), + ]); }); test('should prune old messages checkbox enabled by default in channel and show retention policy banner', async () => { @@ -167,9 +167,9 @@ test.describe.serial('retention-policy', () => { test.describe('retention policy override', () => { let ignoreThreadsSetting: boolean; - test.beforeAll(async ({ api }) => { + test.beforeAll(async ({ api, updateSetting }) => { ignoreThreadsSetting = (await getSettingValueById(api, 'RetentionPolicy_DoNotPruneThreads')) as boolean; - await updateSetting(api, 'RetentionPolicy_TTL_Channels', timeUnitToMs(TIMEUNIT.days, 15)); + await updateSetting('RetentionPolicy_TTL_Channels', timeUnitToMs(TIMEUNIT.days, 15), ignoreThreadsSetting); }); test.beforeEach(async () => { diff --git a/apps/meteor/tests/e2e/saml.spec.ts b/apps/meteor/tests/e2e/saml.spec.ts index 59d30117f56cc..50b8f0e4d6e81 100644 --- a/apps/meteor/tests/e2e/saml.spec.ts +++ b/apps/meteor/tests/e2e/saml.spec.ts @@ -86,11 +86,11 @@ test.describe('SAML', () => { const containerPath = path.join(__dirname, 'containers', 'saml'); - test.beforeAll(async ({ api }) => { + test.beforeAll(async ({ api, updateSetting }) => { await resetTestData({ api }); // Only one setting updated through the API to avoid refreshing the service configurations several times - await updateSetting(api, 'SAML_Custom_Default', true); + await updateSetting('SAML_Custom_Default', true); // Create a new custom role if (constants.IS_EE) { @@ -186,9 +186,9 @@ test.describe('SAML', () => { }); }); - test('Allow password change for OAuth users', async ({ api }) => { + test('Allow password change for OAuth users', async ({ api, updateSetting }) => { await test.step("should not send password reset mail if 'Allow Password Change for OAuth Users' setting is disabled", async () => { - await updateSetting(api, 'Accounts_AllowPasswordChangeForOAuthUsers', false); + await updateSetting('Accounts_AllowPasswordChangeForOAuthUsers', false); const response = await api.post('/method.call/sendForgotPasswordEmail', { message: JSON.stringify({ msg: 'method', id: 'id', method: 'sendForgotPasswordEmail', params: ['samluser1@example.com'] }), @@ -199,7 +199,7 @@ test.describe('SAML', () => { }); await test.step("should send password reset mail if 'Allow Password Change for OAuth Users' setting is enabled", async () => { - await updateSetting(api, 'Accounts_AllowPasswordChangeForOAuthUsers', true); + await updateSetting('Accounts_AllowPasswordChangeForOAuthUsers', true); const response = await api.post('/method.call/sendForgotPasswordEmail', { message: JSON.stringify({ msg: 'method', id: 'id', method: 'sendForgotPasswordEmail', params: ['samluser1@example.com'] }), @@ -239,9 +239,9 @@ test.describe('SAML', () => { }); }; - test('Logout - Rocket.Chat only', async ({ page, api }) => { + test('Logout - Rocket.Chat only', async ({ page, updateSetting }) => { await test.step('Configure logout to only logout from Rocket.Chat', async () => { - await updateSetting(api, 'SAML_Custom_Default_logout_behaviour', 'Local'); + await updateSetting('SAML_Custom_Default_logout_behaviour', 'Local'); }); await page.goto('/home'); @@ -255,9 +255,9 @@ test.describe('SAML', () => { }); }); - test('Logout - Single Sign Out', async ({ page, api }) => { + test('Logout - Single Sign Out', async ({ page, updateSetting }) => { await test.step('Configure logout to terminate SAML session', async () => { - await updateSetting(api, 'SAML_Custom_Default_logout_behaviour', 'SAML'); + await updateSetting('SAML_Custom_Default_logout_behaviour', 'SAML'); }); await page.goto('/home'); @@ -272,9 +272,9 @@ test.describe('SAML', () => { }); }); - test('User Merge - By Email', async ({ page, api }) => { + test('User Merge - By Email', async ({ page, api, updateSetting }) => { await test.step('Configure SAML to identify users by email', async () => { - await updateSetting(api, 'SAML_Custom_Default_immutable_property', 'EMail'); + await updateSetting('SAML_Custom_Default_immutable_property', 'EMail'); }); await doLoginStep(page, 'samluser2'); @@ -291,10 +291,12 @@ test.describe('SAML', () => { }); }); - test('User Merge - By Email with Name Override', async ({ page, api }) => { + test('User Merge - By Email with Name Override', async ({ page, api, updateSetting }) => { await test.step('Configure SAML to identify users by email', async () => { - await updateSetting(api, 'SAML_Custom_Default_immutable_property', 'EMail'); - await updateSetting(api, 'SAML_Custom_Default_name_overwrite', true); + await Promise.all([ + updateSetting('SAML_Custom_Default_immutable_property', 'EMail'), + updateSetting('SAML_Custom_Default_name_overwrite', true), + ]); }); await doLoginStep(page, 'samluser2'); @@ -311,11 +313,13 @@ test.describe('SAML', () => { }); }); - test('User Merge - By Username', async ({ page, api }) => { + test('User Merge - By Username', async ({ page, api, updateSetting }) => { await test.step('Configure SAML to identify users by username', async () => { - await updateSetting(api, 'SAML_Custom_Default_immutable_property', 'Username'); - await updateSetting(api, 'SAML_Custom_Default_name_overwrite', false); - await updateSetting(api, 'SAML_Custom_Default_mail_overwrite', false); + await Promise.all([ + updateSetting('SAML_Custom_Default_immutable_property', 'Username'), + updateSetting('SAML_Custom_Default_name_overwrite', false), + updateSetting('SAML_Custom_Default_mail_overwrite', false), + ]); }); await doLoginStep(page, 'samluser3'); @@ -332,11 +336,13 @@ test.describe('SAML', () => { }); }); - test('User Merge - By Username with Email Override', async ({ page, api }) => { + test('User Merge - By Username with Email Override', async ({ page, api, updateSetting }) => { await test.step('Configure SAML to identify users by username', async () => { - await updateSetting(api, 'SAML_Custom_Default_immutable_property', 'Username'); - await updateSetting(api, 'SAML_Custom_Default_name_overwrite', false); - await updateSetting(api, 'SAML_Custom_Default_mail_overwrite', true); + await Promise.all([ + updateSetting('SAML_Custom_Default_immutable_property', 'Username'), + updateSetting('SAML_Custom_Default_name_overwrite', false), + updateSetting('SAML_Custom_Default_mail_overwrite', true), + ]); }); await doLoginStep(page, 'samluser3'); @@ -353,10 +359,12 @@ test.describe('SAML', () => { }); }); - test('User Merge - By Username with Name Override', async ({ page, api }) => { + test('User Merge - By Username with Name Override', async ({ page, api, updateSetting }) => { await test.step('Configure SAML to identify users by username', async () => { - await updateSetting(api, 'SAML_Custom_Default_immutable_property', 'Username'); - await updateSetting(api, 'SAML_Custom_Default_name_overwrite', true); + await Promise.all([ + updateSetting('SAML_Custom_Default_immutable_property', 'Username'), + updateSetting('SAML_Custom_Default_name_overwrite', true), + ]); }); await doLoginStep(page, 'samluser3'); diff --git a/apps/meteor/tests/e2e/search-discussion.spec.ts b/apps/meteor/tests/e2e/search-discussion.spec.ts index 50526e8bf4176..1d4dc5cf14349 100644 --- a/apps/meteor/tests/e2e/search-discussion.spec.ts +++ b/apps/meteor/tests/e2e/search-discussion.spec.ts @@ -2,21 +2,15 @@ import type { Page } from '@playwright/test'; import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { createTargetDiscussion, deleteRoom, updateSetting } from './utils'; -import { getSettingValueById } from './utils/getSettingValueById'; +import { createTargetDiscussion, deleteRoom } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.user1.state }); test.describe.serial('search-discussion', () => { - let settingDefaultValue: unknown; let poHomeChannel: HomeChannel; let discussion: Record; - test.beforeAll(async ({ api }) => { - settingDefaultValue = await getSettingValueById(api, 'UI_Allow_room_names_with_special_chars'); - }); - test.beforeEach(async ({ page, api }) => { discussion = await createTargetDiscussion(api); poHomeChannel = new HomeChannel(page); @@ -24,7 +18,6 @@ test.describe.serial('search-discussion', () => { }); test.afterAll(async ({ api }) => { - await updateSetting(api, 'UI_Allow_room_names_with_special_chars', settingDefaultValue); await deleteRoom(api, discussion._id); }); @@ -35,13 +28,13 @@ test.describe.serial('search-discussion', () => { await expect(targetSearchItem).toBeVisible(); }; - test('expect search discussion to show fname when UI_Allow_room_names_with_special_chars=true', async ({ page, api }) => { - await updateSetting(api, 'UI_Allow_room_names_with_special_chars', true); + test('expect search discussion to show fname when UI_Allow_room_names_with_special_chars=true', async ({ page, updateSetting }) => { + await updateSetting('UI_Allow_room_names_with_special_chars', true, false); await testDiscussionSearch(page); }); - test('expect search discussion to show fname when UI_Allow_room_names_with_special_chars=false', async ({ page, api }) => { - await updateSetting(api, 'UI_Allow_room_names_with_special_chars', false); + test('expect search discussion to show fname when UI_Allow_room_names_with_special_chars=false', async ({ page, updateSetting }) => { + await updateSetting('UI_Allow_room_names_with_special_chars', false, false); await testDiscussionSearch(page); }); }); diff --git a/apps/meteor/tests/e2e/settings-persistence-on-ui-navigation.spec.ts b/apps/meteor/tests/e2e/settings-persistence-on-ui-navigation.spec.ts index d54b0c0a021a5..e1624cecd4f3f 100644 --- a/apps/meteor/tests/e2e/settings-persistence-on-ui-navigation.spec.ts +++ b/apps/meteor/tests/e2e/settings-persistence-on-ui-navigation.spec.ts @@ -1,11 +1,10 @@ import { Users } from './fixtures/userStates'; -import { updateSetting } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); test.describe.serial('settings-persistence-on-ui-navigation', () => { - test.beforeAll(({ api }) => updateSetting(api, 'Hide_System_Messages', [])); + test.beforeAll(({ updateSetting }) => updateSetting('Hide_System_Messages', [], [])); test.beforeEach(async ({ page }) => { await page.goto('/admin/settings/Message'); @@ -23,8 +22,6 @@ test.describe.serial('settings-persistence-on-ui-navigation', () => { }); }); - test.afterAll(({ api }) => updateSetting(api, 'Hide_System_Messages', [])); - test('expect settings to persist in ui when navigating back and forth', async ({ page }) => { const settingInput = await page.locator('[data-qa-setting-id="Hide_System_Messages"] input'); await settingInput.pressSequentially('User joined'); diff --git a/apps/meteor/tests/e2e/system-messages.spec.ts b/apps/meteor/tests/e2e/system-messages.spec.ts index e269843387517..b53ec7c32622d 100644 --- a/apps/meteor/tests/e2e/system-messages.spec.ts +++ b/apps/meteor/tests/e2e/system-messages.spec.ts @@ -4,7 +4,6 @@ import type { IRoom, IUser } from '@rocket.chat/core-typings'; import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { updateSetting } from './utils'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); @@ -26,8 +25,8 @@ test.describe.serial('System Messages', () => { let user: IUser; let group: IRoom; - test.beforeAll(async ({ api }) => { - await updateSetting(api, 'Hide_System_Messages', []); + test.beforeAll(async ({ api, updateSetting }) => { + await updateSetting('Hide_System_Messages', [], []); const groupResult = await api.post('/groups.create', { name: faker.string.uuid() }); await expect(groupResult.status()).toBe(200); @@ -61,8 +60,8 @@ test.describe.serial('System Messages', () => { await expect(findSysMes(page, 'au')).toBeVisible(); }); - test('expect "User added" system message to be hidden', async ({ page, api }) => { - await updateSetting(api, 'Hide_System_Messages', ['au']); + test('expect "User added" system message to be hidden', async ({ page, updateSetting }) => { + await updateSetting('Hide_System_Messages', ['au'], []); await expect(findSysMes(page, 'au')).not.toBeVisible(); }); @@ -73,8 +72,8 @@ test.describe.serial('System Messages', () => { await expect(findSysMes(page, 'ru')).toBeVisible(); }); - test('expect "User removed" system message to be hidden', async ({ page, api }) => { - await updateSetting(api, 'Hide_System_Messages', ['ru']); + test('expect "User removed" system message to be hidden', async ({ page, updateSetting }) => { + await updateSetting('Hide_System_Messages', ['ru'], []); await expect(findSysMes(page, 'ru')).not.toBeVisible(); }); diff --git a/apps/meteor/tests/e2e/translations.spec.ts b/apps/meteor/tests/e2e/translations.spec.ts index 62915b5236876..235a75cda1c99 100644 --- a/apps/meteor/tests/e2e/translations.spec.ts +++ b/apps/meteor/tests/e2e/translations.spec.ts @@ -1,25 +1,17 @@ import { Users } from './fixtures/userStates'; -import { updateSettings } from './utils'; import { setUserPreferences } from './utils/setUserPreferences'; import { test, expect } from './utils/test'; test.use({ storageState: Users.admin.state }); test.describe('Translations', () => { - test.beforeAll(async ({ api }) => { + test.beforeAll(async ({ api, updateSetting }) => { expect((await setUserPreferences(api, { language: '' })).status()).toBe(200); - await updateSettings(api, { - Language: 'en', - Site_Name: 'Rocket.Chat', - }); + await Promise.all([updateSetting('Language', 'en', 'en'), updateSetting('Site_Name', 'Rocket.Chat', 'Rocket.Chat')]); }); test.afterAll(async ({ api }) => { await setUserPreferences(api, { language: '' }); - await updateSettings(api, { - Language: 'en', - Site_Name: 'Rocket.Chat', - }); }); test("expect to display text in the user's preference language", async ({ page, api }) => { From cd618f7ad4333b8ddeb1eef7ce1fed49d1af7b6e Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Wed, 9 Apr 2025 21:02:14 -0300 Subject: [PATCH 8/9] test: added restoreSettings fixture --- apps/meteor/tests/e2e/utils/test.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/meteor/tests/e2e/utils/test.ts b/apps/meteor/tests/e2e/utils/test.ts index ea84c0ca5182c..849f9219e840a 100644 --- a/apps/meteor/tests/e2e/utils/test.ts +++ b/apps/meteor/tests/e2e/utils/test.ts @@ -28,7 +28,14 @@ export type BaseTest = { makeAxeBuilder: () => AxeBuilder; updateSetting: (settingId: string, value: ISetting['value'], defaultValue?: ISetting['value']) => Promise; + + restoreSettings: () => Promise; +}; + +type WorkerFixtures = { + _updatedSettingsDefaults: Record; }; + declare global { // eslint-disable-next-line @typescript-eslint/naming-convention interface Window { @@ -41,7 +48,7 @@ let apiContext: APIRequestContext; const cacheFromCredentials = new Map(); -export const test = baseTest.extend({ +export const test = baseTest.extend({ context: async ({ context }, use) => { if (!process.env.E2E_COVERAGE) { await use(context); @@ -135,18 +142,20 @@ export const test = baseTest.extend({ await use(makeAxeBuilder); }, - updateSetting: async ({ api }, use) => { - const _defaultSettings: Record = {}; + _updatedSettingsDefaults: [{}, { option: true, scope: 'worker' }], + updateSetting: async ({ api, _updatedSettingsDefaults }, use) => { await use((settingId: ISetting['_id'], value: ISetting['value'], defaultValue: ISetting['value']) => { if (defaultValue !== undefined) { - _defaultSettings[settingId] = defaultValue; + _updatedSettingsDefaults[settingId] = defaultValue; } return updateSetting(api, settingId, value); }); + }, - await updateSettings(api, _defaultSettings); + restoreSettings: async ({ api, _updatedSettingsDefaults }, use) => { + await use(() => updateSettings(api, _updatedSettingsDefaults)); }, }); From 219a6649a8ad3f5dd6702320d72c8f6e53dcaeb9 Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Wed, 9 Apr 2025 21:02:30 -0300 Subject: [PATCH 9/9] test: update test files to use restoreSettings fixture --- .../tests/e2e/access-security-page.spec.ts | 4 +++ ...account-forgetSessionOnWindowClose.spec.ts | 4 +++ apps/meteor/tests/e2e/administration.spec.ts | 4 +++ apps/meteor/tests/e2e/anonymous-user.spec.ts | 4 +++ apps/meteor/tests/e2e/avatar-settings.ts | 4 +++ apps/meteor/tests/e2e/e2e-encryption.spec.ts | 8 +++++ apps/meteor/tests/e2e/feature-preview.spec.ts | 3 +- apps/meteor/tests/e2e/file-upload.spec.ts | 3 +- apps/meteor/tests/e2e/homepage.spec.ts | 19 ++++++++++- apps/meteor/tests/e2e/login.spec.ts | 4 +++ ...nichannel-auto-onhold-chat-closing.spec.ts | 3 +- ...nnel-auto-transfer-unanswered-chat.spec.ts | 3 +- .../omnichannel-business-hours.spec.ts | 3 +- ...nel-changing-room-priority-and-sla.spec.ts | 3 +- .../omnichannel-close-inquiry.spec.ts | 8 +++-- ...annel-contact-center-chats-filters.spec.ts | 4 +-- .../omnichannel-current-chats.spec.ts | 8 ++++- .../omnichannel-departaments.spec.ts | 8 +++++ .../omnichannel-livechat-api.spec.ts | 6 ++-- .../omnichannel-livechat-background.spec.ts | 3 +- ...hat-queue-management-autoselection.spec.ts | 5 ++- ...ichannel-livechat-queue-management.spec.ts | 13 ++++---- .../omnichannel/omnichannel-livechat.spec.ts | 20 ++++++++---- .../omnichannel-manager-role.spec.ts | 3 +- ...mnichannel-manual-selection-logout.spec.ts | 5 ++- .../omnichannel-manual-selection.spec.ts | 4 +-- .../omnichannel-monitor-role.spec.ts | 3 +- .../omnichannel-priorities-sidebar.spec.ts | 3 +- .../omnichannel/omnichannel-takeChat.spec.ts | 5 ++- ...channel-transfer-to-another-agents.spec.ts | 3 +- ...hannel-triggers-after-registration.spec.ts | 6 +++- apps/meteor/tests/e2e/permissions.spec.ts | 32 +++++++++++++++++++ apps/meteor/tests/e2e/presence.spec.ts | 8 +++++ apps/meteor/tests/e2e/read-receipts.spec.ts | 4 +++ apps/meteor/tests/e2e/register.spec.ts | 12 +++++++ apps/meteor/tests/e2e/reset-password.spec.ts | 4 +++ .../tests/e2e/search-discussion.spec.ts | 3 +- ...tings-persistence-on-ui-navigation.spec.ts | 4 +++ apps/meteor/tests/e2e/system-messages.spec.ts | 4 +++ apps/meteor/tests/e2e/translations.spec.ts | 3 +- 40 files changed, 203 insertions(+), 47 deletions(-) diff --git a/apps/meteor/tests/e2e/access-security-page.spec.ts b/apps/meteor/tests/e2e/access-security-page.spec.ts index b0b976941d0f1..64f86ec88016d 100644 --- a/apps/meteor/tests/e2e/access-security-page.spec.ts +++ b/apps/meteor/tests/e2e/access-security-page.spec.ts @@ -21,6 +21,10 @@ test.describe.serial('access-security-page', () => { await page.waitForSelector('.main-content'); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('security tab is invisible when password change, 2FA and E2E are disabled', async ({ page }) => { const securityTab = poAccountProfile.sidenav.linkSecurity; await expect(securityTab).not.toBeVisible(); diff --git a/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts b/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts index facb61492d116..f61d58d327b38 100644 --- a/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts +++ b/apps/meteor/tests/e2e/account-forgetSessionOnWindowClose.spec.ts @@ -36,6 +36,10 @@ test.describe.serial('Forget session on window close setting', () => { await updateSetting('Accounts_ForgetUserSessionOnWindowClose', true); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('Login using credentials and reload to get logged out', async ({ page, context }) => { await poRegistration.username.type('user1'); await poRegistration.inputPassword.type(DEFAULT_USER_CREDENTIALS.password); diff --git a/apps/meteor/tests/e2e/administration.spec.ts b/apps/meteor/tests/e2e/administration.spec.ts index 65f4e909e6dd9..2080c325fa0c0 100644 --- a/apps/meteor/tests/e2e/administration.spec.ts +++ b/apps/meteor/tests/e2e/administration.spec.ts @@ -290,6 +290,10 @@ test.describe.parallel('administration', () => { await page.goto('/admin/integrations'); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('should display the example payload correctly', async () => { await poAdmin.btnNew.click(); await poAdmin.btnInstructions.click(); diff --git a/apps/meteor/tests/e2e/anonymous-user.spec.ts b/apps/meteor/tests/e2e/anonymous-user.spec.ts index 5d19b55358700..a00ed6a9c038f 100644 --- a/apps/meteor/tests/e2e/anonymous-user.spec.ts +++ b/apps/meteor/tests/e2e/anonymous-user.spec.ts @@ -13,6 +13,10 @@ test.describe('anonymous-user', () => { ]); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test.beforeEach(async ({ page }) => { poHomeChannel = new HomeChannel(page); diff --git a/apps/meteor/tests/e2e/avatar-settings.ts b/apps/meteor/tests/e2e/avatar-settings.ts index 1d902cda3b9b3..8c494dc395c9c 100644 --- a/apps/meteor/tests/e2e/avatar-settings.ts +++ b/apps/meteor/tests/e2e/avatar-settings.ts @@ -40,6 +40,10 @@ test.describe('avatar-settings', () => { ]); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test.describe('public channels', () => { let channelName = ''; let avatarUrl = ''; diff --git a/apps/meteor/tests/e2e/e2e-encryption.spec.ts b/apps/meteor/tests/e2e/e2e-encryption.spec.ts index a85968b4dd969..8bdd6a99fd4f3 100644 --- a/apps/meteor/tests/e2e/e2e-encryption.spec.ts +++ b/apps/meteor/tests/e2e/e2e-encryption.spec.ts @@ -25,6 +25,10 @@ test.describe.serial('e2e-encryption initial setup', () => { await Promise.all([updateSetting('E2E_Enable', true, false), updateSetting('E2E_Allow_Unencrypted_Messages', true, false)]); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test.afterEach(async ({ api }) => { await api.recreateContext(); }); @@ -257,6 +261,10 @@ test.describe.serial('e2e-encryption', () => { await updateSetting('E2E_Allow_Unencrypted_Messages', true, false); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect create a private channel encrypted and send an encrypted message', async ({ page }) => { const channelName = faker.string.uuid(); diff --git a/apps/meteor/tests/e2e/feature-preview.spec.ts b/apps/meteor/tests/e2e/feature-preview.spec.ts index bd02abe207909..d50ee599cbd2b 100644 --- a/apps/meteor/tests/e2e/feature-preview.spec.ts +++ b/apps/meteor/tests/e2e/feature-preview.spec.ts @@ -32,7 +32,8 @@ test.describe.serial('feature preview', () => { targetDiscussion = await createTargetDiscussion(api); }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ api, restoreSettings }) => { + await restoreSettings(); await deleteChannel(api, targetChannel); await deleteRoom(api, targetDiscussion._id); }); diff --git a/apps/meteor/tests/e2e/file-upload.spec.ts b/apps/meteor/tests/e2e/file-upload.spec.ts index 2ee2b53524339..754c5a87a295f 100644 --- a/apps/meteor/tests/e2e/file-upload.spec.ts +++ b/apps/meteor/tests/e2e/file-upload.spec.ts @@ -21,7 +21,8 @@ test.describe.serial('file-upload', () => { await poHomeChannel.sidenav.openChat(targetChannel); }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ api, restoreSettings }) => { + await restoreSettings(); expect((await api.post('/channels.delete', { roomName: targetChannel })).status()).toBe(200); }); diff --git a/apps/meteor/tests/e2e/homepage.spec.ts b/apps/meteor/tests/e2e/homepage.spec.ts index be0d1ae5e52fa..cfaed2e9bf66b 100644 --- a/apps/meteor/tests/e2e/homepage.spec.ts +++ b/apps/meteor/tests/e2e/homepage.spec.ts @@ -68,6 +68,10 @@ test.describe.serial('homepage', () => { await updateSetting('Layout_Home_Body', 'Hello admin', ''); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('visibility and button functionality in custom body with custom content', async () => { await test.step('expect custom body to be visible', async () => { await expect(adminPage.locator('div >> text="Hello admin"')).toBeVisible(); @@ -90,6 +94,10 @@ test.describe.serial('homepage', () => { ]); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('display custom content only', async () => { await test.step('expect default layout to not be visible (show only custom content card)', async () => { await expect(adminPage.locator('role=heading[name="Welcome to Rocket.Chat"]')).not.toBeVisible(); @@ -118,7 +126,8 @@ test.describe.serial('homepage', () => { await regularUserPage.waitForSelector('[data-qa-id="home-header"]'); }); - test.afterAll(async () => { + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); await regularUserPage.close(); }); @@ -155,6 +164,10 @@ test.describe.serial('homepage', () => { updateSetting('Layout_Home_Title', 'NewTitle', 'Home'), ]); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + await regularUserPage.goto('/home'); await regularUserPage.waitForSelector('[data-qa-id="home-header"]'); }); @@ -178,6 +191,10 @@ test.describe.serial('homepage', () => { await regularUserPage.waitForSelector('[data-qa-id="home-header"]'); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect custom body to be visible', async () => { await expect(regularUserPage.locator('div >> text="Hello"')).toBeVisible(); }); diff --git a/apps/meteor/tests/e2e/login.spec.ts b/apps/meteor/tests/e2e/login.spec.ts index 89c3aa2811860..42a44885fb173 100644 --- a/apps/meteor/tests/e2e/login.spec.ts +++ b/apps/meteor/tests/e2e/login.spec.ts @@ -15,6 +15,10 @@ test.describe.parallel('Login', () => { await page.goto('/home'); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('should not have any accessibility violations', async ({ makeAxeBuilder }) => { const results = await makeAxeBuilder().analyze(); expect(results.violations).toEqual([]); 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 f3ffe614536c3..84fa8e8bb85d9 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 @@ -26,10 +26,11 @@ test.describe('omnichannel-auto-onhold-chat-closing', () => { const { page } = await createAuxContext(browser, Users.user1); agent = { page, poHomeChannel: new HomeChannel(page) }; }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ api, restoreSettings }) => { await agent.page.close(); await api.delete('/livechat/users/agent/user1').then((res) => expect(res.status()).toBe(200)); + await restoreSettings(); }); test.beforeEach(async ({ page, api }) => { 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 cdfd221ff2f5e..0c98f5bd99c15 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 @@ -31,13 +31,14 @@ test.describe('omnichannel-auto-transfer-unanswered-chat', () => { agent2 = { page: page2, poHomeChannel: new HomeChannel(page2) }; }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ api, restoreSettings }) => { await agent1.page.close(); await agent2.page.close(); 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)), + restoreSettings(), ]); }); 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 fb2cca43bf613..0c6cf2540b0e1 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-business-hours.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-business-hours.spec.ts @@ -29,10 +29,11 @@ test.describe('OC - Business Hours', () => { ]); }); - test.afterAll(async () => { + test.afterAll(async ({ restoreSettings }) => { await department.delete(); await department2.delete(); await agent.delete(); + await restoreSettings(); }); 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 5ab5190a40bc3..fe6680af25f8d 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 @@ -43,12 +43,13 @@ test.describe.serial('omnichannel-changing-room-priority-and-sla', () => { await agent.poHomeChannel.sidenav.switchStatus('online'); }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ api, restoreSettings }) => { await agent.page.close(); await Promise.all([ api.delete(`/livechat/users/agent/${ADMIN_CREDENTIALS.username}`), api.delete(`/livechat/users/manager/${ADMIN_CREDENTIALS.username}`), + restoreSettings(), ]); }); 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 3251e0dba2420..7d549e3e1788a 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-close-inquiry.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-close-inquiry.spec.ts @@ -31,8 +31,12 @@ test.describe('Omnichannel close inquiry', () => { await agent.page.close(); }); - test.afterAll(async ({ api }) => { - await Promise.all([await api.delete('/livechat/users/agent/user1'), await api.delete('/livechat/users/manager/user1')]); + test.afterAll(async ({ api, restoreSettings }) => { + await Promise.all([ + await api.delete('/livechat/users/agent/user1'), + await api.delete('/livechat/users/manager/user1'), + restoreSettings(), + ]); }); test('Receiving a message from visitor', async ({ page }) => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center-chats-filters.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center-chats-filters.spec.ts index a4862cd0cc4db..3e7545147386c 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center-chats-filters.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-contact-center-chats-filters.spec.ts @@ -45,8 +45,8 @@ test.describe('OC - Contact Center - Chats', () => { await page.close(); }); - test.afterAll(async () => { - await Promise.all([...conversations.map((conversation) => conversation.delete()), agent.delete()]); + test.afterAll(async ({ restoreSettings }) => { + await Promise.all([...conversations.map((conversation) => conversation.delete()), agent.delete(), restoreSettings()]); }); test(`OC - Contact Center - Chats - Filter from and to same date`, async ({ page }) => { 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 d00661ca83fcc..43ece17a0baeb 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-current-chats.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-current-chats.spec.ts @@ -112,7 +112,7 @@ test.describe('OC - Current Chats [Auto Selection]', async () => { await poCurrentChats.sidenav.linkCurrentChats.click(); }); - test.afterAll(async () => { + test.afterAll(async ({ restoreSettings }) => { await Promise.all([ // Delete conversations ...conversations.map((conversation) => conversation.delete()), @@ -122,6 +122,8 @@ test.describe('OC - Current Chats [Auto Selection]', async () => { ...agents.map((agent) => agent.delete()), // Delete tags ...tags.map((tag) => tag.delete()), + + restoreSettings(), ]); }); @@ -288,6 +290,10 @@ test.describe('OC - Current Chats [Manual Selection]', () => { await updateSetting('Livechat_Routing_Method', 'Manual_Selection', 'Auto_Selection'); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test.beforeAll(async ({ api }) => { agent = await createAgent(api, 'rocketchat.internal.admin.test'); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts index 338eb83e880b9..a9660dfdef2b4 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts @@ -25,6 +25,10 @@ test.describe('OC - Manage Departments', () => { await updateSetting('Omnichannel_enable_department_removal', true, false); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test.describe('Create first department', async () => { test.beforeEach(async ({ page }: { page: Page }) => { poOmnichannelDepartments = new OmnichannelDepartments(page); @@ -112,6 +116,10 @@ test.describe('OC - Manage Departments', () => { await deleteDepartment(api, { id: department._id }); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('Edit department', async () => { await test.step('expect create new department', async () => { await poOmnichannelDepartments.search(department.name); 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 2d1d5a99ea8bd..58dd06ded64a8 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-api.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-api.spec.ts @@ -262,13 +262,14 @@ test.describe('OC - Livechat API', () => { await pageContext?.close(); }); - test.afterAll(async ({ updateSetting }) => { + test.afterAll(async ({ updateSetting, restoreSettings }) => { await agent.delete(); await agent2.delete(); await updateSetting('Omnichannel_enable_department_removal', true); await Promise.all([...departments.map((department) => department.delete())]); await updateSetting('Omnichannel_enable_department_removal', false); + await restoreSettings(); }); // clearBusinessUnit @@ -725,8 +726,9 @@ test.describe('OC - Livechat API', () => { await page.close(); }); - test.afterAll(async () => { + test.afterAll(async ({ restoreSettings }) => { await agent.delete(); + await restoreSettings(); }); test('OC - Livechat API - onChatMaximized & onChatMinimized', async () => { 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 3ce61fe0ace36..34776eba7fddf 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-background.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-background.spec.ts @@ -41,8 +41,9 @@ test.describe('OC - Livechat - Message list background', async () => { await page.close(); }); - test.afterAll(async () => { + test.afterAll(async ({ restoreSettings }) => { await agent.delete(); + await restoreSettings(); }); test('OC - Livechat - Change message list background', async ({ page, updateSetting }) => { 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 314fb8e45dcbc..a89d6428586b3 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 @@ -43,9 +43,8 @@ test.describe('OC - Livechat - Queue Management', () => { await poLiveChat.page.goto('/livechat'); }); - test.afterAll(async ({ api }) => { - await api.delete('/livechat/users/agent/user1'); - await poHomeOmnichannel.page.close(); + test.afterAll(async ({ api, restoreSettings }) => { + await Promise.all([api.delete('/livechat/users/agent/user1'), restoreSettings(), poHomeOmnichannel.page.close()]); }); test.describe('OC - Queue Management - Auto Selection', () => { 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 e4fea08c6b575..68f40144fa782 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 @@ -41,9 +41,8 @@ test.describe('OC - Livechat - Queue Management', () => { await poLiveChat.page.goto('/livechat'); }); - test.afterAll(async ({ api }) => { - await api.delete('/livechat/users/agent/user1'); - await poHomeOmnichannel.page.close(); + test.afterAll(async ({ api, restoreSettings }) => { + await Promise.all([api.delete('/livechat/users/agent/user1'), restoreSettings(), poHomeOmnichannel.page.close()]); }); test.afterEach(async () => { @@ -153,15 +152,15 @@ test.describe('OC - Contact Manager Routing', () => { await poLiveChat.page.goto('/livechat'); }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ api, restoreSettings }) => { await Promise.all([ + restoreSettings(), api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/agent/user2'), api.delete(`/omnichannel/contact/${contactId}`), + poHomeOmnichannel.page.close(), + poHomeOmnichannelUser2.page.close(), ]); - - await poHomeOmnichannel.page.close(); - await poHomeOmnichannelUser2.page.close(); }); test.afterEach(async () => { diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts index 1a4d334651218..b445be71a113c 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts @@ -127,9 +127,8 @@ test.describe.serial('OC - Livechat - Visitors closing the room is disabled', () poHomeOmnichannel = new HomeOmnichannel(omniPage); }); - test.afterAll(async ({ api }) => { - await api.delete('/livechat/users/agent/user1'); - await poLiveChat.page.close(); + test.afterAll(async ({ api, restoreSettings }) => { + await Promise.all([api.delete('/livechat/users/agent/user1'), restoreSettings(), poLiveChat.page.close()]); }); test('OC - Livechat - Close Chat disabled', async () => { @@ -177,10 +176,13 @@ test.describe.serial('OC - Livechat - Resub after close room', () => { await poLiveChat.sendMessageAndCloseChat(firstVisitor); }); - test.afterAll(async ({ api }) => { - await api.delete('/livechat/users/agent/user1'); - await poLiveChat.page.close(); - await poHomeOmnichannel.page.close(); + test.afterAll(async ({ api, restoreSettings }) => { + await Promise.all([ + restoreSettings(), + api.delete('/livechat/users/agent/user1'), + poLiveChat.page.close(), + poHomeOmnichannel.page.close(), + ]); }); test('OC - Livechat - Resub after close room', async () => { @@ -330,6 +332,10 @@ test.describe('OC - Livechat - Livechat_Display_Offline_Form', () => { await poLiveChat.page.goto('/livechat'); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('OC - Livechat - Livechat_Display_Offline_Form false', async () => { await test.step('expect offline form to not be visible', async () => { await poLiveChat.openAnyLiveChat(); 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 9af3882d456f1..45e087751069e 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-manager-role.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-manager-role.spec.ts @@ -80,12 +80,13 @@ test.describe('OC - Manager Role', () => { }); // Delete all created data - test.afterAll(async () => { + test.afterAll(async ({ restoreSettings }) => { await Promise.all([ ...agents.map((agent) => agent.delete()), ...departments.map((department) => department.delete()), ...conversations.map((conversation) => conversation.delete()), manager.delete(), + restoreSettings(), ]); }); 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 e29206e103b8e..14d993c1b6ad0 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 @@ -40,9 +40,8 @@ test.describe('OC - Manual Selection After Relogin', () => { }); // Delete all data - test.afterAll(async () => { - await agent.delete(); - await injectInitialData(); + test.afterAll(async ({ restoreSettings }) => { + await Promise.all([agent.delete(), restoreSettings(), injectInitialData()]); }); test('OC - Manual Selection - Logout & Login', async ({ api }) => { 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 f5f0f60eb4dbe..3447da203fd60 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-manual-selection.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-manual-selection.spec.ts @@ -42,8 +42,8 @@ test.describe('OC - Manual Selection', () => { await agentB.page.close(); }); // Delete all data - test.afterAll(async () => { - await Promise.all(agents.map((agent) => agent.delete())); + test.afterAll(async ({ restoreSettings }) => { + await Promise.all(agents.map((agent) => agent.delete(), restoreSettings())); }); 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 e95851848ed24..e0973e5c247b5 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-monitor-role.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-monitor-role.spec.ts @@ -109,13 +109,14 @@ test.describe('OC - Monitor Role', () => { }); // Delete all created data - test.afterAll(async () => { + test.afterAll(async ({ restoreSettings }) => { await Promise.all([ ...agents.map((agent) => agent.delete()), ...departments.map((department) => department.delete()), ...conversations.map((conversation) => conversation.delete()), ...units.map((unit) => unit.delete()), ...monitors.map((monitor) => monitor.delete()), + restoreSettings(), ]); }); 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 93e5eb251770a..fc1601ca9e00b 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-priorities-sidebar.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-priorities-sidebar.spec.ts @@ -43,7 +43,8 @@ test.describe.serial('OC - Priorities [Sidebar]', () => { await createConversation(api, { visitorName: visitor.name }); }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ api, restoreSettings }) => { + await restoreSettings(); (await Promise.all([api.delete('/livechat/users/agent/user1'), api.delete('/livechat/users/manager/user1')])).every((res) => expect(res.status()).toBe(200), ); diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-takeChat.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-takeChat.spec.ts index 6330593cc8885..4c9ee68f859ba 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-takeChat.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-takeChat.spec.ts @@ -30,12 +30,11 @@ test.describe('omnichannel-takeChat', () => { agent = { page, poHomeChannel: new HomeOmnichannel(page) }; }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ api, restoreSettings }) => { await agent.poHomeChannel.sidenav.switchOmnichannelStatus('online'); await agent.poHomeChannel.sidenav.switchStatus('online'); - await agent.page.close(); - await api.delete('/livechat/users/agent/user1'); + await Promise.all([agent.page.close(), api.delete('/livechat/users/agent/user1'), restoreSettings()]); }); test.beforeEach('start a new livechat chat', async ({ page, api }) => { 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 bd8fa5db0ee24..ef0d0d7a1a9b8 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 @@ -35,11 +35,12 @@ test.describe('OC - Chat transfers [Agent role]', () => { }); // Delete all data - test.afterAll(async () => { + test.afterAll(async ({ restoreSettings }) => { await Promise.all([ ...conversations.map((conversation) => conversation.delete()), ...agents.map((agent) => agent.delete()), ...managers.map((manager) => manager.delete()), + restoreSettings(), ]); }); 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 37768d0abfddc..bc4db2edc02c5 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 @@ -66,7 +66,7 @@ test.describe('OC - Livechat New Chat Triggers - After Registration', () => { }); test.afterAll(async ({ updateSetting }) => { - await updateSetting('Livechat_clear_local_storage_when_chat_ended', false, false); + await updateSetting('Livechat_clear_local_storage_when_chat_ended', false); }); test.describe('OC - Livechat New Chat Triggers - After Registration', async () => { @@ -117,6 +117,10 @@ test.describe('OC - Livechat New Chat Triggers - After Registration', () => { await updateSetting('Livechat_clear_local_storage_when_chat_ended', true, false); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect trigger message after registration not be visible after local storage clear', async () => { await poLiveChat.page.goto('/livechat'); await poLiveChat.sendMessageAndCloseChat(newVisitor); diff --git a/apps/meteor/tests/e2e/permissions.spec.ts b/apps/meteor/tests/e2e/permissions.spec.ts index 90e86f5e823fd..cd9442ba8afaf 100644 --- a/apps/meteor/tests/e2e/permissions.spec.ts +++ b/apps/meteor/tests/e2e/permissions.spec.ts @@ -24,6 +24,10 @@ test.describe.serial('permissions', () => { await updateSetting('Message_AllowEditing', false, true); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect option(edit) not be visible', async ({ page }) => { await poHomeChannel.sidenav.openChat(targetChannel); @@ -43,6 +47,10 @@ test.describe.serial('permissions', () => { await updateSetting('Message_AllowDeleting', false, true); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect option(delete) not be visible', async ({ page }) => { await poHomeChannel.sidenav.openChat(targetChannel); await poHomeChannel.content.sendMessage('expect option(delete) not be visible'); @@ -65,6 +73,10 @@ test.describe.serial('permissions', () => { await updateSetting('Message_AllowPinning', false, true); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect option(pin) not be visible', async ({ page }) => { await poHomeChannel.sidenav.openChat(targetChannel); await poHomeChannel.content.sendMessage('expect option(pin) not be visible'); @@ -83,6 +95,10 @@ test.describe.serial('permissions', () => { await updateSetting('Message_AllowStarring', false, true); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect option(star) not be visible', async ({ page }) => { await poHomeChannel.sidenav.openChat(targetChannel); await poHomeChannel.content.sendMessage('expect option(star) not be visible'); @@ -102,6 +118,10 @@ test.describe.serial('permissions', () => { await updateSetting('FileUpload_Enabled', false, true); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect option (upload file) not be visible', async () => { await poHomeChannel.sidenav.openChat(targetChannel); await expect(poHomeChannel.content.btnOptionFileUpload).toBeDisabled(); @@ -113,6 +133,10 @@ test.describe.serial('permissions', () => { await updateSetting('Message_AudioRecorderEnabled', false, true); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect option (upload audio) not be visible', async () => { await poHomeChannel.sidenav.openChat(targetChannel); await expect(poHomeChannel.content.btnRecordAudio).toBeDisabled(); @@ -124,6 +148,10 @@ test.describe.serial('permissions', () => { await updateSetting('Message_VideoRecorderEnabled', false, true); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect option (upload video) not be visible', async () => { await poHomeChannel.sidenav.openChat(targetChannel); await expect(poHomeChannel.content.btnVideoMessage).toBeDisabled(); @@ -138,6 +166,10 @@ test.describe.serial('permissions', () => { ]); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect badword be censored', async () => { await poHomeChannel.sidenav.openChat(targetChannel); await poHomeChannel.content.sendMessage('badword'); diff --git a/apps/meteor/tests/e2e/presence.spec.ts b/apps/meteor/tests/e2e/presence.spec.ts index 14cdde7d64ad9..2c54b8d7900b3 100644 --- a/apps/meteor/tests/e2e/presence.spec.ts +++ b/apps/meteor/tests/e2e/presence.spec.ts @@ -16,6 +16,10 @@ test.describe.serial('Presence', () => { await updateSetting('API_Use_REST_For_DDP_Calls', true, true); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test.describe('Login using default settings', () => { test('expect user to be online after log in', async ({ page }) => { await poRegistration.username.type('user1'); @@ -52,6 +56,10 @@ test.describe.serial('Presence', () => { await updateSetting('Calendar_BusyStatus_Enabled', true, false); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('Should change user status to busy when there is an appointment', async ({ page, api }) => { await page.goto('/home'); diff --git a/apps/meteor/tests/e2e/read-receipts.spec.ts b/apps/meteor/tests/e2e/read-receipts.spec.ts index 3a64ec22d7b1e..b022d60eab748 100644 --- a/apps/meteor/tests/e2e/read-receipts.spec.ts +++ b/apps/meteor/tests/e2e/read-receipts.spec.ts @@ -42,6 +42,10 @@ test.describe.serial('read-receipts', () => { ]); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + let auxContext: { page: Page; poHomeChannel: HomeChannel } | undefined; test.afterEach(async () => { diff --git a/apps/meteor/tests/e2e/register.spec.ts b/apps/meteor/tests/e2e/register.spec.ts index 0f5edb18a8be0..b443424b27ed3 100644 --- a/apps/meteor/tests/e2e/register.spec.ts +++ b/apps/meteor/tests/e2e/register.spec.ts @@ -54,6 +54,10 @@ test.describe.parallel('register', () => { await poRegistration.goToRegister.click(); }); + test.afterEach(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect to register a user without password confirmation', async () => { await test.step('expect to not have password confirmation field', async () => { await expect(poRegistration.inputPasswordConfirm).toBeHidden(); @@ -83,6 +87,10 @@ test.describe.parallel('register', () => { await poRegistration.goToRegister.click(); }); + test.afterEach(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('it should expect to have a textbox asking the reason for the registration', async () => { await test.step('expect to have a textbox asking the reason for the registration', async () => { await expect(poRegistration.inputReason).toBeVisible(); @@ -127,6 +135,10 @@ test.describe.parallel('register', () => { ]); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('It should expect a message warning that registration is disabled', async ({ page }) => { await page.goto('/home'); await poRegistration.goToRegister.click(); diff --git a/apps/meteor/tests/e2e/reset-password.spec.ts b/apps/meteor/tests/e2e/reset-password.spec.ts index 745aa630fe443..8ccdc539339cb 100644 --- a/apps/meteor/tests/e2e/reset-password.spec.ts +++ b/apps/meteor/tests/e2e/reset-password.spec.ts @@ -11,6 +11,10 @@ test.describe.parallel('Reset Password', () => { await page.goto('/reset-password/someToken'); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('should confirm password be invalid', async () => { await poRegistration.inputPassword.fill('123456'); await poRegistration.inputPasswordConfirm.fill('123455'); diff --git a/apps/meteor/tests/e2e/search-discussion.spec.ts b/apps/meteor/tests/e2e/search-discussion.spec.ts index 1d4dc5cf14349..d9b5eb41bf67b 100644 --- a/apps/meteor/tests/e2e/search-discussion.spec.ts +++ b/apps/meteor/tests/e2e/search-discussion.spec.ts @@ -17,7 +17,8 @@ test.describe.serial('search-discussion', () => { await page.goto('/home'); }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ api, restoreSettings }) => { + await restoreSettings(); await deleteRoom(api, discussion._id); }); diff --git a/apps/meteor/tests/e2e/settings-persistence-on-ui-navigation.spec.ts b/apps/meteor/tests/e2e/settings-persistence-on-ui-navigation.spec.ts index e1624cecd4f3f..a47e38edfef42 100644 --- a/apps/meteor/tests/e2e/settings-persistence-on-ui-navigation.spec.ts +++ b/apps/meteor/tests/e2e/settings-persistence-on-ui-navigation.spec.ts @@ -22,6 +22,10 @@ test.describe.serial('settings-persistence-on-ui-navigation', () => { }); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect settings to persist in ui when navigating back and forth', async ({ page }) => { const settingInput = await page.locator('[data-qa-setting-id="Hide_System_Messages"] input'); await settingInput.pressSequentially('User joined'); diff --git a/apps/meteor/tests/e2e/system-messages.spec.ts b/apps/meteor/tests/e2e/system-messages.spec.ts index b53ec7c32622d..6048fb91aeb7d 100644 --- a/apps/meteor/tests/e2e/system-messages.spec.ts +++ b/apps/meteor/tests/e2e/system-messages.spec.ts @@ -54,6 +54,10 @@ test.describe.serial('System Messages', () => { await expect((await api.post('/groups.delete', { roomId: group._id })).status()).toBe(200); }); + test.afterAll(async ({ restoreSettings }) => { + await restoreSettings(); + }); + test('expect "User added" system message to be visible', async ({ page, api }) => { await expect((await api.post('/groups.invite', { roomId: group._id, userId: user._id })).status()).toBe(200); diff --git a/apps/meteor/tests/e2e/translations.spec.ts b/apps/meteor/tests/e2e/translations.spec.ts index 235a75cda1c99..e3062da799721 100644 --- a/apps/meteor/tests/e2e/translations.spec.ts +++ b/apps/meteor/tests/e2e/translations.spec.ts @@ -10,8 +10,9 @@ test.describe('Translations', () => { await Promise.all([updateSetting('Language', 'en', 'en'), updateSetting('Site_Name', 'Rocket.Chat', 'Rocket.Chat')]); }); - test.afterAll(async ({ api }) => { + test.afterAll(async ({ api, restoreSettings }) => { await setUserPreferences(api, { language: '' }); + await restoreSettings(); }); test("expect to display text in the user's preference language", async ({ page, api }) => {