wix-style-react
Version:
wix-style-react
307 lines (256 loc) • 10.4 kB
JavaScript
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 { formFieldTestkitFactory, inputTestkitFactory } from '../../testkit/protractor';
import { waitForVisibilityOf, scrollToElement } from 'wix-ui-test-utils/protractor';
import { createStoryUrl } from '../../test/utils/storybook-helpers';
import autoExampleDriver from 'wix-storybook-utils/AutoExampleDriver';
var storyUrl = createStoryUrl({
kind: 'Components',
story: 'FormField',
withExamples: false
});
var storyUrlWithExamples = createStoryUrl({
kind: 'Components',
story: 'FormField',
withExamples: true
});
var driver = formFieldTestkitFactory({ dataHook: 'storybook-formfield' });
describe('FormField', function () {
describe('[AutoExample]', function () {
beforeAll(function () {
return browser.get(storyUrl);
});
eyes.it('should render with label', _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 autoExampleDriver.setProps({ label: 'hello' });
case 2:
_context.next = 4;
return waitForVisibilityOf(driver.element(), 'Cannot find FormField component');
case 4:
_context.t0 = expect;
_context.next = 7;
return driver.hasTopLabel();
case 7:
_context.t1 = _context.sent;
(0, _context.t0)(_context.t1).toBeTruthy();
case 9:
case 'end':
return _context.stop();
}
}
}, _callee, _this);
})), { version: 'no maxlength' });
eyes.it('should render with label on the right', _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 autoExampleDriver.setProps({
label: 'hello',
labelPlacement: 'right'
});
case 2:
_context2.next = 4;
return waitForVisibilityOf(driver.element(), 'Cannot find FormField component');
case 4:
_context2.t0 = expect;
_context2.next = 7;
return driver.hasRightLabel();
case 7:
_context2.t1 = _context2.sent;
(0, _context2.t0)(_context2.t1).toBeTruthy();
case 9:
case 'end':
return _context2.stop();
}
}
}, _callee2, _this);
})), { version: 'no maxlength' });
eyes.it('should render with label on the left', _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 autoExampleDriver.setProps({
label: 'hello',
labelPlacement: 'left'
});
case 2:
_context3.next = 4;
return waitForVisibilityOf(driver.element(), 'Cannot find FormField component');
case 4:
_context3.t0 = expect;
_context3.next = 7;
return driver.hasLeftLabel();
case 7:
_context3.t1 = _context3.sent;
(0, _context3.t0)(_context3.t1).toBeTruthy();
case 9:
case 'end':
return _context3.stop();
}
}
}, _callee3, _this);
})), { version: 'no maxlength' });
eyes.it('should render as required given required and no label props', _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 autoExampleDriver.setProps({ required: true });
case 2:
_context4.next = 4;
return waitForVisibilityOf(driver.element(), 'Cannot find FormField component');
case 4:
_context4.t0 = expect;
_context4.next = 7;
return driver.isRequired();
case 7:
_context4.t1 = _context4.sent;
(0, _context4.t0)(_context4.t1).toBe(true);
case 9:
case 'end':
return _context4.stop();
}
}
}, _callee4, _this);
})));
eyes.it('should render info icon given infoContent prop', _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 autoExampleDriver.setProps({ infoContent: 'hello' });
case 2:
_context5.next = 4;
return waitForVisibilityOf(driver.element(), 'Cannot find FormField component');
case 4:
_context5.t0 = expect;
_context5.next = 7;
return driver.isInfoIconVisible();
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 render info icon given infoContent prop', _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 autoExampleDriver.setProps({ infoContent: 'hello' });
case 2:
_context6.next = 4;
return waitForVisibilityOf(driver.element(), 'Cannot find FormField component');
case 4:
_context6.t0 = expect;
_context6.next = 7;
return driver.isInfoIconVisible();
case 7:
_context6.t1 = _context6.sent;
(0, _context6.t0)(_context6.t1).toBe(true);
case 9:
case 'end':
return _context6.stop();
}
}
}, _callee6, _this);
})));
eyes.it('should not stretch the children when stretchContent prop is false', _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 autoExampleDriver.setProps({ stretchContent: false });
case 2:
_context7.next = 4;
return waitForVisibilityOf(driver.element(), 'Cannot find FormField component');
case 4:
_context7.t0 = expect;
_context7.next = 7;
return driver.isContentStretched();
case 7:
_context7.t1 = _context7.sent;
(0, _context7.t0)(_context7.t1).toBeFalsy();
case 9:
case 'end':
return _context7.stop();
}
}
}, _callee7, _this);
})));
});
eyes.it('should render length count', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {
var formFieldDriver, element, inputDriver;
return regeneratorRuntime.wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
_context8.next = 2;
return browser.get(storyUrlWithExamples);
case 2:
formFieldDriver = formFieldTestkitFactory({
dataHook: 'storybook-formfield-length-count'
});
element = formFieldDriver.element();
inputDriver = inputTestkitFactory({
dataHook: 'storybook-formfield-length-count-input'
});
_context8.next = 7;
return waitForVisibilityOf(element, 'Cannot find FormField component');
case 7:
_context8.next = 9;
return scrollToElement(element);
case 9:
_context8.next = 11;
return eyes.checkWindow('count is zero');
case 11:
_context8.next = 13;
return inputDriver.enterText('11111-11111');
case 13:
_context8.next = 15;
return inputDriver.enterText('11111-11111-11111-11111');
case 15:
case 'end':
return _context8.stop();
}
}
}, _callee8, _this);
})));
eyes.it('should be rendered within Grid', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {
var formFieldDriver;
return regeneratorRuntime.wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
_context9.next = 2;
return browser.get(storyUrlWithExamples);
case 2:
formFieldDriver = formFieldTestkitFactory({
dataHook: 'storybook-formfield-grid'
});
expect(formFieldDriver.element().isDisplayed()).toBeTruthy();
case 4:
case 'end':
return _context9.stop();
}
}
}, _callee9, _this);
})));
});