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');
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2024-05-15 05:07:58 +08:00
|
|
|
const initialValueStopWatch = await timeInSeconds(timerCurrentLocator);
|
|
|
|
const initialValueStopWatchIndicator = await timeInSeconds(timerIndicatorLocator);
|
2023-10-25 21:19:04 +08:00
|
|
|
|
2024-05-15 05:07:58 +08:00
|
|
|
await this.modPage.hasText(e.timerCurrent, /00:00/);
|
2023-10-24 20:56:36 +08: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);
|
2024-05-15 05:07:58 +08:00
|
|
|
await expect(currentValueStopwatch).toBeGreaterThan(initialValueStopWatch);
|
|
|
|
await expect(currentValueStopwatchIndicator).toBeGreaterThan(initialValueStopWatchIndicator);
|
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);
|
2024-05-15 05:07:58 +08:00
|
|
|
await this.modPage.hasText(e.timerCurrent, /00:00/);
|
|
|
|
await this.modPage.hasText(e.timerIndicator, /00:00/);
|
2023-10-24 20:56:36 +08:00
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.timerButton);
|
2024-05-15 05:07:58 +08:00
|
|
|
await this.modPage.hasElement(e.timerContainer);
|
|
|
|
await this.modPage.getLocator(e.secondsInput).press('Backspace');
|
|
|
|
await this.modPage.type(e.secondsInput, '4');
|
|
|
|
await this.modPage.waitAndClick(e.startStopTimer);
|
|
|
|
await this.modPage.hasText(e.timerCurrent, /00:02/);
|
|
|
|
await this.modPage.hasText(e.timerIndicator, /00:02/);
|
2023-10-24 20:56:36 +08:00
|
|
|
|
2024-05-15 05:07:58 +08:00
|
|
|
// await this.modPage.getLocator(e.secondsInput).press('Backspace');
|
|
|
|
await this.modPage.type(e.secondsInput, '6');
|
|
|
|
await this.modPage.type(e.minutesInput, '2');
|
|
|
|
await this.modPage.hasText(e.timerCurrent, /02:44/);
|
|
|
|
await this.modPage.hasText(e.timerIndicator, /02:44/);
|
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
|
|
|
|
2024-05-15 05:07:58 +08:00
|
|
|
await this.modPage.hasText(e.timerCurrent, /00:06/);
|
|
|
|
await this.modPage.hasText(e.timerIndicator, /00:06/);
|
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;
|