wix-style-react
Version:
210 lines (178 loc) • 6.9 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _protractor = require("wix-ui-test-utils/protractor");
var _PopoverUni = require("../Popover/Popover.uni.driver");
var _constants = require("./constants");
var _default = function _default(component, _body, _ref) {
var dataHook = _ref.dataHook;
var getSliderTooltipDataHook = function getSliderTooltipDataHook(index) {
return dataHook ? "".concat(dataHook, "-").concat(_constants.dataHooks.sliderTooltip, "-").concat(index) : "".concat(_constants.dataHooks.sliderTooltip, "-").concat(index);
};
var sliderHandle = function sliderHandle(index) {
return component.$("[data-hook=\"".concat(getSliderTooltipDataHook(index), "\"]"));
};
var currentHandleIndex = 0;
var actions = {
element: function element() {
return component;
},
exists: function exists() {
return !!component;
},
handleTooltipValue: function () {
var _handleTooltipValue = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_ref2) {
var index, popoverTestkit, text;
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
index = _ref2.index;
popoverTestkit = (0, _protractor.protractorUniTestkitFactoryCreator)(_PopoverUni.popoverDriverFactory)({
dataHook: getSliderTooltipDataHook(index)
});
_context.next = 4;
return popoverTestkit.mouseEnter();
case 4:
_context.t0 = parseInt;
_context.next = 7;
return popoverTestkit.getContentElement();
case 7:
_context.next = 9;
return _context.sent.getText();
case 9:
_context.t1 = _context.sent;
text = (0, _context.t0)(_context.t1);
_context.next = 13;
return actions.unHoverHandle({
index: index
});
case 13:
return _context.abrupt("return", text);
case 14:
case "end":
return _context.stop();
}
}
}, _callee);
}));
function handleTooltipValue(_x) {
return _handleTooltipValue.apply(this, arguments);
}
return handleTooltipValue;
}(),
isHandleTooltipDisplayed: function () {
var _isHandleTooltipDisplayed = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
var popoverTestkit;
return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
popoverTestkit = (0, _protractor.protractorUniTestkitFactoryCreator)(_PopoverUni.popoverDriverFactory)({
dataHook: getSliderTooltipDataHook(currentHandleIndex)
});
return _context2.abrupt("return", popoverTestkit.isContentElementExists());
case 2:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
function isHandleTooltipDisplayed() {
return _isHandleTooltipDisplayed.apply(this, arguments);
}
return isHandleTooltipDisplayed;
}(),
hoverHandle: function () {
var _hoverHandle = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(_ref3) {
var index, handle;
return _regenerator["default"].wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
index = _ref3.index;
currentHandleIndex = index;
_context3.next = 4;
return actions.unHoverHandle({
index: index
});
case 4:
handle = sliderHandle(index);
_context3.next = 7;
return browser.actions().mouseMove(handle).perform();
case 7:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
function hoverHandle(_x2) {
return _hoverHandle.apply(this, arguments);
}
return hoverHandle;
}(),
dragHandle: function () {
var _dragHandle = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(_ref4) {
var index, offset, ONE_DOT_MOVEMENT, handle;
return _regenerator["default"].wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
index = _ref4.index, offset = _ref4.offset;
ONE_DOT_MOVEMENT = 64;
handle = sliderHandle(index);
_context4.next = 5;
return browser.actions().dragAndDrop(handle, {
x: offset * ONE_DOT_MOVEMENT,
y: 0
}).perform();
case 5:
case "end":
return _context4.stop();
}
}
}, _callee4);
}));
function dragHandle(_x3) {
return _dragHandle.apply(this, arguments);
}
return dragHandle;
}(),
unHoverHandle: function () {
var _unHoverHandle = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_ref5) {
var index, handle;
return _regenerator["default"].wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
index = _ref5.index;
currentHandleIndex = 0;
handle = sliderHandle(index);
_context5.next = 5;
return browser.actions().mouseMove(handle).mouseMove({
x: -100,
y: -100
}).perform();
case 5:
case "end":
return _context5.stop();
}
}
}, _callee5);
}));
function unHoverHandle(_x4) {
return _unHoverHandle.apply(this, arguments);
}
return unHoverHandle;
}()
};
return actions;
};
exports["default"] = _default;