forked from webex/widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutdial-call-test.spec.ts
More file actions
75 lines (66 loc) · 3.67 KB
/
outdial-call-test.spec.ts
File metadata and controls
75 lines (66 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import {test, expect} from '@playwright/test';
import {changeUserState, verifyCurrentState} from '../Utils/userStateUtils';
import {acceptExtensionCall, endCallTask} from '../Utils/incomingTaskUtils';
import {USER_STATES, WRAPUP_REASONS} from '../constants';
import {submitWrapup, waitForWrapupAfterCallEnd} from '../Utils/wrapupUtils';
import {waitForState} from '../Utils/helperUtils';
import {TestManager} from '../test-manager';
import {enterOutdialNumber, clickOutdialButton, acceptCustomerCall} from '../Utils/outdialUtils';
export default function createOutdialCallTests() {
test.describe('Outdial Call - Desktop Mode', () => {
let testManager: TestManager;
test.beforeAll(async ({browser}, testInfo) => {
const projectName = testInfo.project.name;
testManager = new TestManager(projectName);
await testManager.setupForOutdialDesktop(browser);
});
test('should make an outdial call in Desktop mode and complete wrapup', async () => {
test.skip(!process.env.PW_DIAL_NUMBER, 'PW_DIAL_NUMBER not set');
await changeUserState(testManager.agent1Page, USER_STATES.AVAILABLE);
await expect(testManager.agent1Page.getByTestId('outdial-call-container')).toBeVisible();
await enterOutdialNumber(testManager.agent1Page, process.env.PW_DIAL_NUMBER!);
await clickOutdialButton(testManager.agent1Page);
await acceptCustomerCall(testManager.callerPage);
await waitForState(testManager.agent1Page, USER_STATES.ENGAGED);
await verifyCurrentState(testManager.agent1Page, USER_STATES.ENGAGED);
await testManager.agent1Page.waitForTimeout(3000);
await testManager.agent1Page.getByTestId('call-control:end-call').first().click({timeout: 5000});
await testManager.agent1Page.waitForTimeout(2000);
await submitWrapup(testManager.agent1Page, WRAPUP_REASONS.SALE);
await waitForState(testManager.agent1Page, USER_STATES.AVAILABLE);
await verifyCurrentState(testManager.agent1Page, USER_STATES.AVAILABLE);
});
test.afterAll(async () => {
await testManager.cleanup();
});
});
test.describe('Outdial Call - Extension Mode', () => {
let testManager: TestManager;
test.beforeAll(async ({browser}, testInfo) => {
const projectName = testInfo.project.name;
testManager = new TestManager(projectName);
await testManager.setupForOutdialExtension(browser);
});
test('should make an outdial call in Extension mode and complete wrapup', async () => {
test.skip(!process.env.PW_DIAL_NUMBER, 'PW_DIAL_NUMBER not set');
await changeUserState(testManager.agent1Page, USER_STATES.AVAILABLE);
await expect(testManager.agent1Page.getByTestId('outdial-call-container')).toBeVisible();
await enterOutdialNumber(testManager.agent1Page, process.env.PW_DIAL_NUMBER!);
await clickOutdialButton(testManager.agent1Page);
await expect(testManager.agent1ExtensionPage.locator('#answer').first()).toBeEnabled({timeout: 40000});
await acceptExtensionCall(testManager.agent1ExtensionPage);
await acceptCustomerCall(testManager.callerPage);
await waitForState(testManager.agent1Page, USER_STATES.ENGAGED);
await verifyCurrentState(testManager.agent1Page, USER_STATES.ENGAGED);
await testManager.agent1Page.waitForTimeout(3000);
await endCallTask(testManager.agent1ExtensionPage);
await waitForWrapupAfterCallEnd(testManager.agent1Page);
await submitWrapup(testManager.agent1Page, WRAPUP_REASONS.SALE);
await waitForState(testManager.agent1Page, USER_STATES.AVAILABLE);
await verifyCurrentState(testManager.agent1Page, USER_STATES.AVAILABLE);
});
test.afterAll(async () => {
await testManager.cleanup();
});
});
}