2022-06-08 02:52:22 +08:00
|
|
|
const { expect, test } = require('@playwright/test');
|
2021-12-02 12:12:14 +08:00
|
|
|
const { MultiUsers } = require('../user/multiusers');
|
2021-11-26 02:23:58 +08:00
|
|
|
const e = require('../core/elements');
|
|
|
|
const util = require('./util.js');
|
|
|
|
const utilPresentation = require('../presentation/util');
|
|
|
|
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
2022-06-08 02:52:22 +08:00
|
|
|
const { getSettings } = require('../core/settings');
|
|
|
|
const { waitAndClearDefaultPresentationNotification } = require('../notifications/util');
|
2022-11-26 03:54:32 +08:00
|
|
|
const { sleep } = require('../core/helpers');
|
2021-11-26 02:23:58 +08:00
|
|
|
|
2021-12-02 12:12:14 +08:00
|
|
|
class Polling extends MultiUsers {
|
2021-11-26 02:23:58 +08:00
|
|
|
constructor(browser, context) {
|
2021-12-02 12:12:14 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
async pollAnonymous() {
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await util.startPoll(this.modPage, false, true);
|
|
|
|
await this.modPage.waitForSelector(e.publishPollingLabel);
|
|
|
|
await this.userPage.waitAndClick(e.pollAnswerOptionBtn);
|
2021-12-01 22:02:26 +08:00
|
|
|
await this.userPage.wasRemoved(e.receivedAnswer);
|
2021-11-26 02:23:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async quickPoll() {
|
2022-07-02 04:55:32 +08:00
|
|
|
await waitAndClearDefaultPresentationNotification(this.modPage);
|
2022-07-05 23:27:40 +08:00
|
|
|
await utilPresentation.uploadSinglePresentation(this.modPage, e.questionSlideFileName);
|
2021-11-26 02:23:58 +08:00
|
|
|
|
2022-08-12 08:13:36 +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);
|
2021-11-26 02:23:58 +08:00
|
|
|
await this.modPage.waitForSelector(e.pollMenuButton);
|
|
|
|
|
|
|
|
await this.userPage.hasElement(e.pollingContainer);
|
|
|
|
}
|
|
|
|
|
|
|
|
async pollUserResponse() {
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard);
|
|
|
|
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.waitForSelector(e.pollingContainer);
|
|
|
|
await this.userPage.type(e.pollAnswerOptionInput, e.answerMessage);
|
|
|
|
await this.userPage.waitAndClick(e.pollSubmitAnswer);
|
|
|
|
|
|
|
|
await this.modPage.hasText(e.receivedAnswer, e.answerMessage);
|
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.publishPollingLabel);
|
|
|
|
await this.modPage.waitForSelector(e.restartPoll);
|
|
|
|
|
2022-07-02 04:55:32 +08:00
|
|
|
await this.modPage.hasElement(e.wbTypedText);
|
2021-11-26 02:23:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async stopPoll() {
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await util.startPoll(this.modPage);
|
|
|
|
await this.userPage.waitForSelector(e.pollingContainer);
|
|
|
|
await this.modPage.waitAndClick(e.cancelPollBtn);
|
|
|
|
await this.userPage.wasRemoved(e.pollingContainer);
|
|
|
|
}
|
|
|
|
|
|
|
|
async pollResultsOnChat() {
|
2022-03-29 21:53:07 +08:00
|
|
|
const { pollChatMessage } = getSettings();
|
|
|
|
test.fail(!pollChatMessage, 'Poll results on chat is disabled');
|
|
|
|
|
2021-11-26 02:23:58 +08:00
|
|
|
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await util.startPoll(this.modPage, true);
|
|
|
|
await this.modPage.waitAndClick(e.chatButton);
|
|
|
|
|
|
|
|
await this.modPage.hasElement(e.chatPollMessageText);
|
|
|
|
await this.userPage.hasElement(e.chatPollMessageText);
|
|
|
|
}
|
|
|
|
|
|
|
|
async pollResultsOnWhiteboard() {
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await util.startPoll(this.modPage, true);
|
2022-07-02 04:55:32 +08:00
|
|
|
await this.modPage.hasElement(e.wbTypedText);
|
2021-11-26 02:23:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async pollResultsInDifferentPresentation() {
|
2022-07-02 04:55:32 +08:00
|
|
|
await waitAndClearDefaultPresentationNotification(this.modPage);
|
2021-11-26 02:23:58 +08:00
|
|
|
await util.startPoll(this.modPage);
|
|
|
|
|
2022-07-06 00:21:38 +08:00
|
|
|
await utilPresentation.uploadSinglePresentation(this.modPage, e.questionSlideFileName);
|
2021-11-26 02:23:58 +08:00
|
|
|
await this.modPage.waitAndClick(e.publishPollingLabel);
|
|
|
|
|
|
|
|
// Check poll results
|
2022-07-02 04:55:32 +08:00
|
|
|
await this.modPage.hasElement(e.wbTypedText);
|
2021-11-26 02:23:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
async manageResponseChoices() {
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
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).toEqual(await this.getAnswerOptionCount());
|
|
|
|
await this.checkLastOptionText();
|
|
|
|
|
|
|
|
// Delete
|
|
|
|
await this.startNewPoll();
|
|
|
|
await this.modPage.waitAndClick(e.deletePollOption);
|
|
|
|
await this.modPage.waitAndClick(e.startPoll);
|
|
|
|
|
|
|
|
await expect(initialRespCount - 1).toEqual(await this.getAnswerOptionCount());
|
|
|
|
|
|
|
|
// Edit
|
|
|
|
await this.startNewPoll();
|
|
|
|
await this.typeOnLastChoiceInput();
|
|
|
|
await this.modPage.waitAndClick(e.startPoll);
|
|
|
|
|
|
|
|
await expect(initialRespCount).toEqual(await this.getAnswerOptionCount());
|
|
|
|
await this.checkLastOptionText();
|
|
|
|
}
|
|
|
|
|
|
|
|
async startNewPoll() {
|
2021-12-02 12:12:14 +08:00
|
|
|
const hasPollStarted = await this.modPage.checkElement(e.pollMenuButton);
|
2021-11-26 02:23:58 +08:00
|
|
|
if (hasPollStarted) {
|
|
|
|
await this.modPage.waitAndClick(e.cancelPollBtn);
|
|
|
|
await this.userPage.wasRemoved(e.pollingContainer);
|
|
|
|
}
|
|
|
|
await util.openPoll(this.modPage);
|
|
|
|
}
|
|
|
|
|
|
|
|
async getAnswerOptionCount() {
|
|
|
|
await this.userPage.waitForSelector(e.pollingContainer);
|
|
|
|
return this.userPage.getSelectorCount(e.pollAnswerOptionBtn);
|
|
|
|
}
|
|
|
|
|
|
|
|
async typeOnLastChoiceInput() {
|
2022-02-05 03:26:35 +08:00
|
|
|
const lastInput = this.modPage.getLocatorByIndex(e.pollOptionItem, -1);
|
2021-11-26 02:23:58 +08:00
|
|
|
await lastInput.fill(this.newInputText);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
async checkLastOptionText() {
|
|
|
|
await this.userPage.waitForSelector(e.pollingContainer);
|
2022-02-05 03:26:35 +08:00
|
|
|
const lastOptionText = this.userPage.getLocatorByIndex(e.pollAnswerOptionBtn, -1);
|
|
|
|
await expect(lastOptionText).toHaveText(this.newInputText);
|
2021-11-26 02:23:58 +08:00
|
|
|
}
|
2022-10-26 04:12:59 +08:00
|
|
|
|
2022-10-27 04:25:48 +08:00
|
|
|
async notAbleStartNewPollWithoutPresentation() {
|
2022-10-26 04:12:59 +08:00
|
|
|
await this.modPage.waitAndClick(e.actions);
|
|
|
|
await this.modPage.waitAndClick(e.managePresentations);
|
|
|
|
await this.modPage.waitAndClick(e.removePresentation);
|
|
|
|
await this.modPage.waitAndClick(e.confirmManagePresentation);
|
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.actions);
|
|
|
|
await this.modPage.waitAndClick(e.polling);
|
|
|
|
await this.modPage.hasElement(e.noPresentation);
|
|
|
|
}
|
|
|
|
|
|
|
|
async customInput() {
|
|
|
|
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.startPoll);
|
|
|
|
|
|
|
|
await this.userPage.hasElement(e.pollingContainer);
|
2022-11-26 03:54:32 +08:00
|
|
|
await this.userPage.waitAndClick(e.firstPollAnswerOptionBtn);
|
2022-10-26 04:12:59 +08:00
|
|
|
|
|
|
|
await this.modPage.hasText(e.currentPollQuestion, /Test/);
|
2022-10-27 04:25:48 +08:00
|
|
|
await this.modPage.hasText(e.answer1, '1');
|
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);
|
|
|
|
|
|
|
|
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/);
|
|
|
|
|
2022-10-27 04:25:48 +08:00
|
|
|
await this.userPage.waitAndClick(e.pollAnswerDescTest1);
|
|
|
|
await this.userPage.waitAndClick(e.pollAnswerDescTest2);
|
2022-10-26 04:12:59 +08:00
|
|
|
await this.userPage.waitAndClickElement(e.submitAnswersMultiple);
|
|
|
|
|
|
|
|
await this.modPage.hasText(e.answer1, '1');
|
|
|
|
await this.modPage.hasText(e.answer2, '1');
|
|
|
|
}
|
|
|
|
|
|
|
|
async smartSlidesQuestions() {
|
|
|
|
await utilPresentation.uploadSinglePresentation(this.modPage, e.smartSlides1, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
await this.userPage.hasElement(e.presentationTitle);
|
2022-11-26 03:54:32 +08:00
|
|
|
|
2022-10-26 04:12:59 +08:00
|
|
|
await this.modPage.waitAndClick(e.quickPoll);
|
|
|
|
await this.userPage.hasElement(e.responsePollQuestion);
|
|
|
|
await this.userPage.type(e.pollAnswerOptionInput, 'test');
|
|
|
|
await this.userPage.waitAndClick(e.pollSubmitAnswer);
|
|
|
|
|
2022-10-27 04:25:48 +08:00
|
|
|
await this.modPage.hasText(e.receivedAnswer, 'test');
|
|
|
|
|
2022-10-26 04:12:59 +08:00
|
|
|
await this.modPage.waitAndClick(e.publishPollingLabel);
|
|
|
|
await this.modPage.waitAndClick(e.nextSlide);
|
|
|
|
await this.modPage.waitAndClick(e.quickPoll);
|
2022-10-27 04:25:48 +08:00
|
|
|
await this.userPage.waitAndClick(e.checkboxInput);
|
2022-10-26 04:12:59 +08:00
|
|
|
await this.userPage.waitAndClick(e.submitAnswersMultiple);
|
|
|
|
|
|
|
|
await this.modPage.hasText(e.answer1, '1');
|
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.waitAndClick(e.nextSlide);
|
|
|
|
await this.modPage.waitAndClick(e.quickPoll);
|
2022-11-26 03:54:32 +08:00
|
|
|
await this.userPage.waitAndClick(e.pollAnswerDescTest1);
|
2022-10-26 04:12:59 +08:00
|
|
|
|
2022-10-27 04:25:48 +08:00
|
|
|
await this.modPage.hasText(e.answer1, '1');
|
2022-10-26 04:12:59 +08:00
|
|
|
await this.modPage.hasElementDisabled(e.nextSlide);
|
|
|
|
}
|
2021-11-26 02:23:58 +08:00
|
|
|
}
|
|
|
|
|
2021-12-04 01:01:36 +08:00
|
|
|
exports.Polling = Polling;
|