@uuv/assistant
Version:
UUV Helper used to improve the life of testers and developers by generating cucumber phrases from the GUI.
52 lines (51 loc) • 1.76 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HighlightHelper = exports.HIGHLIGHT_ORANGE_PROPS = void 0;
const inspector_dom_1 = __importDefault(require("./inspector-dom"));
const informative_nodes_helper_1 = require("../informative-nodes-helper");
exports.HIGHLIGHT_ORANGE_PROPS = {
width: 4,
borderColor: "orange"
};
class HighlightHelper {
constructor(onSelect) {
this.onSelect = onSelect;
}
createInspector(onMouseOver, onMouseOut) {
this.inspector = (0, inspector_dom_1.default)({
root: "body",
outlineStyle: "2px solid red",
onClick: (el) => {
this.onSelect(el);
this.inspector.cancel();
},
onMouseOver,
onMouseOut
});
}
enableBasicHighlight() {
this.createInspector(el => this.inspector.highlight(el), el => this.inspector.removeHighlight(el));
this.inspector.enable();
}
enableRefinedHighlight() {
const informativeNodesHelper = new informative_nodes_helper_1.InformativeNodesHelper();
const nodesWithInfo = informativeNodesHelper.getAvailableNodes();
this.createInspector(el => {
if (nodesWithInfo.includes(el)) {
this.inspector.highlight(el);
}
}, el => {
if (nodesWithInfo.includes(el)) {
this.inspector.removeHighlight(el);
}
});
this.inspector.enable();
}
cancel() {
this.inspector.cancel();
}
}
exports.HighlightHelper = HighlightHelper;