From bcdb1d5103c3933f736d11fc8342d516cca8c82a Mon Sep 17 00:00:00 2001 From: MartinSchoeler Date: Tue, 26 Mar 2024 15:03:13 -0300 Subject: [PATCH] test(Livechat): `registerguest()` with different guests --- .../omnichannel-livechat-api.spec.ts | 50 +++++++++++++++++++ .../omnichannel-livechat-embedded.ts | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) 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 1c6cf2404fe4..2800709ef9ba 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-api.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat-api.spec.ts @@ -405,6 +405,56 @@ test.describe('OC - Livechat API', () => { }); }); + test('OC - Livechat API - registerGuest different guests', async () => { + const registerGuestVisitor1 = { + name: faker.person.firstName(), + email: faker.internet.email(), + token: faker.string.uuid(), + }; + + const registerGuestVisitor2 = { + name: faker.person.firstName(), + email: faker.internet.email(), + token: faker.string.uuid(), + }; + + await test.step('Expect registerGuest to create guest 1', async () => { + await poLiveChat.page.evaluate(() => window.RocketChat.livechat.maximizeWidget()); + await expect(poLiveChat.page.frameLocator('#rocketchat-iframe').getByText('Start Chat')).toBeVisible(); + + await poLiveChat.page.evaluate( + (registerGuestVisitor1) => window.RocketChat.livechat.registerGuest(registerGuestVisitor1), + registerGuestVisitor1, + ); + + await expect(poLiveChat.page.frameLocator('#rocketchat-iframe').getByText('Start Chat')).not.toBeVisible(); + + await poLiveChat.onlineAgentMessage.type('this_a_test_message_from_visitor_1'); + await poLiveChat.btnSendMessageToOnlineAgent.click(); + + await expect(poLiveChat.txtChatMessage('this_a_test_message_from_visitor_1')).toBeVisible(); + + }); + + await test.step('Expect registerGuest to create guest 2', async () => { + await poLiveChat.page.evaluate( + (registerGuestVisitor2) => window.RocketChat.livechat.registerGuest(registerGuestVisitor2), + registerGuestVisitor2, + ); + + await poLiveChat.page.frameLocator('#rocketchat-iframe').getByText('this_a_test_message_from_visitor').waitFor({ state: 'hidden' }); + + await expect(poLiveChat.page.frameLocator('#rocketchat-iframe').getByText('Start Chat')).not.toBeVisible(); + + await poLiveChat.onlineAgentMessage.type('this_a_test_message_from_visitor_2'); + await poLiveChat.btnSendMessageToOnlineAgent.click(); + + await poLiveChat.txtChatMessage('this_a_test_message_from_visitor_2').waitFor({ state: 'visible' }); + await expect(poLiveChat.txtChatMessage('this_a_test_message_from_visitor_2')).toBeVisible(); + + }); + }); + test('OC - Livechat API - registerGuest multiple times', async () => { const registerGuestVisitor = { name: faker.person.firstName(), diff --git a/apps/meteor/tests/e2e/page-objects/omnichannel-livechat-embedded.ts b/apps/meteor/tests/e2e/page-objects/omnichannel-livechat-embedded.ts index 8d5fff57412b..db4993eaaac6 100644 --- a/apps/meteor/tests/e2e/page-objects/omnichannel-livechat-embedded.ts +++ b/apps/meteor/tests/e2e/page-objects/omnichannel-livechat-embedded.ts @@ -40,7 +40,7 @@ export class OmnichannelLiveChatEmbedded { } txtChatMessage(message: string): Locator { - return this.page.frameLocator('#rocketchat-iframe').locator(`text="${message}"`); + return this.page.frameLocator('#rocketchat-iframe').locator(`li >> text="${message}"`); } async closeChat(): Promise {