UNPKG

wix-style-react

Version:
245 lines (204 loc) • 8.63 kB
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 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 { eyesItInstance } from '../../test/utils/eyes-it'; import { createStoryUrl, createTestStoryUrl } from '../../test/utils/storybook-helpers'; import { waitForVisibilityOf } from 'wix-ui-test-utils/protractor'; import autoExampleDriver from 'wix-storybook-utils/AutoExampleDriver'; import { tagTestkitFactory } from '../../testkit/protractor'; import { tooltipTestkitFactory } from 'wix-ui-core/dist/src/testkit/protractor'; import { createAutoExampleProps } from '../../stories/AutoExampleWrapperContants'; import { storySettings } from '../../stories/Tag/storySettings'; describe('Tag', function () { var eyes = eyesItInstance(); var url = createStoryUrl({ kind: storySettings.category, story: storySettings.storyName, withExamples: false }); var tagDriver = tagTestkitFactory({ dataHook: 'story-tag' }); describe('AutoExample', function () { beforeAll(_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 browser.get(url); case 2: case 'end': return _context.stop(); } } }, _callee, _this); }))); afterEach(function () { return autoExampleDriver.remount(); }); function sizesTests(autoExampleProps) { var _this2 = this; function setProps(props) { return autoExampleDriver.setProps(_extends({}, props, createAutoExampleProps(autoExampleProps))); } ['tiny', 'small', 'medium', 'large'].forEach(function (size) { eyes.it('should render ' + size + ' size properly', _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 waitForVisibilityOf(tagDriver.element(), 'Cannot find <Tag/>'); case 2: _context2.next = 4; return setProps({ size: size }); case 4: _context2.next = 6; return eyes.checkWindow(size + ' size'); case 6: _context2.next = 8; return setProps({ story__withThumb: true }); case 8: _context2.next = 10; return eyes.checkWindow(size + ' size'); case 10: _context2.next = 12; return setProps({ removable: false }); case 12: _context2.next = 14; return eyes.checkWindow(size + ' size: without remove button'); case 14: case 'end': return _context2.stop(); } } }, _callee2, _this2); }))); }); } describe('LTR', function () { sizesTests({}); }); describe('RTL', function () { sizesTests({ rtl: true }); }); eyes.it('should render themes', _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 waitForVisibilityOf(tagDriver.element(), 'Cannot find <Tag/>'); case 2: autoExampleDriver.setProps({ theme: 'error' }); _context3.next = 5; return eyes.checkWindow('theme: error'); case 5: autoExampleDriver.setProps({ theme: 'warning' }); _context3.next = 8; return eyes.checkWindow('theme: warning'); case 8: case 'end': return _context3.stop(); } } }, _callee3, _this); }))); eyes.it('should render disabled', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() { return regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.next = 2; return waitForVisibilityOf(tagDriver.element(), 'Cannot find <Tag/>'); case 2: autoExampleDriver.setProps({ disabled: true }); _context4.next = 5; return eyes.checkWindow('disabled'); case 5: case 'end': return _context4.stop(); } } }, _callee4, _this); }))); eyes.it('should show tooltip on hover when text is truncated with ellipses', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() { var dataHook, _tagDriver, tooltipDriver; return regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: dataHook = 'story-tag'; _context5.next = 3; return autoExampleDriver.setProps({ wrap: true, maxWidth: 70 }); case 3: _tagDriver = tagTestkitFactory({ dataHook: dataHook }); tooltipDriver = tooltipTestkitFactory({ dataHook: dataHook }); _context5.next = 7; return waitForVisibilityOf(_tagDriver.element(), 'Cannot find Tag'); case 7: _context5.t0 = expect; _context5.next = 10; return tooltipDriver.isContentElementExists(); case 10: _context5.t1 = _context5.sent; (0, _context5.t0)(_context5.t1).toBeFalsy(); _context5.next = 14; return tooltipDriver.mouseEnter(); case 14: _context5.t2 = expect; _context5.next = 17; return tooltipDriver.isContentElementExists(); case 17: _context5.t3 = _context5.sent; (0, _context5.t2)(_context5.t3).toBeTruthy(); case 19: case 'end': return _context5.stop(); } } }, _callee5, _this); }))); }); describe('TestPage', function () { var getTestUrl = function getTestUrl(rtl) { return createTestStoryUrl({ kind: storySettings.category, story: storySettings.storyName, testName: '1. Thumb Variations', rtl: rtl }); }; describe('LTR', function () { eyes.it('should render all thumb variations', _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 browser.get(getTestUrl()); case 2: case 'end': return _context6.stop(); } } }, _callee6, _this); }))); }); describe('RTL', function () { eyes.it('should render all thumb variations', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() { return regeneratorRuntime.wrap(function _callee7$(_context7) { while (1) { switch (_context7.prev = _context7.next) { case 0: _context7.next = 2; return browser.get(getTestUrl(true)); case 2: case 'end': return _context7.stop(); } } }, _callee7, _this); }))); }); }); });