2024-12-10 11:22:44 -06:00
|
|
|
import { LOG_PREFIX } from '../helpers/browserLogger';
|
|
|
|
|
|
2024-12-20 06:17:49 -06:00
|
|
|
import BasePageObject from './BasePageObject';
|
|
|
|
|
|
2024-12-10 11:22:44 -06:00
|
|
|
/**
|
|
|
|
|
* The Iframe API and helpers from iframeAPITest.html
|
|
|
|
|
*/
|
2024-12-20 06:17:49 -06:00
|
|
|
export default class IframeAPI extends BasePageObject {
|
2024-12-10 11:22:44 -06:00
|
|
|
/**
|
|
|
|
|
* Returns the json object from the iframeAPI helper.
|
|
|
|
|
* @param event
|
|
|
|
|
*/
|
|
|
|
|
async getEventResult(event: string): Promise<any> {
|
2024-12-12 08:29:15 -06:00
|
|
|
return await this.participant.driver.execute(
|
2024-12-10 11:22:44 -06:00
|
|
|
eventName => {
|
|
|
|
|
const result = window.jitsiAPI.test[eventName];
|
|
|
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}, event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds an event listener to the iframeAPI.
|
|
|
|
|
* @param eventName The event name.
|
|
|
|
|
*/
|
|
|
|
|
async addEventListener(eventName: string) {
|
2024-12-12 08:29:15 -06:00
|
|
|
return await this.participant.driver.execute(
|
|
|
|
|
(event, prefix) => {
|
|
|
|
|
console.log(`${new Date().toISOString()} ${prefix} Adding listener for event: ${event}`);
|
|
|
|
|
window.jitsiAPI.addListener(event, evt => {
|
|
|
|
|
console.log(
|
|
|
|
|
`${new Date().toISOString()} ${prefix} Received ${event} event: ${JSON.stringify(evt)}`);
|
|
|
|
|
window.jitsiAPI.test[event] = evt;
|
|
|
|
|
});
|
|
|
|
|
}, eventName, LOG_PREFIX);
|
2024-12-10 11:22:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns an array of available rooms and details of it.
|
|
|
|
|
*/
|
|
|
|
|
async getRoomsInfo() {
|
2024-12-12 08:29:15 -06:00
|
|
|
return await this.participant.driver.execute(() => window.jitsiAPI.getRoomsInfo());
|
2024-12-10 11:22:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the number of participants in the conference.
|
|
|
|
|
*/
|
|
|
|
|
async getNumberOfParticipants() {
|
2024-12-12 08:29:15 -06:00
|
|
|
return await this.participant.driver.execute(() => window.jitsiAPI.getNumberOfParticipants());
|
2024-12-10 11:22:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Executes command using iframeAPI.
|
|
|
|
|
* @param command The command.
|
|
|
|
|
* @param args The arguments.
|
|
|
|
|
*/
|
|
|
|
|
async executeCommand(command: string, ...args: any[]) {
|
2024-12-12 08:29:15 -06:00
|
|
|
return await this.participant.driver.execute(
|
2024-12-10 11:22:44 -06:00
|
|
|
(commandName, commandArgs) =>
|
|
|
|
|
window.jitsiAPI.executeCommand(commandName, ...commandArgs)
|
|
|
|
|
, command, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the current state of the participant's pane.
|
|
|
|
|
*/
|
|
|
|
|
async isParticipantsPaneOpen() {
|
2024-12-12 08:29:15 -06:00
|
|
|
return await this.participant.driver.execute(() => window.jitsiAPI.isParticipantsPaneOpen());
|
2024-12-10 11:22:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes the embedded Jitsi Meet conference.
|
|
|
|
|
*/
|
|
|
|
|
async dispose() {
|
2024-12-12 08:29:15 -06:00
|
|
|
return await this.participant.driver.execute(() => window.jitsiAPI.dispose());
|
2024-12-10 11:22:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|