Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(Livechat): Clean up after registerGuest() test #32092

Merged
merged 1 commit into from
Mar 28, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ test.describe('OC - Livechat API', () => {
let agent: Awaited<ReturnType<typeof createAgent>>;
let agent2: Awaited<ReturnType<typeof createAgent>>;
let departments: Awaited<ReturnType<typeof createDepartment>>[];
let pageContext: Page;

test.beforeAll(async ({ api }) => {
agent = await createAgent(api, 'user1');
Expand Down Expand Up @@ -262,6 +263,7 @@ test.describe('OC - Livechat API', () => {
await poAuxContext.page.close();
await page.close();
await poAuxContext2?.page.close();
await pageContext?.close();
});

test.afterAll(async ({ api }) => {
Expand Down Expand Up @@ -388,20 +390,20 @@ test.describe('OC - Livechat API', () => {
});

await test.step('Expect registerGuest to log in an existing guest and load chat history', async () => {
const { page: pageCtx } = await createAuxContext(browser, Users.user1);
({ page: pageContext } = await createAuxContext(browser, Users.user1));

await pageCtx.goto('/packages/rocketchat_livechat/assets/demo.html');
await pageContext.goto('/packages/rocketchat_livechat/assets/demo.html');

await pageCtx.evaluate(() => window.RocketChat.livechat.maximizeWidget());
await expect(pageCtx.frameLocator('#rocketchat-iframe').getByText('Start Chat')).toBeVisible();
await pageContext.evaluate(() => window.RocketChat.livechat.maximizeWidget());
await expect(pageContext.frameLocator('#rocketchat-iframe').getByText('Start Chat')).toBeVisible();

await pageCtx.evaluate(
await pageContext.evaluate(
(registerGuestVisitor) => window.RocketChat.livechat.registerGuest(registerGuestVisitor),
registerGuestVisitor,
);

await expect(pageCtx.frameLocator('#rocketchat-iframe').getByText('Start Chat')).not.toBeVisible();
await expect(pageCtx.frameLocator('#rocketchat-iframe').getByText('this_a_test_message_from_visitor')).toBeVisible();
await expect(pageContext.frameLocator('#rocketchat-iframe').getByText('Start Chat')).not.toBeVisible();
await expect(pageContext.frameLocator('#rocketchat-iframe').getByText('this_a_test_message_from_visitor')).toBeVisible();
});
});

Expand Down Expand Up @@ -593,20 +595,20 @@ test.describe('OC - Livechat API', () => {
await poLiveChat.btnSendMessageToOnlineAgent.click();

await test.step('Expect setGuestToken to log in an existing guest and load chat history', async () => {
const { page: pageCtx } = await createAuxContext(browser, Users.user1);
({ page: pageContext } = await createAuxContext(browser, Users.user1));

await pageCtx.goto('/packages/rocketchat_livechat/assets/demo.html');
await pageContext.goto('/packages/rocketchat_livechat/assets/demo.html');

await pageCtx.evaluate(() => window.RocketChat.livechat.maximizeWidget());
await expect(pageCtx.frameLocator('#rocketchat-iframe').getByText('Start Chat')).toBeVisible();
await pageContext.evaluate(() => window.RocketChat.livechat.maximizeWidget());
await expect(pageContext.frameLocator('#rocketchat-iframe').getByText('Start Chat')).toBeVisible();

await pageCtx.evaluate(
await pageContext.evaluate(
(registerGuestVisitor) => window.RocketChat.livechat.setGuestToken(registerGuestVisitor.token),
registerGuestVisitor,
);

await expect(pageCtx.frameLocator('#rocketchat-iframe').getByText('Start Chat')).not.toBeVisible();
await expect(pageCtx.frameLocator('#rocketchat-iframe').getByText('this_a_test_message_from_visitor')).toBeVisible();
await expect(pageContext.frameLocator('#rocketchat-iframe').getByText('Start Chat')).not.toBeVisible();
await expect(pageContext.frameLocator('#rocketchat-iframe').getByText('this_a_test_message_from_visitor')).toBeVisible();
});
});
});
Expand Down
Loading