2021-11-23 05:51:16 +08:00
|
|
|
const { expect } = require('@playwright/test');
|
|
|
|
const Page = require('../core/page');
|
|
|
|
const e = require('../core/elements');
|
|
|
|
const { ELEMENT_WAIT_LONGER_TIME } = require('../core/constants');
|
|
|
|
|
|
|
|
class Draw extends Page {
|
|
|
|
constructor(browser, page) {
|
|
|
|
super(browser, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
async test() {
|
|
|
|
await this.waitForSelector(e.whiteboard, ELEMENT_WAIT_LONGER_TIME);
|
2022-07-02 04:55:32 +08:00
|
|
|
await this.waitAndClick(e.wbRectangleShape);
|
2021-11-23 05:51:16 +08:00
|
|
|
|
2024-03-02 02:15:18 +08:00
|
|
|
const modWbLocator = this.getLocator(e.whiteboard);
|
|
|
|
const wbBox = await modWbLocator.boundingBox();
|
|
|
|
const screenshotOptions = {
|
|
|
|
maxDiffPixels: 1000,
|
|
|
|
};
|
2023-08-08 01:08:26 +08:00
|
|
|
|
2021-11-23 05:51:16 +08:00
|
|
|
await this.page.mouse.move(wbBox.x + 0.3 * wbBox.width, wbBox.y + 0.3 * wbBox.height);
|
|
|
|
await this.page.mouse.down();
|
|
|
|
await this.page.mouse.move(wbBox.x + 0.7 * wbBox.width, wbBox.y + 0.7 * wbBox.height);
|
|
|
|
await this.page.mouse.up();
|
|
|
|
|
2022-07-02 04:55:32 +08:00
|
|
|
await this.waitForSelector(e.wbDrawnRectangle);
|
2024-03-02 02:15:18 +08:00
|
|
|
|
2024-03-12 19:35:41 +08:00
|
|
|
await this.setHeightWidthViewPortSize();
|
2024-03-02 02:15:18 +08:00
|
|
|
await expect(modWbLocator).toHaveScreenshot('moderator-rect-ci.png', screenshotOptions);
|
2021-11-23 05:51:16 +08:00
|
|
|
}
|
|
|
|
|
2022-07-02 04:55:32 +08:00
|
|
|
async getOuterHtmlDrawn() {
|
|
|
|
return this.page.evaluate((selector) => document.querySelector(selector).outerHTML, e.wbLayer);
|
2021-11-23 05:51:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-02 12:12:14 +08:00
|
|
|
exports.Draw = Draw;
|