Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/imports/server/rest/appearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
50 changes: 50 additions & 0 deletions apps/meteor/tests/e2e/omnichannel/omnichannel-appearance.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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"]');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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"]');
}
}
18 changes: 13 additions & 5 deletions apps/meteor/tests/end-to-end/api/livechat/02-appearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,33 +199,37 @@ 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);

// 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('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'))
Expand All @@ -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);
Expand All @@ -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');
});
});
Expand Down