2018-11-23 20:55:16 +08:00
|
|
|
const Page = require('../core/page');
|
2021-09-22 11:51:29 +08:00
|
|
|
const e = require('../core/elements');
|
2018-08-27 23:00:42 +08:00
|
|
|
|
2018-11-23 22:43:35 +08:00
|
|
|
class Draw extends Page {
|
2018-11-23 03:15:52 +08:00
|
|
|
constructor() {
|
2021-09-23 03:22:47 +08:00
|
|
|
super();
|
2018-11-23 03:15:52 +08:00
|
|
|
}
|
2018-08-27 23:00:42 +08:00
|
|
|
|
2018-11-23 03:15:52 +08:00
|
|
|
async test() {
|
2021-02-17 04:57:10 +08:00
|
|
|
try {
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.waitForSelector(e.whiteboard);
|
|
|
|
await this.waitAndClick(e.tools);
|
|
|
|
await this.waitAndClick(e.rectangle);
|
2021-02-17 04:57:10 +08:00
|
|
|
|
2021-09-22 21:24:38 +08:00
|
|
|
const shapes1 = await this.getTestElements();
|
|
|
|
const test1 = shapes1 === '<g></g>';
|
2021-02-17 04:57:10 +08:00
|
|
|
|
|
|
|
const wb = await this.page.$(e.whiteboard);
|
|
|
|
const wbBox = await wb.boundingBox();
|
|
|
|
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();
|
|
|
|
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.waitForSelector(e.drawnRectangle);
|
2021-09-22 21:24:38 +08:00
|
|
|
const shapes2 = await this.getTestElements();
|
|
|
|
const test2 = shapes2 !== '<g></g>';
|
2021-08-14 01:35:00 +08:00
|
|
|
|
2021-09-22 21:24:38 +08:00
|
|
|
return test1 && test2;
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.logger(err);
|
2021-02-17 04:57:10 +08:00
|
|
|
return false;
|
|
|
|
}
|
2018-08-27 23:00:42 +08:00
|
|
|
}
|
|
|
|
|
2018-10-13 02:46:26 +08:00
|
|
|
async getTestElements() {
|
2021-08-14 01:35:00 +08:00
|
|
|
try {
|
2021-09-22 21:11:56 +08:00
|
|
|
await this.waitForSelector(e.whiteboardViewBox);
|
2021-09-22 21:24:38 +08:00
|
|
|
return this.page.evaluate((selector) => document.querySelector(selector).children[1].outerHTML, e.whiteboardViewBox);
|
2021-08-26 22:13:18 +08:00
|
|
|
} catch (err) {
|
|
|
|
await this.logger(err);
|
2021-08-14 01:35:00 +08:00
|
|
|
}
|
2018-08-27 23:00:42 +08:00
|
|
|
}
|
2018-10-13 02:46:26 +08:00
|
|
|
}
|
2018-08-27 23:00:42 +08:00
|
|
|
|
2018-11-23 22:43:35 +08:00
|
|
|
module.exports = exports = Draw;
|