2024-07-31 06:49:02 +08:00
const { expect } = 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' ) ;
2024-07-31 06:49:02 +08:00
const { ELEMENT _WAIT _LONGER _TIME , ELEMENT _WAIT _TIME } = require ( '../core/constants' ) ;
2022-06-08 02:52:22 +08:00
const { getSettings } = require ( '../core/settings' ) ;
2024-07-31 06:49:02 +08:00
const { skipSlide } = require ( '../presentation/util' ) ;
2024-01-20 00:42:01 +08:00
const { sleep } = require ( '../core/helpers.js' ) ;
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ( ) {
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ( ) {
2024-04-06 00:35:32 +08:00
await util . uploadSPresentationForTestingPolls ( 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 ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . pollMenuButton , 'should display the poll menu button' ) ;
2021-11-26 02:23:58 +08:00
2024-07-31 06:49:02 +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 ) ;
2024-07-31 06:49:02 +08:00
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 ( ) {
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . wasRemoved ( e . pollingContainer , 'should close the polling container after publishing the label' ) ;
2021-11-26 02:23:58 +08:00
2024-06-11 05:12:40 +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 ( ) {
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ( ) {
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ( ) {
2024-07-31 06:49:02 +08:00
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 ) ;
2024-04-04 02:56:38 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ( ) {
2024-04-06 00:35:32 +08:00
await util . uploadSPresentationForTestingPolls ( this . modPage , e . uploadPresentationFileName ) ;
2024-07-31 06:49:02 +08:00
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' ) ;
2024-02-02 19:37:28 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . hasElement ( e . pollingContainer , 'should display the polling container for the attendee after starting the poll' ) ;
2022-11-30 23:50:43 +08:00
await this . userPage . waitAndClick ( e . pollAnswerOptionBtn ) ;
2022-10-26 04:12:59 +08:00
2024-07-31 06:49:02 +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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-04-06 00:35:32 +08:00
await util . uploadSPresentationForTestingPolls ( this . modPage , e . smartSlides1 ) ;
2024-07-31 06:49:02 +08:00
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
2024-04-06 00:35:32 +08:00
await this . modPage . waitAndClick ( e . quickPoll , ELEMENT _WAIT _LONGER _TIME ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
await this . userPage . wasRemoved ( e . pollingContainer , 'should not display the polling container after the attendee answer the poll' , ELEMENT _WAIT _LONGER _TIME ) ;
2024-04-04 02:56:38 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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
2024-01-20 00:42:01 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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
2024-01-20 00:42:01 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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
2024-01-20 00:42:01 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-04-04 02:56:38 +08:00
await this . modPage . wasRemoved ( e . pollingContainer ) ;
2022-10-26 04:12:59 +08:00
2023-05-25 23:58:44 +08:00
// True/False
2024-01-20 00:42:01 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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
2024-07-31 06:49:02 +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
2024-07-31 06:49:02 +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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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
2023-05-08 21:14:26 +08:00
const lastChatPollMessageTextModerator = await this . modPage . getLocator ( e . chatPollMessageText ) . last ( ) ;
2023-11-08 19:50:16 +08:00
if ( ! pollChatMessage ) {
2024-07-31 06:49:02 +08:00
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
}
2024-07-31 06:49:02 +08:00
await expect ( lastChatPollMessageTextModerator , 'should display the last chaat poll message on the chat, so the poll results on the chat' ) . toBeVisible ( ) ;
2023-05-08 21:14:26 +08:00
const lastChatPollMessageTextUser = await this . userPage . getLocator ( e . chatPollMessageText ) . last ( ) ;
2024-07-31 06:49:02 +08:00
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 ( ) {
2024-07-31 06:49:02 +08:00
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 ) ;
2024-06-11 05:12:40 +08:00
const wbDrawnRectangleLocator = await this . modPage . getLocator ( e . wbPollShape ) ;
2024-04-04 02:56:38 +08:00
const initialWbDrawnRectangleCount = await wbDrawnRectangleLocator . count ( ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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
2024-04-04 02:56:38 +08:00
const lastWbDrawnRectangleLocator = await wbDrawnRectangleLocator . last ( ) ;
2024-07-31 06:49:02 +08:00
await expect ( lastWbDrawnRectangleLocator , 'should display the last rectangle with the poll information on the whiteboard' ) . toBeVisible ( { timeout : ELEMENT _WAIT _TIME } ) ;
2023-05-08 21:14:26 +08:00
2023-07-28 20:16:07 +08:00
const modWbLocator = this . modPage . getLocator ( e . whiteboard ) ;
const wbBox = await modWbLocator . boundingBox ( ) ;
2024-04-04 02:56:38 +08:00
// 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 ( ) ;
2024-04-04 02:56:38 +08:00
await lastWbDrawnRectangleLocator . dblclick ( { timeout : ELEMENT _WAIT _TIME } ) ;
2023-07-28 20:16:07 +08:00
await this . modPage . page . keyboard . type ( 'test' ) ;
2024-07-31 06:49:02 +08:00
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 ) ;
2024-06-11 05:12:40 +08:00
const wbDrawnRectangleUserLocator = await this . userPage . getLocator ( e . wbPollShape ) . last ( ) ;
2024-04-04 02:56:38 +08:00
await wbDrawnRectangleUserLocator . dblclick ( { timeout : ELEMENT _WAIT _TIME } ) ;
2023-07-28 20:16:07 +08:00
await this . userPage . page . keyboard . type ( 'testUser' ) ;
2024-07-31 06:49:02 +08:00
await expect ( wbDrawnRectangleUserLocator , 'should display the edit that the attendee made to the poll results rectangle on the whiteboard' ) . toContainText ( 'testUser' ) ;
2024-04-04 02:56:38 +08:00
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 ( ) {
2023-05-08 21:14:26 +08:00
await util . startPoll ( this . modPage ) ;
2024-04-04 02:56:38 +08:00
await this . userPage . waitAndClick ( e . pollAnswerOptionBtn ) ;
2024-04-06 00:35:32 +08:00
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
2024-06-11 05:12:40 +08:00
await this . modPage . hasElement ( e . wbPollShape ) ;
2023-05-08 21:14:26 +08:00
}
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 ) ;
2024-07-31 06:49:02 +08:00
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 ( ) {
2024-07-31 06:49:02 +08:00
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 ( ) {
2024-07-31 06:49:02 +08:00
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 ) ;
2024-07-31 06:49:02 +08:00
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 ;