UNPKG

wix-style-react

Version:
214 lines (178 loc) • 7.08 kB
var _this = this; 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"); }); }; } import eyes from 'eyes.it'; import { editableSelectorTestkitFactory } from '../../testkit/protractor'; import { waitForVisibilityOf } from 'wix-ui-test-utils/protractor'; import { getStoryUrl } from '../../test/utils/storybook-helpers'; describe('EditableSelector', function () { var storyUrl = getStoryUrl('11. Pickers and Selectors', '11.2 EditableSelector'); var dataHook = 'story-editable-selector'; var driver = void 0; beforeEach(function () { driver = editableSelectorTestkitFactory({ dataHook: dataHook }); return browser.get(storyUrl); }); eyes.it('should render a title', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return waitForVisibilityOf(driver.element(), 'Cannot find EditableSelector'); case 2: _context.t0 = expect; _context.next = 5; return driver.title().getText(); case 5: _context.t1 = _context.sent; (0, _context.t0)(_context.t1).toBe('Type of Seeds'); case 7: case 'end': return _context.stop(); } } }, _callee, _this); }))); eyes.it('should create a new option', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { var newOption; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return waitForVisibilityOf(driver.element(), 'Cannot find EditableSelector'); case 2: newOption = 'Shir'; _context2.next = 5; return driver.createNewRow(newOption); case 5: _context2.next = 7; return driver.clickApprove(); case 7: _context2.t0 = expect; _context2.next = 10; return driver.item(2).getText(); case 10: _context2.t1 = _context2.sent; _context2.t2 = newOption; (0, _context2.t0)(_context2.t1).toBe(_context2.t2); case 13: case 'end': return _context2.stop(); } } }, _callee2, _this); }))); // No eyes: I don't think eyes is needed here. It fails for unknown reason. // The snapshot used to include the edit button (which is visible on hover only) // And it started breaking (no edit button in snapshot). So we decided to disable eyes here. it('should not modify an option when edit is cancelled', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() { var newOption; return regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return waitForVisibilityOf(driver.element(), 'Cannot find EditableSelector'); case 2: newOption = 'Shir'; _context3.next = 5; return driver.editRow(1, newOption); case 5: _context3.next = 7; return driver.clickCancel(); case 7: _context3.t0 = expect; _context3.next = 10; return driver.item(1).getText(); case 10: _context3.t1 = _context3.sent; _context3.t2 = newOption; (0, _context3.t0)(_context3.t1).not.toBe(_context3.t2); case 13: case 'end': return _context3.stop(); } } }, _callee3, _this); }))); eyes.it('should save an option when edit is approved', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() { var newOption; return regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.next = 2; return waitForVisibilityOf(driver.element(), 'Cannot find EditableSelector'); case 2: newOption = 'Shir'; _context4.next = 5; return driver.editRow(1, newOption); case 5: _context4.next = 7; return driver.clickApprove(); case 7: _context4.t0 = expect; _context4.next = 10; return driver.item(1).getText(); case 10: _context4.t1 = _context4.sent; _context4.t2 = newOption; (0, _context4.t0)(_context4.t1).toBe(_context4.t2); case 13: case 'end': return _context4.stop(); } } }, _callee4, _this); }))); eyes.it('should select an option when clicked', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() { return regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return waitForVisibilityOf(driver.element(), 'Cannot find EditableSelector'); case 2: _context5.next = 4; return driver.toggleItem(0); case 4: _context5.t0 = expect; _context5.next = 7; return driver.isSelected(0); case 7: _context5.t1 = _context5.sent; (0, _context5.t0)(_context5.t1).toBe(true); case 9: case 'end': return _context5.stop(); } } }, _callee5, _this); }))); eyes.it('should delete an option', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() { return regeneratorRuntime.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: _context6.next = 2; return waitForVisibilityOf(driver.element(), 'Cannot find EditableSelector'); case 2: _context6.next = 4; return driver.deleteRow(1); case 4: _context6.t0 = expect; _context6.next = 7; return driver.items().count(); case 7: _context6.t1 = _context6.sent; _context6.next = 10; return (0, _context6.t0)(_context6.t1).toBe(1); case 10: case 'end': return _context6.stop(); } } }, _callee6, _this); }))); });