Skip to content
Snippets Groups Projects
Unverified Commit 13f36426 authored by Aleksander Nicacio da Silva's avatar Aleksander Nicacio da Silva Committed by GitHub
Browse files

regression: multiSelect type settings not being saved by livechat/appearance endpoint (#32074)

parent 9bfae80b
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,7 @@ API.v1.addRoute(
throw new Error('invalid-setting');
}
const dbSettings = await Settings.findByIds(validSettingList, { projection: { _id: 1, value: 1, type: 1 } })
const dbSettings = await Settings.findByIds(validSettingList, { projection: { _id: 1, value: 1, type: 1, values: 1 } })
.map((dbSetting) => {
const setting = settings.find(({ _id }) => _id === dbSetting._id);
if (!setting || dbSetting.value === setting.value) {
......
import { IS_EE } from '../config/constants';
import { Users } from '../fixtures/userStates';
import { OmnichannelLivechatAppearance } from '../page-objects/omnichannel-livechat-appearance';
import { test, expect } from '../utils/test';
test.use({ storageState: Users.admin.state });
test.skip(!IS_EE, 'Enterprise Only');
test.describe.serial('OC - Livechat Appearance', () => {
let poLivechatAppearance: OmnichannelLivechatAppearance;
test.beforeEach(async ({ page }) => {
poLivechatAppearance = new OmnichannelLivechatAppearance(page);
await page.goto('/omnichannel');
await poLivechatAppearance.sidenav.linkLivechatAppearance.click();
});
test.afterAll(async ({ api }) => {
const res = await api.post('/settings/Livechat_hide_system_messages', { value: ['uj', 'ul', 'livechat-close'] });
await expect(res.status()).toBe(200);
});
test('OC - Livechat Appearance - Hide system messages', async ({ page }) => {
await test.step('expect to have default values', async () => {
await poLivechatAppearance.inputHideSystemMessages.click();
await expect(poLivechatAppearance.findHideSystemMessageOption('uj')).toHaveAttribute('aria-selected', 'true');
await expect(poLivechatAppearance.findHideSystemMessageOption('ul')).toHaveAttribute('aria-selected', 'true');
await expect(poLivechatAppearance.findHideSystemMessageOption('livechat-close')).toHaveAttribute('aria-selected', 'true');
await poLivechatAppearance.inputHideSystemMessages.click();
});
await test.step('expect to change values', async () => {
await poLivechatAppearance.inputHideSystemMessages.click();
await poLivechatAppearance.findHideSystemMessageOption('livechat_transfer_history').click();
await poLivechatAppearance.findHideSystemMessageOption('livechat-close').click();
await poLivechatAppearance.btnSave.click();
});
await test.step('expect to have saved changes', async () => {
await page.reload();
await poLivechatAppearance.inputHideSystemMessages.click();
await expect(poLivechatAppearance.findHideSystemMessageOption('uj')).toHaveAttribute('aria-selected', 'true');
await expect(poLivechatAppearance.findHideSystemMessageOption('ul')).toHaveAttribute('aria-selected', 'true');
await expect(poLivechatAppearance.findHideSystemMessageOption('livechat_transfer_history')).toHaveAttribute('aria-selected', 'true');
await expect(poLivechatAppearance.findHideSystemMessageOption('livechat-close')).toHaveAttribute('aria-selected', 'false');
});
});
});
......@@ -66,4 +66,8 @@ export class OmnichannelSidenav {
get linkUnits(): Locator {
return this.page.locator('a[href="/omnichannel/units"]');
}
get linkLivechatAppearance(): Locator {
return this.page.locator('a[href="/omnichannel/appearance"]');
}
}
import type { Locator } from '@playwright/test';
import { OmnichannelAdministration } from './omnichannel-administration';
export class OmnichannelLivechatAppearance extends OmnichannelAdministration {
get inputHideSystemMessages(): Locator {
return this.page.locator('[name="Livechat_hide_system_messages"]');
}
findHideSystemMessageOption(option: string): Locator {
return this.page.locator(`[role="option"][value="${option}"]`);
}
get btnSave(): Locator {
return this.page.locator('role=button[name="Save changes"]');
}
get btnCancel(): Locator {
return this.page.locator('role=button[name="Cancel"]');
}
}
......@@ -199,24 +199,26 @@ describe('LIVECHAT - appearance', function () {
const { body } = await request.get(api('livechat/config')).set(credentials).expect(200);
expect(body.config.settings.limitTextLength).to.be.false;
});
(IS_EE ? it : it.skip)('should accept an array setting', async () => {
await request
.post(api('livechat/appearance'))
.set(credentials)
.send([{ _id: 'Livechat_hide_system_messages', value: ['uj'] }])
.send([{ _id: 'Livechat_hide_system_messages', value: ['livechat-started'] }])
.expect(200);
await sleep(500);
// Get data from livechat/config
const { body } = await request.get(api('livechat/config')).set(credentials).expect(200);
expect(body.config.settings.hiddenSystemMessages).to.be.an('array');
expect(body.config.settings.hiddenSystemMessages).to.include('uj');
expect(body.config.settings.hiddenSystemMessages).to.include('livechat-started');
});
(IS_EE ? it : it.skip)('should accept an array setting with multiple values', async () => {
await request
.post(api('livechat/appearance'))
.set(credentials)
.send([{ _id: 'Livechat_hide_system_messages', value: ['uj', 'ul'] }])
.send([{ _id: 'Livechat_hide_system_messages', value: ['uj', 'livechat_transfer_history'] }])
.expect(200);
await sleep(500);
......@@ -224,8 +226,10 @@ describe('LIVECHAT - appearance', function () {
const { body } = await request.get(api('livechat/config')).set(credentials).expect(200);
expect(body.config.settings.hiddenSystemMessages).to.be.an('array');
expect(body.config.settings.hiddenSystemMessages).to.include('uj');
expect(body.config.settings.hiddenSystemMessages).to.include('ul');
expect(body.config.settings.hiddenSystemMessages).to.include('livechat_transfer_history');
expect(body.config.settings.hiddenSystemMessages).not.to.include('livechat-started');
});
(IS_EE ? it : it.skip)('should not update an array setting with a value other than array', async () => {
await request
.post(api('livechat/appearance'))
......@@ -239,12 +243,14 @@ describe('LIVECHAT - appearance', function () {
const { body } = await request.get(api('livechat/config')).set(credentials).expect(200);
expect(body.config.settings.hiddenSystemMessages).to.be.an('array');
expect(body.config.settings.hiddenSystemMessages).to.include('uj');
expect(body.config.settings.hiddenSystemMessages).to.include('livechat_transfer_history');
});
(IS_EE ? it : it.skip)('should not update an array setting with values that are not valid setting values', async () => {
await request
.post(api('livechat/appearance'))
.set(credentials)
.send([{ _id: 'Livechat_hide_system_messages', value: ['uj', 'invalid'] }])
.send([{ _id: 'Livechat_hide_system_messages', value: ['livechat-started', 'invalid'] }])
.expect(200);
await sleep(500);
......@@ -253,6 +259,8 @@ describe('LIVECHAT - appearance', function () {
const { body } = await request.get(api('livechat/config')).set(credentials).expect(200);
expect(body.config.settings.hiddenSystemMessages).to.be.an('array');
expect(body.config.settings.hiddenSystemMessages).to.include('uj');
expect(body.config.settings.hiddenSystemMessages).to.include('livechat_transfer_history');
expect(body.config.settings.hiddenSystemMessages).to.not.include('livechat-started');
expect(body.config.settings.hiddenSystemMessages).to.not.include('invalid');
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment