bigbluebutton-Github/bigbluebutton-tests/playwright/learningdashboard/learningdashboard.js

117 lines
4.6 KiB
JavaScript
Raw Normal View History

2023-02-24 01:37:17 +08:00
const { MultiUsers } = require("../user/multiusers");
const e = require('../core/elements');
2023-03-01 01:44:30 +08:00
const { openChat } = require('../chat/util');
const { expect } = require("@playwright/test");
const Page = require("../core/page");
2023-03-03 03:57:02 +08:00
const { sleep } = require("../core/helpers");
const { ELEMENT_WAIT_EXTRA_LONG_TIME } = require("../core/constants");
const { openPoll, timeInSeconds } = require("./util");
2023-02-24 01:37:17 +08:00
class LearningDashboard extends MultiUsers {
constructor(browser, context) {
super(browser, context);
}
2023-03-01 01:44:30 +08:00
async getDashboardPage(context) {
await this.modPage.waitAndClick(e.manageUsers);
2023-02-24 01:37:17 +08:00
2023-03-01 01:44:30 +08:00
const [dashboardPage] = await Promise.all([
context.waitForEvent('page'),
this.modPage.waitAndClick(e.learningDashboard),
]);
2023-03-10 22:24:14 +08:00
2023-03-01 01:44:30 +08:00
await expect(dashboardPage).toHaveTitle(/Dashboard/);
this.dashboardPage = new Page(context, dashboardPage);
}
async writeOnPublicChat() {
await openChat(this.modPage);
await this.modPage.checkElementCount(e.chatUserMessageText, 0);
await this.modPage.type(e.chatBox, e.message);
await this.modPage.waitAndClick(e.sendButton);
await this.modPage.checkElementCount(e.chatUserMessageText, 1);
await this.dashboardPage.reloadPage();
await this.dashboardPage.hasText(e.messageLearningDashboard, '1', ELEMENT_WAIT_EXTRA_LONG_TIME);
2023-02-24 01:37:17 +08:00
}
2023-03-01 01:44:30 +08:00
2023-03-09 04:34:54 +08:00
async userTimeOnMeeting() {
2023-03-03 03:57:02 +08:00
await this.modPage.waitAndClick(e.recordingIndicator);
await this.modPage.waitAndClick(e.confirmRecording);
await this.modPage.hasText(e.recordingIndicator, '00:0000:00');
const timeLocator = this.dashboardPage.getLocator(e.userOnlineTime);
const timeContent = await (timeLocator).textContent();
2023-03-10 22:24:14 +08:00
const time = timeInSeconds(timeContent);
2023-03-09 04:34:54 +08:00
await sleep(1000);
await this.dashboardPage.reloadPage();
const timeContentGreater = await (timeLocator).textContent();
2023-03-10 22:24:14 +08:00
const timeGreater = timeInSeconds(timeContentGreater);
2023-03-03 03:57:02 +08:00
await expect(timeGreater).toBeGreaterThan(time);
2023-03-03 03:57:02 +08:00
}
2023-03-09 04:34:54 +08:00
async polls() {
// True/False
await openPoll(this.modPage);
await this.modPage.type(e.pollQuestionArea, 'True/False?');
2023-03-03 03:57:02 +08:00
await this.modPage.waitAndClick(e.pollTrueFalse);
await this.modPage.waitAndClick(e.startPoll);
2023-03-09 04:34:54 +08:00
await this.userPage.waitAndClick(e.pollAnswerOptionBtn);
2023-03-03 03:57:02 +08:00
await this.modPage.hasText(e.numberVotes, '1');
2023-03-09 04:34:54 +08:00
await this.modPage.waitAndClick(e.cancelPollBtn);
2023-03-03 03:57:02 +08:00
2023-03-09 04:34:54 +08:00
//ABCD
await this.modPage.getLocator(e.pollQuestionArea).fill(' ');
await this.modPage.type(e.pollQuestionArea, 'ABCD?');
2023-03-03 03:57:02 +08:00
await this.modPage.waitAndClick(e.pollLetterAlternatives);
await this.modPage.waitAndClick(e.startPoll);
2023-03-09 04:34:54 +08:00
await this.userPage.waitAndClick(e.pollAnswerOptionBtn);
await this.modPage.hasText(e.numberVotes, '1');
await this.modPage.waitAndClick(e.cancelPollBtn);
2023-03-03 03:57:02 +08:00
2023-03-09 04:34:54 +08:00
//Yes/No/Abstention
await this.modPage.getLocator(e.pollQuestionArea).fill(' ');
await this.modPage.type(e.pollQuestionArea, 'Yes/No/Abstention?');
2023-03-03 03:57:02 +08:00
await this.modPage.waitAndClick(e.pollYesNoAbstentionBtn);
await this.modPage.waitAndClick(e.startPoll);
2023-03-09 04:34:54 +08:00
await this.userPage.waitAndClick(e.pollAnswerOptionBtn);
await this.modPage.hasText(e.numberVotes, '1');
await this.modPage.waitAndClick(e.cancelPollBtn);
2023-03-03 03:57:02 +08:00
2023-03-09 04:34:54 +08:00
//User Response
await this.modPage.getLocator(e.pollQuestionArea).fill(' ');
await this.modPage.type(e.pollQuestionArea, 'User response?');
2023-03-03 03:57:02 +08:00
await this.modPage.waitAndClick(e.userResponseBtn);
await this.modPage.waitAndClick(e.startPoll);
2023-03-09 04:34:54 +08:00
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.numberVotes, '1');
await this.modPage.waitAndClick(e.cancelPollBtn);
2023-03-03 03:57:02 +08:00
2023-03-10 22:24:14 +08:00
//Checks
await this.dashboardPage.reloadPage();
await this.dashboardPage.waitAndClick(e.pollPanel);
2023-03-10 22:24:14 +08:00
await this.dashboardPage.hasText(e.pollTotal, '4', ELEMENT_WAIT_EXTRA_LONG_TIME);
//True / False
await this.dashboardPage.hasText(e.pollTrueFalseQuestion, 'True/False?');
2023-03-09 04:34:54 +08:00
await this.dashboardPage.hasText(e.pollTrueFalseAnswer, 'True');
2023-03-06 21:46:31 +08:00
2023-03-09 04:34:54 +08:00
//ABCD
2023-03-10 22:24:14 +08:00
await this.dashboardPage.hasText(e.pollABCDQuestion, 'ABCD?');
2023-03-09 04:34:54 +08:00
await this.dashboardPage.hasText(e.pollABCDAnswer, 'A');
//Yes No
2023-03-10 22:24:14 +08:00
await this.dashboardPage.hasText(e.pollYesNoQuestion, 'Yes/No/Abstention?');
2023-03-09 04:34:54 +08:00
await this.dashboardPage.hasText(e.pollYesNoAnswer, 'Yes');
// User Response
2023-03-10 22:24:14 +08:00
await this.dashboardPage.hasText(e.pollUserResponseQuestion, 'User response?');
2023-03-09 04:34:54 +08:00
await this.dashboardPage.hasText(e.pollUserResponseAnswer, e.answerMessage);
2023-03-03 03:57:02 +08:00
}
2023-02-24 01:37:17 +08:00
}
exports.LearningDashboard = LearningDashboard;