forked from webex/widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutdialUtils.ts
More file actions
50 lines (46 loc) · 2.21 KB
/
outdialUtils.ts
File metadata and controls
50 lines (46 loc) · 2.21 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
import {Page, expect} from '@playwright/test';
import {ACCEPT_TASK_TIMEOUT, AWAIT_TIMEOUT, UI_SETTLE_TIMEOUT} from '../constants';
/**
* Enters a phone number into the outdial number input field.
* Prerequisite: Agent must be logged in and outdial-call-container must be visible.
* @param page Playwright Page object (agent widget page)
* @param number Phone number to dial (e.g., +14698041796)
*/
export async function enterOutdialNumber(page: Page, number: string): Promise<void> {
await page.bringToFront();
await expect(page.getByTestId('outdial-call-container')).toBeVisible({timeout: AWAIT_TIMEOUT});
const input = page.getByTestId('outdial-number-input').locator('input');
await input.fill(number, {timeout: AWAIT_TIMEOUT});
}
/**
* Clicks the outdial call button to initiate the outbound call.
* Prerequisite: A valid number must be entered in the outdial input.
* @param page Playwright Page object (agent widget page)
*/
export async function clickOutdialButton(page: Page): Promise<void> {
await page.bringToFront();
const dialButton = page.getByTestId('outdial-call-button');
await expect(dialButton).toBeEnabled({timeout: AWAIT_TIMEOUT});
await dialButton.click({timeout: AWAIT_TIMEOUT});
}
/**
* Accepts an incoming call on the customer's Webex Calling web client.
* Used for outdial scenarios where the customer receives the outbound call.
* @param customerPage Playwright Page object (customer's Webex Calling web client)
*/
export async function acceptCustomerCall(customerPage: Page): Promise<void> {
await customerPage.bringToFront();
await expect(customerPage.locator('#answer').first()).toBeEnabled({timeout: ACCEPT_TASK_TIMEOUT});
await customerPage.waitForTimeout(UI_SETTLE_TIMEOUT);
await customerPage.locator('#answer').first().click({timeout: AWAIT_TIMEOUT});
}
/**
* Ends the call on the customer's Webex Calling web client.
* @param customerPage Playwright Page object (customer's Webex Calling web client)
*/
export async function endCustomerCall(customerPage: Page): Promise<void> {
await customerPage.bringToFront();
const endBtn = customerPage.locator('#end-call').first();
await expect(endBtn).toBeEnabled({timeout: AWAIT_TIMEOUT});
await endBtn.click({timeout: AWAIT_TIMEOUT});
}