mirror of
https://github.com/RocketChat/Rocket.Chat.git
synced 2025-12-27 22:40:49 +00:00
test: Replace magic tag names in e2e tests (#37932)
This commit is contained in:
parent
32fce68a95
commit
87967533af
@ -21,7 +21,10 @@ test.describe('OC - Tags Visibility', () => {
|
||||
let departmentA: Awaited<ReturnType<typeof createDepartment>>;
|
||||
let departmentB: Awaited<ReturnType<typeof createDepartment>>;
|
||||
let agent: Awaited<ReturnType<typeof createAgent>>;
|
||||
let tags: Awaited<ReturnType<typeof createTag>>[] = [];
|
||||
let tagA: Awaited<ReturnType<typeof createTag>>;
|
||||
let tagB: Awaited<ReturnType<typeof createTag>>;
|
||||
let globalTag: Awaited<ReturnType<typeof createTag>>;
|
||||
let sharedTag: Awaited<ReturnType<typeof createTag>>;
|
||||
|
||||
test.beforeAll('Create departments', async ({ api }) => {
|
||||
departmentA = await createDepartment(api, { name: 'Department A' });
|
||||
@ -40,16 +43,12 @@ test.describe('OC - Tags Visibility', () => {
|
||||
});
|
||||
|
||||
test.beforeAll('Create tags', async ({ api }) => {
|
||||
tags = await Promise.all([
|
||||
createTag(api, { name: 'TagA', description: 'tag A', departments: [departmentA.data._id] }),
|
||||
createTag(api, { name: 'TagB', description: 'tag B', departments: [departmentB.data._id] }),
|
||||
createTag(api, { name: 'GlobalTag', description: 'public tag', departments: [] }),
|
||||
createTag(api, {
|
||||
name: 'SharedTag',
|
||||
description: 'tag for both departments',
|
||||
departments: [departmentA.data._id, departmentB.data._id],
|
||||
}),
|
||||
]);
|
||||
tagA = await createTag(api, { departments: [departmentA.data._id] });
|
||||
tagB = await createTag(api, { departments: [departmentB.data._id] });
|
||||
globalTag = await createTag(api, { departments: [] });
|
||||
sharedTag = await createTag(api, {
|
||||
departments: [departmentA.data._id, departmentB.data._id],
|
||||
});
|
||||
});
|
||||
|
||||
test.beforeAll('Create conversations', async ({ api }) => {
|
||||
@ -66,7 +65,7 @@ test.describe('OC - Tags Visibility', () => {
|
||||
|
||||
test.afterAll(async () => {
|
||||
await Promise.all(conversations.map((conversation) => conversation.delete()));
|
||||
await Promise.all(tags.map((tag) => tag.delete()));
|
||||
await Promise.all([tagA, tagB, globalTag, sharedTag].map((tag) => tag.delete()));
|
||||
await agent.delete();
|
||||
await departmentA.delete();
|
||||
await departmentB.delete();
|
||||
@ -88,31 +87,31 @@ test.describe('OC - Tags Visibility', () => {
|
||||
});
|
||||
|
||||
await test.step('Should see TagA (department A specific)', async () => {
|
||||
await expect(poOmnichannel.roomInfo.optionTags('TagA')).toBeVisible();
|
||||
await expect(poOmnichannel.roomInfo.optionTags(tagA.data.name)).toBeVisible();
|
||||
});
|
||||
|
||||
await test.step('Should see SharedTag (both departments)', async () => {
|
||||
await expect(poOmnichannel.roomInfo.optionTags('SharedTag')).toBeVisible();
|
||||
await expect(poOmnichannel.roomInfo.optionTags(sharedTag.data.name)).toBeVisible();
|
||||
});
|
||||
|
||||
await test.step('Should see Public Tags for all chats (no department restriction)', async () => {
|
||||
await expect(poOmnichannel.roomInfo.optionTags('GlobalTag')).toBeVisible();
|
||||
await expect(poOmnichannel.roomInfo.optionTags(globalTag.data.name)).toBeVisible();
|
||||
});
|
||||
|
||||
await test.step('Should not see TagB (department B specific)', async () => {
|
||||
await expect(poOmnichannel.roomInfo.optionTags('TagB')).not.toBeVisible();
|
||||
await expect(poOmnichannel.roomInfo.optionTags(tagB.data.name)).not.toBeVisible();
|
||||
});
|
||||
|
||||
await test.step('add tags and save', async () => {
|
||||
await poOmnichannel.roomInfo.selectTag('TagA');
|
||||
await poOmnichannel.roomInfo.selectTag('GlobalTag');
|
||||
await poOmnichannel.roomInfo.selectTag(tagA.data.name);
|
||||
await poOmnichannel.roomInfo.selectTag(globalTag.data.name);
|
||||
await poOmnichannel.roomInfo.btnSaveEditRoom.click();
|
||||
});
|
||||
|
||||
await test.step('verify selected tags are displayed under room information', async () => {
|
||||
await expect(poOmnichannel.roomInfo.getLabel('Tags')).toBeVisible();
|
||||
await expect(poOmnichannel.roomInfo.getTagInfoByLabel('TagA')).toBeVisible();
|
||||
await expect(poOmnichannel.roomInfo.getTagInfoByLabel('GlobalTag')).toBeVisible();
|
||||
await expect(poOmnichannel.roomInfo.getTagInfoByLabel(tagA.data.name)).toBeVisible();
|
||||
await expect(poOmnichannel.roomInfo.getTagInfoByLabel(globalTag.data.name)).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
@ -125,11 +124,11 @@ test.describe('OC - Tags Visibility', () => {
|
||||
});
|
||||
|
||||
await test.step('Agent associated with DepartmentB should be able to see tags for Department B', async () => {
|
||||
await expect(poOmnichannel.roomInfo.optionTags('TagB')).toBeVisible();
|
||||
await expect(poOmnichannel.roomInfo.optionTags(tagB.data.name)).toBeVisible();
|
||||
});
|
||||
|
||||
await test.step('Agent associated with DepartmentB should not be able to see tags for DepartmentA', async () => {
|
||||
await expect(poOmnichannel.roomInfo.optionTags('TagA')).not.toBeVisible();
|
||||
await expect(poOmnichannel.roomInfo.optionTags(tagA.data.name)).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -23,7 +23,8 @@ test.describe('OC - Contact Center Chats [Auto Selection]', async () => {
|
||||
let departments: Awaited<ReturnType<typeof createDepartment>>[];
|
||||
let conversations: Awaited<ReturnType<typeof createConversation>>[];
|
||||
let agents: Awaited<ReturnType<typeof createAgent>>[];
|
||||
let tags: Awaited<ReturnType<typeof createTag>>[];
|
||||
let tagA: Awaited<ReturnType<typeof createTag>>;
|
||||
let tagB: Awaited<ReturnType<typeof createTag>>;
|
||||
|
||||
// Allow manual on hold
|
||||
test.beforeAll(async ({ api }) => {
|
||||
@ -62,9 +63,10 @@ test.describe('OC - Contact Center Chats [Auto Selection]', async () => {
|
||||
|
||||
// Create tags
|
||||
test.beforeAll(async ({ api }) => {
|
||||
tags = await Promise.all([createTag(api, { name: 'tagA' }), createTag(api, { name: 'tagB' })]);
|
||||
tagA = await createTag(api);
|
||||
tagB = await createTag(api);
|
||||
|
||||
tags.forEach((res) => expect(res.response.status()).toBe(200));
|
||||
[tagA, tagB].forEach((res) => expect(res.response.status()).toBe(200));
|
||||
});
|
||||
|
||||
// Create rooms
|
||||
@ -96,12 +98,12 @@ test.describe('OC - Contact Center Chats [Auto Selection]', async () => {
|
||||
updateRoom(api, {
|
||||
roomId: conversationA.room._id,
|
||||
visitorId: conversationA.visitor._id,
|
||||
tags: ['tagA'],
|
||||
tags: [tagA.data.name],
|
||||
}),
|
||||
updateRoom(api, {
|
||||
roomId: conversationB.room._id,
|
||||
visitorId: conversationB.visitor._id,
|
||||
tags: ['tagB'],
|
||||
tags: [tagB.data.name],
|
||||
}),
|
||||
]);
|
||||
});
|
||||
@ -122,7 +124,7 @@ test.describe('OC - Contact Center Chats [Auto Selection]', async () => {
|
||||
// Delete agents
|
||||
...agents.map((agent) => agent.delete()),
|
||||
// Delete tags
|
||||
...tags.map((tag) => tag.delete()),
|
||||
...[tagA, tagB].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 }),
|
||||
|
||||
@ -26,7 +26,8 @@ test.describe('OC - Contact Center', async () => {
|
||||
let departments: Awaited<ReturnType<typeof createDepartment>>[];
|
||||
let conversations: Awaited<ReturnType<typeof createConversation>>[];
|
||||
let agents: Awaited<ReturnType<typeof createAgent>>[];
|
||||
let tags: Awaited<ReturnType<typeof createTag>>[];
|
||||
let tagA: Awaited<ReturnType<typeof createTag>>;
|
||||
let tagB: Awaited<ReturnType<typeof createTag>>;
|
||||
let units: Awaited<ReturnType<typeof createOrUpdateUnit>>[];
|
||||
let poContacts: OmnichannelContacts;
|
||||
let poOmniSection: OmnichannelSection;
|
||||
@ -68,9 +69,10 @@ test.describe('OC - Contact Center', async () => {
|
||||
|
||||
// Create tags
|
||||
test.beforeAll(async ({ api }) => {
|
||||
tags = await Promise.all([createTag(api, { name: 'tagA' }), createTag(api, { name: 'tagB' })]);
|
||||
tagA = await createTag(api);
|
||||
tagB = await createTag(api);
|
||||
|
||||
tags.forEach((res) => expect(res.response.status()).toBe(200));
|
||||
[tagA, tagB].forEach((res) => expect(res.response.status()).toBe(200));
|
||||
});
|
||||
|
||||
// Create unit
|
||||
@ -118,12 +120,12 @@ test.describe('OC - Contact Center', async () => {
|
||||
updateRoom(api, {
|
||||
roomId: conversationA.room._id,
|
||||
visitorId: conversationA.visitor._id,
|
||||
tags: ['tagA'],
|
||||
tags: [tagA.data.name],
|
||||
}),
|
||||
updateRoom(api, {
|
||||
roomId: conversationB.room._id,
|
||||
visitorId: conversationB.visitor._id,
|
||||
tags: ['tagB'],
|
||||
tags: [tagB.data.name],
|
||||
}),
|
||||
]);
|
||||
});
|
||||
@ -132,12 +134,12 @@ test.describe('OC - Contact Center', async () => {
|
||||
await Promise.all([
|
||||
// Delete conversations
|
||||
...conversations.map((conversation) => conversation.delete()),
|
||||
// // Delete departments
|
||||
// Delete departments
|
||||
...departments.map((department) => department.delete()),
|
||||
// Delete agents
|
||||
...agents.map((agent) => agent.delete()),
|
||||
// Delete tags
|
||||
...tags.map((tag) => tag.delete()),
|
||||
...[tagA, tagB].map((tag) => tag.delete()),
|
||||
// Delete units
|
||||
...units.map((unit) => unit.delete()),
|
||||
// Reset setting
|
||||
@ -264,19 +266,19 @@ test.describe('OC - Contact Center', async () => {
|
||||
});
|
||||
|
||||
await test.step('expect to filter by tags', async () => {
|
||||
await poContacts.selectTag('tagA');
|
||||
await poContacts.selectTag(tagA.data.name);
|
||||
await expect(poContacts.findRowByName(visitorA)).toBeVisible();
|
||||
await expect(poContacts.findRowByName(visitorB)).not.toBeVisible();
|
||||
|
||||
await poContacts.selectTag('tagB');
|
||||
await poContacts.selectTag(tagB.data.name);
|
||||
await expect(poContacts.findRowByName(visitorA)).toBeVisible();
|
||||
await expect(poContacts.findRowByName(visitorB)).toBeVisible();
|
||||
|
||||
await poContacts.removeTag('tagA');
|
||||
await poContacts.removeTag(tagA.data.name);
|
||||
await expect(poContacts.findRowByName(visitorB)).toBeVisible();
|
||||
await expect(poContacts.findRowByName(visitorA)).not.toBeVisible();
|
||||
|
||||
await poContacts.removeTag('tagB');
|
||||
await poContacts.removeTag(tagB.data.name);
|
||||
await expect(poContacts.findRowByName(visitorB)).toBeVisible();
|
||||
await expect(poContacts.findRowByName(visitorA)).toBeVisible();
|
||||
});
|
||||
@ -312,7 +314,7 @@ test.describe('OC - Contact Center', async () => {
|
||||
await poContacts.selectServedBy('user1');
|
||||
await poContacts.selectStatus('onhold');
|
||||
await poContacts.selectDepartment(departmentA.name);
|
||||
await poContacts.selectTag('tagA');
|
||||
await poContacts.selectTag(tagA.data.name);
|
||||
await poContacts.selectUnit(unitA.name);
|
||||
|
||||
await expect(poContacts.findRowByName(visitorA)).toBeVisible();
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { faker } from '@faker-js/faker';
|
||||
import type { ILivechatTag } from '@rocket.chat/core-typings';
|
||||
|
||||
import type { BaseTest } from '../test';
|
||||
@ -11,12 +12,12 @@ type CreateTagParams = {
|
||||
|
||||
const removeTag = async (api: BaseTest['api'], id: string) => api.post('/livechat/tags.delete', { id });
|
||||
|
||||
export const createTag = async (api: BaseTest['api'], { id = null, name, description = '', departments = [] }: CreateTagParams = {}) => {
|
||||
export const createTag = async (api: BaseTest['api'], { id = null, name, description, departments = [] }: CreateTagParams = {}) => {
|
||||
const response = await api.post('/livechat/tags.save', {
|
||||
_id: id,
|
||||
tagData: {
|
||||
name,
|
||||
description,
|
||||
name: name ?? faker.string.alpha({ length: 8 }),
|
||||
description: description ?? faker.string.alpha({ length: 16 }),
|
||||
},
|
||||
...(departments.length > 0 && { tagDepartments: departments }),
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user