bigbluebutton-Github/bigbluebutton-tests/playwright/polling/poll.js

347 lines
19 KiB
JavaScript
Raw Normal View History

const { expect } = require('@playwright/test');
const { MultiUsers } = require('../user/multiusers');
2021-11-26 02:23:58 +08:00
const e = require('../core/elements');
const util = require('./util.js');
const { ELEMENT_WAIT_LONGER_TIME, ELEMENT_WAIT_TIME } = require('../core/constants');
2022-06-08 02:52:22 +08:00
const { getSettings } = require('../core/settings');
const { skipSlide } = require('../presentation/util');
const { sleep } = require('../core/helpers.js');
2021-11-26 02:23:58 +08:00
class Polling extends MultiUsers {
2021-11-26 02:23:58 +08:00
constructor(browser, context) {
super(browser, context);
2021-11-26 02:23:58 +08:00
this.newInputText = 'new option';
}
async createPoll() {
await util.startPoll(this.modPage);
await this.modPage.hasElement(e.pollMenuButton, 'should display the poll menu button after starting the poll');
await this.modPage.hasElement(e.publishPollingLabel, 'should display the publish poll button');
await this.modPage.hasElement(e.cancelPollBtn, 'should display the cancel poll button after the poll creation');
await this.userPage.hasElement(e.pollingContainer, 'should display the poll container for the attendee');
2023-04-28 20:30:29 +08:00
await this.modPage.waitAndClick(e.closePollingBtn);
await this.modPage.wasRemoved(e.closePollingBtn, 'should not display the close poll button after clicking to close the poll');
2021-11-26 02:23:58 +08:00
}
async pollAnonymous() {
await this.modPage.hasElement(e.whiteboard, 'should display the whiteboard', ELEMENT_WAIT_LONGER_TIME);
2024-03-05 00:44:47 +08:00
await util.startPoll(this.modPage, true);
await this.modPage.hasElement(e.publishPollingLabel, 'should display the poll publish button after the poll starts');
2021-11-26 02:23:58 +08:00
await this.userPage.waitAndClick(e.pollAnswerOptionBtn);
await this.userPage.wasRemoved(e.receivedAnswer, 'should not display the received answer for the attendee');
2023-04-28 20:30:29 +08:00
await this.modPage.waitAndClick(e.closePollingBtn);
await this.modPage.wasRemoved(e.closePollingBtn, 'should not display the close poll button after the poll closes');
2021-11-26 02:23:58 +08:00
}
async quickPoll() {
await util.uploadSPresentationForTestingPolls(this.modPage, e.questionSlideFileName);
2021-11-26 02:23:58 +08:00
// The slide needs to be uploaded and converted, so wait a bit longer for this step
await this.modPage.waitAndClick(e.quickPoll, ELEMENT_WAIT_LONGER_TIME);
await this.modPage.hasElement(e.pollMenuButton, 'should display the poll menu button');
2021-11-26 02:23:58 +08:00
await this.userPage.hasElement(e.pollingContainer, 'should display the polling container for the attendeee to answer it');
2023-04-28 20:30:29 +08:00
await this.modPage.waitAndClick(e.closePollingBtn);
await this.modPage.wasRemoved(e.closePollingBtn, 'should not display the close poll button after the poll closes');
2021-11-26 02:23:58 +08:00
}
async pollUserResponse() {
await this.modPage.hasElement(e.whiteboard, 'should display the whiteboard for the moderator');
2021-11-26 02:23:58 +08:00
await util.openPoll(this.modPage);
await this.modPage.type(e.pollQuestionArea, e.pollQuestion);
await this.modPage.waitAndClick(e.userResponseBtn);
await this.modPage.waitAndClick(e.startPoll);
await this.userPage.hasElement(e.pollingContainer, 'should display the polling container for the user to answer it');
2021-11-26 02:23:58 +08:00
await this.userPage.type(e.pollAnswerOptionInput, e.answerMessage);
await this.userPage.waitAndClick(e.pollSubmitAnswer);
await this.modPage.hasText(e.userVoteLiveResult, e.answerMessage, 'should display the answer sent by the attendee');
2021-11-26 02:23:58 +08:00
await this.modPage.waitAndClick(e.publishPollingLabel);
await this.modPage.wasRemoved(e.pollingContainer, 'should close the polling container after publishing the label');
2021-11-26 02:23:58 +08:00
await this.modPage.hasElement(e.wbPollShape, ELEMENT_WAIT_LONGER_TIME);
await this.userPage.hasElement(e.wbPollShape);
2021-11-26 02:23:58 +08:00
}
async stopPoll() {
await this.modPage.hasElement(e.whiteboard, 'should display the whiteboard for the moderator', ELEMENT_WAIT_LONGER_TIME);
2021-11-26 02:23:58 +08:00
await util.startPoll(this.modPage);
await this.userPage.hasElement(e.pollingContainer, 'should display the polling container for the attendeee after the poll is created');
2021-11-26 02:23:58 +08:00
await this.modPage.waitAndClick(e.cancelPollBtn);
await this.userPage.wasRemoved(e.pollingContainer, 'should not display the polling container after the poll is canceled');
2022-03-29 21:53:07 +08:00
2023-04-28 20:30:29 +08:00
await this.modPage.waitAndClick(e.closePollingBtn);
await this.modPage.wasRemoved(e.closePollingBtn, 'should not display the close polling button for the moderator after the poll is closed');
2021-11-26 02:23:58 +08:00
}
async manageResponseChoices() {
await this.modPage.hasElement(e.whiteboard, 'should display the whiteboard for the moderator', ELEMENT_WAIT_LONGER_TIME);
2021-11-26 02:23:58 +08:00
await this.startNewPoll();
const initialRespCount = await this.modPage.getSelectorCount(e.pollOptionItem);
// Add
await this.modPage.waitAndClick(e.addPollItem);
await this.typeOnLastChoiceInput();
await this.modPage.waitAndClick(e.startPoll);
await expect(initialRespCount + 1, 'should display the initial quantity of poll options itens plus 1').toEqual(await this.getAnswerOptionCount());
2021-11-26 02:23:58 +08:00
await this.checkLastOptionText();
// Delete
await this.startNewPoll();
await this.modPage.waitAndClick(e.deletePollOption);
await this.modPage.waitAndClick(e.startPoll);
await expect(initialRespCount - 1, 'should display the initial quantity of poll options itens minus 1').toEqual(await this.getAnswerOptionCount());
2021-11-26 02:23:58 +08:00
// Edit
await this.startNewPoll();
await this.typeOnLastChoiceInput();
await this.modPage.waitAndClick(e.startPoll);
await expect(initialRespCount, 'should display the initial quantity of poll options itens').toEqual(await this.getAnswerOptionCount());
2021-11-26 02:23:58 +08:00
await this.checkLastOptionText();
2023-04-28 20:30:29 +08:00
await this.modPage.waitAndClick(e.closePollingBtn);
2021-11-26 02:23:58 +08:00
}
2023-04-28 20:30:29 +08:00
async notAbleStartNewPollWithoutPresentation() {
await this.modPage.hasElement(e.whiteboard, 'should display the whiteboard for the moderator when joining the meeting', ELEMENT_WAIT_LONGER_TIME);
2023-04-28 20:30:29 +08:00
await this.modPage.waitAndClick(e.actions);
await this.modPage.waitAndClick(e.managePresentations);
const allRemovePresentationBtn = await this.modPage.getLocator(e.removePresentation).all();
// reversing the order of clicking is needed to avoid failure as the tooltip shows in front of the below button
const reversedRemovePresentationButtons = allRemovePresentationBtn.reverse();
for (const removeBtn of reversedRemovePresentationButtons) {
await removeBtn.click({ timeout: ELEMENT_WAIT_TIME });
}
await this.modPage.waitAndClick(e.confirmManagePresentation);
2023-04-28 20:30:29 +08:00
await this.modPage.waitAndClick(e.actions);
await this.modPage.waitAndClick(e.polling);
await this.modPage.hasElement(e.noPresentation, 'should display the no presentation for not being able to start a poll whitout presentation');
2023-04-28 20:30:29 +08:00
}
2023-05-06 02:12:32 +08:00
async customInput() {
await util.uploadSPresentationForTestingPolls(this.modPage, e.uploadPresentationFileName);
await this.modPage.hasElement(e.whiteboard, 'should display the whiteboard for the moderator when joining the meeting', 20000);
2022-10-26 04:12:59 +08:00
await this.modPage.waitAndClick(e.actions);
await this.modPage.waitAndClick(e.polling);
await this.modPage.waitAndClickElement(e.autoOptioningPollBtn);
await this.modPage.type(e.pollQuestionArea, 'Test');
await this.modPage.waitAndClick(e.addPollItem);
await this.modPage.type(e.pollOptionItem, 'test1');
await this.modPage.waitAndClick(e.addPollItem);
await this.modPage.type(e.pollOptionItem2, 'test2');
2022-10-26 04:12:59 +08:00
await this.modPage.waitAndClick(e.startPoll);
await this.userPage.hasElement(e.pollingContainer, 'should display the polling container for the attendee after starting the poll');
await this.userPage.waitAndClick(e.pollAnswerOptionBtn);
2022-10-26 04:12:59 +08:00
await this.modPage.hasText(e.currentPollQuestion, /Test/, 'should display the answer that the ateendee selected');
await this.modPage.hasText(e.userVoteLiveResult, '1', 'should display the live result');
2023-05-06 02:12:32 +08:00
await this.modPage.waitAndClick(e.closePollingBtn);
await this.modPage.wasRemoved(e.closePollingBtn, 'should not display the close polling button after the poll is closed');
2022-10-26 04:12:59 +08:00
}
async allowMultipleChoices() {
await this.modPage.waitAndClick(e.actions);
await this.modPage.waitAndClick(e.polling);
await this.modPage.waitAndClickElement(e.autoOptioningPollBtn);
await this.modPage.type(e.pollQuestionArea, 'Test');
await this.modPage.waitAndClickElement(e.allowMultiple);
await this.modPage.waitAndClick(e.addPollItem);
await this.modPage.waitAndClick(e.startPoll);
await this.modPage.hasElement(e.errorNoValueInput, 'should display an error after trying to start a poll without any input on the option poll item');
2022-10-26 04:12:59 +08:00
await this.modPage.type(e.pollOptionItem1, 'test1');
await this.modPage.waitAndClick(e.addPollItem);
await this.modPage.type(e.pollOptionItem2, 'test2');
await this.modPage.waitAndClick(e.startPoll);
await this.modPage.hasText(e.currentPollQuestion, /Test/, 'should display the current poll question after the poll has started');
2022-10-26 04:12:59 +08:00
2023-02-14 21:59:46 +08:00
await this.userPage.waitAndClick(e.firstPollAnswerOptionBtn);
await this.userPage.waitAndClick(e.secondPollAnswerOptionBtn);
2022-10-26 04:12:59 +08:00
await this.userPage.waitAndClickElement(e.submitAnswersMultiple);
await this.modPage.hasText(e.userVoteLiveResult, '1', 'should display the user vote number after the attende has answered the poll');
await this.modPage.hasText(e.userVoteLiveResult, '2', 'should display the user vote number after the attende has answered the poll');
2023-05-06 02:12:32 +08:00
await this.modPage.waitAndClick(e.closePollingBtn);
await this.modPage.wasRemoved(e.closePollingBtn, 'should not display the close polling button after the poll is closed');
2022-10-26 04:12:59 +08:00
}
async smartSlidesQuestions() {
2023-02-14 21:59:46 +08:00
await this.modPage.hasElement(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
await util.uploadSPresentationForTestingPolls(this.modPage, e.smartSlides1);
await this.userPage.hasElement(e.userListItem, 'should display the user list item for the attendee');
2022-11-26 03:54:32 +08:00
2023-05-25 23:58:44 +08:00
// Type Response
await this.modPage.waitAndClick(e.quickPoll, ELEMENT_WAIT_LONGER_TIME);
await this.userPage.hasElement(e.responsePollQuestion, 'should display the poll question after quick poll starts');
2022-10-26 04:12:59 +08:00
await this.userPage.type(e.pollAnswerOptionInput, 'test');
await this.userPage.waitAndClick(e.pollSubmitAnswer);
await this.userPage.wasRemoved(e.pollingContainer, 'should not display the polling container after the attendee answer the poll', ELEMENT_WAIT_LONGER_TIME);
await this.modPage.hasText(e.userVoteLiveResult, 'test');
2022-10-27 04:25:48 +08:00
2022-10-26 04:12:59 +08:00
await this.modPage.waitAndClick(e.publishPollingLabel);
await this.modPage.wasRemoved(e.pollingContainer, 'should not display the polling container after the poll be published');
2023-05-06 02:12:32 +08:00
2023-05-25 23:58:44 +08:00
// Multiple Choices
await sleep(500); // avoid error when the tooltip is in front of the button due to layout shift
await skipSlide(this.modPage);
2022-10-26 04:12:59 +08:00
await this.modPage.waitAndClick(e.quickPoll);
2023-05-06 02:12:32 +08:00
await this.userPage.waitAndClick(e.firstPollAnswerDescOption);
2023-05-25 23:58:44 +08:00
await this.userPage.waitAndClick(e.secondPollAnswerDescOption);
2022-10-26 04:12:59 +08:00
await this.userPage.waitAndClick(e.submitAnswersMultiple);
await this.modPage.hasText(e.userVoteLiveResult, 'A) 2222', 'should display the live vote result for the awswers after the attende answer the multiple choices polling ');
await this.modPage.hasText(e.userVoteLiveResult, 'B) 3333', 'should display the live vote result for the awswers after the attende answer the multiple choices polling ');
2022-11-26 03:54:32 +08:00
2022-10-26 04:12:59 +08:00
await this.modPage.waitAndClick(e.publishPollingLabel);
await this.modPage.wasRemoved(e.pollingContainer, 'should not display the polling container after the poll is published');
2023-05-25 23:58:44 +08:00
// One option answer
await sleep(500); // avoid error when the tooltip is in front of the button due to layout shift
await skipSlide(this.modPage);
2022-10-26 04:12:59 +08:00
await this.modPage.waitAndClick(e.quickPoll);
2023-05-25 23:58:44 +08:00
await this.userPage.waitAndClick(e.pollAnswerOptionE);
await this.modPage.hasText(e.userVoteLiveResult, 'E) 22222', 'should display the vote result after the poll is answered');
2023-05-25 23:58:44 +08:00
await this.modPage.waitAndClick(e.publishPollingLabel);
await this.modPage.wasRemoved(e.pollingContainer, 'should not display the polling container after the poll is published');
2022-10-26 04:12:59 +08:00
2023-05-25 23:58:44 +08:00
// Yes/No/Abstention
await sleep(500); // avoid error when the tooltip is in front of the button due to layout shift
await skipSlide(this.modPage);
2023-05-25 23:58:44 +08:00
await this.modPage.waitAndClick(e.yesNoOption);
await this.modPage.waitAndClick(e.yesNoAbstentionOption)
2023-05-06 02:12:32 +08:00
await this.userPage.waitAndClick(e.pollAnswerOptionBtn);
await this.modPage.hasText(e.userVoteLiveResult, 'Yes', 'should display the vote result after the attendee submit the answer');
2022-11-26 03:54:32 +08:00
2022-10-26 04:12:59 +08:00
await this.modPage.waitAndClick(e.publishPollingLabel);
await this.modPage.wasRemoved(e.pollingContainer);
2022-10-26 04:12:59 +08:00
2023-05-25 23:58:44 +08:00
// True/False
await sleep(500); // avoid error when the tooltip is in front of the button due to layout shift
await skipSlide(this.modPage);
2022-10-26 04:12:59 +08:00
await this.modPage.waitAndClick(e.quickPoll);
2023-05-06 02:12:32 +08:00
await this.userPage.waitAndClick(e.pollAnswerOptionBtn);
await this.modPage.hasText(e.userVoteLiveResult, 'True', 'should display the vote result after the attendeee submit the answer');
2023-05-25 23:58:44 +08:00
await this.modPage.waitAndClick(e.publishPollingLabel);
2022-10-26 04:12:59 +08:00
await this.modPage.hasElementDisabled(e.nextSlide, 'should display the next slide button disabled since the smart slides has finished with all the questions');
await this.modPage.wasRemoved(e.pollingContainer, 'should not display the pollling container after all the smart slides questions is finished');
2022-10-26 04:12:59 +08:00
}
2023-05-06 02:12:32 +08:00
async pollResultsOnChat() {
const { pollChatMessage } = getSettings();
2023-11-08 19:50:16 +08:00
await this.modPage.hasElement(e.whiteboard, 'should display the whiteboard for the moderator when joining the meeting', ELEMENT_WAIT_LONGER_TIME);
2024-02-28 22:34:23 +08:00
await util.startPoll(this.modPage);
await this.modPage.hasElementDisabled(e.publishPollingLabel, 'should display the publish polling button disabled without any answer sent from the user');
2024-02-28 22:34:23 +08:00
await this.userPage.waitAndClick(e.pollAnswerOptionBtn);
await this.modPage.hasElement(e.publishPollingLabel, 'should display the publish polling button enabled after the attendee answered the poll');
2024-02-28 22:34:23 +08:00
await this.modPage.waitAndClick(e.publishPollingLabel);
2023-05-06 02:12:32 +08:00
const lastChatPollMessageTextModerator = await this.modPage.getLocator(e.chatPollMessageText).last();
2023-11-08 19:50:16 +08:00
if(!pollChatMessage) {
return expect(lastChatPollMessageTextModerator, 'should not display the last chat poll message on the chat, so the poll results on the chat').toBeHidden({ ELEMENT_WAIT_TIME });
2023-11-08 19:50:16 +08:00
}
await expect(lastChatPollMessageTextModerator, 'should display the last chaat poll message on the chat, so the poll results on the chat').toBeVisible();
const lastChatPollMessageTextUser = await this.userPage.getLocator(e.chatPollMessageText).last();
await expect(lastChatPollMessageTextUser, 'should display the poll results on the chat for the attendee').toBeVisible();
2023-05-06 02:12:32 +08:00
}
async pollResultsOnWhiteboard() {
await this.modPage.hasElement(e.whiteboard, 'should display the whiteboard when the moderator joins the meeting', ELEMENT_WAIT_LONGER_TIME);
2024-02-28 22:34:23 +08:00
await util.startPoll(this.modPage);
const wbDrawnRectangleLocator = await this.modPage.getLocator(e.wbPollShape);
const initialWbDrawnRectangleCount = await wbDrawnRectangleLocator.count();
await this.modPage.hasElementDisabled(e.publishPollingLabel, 'should display the publish poll button disabled before the poll is answered');
2024-02-28 22:34:23 +08:00
await this.userPage.waitAndClick(e.pollAnswerOptionBtn);
await this.modPage.hasElement(e.publishPollingLabel, 'should display the publish poll button enabled after the attendee answered the poll');
2024-02-28 22:34:23 +08:00
await this.modPage.waitAndClick(e.publishPollingLabel);
await expect(wbDrawnRectangleLocator,'should display the rectangle with the poll information on the whiteboard').toHaveCount(initialWbDrawnRectangleCount + 1);
2024-02-28 22:34:23 +08:00
const lastWbDrawnRectangleLocator = await wbDrawnRectangleLocator.last();
await expect(lastWbDrawnRectangleLocator, 'should display the last rectangle with the poll information on the whiteboard').toBeVisible({ timeout: ELEMENT_WAIT_TIME});
2023-07-28 20:16:07 +08:00
const modWbLocator = this.modPage.getLocator(e.whiteboard);
const wbBox = await modWbLocator.boundingBox();
// poll results should be editable by the presenter
await lastWbDrawnRectangleLocator.dblclick({ timeout: ELEMENT_WAIT_TIME });
2023-07-28 20:16:07 +08:00
await this.modPage.page.mouse.down();
await this.modPage.page.mouse.move(wbBox.x + 0.7 * wbBox.width, wbBox.y + 0.7 * wbBox.height);
await this.modPage.page.mouse.up();
await lastWbDrawnRectangleLocator.dblclick({ timeout: ELEMENT_WAIT_TIME });
2023-07-28 20:16:07 +08:00
await this.modPage.page.keyboard.type('test');
await expect(lastWbDrawnRectangleLocator, 'should display the text test on the last rectangle poll results on the whiteboard').toContainText('test');
2023-07-28 20:16:07 +08:00
// user turns to presenter to edit the poll results
await this.modPage.waitAndClick(e.userListItem);
await this.modPage.waitAndClick(e.makePresenter);
2024-02-28 22:34:23 +08:00
await this.userPage.waitAndClick(e.zoomInButton);
await this.userPage.waitAndClick(e.resetZoomButton);
const wbDrawnRectangleUserLocator = await this.userPage.getLocator(e.wbPollShape).last();
await wbDrawnRectangleUserLocator.dblclick({ timeout: ELEMENT_WAIT_TIME });
2023-07-28 20:16:07 +08:00
await this.userPage.page.keyboard.type('testUser');
await expect(wbDrawnRectangleUserLocator, 'should display the edit that the attendee made to the poll results rectangle on the whiteboard').toContainText('testUser');
2023-07-28 20:16:07 +08:00
await this.modPage.waitAndClick(e.currentUser);
await this.modPage.waitAndClick(e.takePresenter);
await this.userPage.waitAndClick(e.hidePublicChat);
2023-05-06 02:12:32 +08:00
}
async pollResultsInDifferentPresentation() {
await util.startPoll(this.modPage);
await this.userPage.waitAndClick(e.pollAnswerOptionBtn);
await util.uploadSPresentationForTestingPolls(this.modPage, e.questionSlideFileName);
2024-05-15 05:07:58 +08:00
await this.modPage.hasElement(e.quickPoll, ELEMENT_WAIT_LONGER_TIME);
2023-05-06 02:12:32 +08:00
await this.modPage.waitAndClick(e.publishPollingLabel);
// Check poll results
await this.modPage.hasElement(e.wbPollShape);
}
2023-05-06 02:12:32 +08:00
async startNewPoll() {
const hasPollStarted = await this.modPage.checkElement(e.pollMenuButton);
if (hasPollStarted) {
await this.modPage.waitAndClick(e.cancelPollBtn);
await this.userPage.wasRemoved(e.pollingContainer, 'should not display the polling container after the poll is canceled');
2023-05-06 02:12:32 +08:00
}
await util.openPoll(this.modPage);
}
async getAnswerOptionCount() {
await this.userPage.hasElement(e.pollingContainer, 'should display the polling container for the attendee');
2023-05-06 02:12:32 +08:00
return this.userPage.getSelectorCount(e.pollAnswerOptionBtn);
}
async typeOnLastChoiceInput() {
const lastInput = this.modPage.getLocatorByIndex(e.pollOptionItem, -1);
await lastInput.fill(this.newInputText);
}
async checkLastOptionText() {
await this.userPage.hasElement(e.pollingContainer, 'should display the polling container for the attendee');
2023-05-06 02:12:32 +08:00
const lastOptionText = this.userPage.getLocatorByIndex(e.pollAnswerOptionBtn, -1);
await expect(lastOptionText, 'should display the last option text for the attendee').toHaveText(this.newInputText);
2023-05-06 02:12:32 +08:00
}
2021-11-26 02:23:58 +08:00
}
2021-12-04 01:01:36 +08:00
exports.Polling = Polling;