2022-12-16 23:39:21 +08:00
|
|
|
const { expect } = require('@playwright/test');
|
|
|
|
const e = require('../core/elements');
|
|
|
|
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
|
|
|
const { MultiUsers } = require('../user/multiusers');
|
2023-03-08 23:33:05 +08:00
|
|
|
const { constructClipObj } = require('../core/util');
|
2022-12-16 23:39:21 +08:00
|
|
|
|
|
|
|
class DrawPencil extends MultiUsers {
|
|
|
|
constructor(browser, context) {
|
|
|
|
super(browser, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
async test() {
|
|
|
|
await this.modPage.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
|
|
|
|
2023-02-14 21:59:46 +08:00
|
|
|
const wbBox = await this.modPage.getElementBoundingBox(e.whiteboard);
|
2023-03-08 23:33:05 +08:00
|
|
|
const clipObj = constructClipObj(wbBox);
|
|
|
|
const screenshotOptions = {
|
|
|
|
maxDiffPixels: 1000,
|
|
|
|
clip: clipObj,
|
|
|
|
};
|
|
|
|
|
|
|
|
await this.modPage.waitAndClick(e.wbPencilShape);
|
|
|
|
|
2022-12-16 23:39:21 +08:00
|
|
|
const moveOptions = { steps: 50 }; // to slow down
|
|
|
|
await this.modPage.page.mouse.move(wbBox.x + 0.2 * wbBox.width, wbBox.y + 0.2 * wbBox.height);
|
|
|
|
await this.modPage.page.mouse.down();
|
|
|
|
await this.modPage.page.mouse.move(wbBox.x + 0.4 * wbBox.width, wbBox.y + 0.4 * wbBox.height, moveOptions);
|
|
|
|
await this.modPage.page.mouse.move(wbBox.x + 0.6 * wbBox.width, wbBox.y + 0.2 * wbBox.height, moveOptions);
|
|
|
|
await this.modPage.page.mouse.move(wbBox.x + 0.8 * wbBox.width, wbBox.y + 0.4 * wbBox.height, moveOptions);
|
|
|
|
await this.modPage.page.mouse.up();
|
|
|
|
|
2023-03-08 23:33:05 +08:00
|
|
|
await expect(this.modPage.page).toHaveScreenshot('moderator1-pencil.png', screenshotOptions);
|
2022-12-16 23:39:21 +08:00
|
|
|
|
2023-03-08 23:33:05 +08:00
|
|
|
await expect(this.modPage2.page).toHaveScreenshot('moderator2-pencil.png', screenshotOptions);
|
2022-12-16 23:39:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.DrawPencil = DrawPencil;
|