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

[FIX] Blank screen after requesting transcript #26385

Merged
merged 8 commits into from
Aug 22, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import {
useEndpoint,
useMethod,
useTranslation,
useRoute,
} from '@rocket.chat/ui-contexts';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Session } from 'meteor/session';
import React, { useCallback, useState, useEffect } from 'react';

import { RoomManager } from '../../../../../../../app/ui-utils/client';
import PlaceChatOnHoldModal from '../../../../../../../ee/app/livechat-enterprise/client/components/modals/PlaceChatOnHoldModal';
import CloseChatModal from '../../../../../../components/Omnichannel/modals/CloseChatModal';
import CloseChatModalData from '../../../../../../components/Omnichannel/modals/CloseChatModalData';
Expand All @@ -34,6 +33,7 @@ export const useQuickActions = (
getAction: (id: string) => void;
} => {
const setModal = useSetModal();
const route = useRoute('home');

const t = useTranslation();
const dispatchToastMessage = useToastMessageDispatch();
Expand Down Expand Up @@ -83,11 +83,11 @@ export const useQuickActions = (
await methodReturn(rid);
closeModal();
Session.set('openedRoom', null);
FlowRouter.go('/home');
route.push();
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
}, [closeModal, dispatchToastMessage, methodReturn, rid]);
}, [closeModal, dispatchToastMessage, methodReturn, rid, route]);

const requestTranscript = useMethod('livechat:requestTranscript');

Expand All @@ -96,7 +96,6 @@ export const useQuickActions = (
try {
await requestTranscript(rid, email, subject);
closeModal();
RoomManager.close(`l${rid}`);
dispatchToastMessage({
type: 'success',
message: t('Livechat_transcript_has_been_requested'),
Expand Down Expand Up @@ -169,13 +168,13 @@ export const useQuickActions = (
throw new Error(departmentId ? t('error-no-agents-online-in-department') : t('error-forwarding-chat'));
}
dispatchToastMessage({ type: 'success', message: t('Transferred') });
FlowRouter.go('/');
route.push();
closeModal();
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
},
[closeModal, dispatchToastMessage, forwardChat, rid, t],
[closeModal, dispatchToastMessage, forwardChat, rid, route, t],
);

const closeChat = useMethod('livechat:closeRoom');
Expand Down
61 changes: 61 additions & 0 deletions apps/meteor/tests/e2e/omnichannel-send-transcript.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { faker } from '@faker-js/faker';
import type { Browser, Page } from '@playwright/test';

import { test, expect } from './utils/test';
import { OmnichannelLiveChat, HomeChannel } from './page-objects';

const createAuxContext = async (browser: Browser, storageState: string): Promise<{ page: Page; poHomeChannel: HomeChannel }> => {
const page = await browser.newPage({ storageState });
const poHomeChannel = new HomeChannel(page);
await page.goto('/');
await page.locator('.main-content').waitFor();

return { page, poHomeChannel };
};

test.describe('omnichannel-transcript', () => {
let poLiveChat: OmnichannelLiveChat;
let newUser: { email: string; name: string };

let agent: { page: Page; poHomeChannel: HomeChannel };
test.beforeAll(async ({ api, browser }) => {
newUser = {
name: faker.name.firstName(),
email: faker.internet.email(),
};

// Set user user 1 as manager and agent
await api.post('/livechat/users/agent', { username: 'user1' });
await api.post('/livechat/users/manager', { username: 'user1' });

agent = await createAuxContext(browser, 'user1-session.json');
});
test.beforeEach(async ({ page }) => {
poLiveChat = new OmnichannelLiveChat(page);
});

test.afterAll(async ({ api }) => {
await api.delete('/livechat/users/agent/user1');
await api.delete('/livechat/users/manager/user1');
});

test('Receiving a message from visitor', async ({ page }) => {
await test.step('Expect send a message as a visitor', async () => {
await page.goto('/livechat');
await poLiveChat.btnOpenLiveChat('R').click();
await poLiveChat.sendMessage(newUser, false);
await poLiveChat.onlineAgentMessage.type('this_a_test_message_from_visitor');
await poLiveChat.btnSendMessageToOnlineAgent.click();
});

await test.step('Expect to have 1 omnichannel assigned to agent 1', async () => {
await agent.poHomeChannel.sidenav.openChat(newUser.name);
});

await test.step('Expect to be able to create transcript', async () => {
await agent.poHomeChannel.content.btnSendTranscript.click();
await agent.poHomeChannel.content.btnModalConfirm.click();
await expect(agent.poHomeChannel.toastSuccess).toBeVisible();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export class HomeContent {
return this.page.locator('[data-qa-id="ToolBoxAction-balloon-arrow-top-right"]');
}

get btnSendTranscript(): Locator {
return this.page.locator('[data-qa-id="ToolBoxAction-mail-arrow-top-right"]');
}

get inputModalAgentUserName(): Locator {
return this.page.locator('#modal-root input:nth-child(1)');
}
Expand Down