bigbluebutton-Github/bigbluebutton-tests/playwright/webcam/webcam.js

158 lines
6.7 KiB
JavaScript
Raw Normal View History

2021-11-27 04:01:41 +08:00
const { expect } = require('@playwright/test');
const Page = require('../core/page');
const e = require('../core/elements');
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);
await this.hasElement('video', 'should display the element video');
await this.hasElement(e.videoDropdownMenu, 'should display the video dropdown menu');
await this.waitAndClick(e.leaveVideo);
await this.hasElement(e.joinVideo, 'should display the join video button');
await this.wasRemoved('video', 'should not display the video element');
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);
await this.waitForSelector(e.webcamVideoItem);
await this.wasRemoved(e.webcamConnecting, 'should not display the webcam connecting element', ELEMENT_WAIT_LONGER_TIME);
const respUser = await webcamContentCheck(this);
await expect(respUser, 'should display the user webcam').toBeTruthy();
2021-11-27 04:01:41 +08:00
}
async talkingIndicator() {
await this.webcamLayoutStart();
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, 'should display the webcam item talking user');
2021-11-27 04:01:41 +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.waitAndClick(e.backgroundSettingsTitle);
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');
}
2023-03-30 00:49:22 +08:00
async webcamFullscreen() {
await this.shareWebcam();
// get default viewport sizes
const { windowWidth, windowHeight } = await this.page.evaluate(() => {
return {
windowWidth: window.innerWidth,
windowHeight: window.innerHeight,
}
});
await this.waitAndClick(e.dropdownWebcamButton);
await this.waitAndClick(e.webcamsFullscreenButton);
2023-03-30 00:49:22 +08:00
// get fullscreen webcam size
const { width, height } = await this.getLocator('video').boundingBox();
await expect(width + 1, 'should the width to be the same as window width').toBe(windowWidth); // not sure why there is a difference of 1 pixel
await expect(height, 'should the height to be the same as window height').toBe(windowHeight);
2023-03-30 00:49:22 +08:00
}
2023-10-03 19:47:50 +08:00
async disableSelfView() {
await this.waitAndClick(e.joinVideo);
await this.waitAndClick(e.backgroundSettingsTitle);
2023-10-03 19:47:50 +08:00
await this.waitForSelector(e.noneBackgroundButton);
await uploadBackgroundVideoImage(this);
await this.waitAndClick(e.selectCustomBackground);
await sleep(1000);
await this.waitAndClick(e.startSharingWebcam);
await this.waitForSelector(e.webcamContainer);
await this.waitAndClick(e.dropdownWebcamButton);
await this.waitAndClick(e.selfViewDisableBtn);
const webcamVideoLocator = await this.getLocator(e.webcamConnecting);
await expect(webcamVideoLocator).toHaveScreenshot('disable-self-view.png');
}
async managingNewBackground() {
await this.waitAndClick(e.joinVideo);
await this.waitAndClick(e.backgroundSettingsTitle);
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');
// Remove
await this.waitAndClick(e.videoDropdownMenu);
await this.waitAndClick(e.advancedVideoSettingsBtn);
await this.waitAndClick(e.backgroundSettingsTitle);
await this.waitAndClick(e.removeCustomBackground);
await this.wasRemoved(e.selectCustomBackground, 'should not display the select custom background');
}
2023-03-30 00:56:53 +08:00
async keepBackgroundWhenRejoin(context) {
await this.waitAndClick(e.joinVideo);
await this.waitAndClick(e.backgroundSettingsTitle);
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.waitAndClick(e.backgroundSettingsTitle);
await openedPage.hasElement(e.selectCustomBackground, 'should display the select custom background');
}
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
}
}
exports.Webcam = Webcam;