UNPKG

wix-style-react

Version:
140 lines (112 loc) • 5.48 kB
'use strict'; var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _eyes = require('eyes.it'); var _eyes2 = _interopRequireDefault(_eyes); var _protractor = require('wix-ui-test-utils/protractor'); var _storySettings = require('../../stories/TableActionCell/storySettings'); var _protractor2 = require('../../testkit/protractor'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } var hoverElement = function hoverElement(element) { return browser.actions().mouseMove(element).perform(); }; describe('Table Action Cell', function () { var storyUrl = (0, _protractor.createStoryUrl)({ kind: _storySettings.storySettings.kind, story: _storySettings.storySettings.storyName }); var verifyItem = function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(name, dataHook) { var driver, element; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: driver = (0, _protractor2.tableActionCellTestkitFactory)({ dataHook: dataHook }); element = driver.element(); _context.next = 4; return (0, _protractor.waitForVisibilityOf)(element, 'Cannot find ' + dataHook); case 4: _context.next = 6; return (0, _protractor.scrollToElement)(element); case 6: _context.next = 8; return _eyes2.default.checkWindow(name + ' idle'); case 8: _context.next = 10; return hoverElement(element); case 10: _context.next = 12; return _eyes2.default.checkWindow(name + ' hovered'); case 12: _context.prev = 12; _context.next = 15; return driver.getHiddenActionsPopoverMenu().click(); case 15: _context.next = 17; return _eyes2.default.checkWindow(name + ' PopoverMenu opened'); case 17: _context.next = 19; return driver.getHiddenActionsPopoverMenu().click(); case 19: _context.next = 23; break; case 21: _context.prev = 21; _context.t0 = _context['catch'](12); case 23: case 'end': return _context.stop(); } } }, _callee, undefined, [[12, 21]]); })); return function verifyItem(_x, _x2) { return _ref.apply(this, arguments); }; }(); var examples = { 'Blue primary action': 'story-primary-blue', 'White primary action': 'story-primary-white', 'Primary and secondary actions': 'story-primary-secondary', 'Primary and hidden secondary actions': 'story-primary-hidden-secondary', 'With custom PopoverMenu props': 'story-popover-menu-props', 'Always visible secondary actions': 'story-always-visible-secondary', 'Only secondary actions': 'story-only-secondary', 'Only visible secondary actions': 'story-only-visible-secondary', 'Primary and secondary actions with RTL': 'story-primary-secondary-rtl' }; beforeAll(_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return browser.get(storyUrl); case 2: case 'end': return _context2.stop(); } } }, _callee2, undefined); }))); Object.entries(examples).forEach(function (_ref3) { var _ref4 = _slicedToArray(_ref3, 2), name = _ref4[0], dataHook = _ref4[1]; _eyes2.default.it('should render correctly for ' + name, _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() { return regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return verifyItem(name, dataHook); case 2: case 'end': return _context3.stop(); } } }, _callee3, undefined); }))); }); });