bigbluebutton-Github/bigbluebutton-tests/playwright/user/timer.js

68 lines
2.9 KiB
JavaScript
Raw Normal View History

2023-10-26 04:29:52 +08:00
const { MultiUsers } = require('./multiusers');
2023-10-24 20:56:36 +08:00
const e = require('../core/elements');
const { timeInSeconds } = require('./util');
const { expect } = require('@playwright/test');
const { sleep } = require('../core/helpers');
2023-10-26 04:29:52 +08:00
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
2023-10-24 20:56:36 +08:00
class Timer extends MultiUsers {
constructor(browser, context) {
super(browser, context);
}
async timerTest() {
await this.modPage.waitForSelector(e.whiteboard);
await this.modPage.waitAndClick(e.actions);
2023-10-26 04:29:52 +08:00
await this.modPage.waitAndClick(e.timerStopwatchFeature);
2023-10-24 20:56:36 +08:00
await this.modPage.waitForSelector(e.timerCurrent);
const timerCurrentLocator = await this.modPage.getLocator(e.timerCurrent);
const timerIndicatorLocator = await this.modPage.getLocator(e.timerIndicator);
const initialValeuStopWatch = await timeInSeconds(timerCurrentLocator);
const initialValeuStopWatchIndicator = await timeInSeconds(timerIndicatorLocator);
2023-10-25 21:19:04 +08:00
2023-10-24 20:56:36 +08:00
await this.modPage.hasText(e.timerCurrent, /00:00:00/);
await this.modPage.waitAndClick(e.startStopTimer);
await sleep(5000);
2023-10-24 22:37:11 +08:00
const currentValueStopwatch = await timeInSeconds(timerCurrentLocator);
2023-10-24 20:56:36 +08:00
const currentValueStopwatchIndicator = await timeInSeconds(timerIndicatorLocator);
2023-10-24 22:37:11 +08:00
await expect(currentValueStopwatch).toBeGreaterThan(initialValeuStopWatch);
2023-10-24 20:56:36 +08:00
await expect(currentValueStopwatchIndicator).toBeGreaterThan(initialValeuStopWatchIndicator);
2023-10-25 21:19:04 +08:00
2023-10-26 04:29:52 +08:00
await this.modPage.waitAndClick(e.startStopTimer);
await this.modPage.waitAndClick(e.resetTimerStopwatch);
2023-10-24 20:56:36 +08:00
await this.modPage.hasText(e.timerCurrent, /00:00:00/);
2023-10-25 21:19:04 +08:00
await this.modPage.hasText(e.timerIndicator, /00:00:00/);
2023-10-24 20:56:36 +08:00
await this.modPage.waitAndClick(e.timerButton);
await this.modPage.hasText(e.timerCurrent, /00:05:00/);
2023-10-24 22:37:11 +08:00
await this.modPage.hasText(e.timerIndicator, /00:05:00/);
2023-10-24 20:56:36 +08:00
2023-10-24 22:37:11 +08:00
await this.modPage.getLocator(e.minutesInput).press('Backspace');
2023-10-24 20:56:36 +08:00
await this.modPage.type(e.minutesInput, '6');
2023-10-24 22:37:11 +08:00
await this.modPage.hasText(e.timerCurrent, /00:06:00/);
await this.modPage.hasText(e.timerIndicator, /00:06:00/);
2023-10-24 20:56:36 +08:00
2023-10-24 22:37:11 +08:00
const timerInitialValue = await timeInSeconds(timerCurrentLocator);
2023-10-25 21:19:04 +08:00
await this.modPage.waitAndClick(e.startStopTimer);
await sleep(5000);
const timerCurrentValue = await timeInSeconds(timerCurrentLocator);
await expect(timerInitialValue).toBeGreaterThan(timerCurrentValue);
2023-10-24 22:37:11 +08:00
await this.modPage.waitAndClick(e.startStopTimer);
2023-10-26 04:29:52 +08:00
await this.modPage.waitAndClick(e.resetTimerStopwatch);
2023-10-25 21:19:04 +08:00
await this.modPage.hasText(e.timerCurrent, /00:06:00/);
await this.modPage.hasText(e.timerIndicator, /00:06:00/);
2023-10-24 22:37:11 +08:00
2023-10-25 21:19:04 +08:00
//Testing Timer Indicator
const initialValueIndicator = await timeInSeconds(timerIndicatorLocator);
await this.modPage.waitAndClick(e.timerIndicator);
2023-10-24 22:37:11 +08:00
await sleep(5000);
2023-10-25 21:19:04 +08:00
const currentValueIndicator = await timeInSeconds(timerIndicatorLocator);
await expect(initialValueIndicator).toBeGreaterThan(currentValueIndicator);
2023-10-24 20:56:36 +08:00
}
}
exports.Timer = Timer;