mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
ACS-8217: Remove internal Boolean pipe (#10101)
This commit is contained in:
@@ -16,9 +16,92 @@
|
||||
*/
|
||||
|
||||
import { browser, ElementFinder } from 'protractor';
|
||||
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { BrowserActions } from '../utils/browser-actions';
|
||||
|
||||
const JS_BIND_INPUT = (target) => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.style.display = 'none';
|
||||
input.addEventListener(
|
||||
'change',
|
||||
() => {
|
||||
target.scrollIntoView(true);
|
||||
|
||||
const rect = target.getBoundingClientRect();
|
||||
const x = rect.left + (rect.width >> 1);
|
||||
const y = rect.top + (rect.height >> 1);
|
||||
const data = { files: input.files };
|
||||
|
||||
['dragenter', 'dragover', 'drop'].forEach((name) => {
|
||||
const mouseEvent: any = document.createEvent('MouseEvent');
|
||||
mouseEvent.initMouseEvent(name, !0, !0, window, 0, 0, 0, x, y, !1, !1, !1, !1, 0, null);
|
||||
mouseEvent.dataTransfer = data;
|
||||
target.dispatchEvent(mouseEvent);
|
||||
});
|
||||
|
||||
document.body.removeChild(input);
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
document.body.appendChild(input);
|
||||
return input;
|
||||
};
|
||||
|
||||
const JS_BIND_INPUT_FOLDER = (target) => {
|
||||
const input: any = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.style.display = 'none';
|
||||
input.multiple = true;
|
||||
input.webkitdirectory = true;
|
||||
input.addEventListener(
|
||||
'change',
|
||||
() => {
|
||||
target.scrollIntoView(true);
|
||||
|
||||
const rect = target.getBoundingClientRect();
|
||||
const x = rect.left + (rect.width >> 1);
|
||||
const y = rect.top + (rect.height >> 1);
|
||||
const data = { files: input.files };
|
||||
|
||||
['dragenter', 'dragover', 'drop'].forEach((name) => {
|
||||
const mouseEvent: any = document.createEvent('MouseEvent');
|
||||
mouseEvent.initMouseEvent(name, !0, !0, window, 0, 0, 0, x, y, !1, !1, !1, !1, 0, null);
|
||||
mouseEvent.dataTransfer = data;
|
||||
target.dispatchEvent(mouseEvent);
|
||||
});
|
||||
|
||||
document.body.removeChild(input);
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
document.body.appendChild(input);
|
||||
return input;
|
||||
};
|
||||
|
||||
export class DropActions {
|
||||
static async dropFile(dropArea, filePath) {
|
||||
const absolutePath = path.resolve(path.join(browser.params.testConfig.main.rootPath, filePath));
|
||||
|
||||
fs.accessSync(absolutePath, fs.constants.F_OK);
|
||||
const elem = await dropArea.getWebElement();
|
||||
const input: any = await browser.executeScript(JS_BIND_INPUT, elem);
|
||||
return input.sendKeys(absolutePath);
|
||||
}
|
||||
|
||||
static async dropFolder(dropArea, folderPath) {
|
||||
const absolutePath = path.resolve(path.join(browser.params.testConfig.main.rootPath, folderPath));
|
||||
fs.accessSync(absolutePath, fs.constants.F_OK);
|
||||
|
||||
const elem = await dropArea.getWebElement();
|
||||
const input: any = await browser.executeScript(JS_BIND_INPUT_FOLDER, elem);
|
||||
return input.sendKeys(absolutePath);
|
||||
}
|
||||
|
||||
static async dragAndDrop(elementToDrag: ElementFinder, locationToDragTo: ElementFinder, locationOffset = { x: 230, y: 280 }) {
|
||||
await BrowserActions.click(elementToDrag);
|
||||
await browser.actions().mouseDown(elementToDrag).mouseMove(locationToDragTo, locationOffset).mouseUp().perform();
|
||||
|
Reference in New Issue
Block a user