Skip to content

Commit

Permalink
Merge pull request #15236 from BrentBaccala/test-suite-updates
Browse files Browse the repository at this point in the history
test: Various test suite updates
  • Loading branch information
antobinary committed Jul 27, 2022
2 parents 2ea3bdb + 279c3e7 commit 9371d20
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
10 changes: 10 additions & 0 deletions bigbluebutton-tests/playwright/core/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,21 @@ class Page {
await expect(locator).toBeHidden({ timeout });
}

async wasNthElementRemoved(selector, count, timeout = ELEMENT_WAIT_TIME) {
const locator = this.getLocator(':nth-match(' + selector + ',' + count + ')');
await expect(locator).toBeHidden({ timeout });
}

async hasElement(selector, timeout = ELEMENT_WAIT_TIME) {
const locator = this.getLocator(selector);
await expect(locator).toBeVisible({ timeout });
}

async hasNElements(selector, count, timeout = ELEMENT_WAIT_TIME) {
const locator = this.getLocator(':nth-match(' + selector + ',' + count + ')');
await expect(locator).toBeVisible({ timeout });
}

async hasElementDisabled(selector, timeout = ELEMENT_WAIT_TIME) {
const locator = this.getLocator(selector);
await expect(locator).toBeDisabled({ timeout });
Expand Down
9 changes: 7 additions & 2 deletions bigbluebutton-tests/playwright/user/lockViewers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@ class LockViewers extends MultiUsers {

async lockShareWebcam() {
await this.modPage.shareWebcam();
await this.modPage.hasElement(e.webcamVideoItem);
await this.userPage.hasElement(e.webcamVideoItem);
await this.userPage2.hasElement(e.webcamVideoItem);
await this.userPage.shareWebcam();
await this.modPage.hasNElements(e.webcamVideoItem, 2);
await this.userPage.hasNElements(e.webcamVideoItem, 2);
await this.userPage2.hasNElements(e.webcamVideoItem, 2);
await openLockViewers(this.modPage);
await this.modPage.waitAndClickElement(e.lockShareWebcam);
await this.modPage.waitAndClick(e.applyLockSettings);
await waitAndClearNotification(this.modPage);
const videoContainerLockedCount = await this.userPage2.getSelectorCount(e.webcamVideoItem);
expect(videoContainerLockedCount).toBe(1);
await this.modPage.wasNthElementRemoved(e.webcamVideoItem, 2);
await this.userPage.wasNthElementRemoved(e.webcamVideoItem, 2);
await this.userPage2.wasNthElementRemoved(e.webcamVideoItem, 2);

await this.userPage2.waitForSelector(e.dropdownWebcamButton);
await this.userPage2.hasText(e.dropdownWebcamButton, this.modPage.username);
Expand Down
3 changes: 2 additions & 1 deletion bigbluebutton-tests/playwright/user/status.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Page = require('../core/page');
const { setStatus } = require('./util');
const { waitAndClearNotification } = require('../notifications/util');
const { waitAndClearNotification, waitAndClearDefaultPresentationNotification } = require('../notifications/util');
const e = require('../core/elements');

class Status extends Page {
Expand All @@ -9,6 +9,7 @@ class Status extends Page {
}

async changeUserStatus() {
await waitAndClearDefaultPresentationNotification(this);
await setStatus(this, e.applaud);
await this.waitForSelector(e.smallToastMsg);
await this.checkElement(e.applauseIcon);
Expand Down
22 changes: 13 additions & 9 deletions bigbluebutton-tests/playwright/webcam/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,41 @@ const e = require('../core/elements');
const { sleep } = require('../core/helpers');
const { LOOP_INTERVAL, ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');

// loop 5 times, every LOOP_INTERVAL milliseconds, and check that all
// videos displayed are changing by comparing a hash of their
// displayed contents

async function webcamContentCheck(test) {
await test.waitForSelector(e.webcamVideoItem);
await test.wasRemoved(e.webcamConnecting, ELEMENT_WAIT_LONGER_TIME);
const repeats = 5;
let check;
for (let i = repeats; i >= 1; i--) {
console.log(`loop ${i}`);
const checkCameras = () => {
const checkCameras = async () => {
const videos = document.querySelectorAll('video');
const lastVideoColor = document.lastVideoColor || {};
document.lastVideoColor = lastVideoColor;
const lastVideoHash = document.lastVideoHash || {};
document.lastVideoHash = lastVideoHash;

for (let v = 0; v < videos.length; v++) {
const video = videos[v];
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
const pixel = context.getImageData(0, 0, 1, 1).data;
const pixelString = new Array(pixel).join(' ').toString();
const pixel = context.getImageData(0, 0, video.videoWidth, video.videoHeight).data;
const pixelHash = await window.crypto.subtle.digest('SHA-1', pixel);

if (lastVideoColor[v]) {
if (lastVideoColor[v] == pixelString) {
if (lastVideoHash[v]) {
if (lastVideoHash[v] == pixelHash) {
return false;
}
}
lastVideoColor[v] = pixelString;
lastVideoHash[v] = pixelHash;
}
return true;
};

check = await test.page.evaluate(checkCameras, i);
check = await test.page.evaluate(checkCameras);
if (!check) return false;
await sleep(LOOP_INTERVAL);
}
Expand Down

0 comments on commit 9371d20

Please sign in to comment.