fix currentUser selector and fix the presenter verification

This commit is contained in:
Anton B 2022-03-01 17:11:45 -03:00
parent 94ea254d21
commit 774c623b30
11 changed files with 31 additions and 36 deletions

View File

@ -429,8 +429,8 @@ class UserListItem extends PureComponent {
&& !showNestedOptions, && !showNestedOptions,
key: 'changeWhiteboardAccess', key: 'changeWhiteboardAccess',
label: user.whiteboardAccess label: user.whiteboardAccess
? intl.formatMessage(messages.removeWhiteboardAccess) ? intl.formatMessage(messages.removeWhiteboardAccess)
: intl.formatMessage(messages.giveWhiteboardAccess), : intl.formatMessage(messages.giveWhiteboardAccess),
onClick: () => { onClick: () => {
WhiteboardService.changeWhiteboardAccess(user.userId, !user.whiteboardAccess); WhiteboardService.changeWhiteboardAccess(user.userId, !user.whiteboardAccess);
this.handleClose(); this.handleClose();
@ -525,7 +525,7 @@ class UserListItem extends PureComponent {
this.handleClose(); this.handleClose();
}, },
icon: 'video_off', icon: 'video_off',
} },
]; ];
const statuses = Object.keys(getEmojiList); const statuses = Object.keys(getEmojiList);
@ -542,10 +542,10 @@ class UserListItem extends PureComponent {
}, },
icon: getEmojiList[s], icon: getEmojiList[s],
dataTest: s, dataTest: s,
}) });
}); });
return availableActions.filter(action => action.allowed); return availableActions.filter((action) => action.allowed);
} }
getDropdownMenuParent() { getDropdownMenuParent() {
@ -713,7 +713,7 @@ class UserListItem extends PureComponent {
const innerContents = ( const innerContents = (
<Styled.UserItemInnerContents> <Styled.UserItemInnerContents>
<Styled.UserAvatar data-test="userAvatar"> <Styled.UserAvatar data-test="userAvatar" data-test-presenter={user.presenter ? '' : undefined}>
{this.renderUserAvatar()} {this.renderUserAvatar()}
</Styled.UserAvatar> </Styled.UserAvatar>
{!compact {!compact

View File

@ -197,7 +197,7 @@ exports.setStatus = 'li[data-test="setStatus"]';
exports.away = 'li[data-test="away"]'; exports.away = 'li[data-test="away"]';
exports.applaud = 'li[data-test="applause"]'; exports.applaud = 'li[data-test="applause"]';
exports.userListItem = 'div[data-test="userListItem"]'; exports.userListItem = 'div[data-test="userListItem"]';
exports.firstUser = 'div[data-test="userListItemCurrent"]'; exports.currentUser = 'div[data-test="userListItemCurrent"]';
exports.multiWhiteboardTool = 'span[data-test="multiWhiteboardTool"]'; exports.multiWhiteboardTool = 'span[data-test="multiWhiteboardTool"]';
exports.manageUsers = 'button[data-test="manageUsers"]'; exports.manageUsers = 'button[data-test="manageUsers"]';
exports.presenterClassName = 'presenter--'; exports.presenterClassName = 'presenter--';

View File

@ -110,7 +110,7 @@ class Page {
async type(selector, text) { async type(selector, text) {
const handle = this.getLocator(selector); const handle = this.getLocator(selector);
await handle.focus(); await handle.focus();
await handle.type(text); await handle.type(text, { timeout: ELEMENT_WAIT_TIME });
} }
async waitAndClickElement(element, index = 0, timeout = ELEMENT_WAIT_TIME) { async waitAndClickElement(element, index = 0, timeout = ELEMENT_WAIT_TIME) {

View File

@ -8,10 +8,5 @@ function checkElementLengthEqualTo([element, count]) {
return document.querySelectorAll(element).length == count; return document.querySelectorAll(element).length == count;
} }
function checkIncludeClass([selector, className]) {
return document.querySelectorAll(`${selector} > div`)[0].className.includes(className);
}
exports.checkElement = checkElement; exports.checkElement = checkElement;
exports.checkElementLengthEqualTo = checkElementLengthEqualTo; exports.checkElementLengthEqualTo = checkElementLengthEqualTo;
exports.checkIncludeClass = checkIncludeClass;

View File

@ -9,7 +9,6 @@ class ScreenShare extends Page {
async startSharing() { async startSharing() {
await startScreenshare(this); await startScreenshare(this);
await getScreenShareBreakoutContainer(this);
await this.hasElement(e.isSharingScreen); await this.hasElement(e.isSharingScreen);
} }

View File

@ -2,7 +2,7 @@ const { expect } = require('@playwright/test');
const Page = require('../core/page'); const Page = require('../core/page');
const e = require('../core/elements'); const e = require('../core/elements');
const c = require('../core/constants'); const c = require('../core/constants');
const { checkPresenterClass } = require('../user/util'); const { checkIsPresenter } = require('../user/util');
class Stress { class Stress {
constructor(browser, context, page) { constructor(browser, context, page) {
@ -18,10 +18,10 @@ class Stress {
for (let i = 1; i <= c.JOIN_AS_MODERATOR_TEST_ROUNDS; i++) { for (let i = 1; i <= c.JOIN_AS_MODERATOR_TEST_ROUNDS; i++) {
await this.modPage.init(true, true, { fullName: `Moderator-${i}` }); await this.modPage.init(true, true, { fullName: `Moderator-${i}` });
await this.modPage.waitForSelector(e.userAvatar); await this.modPage.waitForSelector(e.userAvatar);
const hasPresenterClass = await checkPresenterClass(this.modPage); const isPresenter = await checkIsPresenter(this.modPage);
await this.modPage.waitAndClick(e.actions); await this.modPage.waitAndClick(e.actions);
const canStartPoll = await this.modPage.checkElement(e.polling); const canStartPoll = await this.modPage.checkElement(e.polling);
if (!hasPresenterClass || !canStartPoll) { if (!isPresenter || !canStartPoll) {
failureCount++; failureCount++;
} }

View File

@ -87,7 +87,7 @@ class LockViewers extends MultiUsers {
await this.userPage.waitForSelector(e.hideNotesLabel); await this.userPage.waitForSelector(e.hideNotesLabel);
const sharedNotesLocator = getNotesLocator(this.userPage); const sharedNotesLocator = getNotesLocator(this.userPage);
await sharedNotesLocator.type(e.message); await sharedNotesLocator.type(e.message);
expect(sharedNotesLocator).toContainText(e.message); expect(sharedNotesLocator).toContainText(e.message, { timeout: ELEMENT_WAIT_TIME });
await openLockViewers(this.modPage); await openLockViewers(this.modPage);
await this.modPage.waitAndClickElement(e.lockEditSharedNotes); await this.modPage.waitAndClickElement(e.lockEditSharedNotes);
@ -95,8 +95,8 @@ class LockViewers extends MultiUsers {
await this.userPage.waitAndClick(e.sharedNotes); await this.userPage.waitAndClick(e.sharedNotes);
await this.userPage.waitAndClick(e.sharedNotes); await this.userPage.waitAndClick(e.sharedNotes);
// tries to type, but the element is not editable // tries to type, but the element is not editable
await sharedNotesLocator.type(e.testMessage); await sharedNotesLocator.type(e.testMessage, { timeout: ELEMENT_WAIT_TIME });
await expect(sharedNotesLocator).not.toContainText(e.testMessage); await expect(sharedNotesLocator).not.toContainText(e.testMessage, { timeout: ELEMENT_WAIT_TIME });
} }
async lockSeeOtherViewersUserList() { async lockSeeOtherViewersUserList() {

View File

@ -8,7 +8,7 @@ class MobileDevices extends MultiUsers {
async mobileTagName() { async mobileTagName() {
await this.modPage.waitAndClick(e.userListToggleBtn); await this.modPage.waitAndClick(e.userListToggleBtn);
await this.modPage.waitForSelector(e.firstUser); await this.modPage.waitForSelector(e.currentUser);
await this.modPage.hasElement(e.mobileUser); await this.modPage.hasElement(e.mobileUser);
} }

View File

@ -3,7 +3,7 @@ const Page = require('../core/page');
const e = require('../core/elements'); const e = require('../core/elements');
const { waitAndClearNotification } = require('../notifications/util'); const { waitAndClearNotification } = require('../notifications/util');
const { sleep } = require('../core/helpers'); const { sleep } = require('../core/helpers');
const { checkAvatarIcon, checkPresenterClass } = require('./util'); const { checkAvatarIcon, checkIsPresenter } = require('./util');
class MultiUsers { class MultiUsers {
constructor(browser, context) { constructor(browser, context) {
@ -63,9 +63,9 @@ class MultiUsers {
} }
async userPresence() { async userPresence() {
const firstUserOnModPage = this.modPage.getLocator(e.firstUser); const firstUserOnModPage = this.modPage.getLocator(e.currentUser);
const secondUserOnModPage = this.modPage.getLocator(e.userListItem); const secondUserOnModPage = this.modPage.getLocator(e.userListItem);
const firstUserOnUserPage = this.userPage.getLocator(e.firstUser); const firstUserOnUserPage = this.userPage.getLocator(e.currentUser);
const secondUserOnUserPage = this.userPage.getLocator(e.userListItem); const secondUserOnUserPage = this.userPage.getLocator(e.userListItem);
await expect(firstUserOnModPage).toHaveCount(1); await expect(firstUserOnModPage).toHaveCount(1);
await expect(secondUserOnModPage).toHaveCount(1); await expect(secondUserOnModPage).toHaveCount(1);
@ -81,19 +81,19 @@ class MultiUsers {
await this.userPage.hasElement(e.presentationToolbarWrapper); await this.userPage.hasElement(e.presentationToolbarWrapper);
await this.userPage.hasElement(e.toolsButton); await this.userPage.hasElement(e.toolsButton);
await this.userPage.hasElement(e.actions); await this.userPage.hasElement(e.actions);
const hasPresenterClass = await checkPresenterClass(this.userPage); const isPresenter = await checkIsPresenter(this.userPage);
expect(hasPresenterClass).toBeTruthy(); expect(isPresenter).toBeTruthy();
} }
async takePresenter() { async takePresenter() {
await this.modPage2.waitAndClick(e.firstUser); await this.modPage2.waitAndClick(e.currentUser);
await this.modPage2.waitAndClick(e.takePresenter); await this.modPage2.waitAndClick(e.takePresenter);
await this.modPage2.hasElement(e.startScreenSharing); await this.modPage2.hasElement(e.startScreenSharing);
await this.modPage2.hasElement(e.toolsButton); await this.modPage2.hasElement(e.toolsButton);
await this.modPage2.hasElement(e.presentationToolbarWrapper); await this.modPage2.hasElement(e.presentationToolbarWrapper);
const hasPresenterClass = await checkPresenterClass(this.modPage2); const isPresenter = await checkIsPresenter(this.modPage2);
expect(hasPresenterClass).toBeTruthy(); expect(isPresenter).toBeTruthy();
await this.modPage2.waitAndClick(e.actions); await this.modPage2.waitAndClick(e.actions);
await this.modPage2.hasElement(e.managePresentations); await this.modPage2.hasElement(e.managePresentations);
await this.modPage2.hasElement(e.polling); await this.modPage2.hasElement(e.polling);

View File

@ -21,7 +21,7 @@ class Status extends Page {
async mobileTagName() { async mobileTagName() {
await this.waitAndClick(e.userListToggleBtn); await this.waitAndClick(e.userListToggleBtn);
await this.waitForSelector(e.firstUser); await this.waitForSelector(e.currentUser);
await this.hasElement(e.mobileUser); await this.hasElement(e.mobileUser);
} }
} }

View File

@ -1,8 +1,7 @@
const e = require('../core/elements'); const e = require('../core/elements');
const { checkIncludeClass } = require('../core/util');
async function setStatus(page, status) { async function setStatus(page, status) {
await page.waitAndClick(e.firstUser); await page.waitAndClick(e.currentUser);
await page.waitAndClick(e.setStatus); await page.waitAndClick(e.setStatus);
await page.waitAndClick(status); await page.waitAndClick(status);
} }
@ -19,15 +18,17 @@ async function setGuestPolicyOption(test, option) {
} }
async function checkAvatarIcon(test, checkModIcon = true) { async function checkAvatarIcon(test, checkModIcon = true) {
await test.hasElement(`${e.firstUser} ${checkModIcon ? e.moderatorAvatar : e.viewerAvatar}`); await test.hasElement(`${e.currentUser} ${checkModIcon ? e.moderatorAvatar : e.viewerAvatar}`);
} }
async function checkPresenterClass(test) { async function checkIsPresenter(test) {
return test.page.evaluate(checkIncludeClass, [e.userAvatar, e.presenterClassName]); return test.page.evaluate(([currentAvatarSelector, userAvatarSelector]) => {
return document.querySelectorAll(`${currentAvatarSelector} ${userAvatarSelector}`)[0].hasAttribute('data-test-presenter')
}, [e.currentUser, e.userAvatar])
} }
exports.setStatus = setStatus; exports.setStatus = setStatus;
exports.openLockViewers = openLockViewers; exports.openLockViewers = openLockViewers;
exports.setGuestPolicyOption = setGuestPolicyOption; exports.setGuestPolicyOption = setGuestPolicyOption;
exports.checkAvatarIcon = checkAvatarIcon; exports.checkAvatarIcon = checkAvatarIcon;
exports.checkPresenterClass = checkPresenterClass; exports.checkIsPresenter = checkIsPresenter;