2021-11-27 04:01:41 +08:00
|
|
|
const { expect } = require('@playwright/test');
|
|
|
|
const Page = require('../core/page');
|
|
|
|
const e = require('../core/elements');
|
2023-03-29 22:16:47 +08:00
|
|
|
const { checkVideoUploadData, uploadBackgroundVideoImage, webcamContentCheck } = require('./util');
|
|
|
|
const { VIDEO_LOADING_WAIT_TIME, ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
|
|
|
const { sleep } = require('../core/helpers');
|
2021-11-27 04:01:41 +08:00
|
|
|
|
|
|
|
class Webcam extends Page {
|
|
|
|
constructor(browser, page) {
|
|
|
|
super(browser, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
async share() {
|
2022-03-29 21:53:07 +08:00
|
|
|
const { videoPreviewTimeout, skipVideoPreview, skipVideoPreviewOnFirstJoin } = this.settings;
|
|
|
|
await this.shareWebcam(!(skipVideoPreview || skipVideoPreviewOnFirstJoin), videoPreviewTimeout);
|
2021-11-27 04:01:41 +08:00
|
|
|
await this.hasElement('video');
|
2022-09-13 01:10:57 +08:00
|
|
|
await this.hasElement(e.videoDropdownMenu);
|
|
|
|
await this.waitAndClick(e.leaveVideo);
|
|
|
|
await this.hasElement(e.joinVideo);
|
|
|
|
await this.wasRemoved('video');
|
2021-11-27 04:01:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async checksContent() {
|
2022-03-29 21:53:07 +08:00
|
|
|
const { videoPreviewTimeout, skipVideoPreview, skipVideoPreviewOnFirstJoin } = this.settings;
|
|
|
|
await this.shareWebcam(!(skipVideoPreview || skipVideoPreviewOnFirstJoin), videoPreviewTimeout);
|
2023-03-29 22:16:47 +08:00
|
|
|
await this.waitForSelector(e.webcamVideoItem);
|
|
|
|
await this.wasRemoved(e.webcamConnecting, ELEMENT_WAIT_LONGER_TIME);
|
2021-12-02 12:12:14 +08:00
|
|
|
const respUser = await webcamContentCheck(this);
|
2021-11-27 04:01:41 +08:00
|
|
|
await expect(respUser).toBeTruthy();
|
|
|
|
}
|
|
|
|
|
|
|
|
async talkingIndicator() {
|
|
|
|
await this.webcamLayoutStart();
|
2022-02-03 08:05:26 +08:00
|
|
|
await this.waitForSelector(e.webcamContainer, VIDEO_LOADING_WAIT_TIME);
|
2021-11-27 04:01:41 +08:00
|
|
|
await this.waitForSelector(e.leaveVideo, VIDEO_LOADING_WAIT_TIME);
|
|
|
|
await this.waitForSelector(e.isTalking);
|
|
|
|
await this.hasElement(e.webcamItemTalkingUser);
|
|
|
|
}
|
|
|
|
|
2023-03-29 22:16:47 +08:00
|
|
|
async changeVideoQuality() {
|
|
|
|
const { videoPreviewTimeout } = this.settings;
|
|
|
|
|
|
|
|
const joinWebcamSettingQuality = async (value) => {
|
|
|
|
await this.waitAndClick(e.joinVideo);
|
|
|
|
await this.waitForSelector(e.videoQualitySelector);
|
|
|
|
const langDropdown = await this.page.$(e.videoQualitySelector);
|
|
|
|
await langDropdown.selectOption({ value });
|
|
|
|
await this.waitForSelector(e.videoPreview, videoPreviewTimeout);
|
|
|
|
await this.waitAndClick(e.startSharingWebcam);
|
|
|
|
await this.waitForSelector(e.webcamConnecting);
|
|
|
|
await this.waitForSelector(e.leaveVideo, VIDEO_LOADING_WAIT_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
await joinWebcamSettingQuality('low');
|
|
|
|
await this.waitAndClick(e.connectionStatusBtn);
|
|
|
|
const lowValue = await checkVideoUploadData(this, 0);
|
|
|
|
await this.waitAndClick(e.closeModal);
|
|
|
|
await this.waitAndClick(e.leaveVideo);
|
|
|
|
await joinWebcamSettingQuality('high');
|
|
|
|
await this.waitAndClick(e.connectionStatusBtn);
|
|
|
|
await checkVideoUploadData(this, lowValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
async applyBackground() {
|
|
|
|
await this.waitAndClick(e.joinVideo);
|
|
|
|
await this.waitForSelector(e.noneBackgroundButton);
|
|
|
|
await this.waitAndClick(`${e.selectDefaultBackground}[aria-label="Home"]`);
|
|
|
|
await sleep(1000);
|
|
|
|
await this.waitAndClick(e.startSharingWebcam);
|
|
|
|
await this.waitForSelector(e.webcamContainer);
|
|
|
|
const webcamVideoLocator = await this.getLocator(e.webcamContainer);
|
|
|
|
await expect(webcamVideoLocator).toHaveScreenshot('webcam-with-home-background.png', {
|
|
|
|
maxDiffPixelRatio: 0.1,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async managingNewBackground() {
|
|
|
|
await this.waitAndClick(e.joinVideo);
|
|
|
|
await this.waitForSelector(e.noneBackgroundButton);
|
|
|
|
|
|
|
|
// Upload
|
|
|
|
await uploadBackgroundVideoImage(this);
|
|
|
|
|
|
|
|
// Apply
|
|
|
|
await this.waitAndClick(e.selectCustomBackground);
|
|
|
|
await sleep(1000);
|
|
|
|
await this.waitAndClick(e.startSharingWebcam);
|
|
|
|
await this.waitForSelector(e.webcamContainer);
|
|
|
|
const webcamVideoLocator = await this.getLocator(e.webcamContainer);
|
|
|
|
await expect(webcamVideoLocator).toHaveScreenshot('webcam-with-new-background.png', {
|
|
|
|
maxDiffPixelRatio: 0.1,
|
|
|
|
});
|
|
|
|
|
|
|
|
// Remove
|
|
|
|
await this.waitAndClick(e.videoDropdownMenu);
|
|
|
|
await this.waitAndClick(e.advancedVideoSettingsBtn);
|
|
|
|
await this.waitAndClick(e.removeCustomBackground);
|
|
|
|
await this.wasRemoved(e.selectCustomBackground);
|
|
|
|
}
|
|
|
|
|
|
|
|
async keepScreenshotWhenRejoin(context) {
|
|
|
|
await this.waitAndClick(e.joinVideo);
|
|
|
|
await this.waitForSelector(e.noneBackgroundButton);
|
|
|
|
await uploadBackgroundVideoImage(this);
|
|
|
|
// Create a new page before closing the previous to not close the current context
|
|
|
|
await context.newPage();
|
|
|
|
await this.page.close();
|
|
|
|
const openedPage = await this.getLastTargetPage(context);
|
|
|
|
await openedPage.init(true, true, { meetingId: this.meetingId });
|
|
|
|
await openedPage.waitAndClick(e.joinVideo);
|
|
|
|
await openedPage.hasElement(e.selectCustomBackground);
|
|
|
|
}
|
|
|
|
|
2021-11-27 04:01:41 +08:00
|
|
|
async webcamLayoutStart() {
|
|
|
|
await this.joinMicrophone();
|
2022-03-29 21:53:07 +08:00
|
|
|
const { videoPreviewTimeout, skipVideoPreview, skipVideoPreviewOnFirstJoin } = this.settings;
|
|
|
|
await this.shareWebcam(!(skipVideoPreview || skipVideoPreviewOnFirstJoin), videoPreviewTimeout);
|
2021-11-27 04:01:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-02 12:12:14 +08:00
|
|
|
exports.Webcam = Webcam;
|