2021-02-17 04:57:10 +08:00
|
|
|
const { ELEMENT_WAIT_TIME } = require('../core/constants');
|
2018-11-23 20:55:16 +08:00
|
|
|
const Page = require('../core/page');
|
2018-08-27 23:00:42 +08:00
|
|
|
const e = require('./elements');
|
|
|
|
|
2018-11-23 22:43:35 +08:00
|
|
|
class Draw extends Page {
|
2018-11-23 03:15:52 +08:00
|
|
|
constructor() {
|
|
|
|
super('whiteboard-draw');
|
|
|
|
}
|
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 {
|
|
|
|
await this.waitForSelector(e.tools, ELEMENT_WAIT_TIME);
|
|
|
|
await this.click(e.tools, true);
|
|
|
|
await this.waitForSelector(e.rectangle, ELEMENT_WAIT_TIME);
|
|
|
|
await this.click(e.rectangle, true);
|
|
|
|
await this.waitForSelector(e.whiteboard, ELEMENT_WAIT_TIME);
|
|
|
|
|
|
|
|
const shapes0 = await this.getTestElements();
|
|
|
|
shapes0 === '<g></g>';
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
await this.waitForSelector(e.drawnRectangle, ELEMENT_WAIT_TIME);
|
|
|
|
const shapes1 = await this.getTestElements();
|
|
|
|
shapes1 !== '<g></g>';
|
2021-08-14 01:35:00 +08:00
|
|
|
|
|
|
|
return shapes0 && shapes1;
|
2021-02-17 04:57:10 +08:00
|
|
|
} catch (e) {
|
|
|
|
await this.logger(e);
|
|
|
|
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 {
|
|
|
|
await this.waitForSelector('g[clip-path="url(#viewBox)"]', ELEMENT_WAIT_TIME);
|
|
|
|
const shapes = await this.page.evaluate(() => document.querySelector('svg g[clip-path]').children[1].outerHTML);
|
|
|
|
return shapes;
|
|
|
|
} catch (e) {
|
|
|
|
await this.logger(e);
|
|
|
|
}
|
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;
|