wix-style-react
Version:
wix-style-react
210 lines (169 loc) • 6.74 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 eventually from 'wix-eventually';
import { pageTestkitFactory } from '../../testkit/protractor';
import { waitForVisibilityOf, scrollToElement } from 'wix-ui-test-utils/protractor';
import { createStoryUrl, createTestStoryUrl } from '../../test/utils/storybook-helpers';
import autoExampleDriver from 'wix-storybook-utils/AutoExampleDriver';
import { storySettings } from '../../stories/Page/storySettings';
var category = storySettings.category,
storyName = storySettings.storyName;
var testStoryUrl = function testStoryUrl(testName) {
return createTestStoryUrl({ category: category, storyName: storyName, testName: testName });
};
describe('Page', function () {
var initTest = function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref2) {
var storyUrl = _ref2.storyUrl,
dataHook = _ref2.dataHook,
props = _ref2.props;
var driver;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return browser.get(storyUrl);
case 2:
driver = pageTestkitFactory({ dataHook: dataHook });
_context.next = 5;
return waitForVisibilityOf(driver.element(), 'Cannot find Page');
case 5:
_context.next = 7;
return scrollToElement(driver.element());
case 7:
_context.t0 = props;
if (!_context.t0) {
_context.next = 11;
break;
}
_context.next = 11;
return autoExampleDriver.setProps(props);
case 11:
return _context.abrupt('return', driver);
case 12:
case 'end':
return _context.stop();
}
}
}, _callee, _this);
}));
return function initTest(_x) {
return _ref.apply(this, arguments);
};
}();
var runTestCases = function runTestCases(initTestConfig) {
eyes.it('should hide title on scroll threshold', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var driver;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return initTest(initTestConfig);
case 2:
driver = _context2.sent;
_context2.t0 = expect;
_context2.next = 6;
return driver.titleExists();
case 6:
_context2.t1 = _context2.sent;
_context2.next = 9;
return (0, _context2.t0)(_context2.t1).toBeTruthy();
case 9:
_context2.next = 11;
return eyes.checkWindow('Page title shown');
case 11:
_context2.next = 13;
return driver.scrollDown();
case 13:
_context2.next = 15;
return eventually(function () {
return !driver.titleExists();
});
case 15:
_context2.next = 17;
return eyes.checkWindow('Page title hidden');
case 17:
_context2.next = 19;
return driver.scrollUp();
case 19:
_context2.next = 21;
return eventually(function () {
return driver.titleExists();
});
case 21:
_context2.next = 23;
return eyes.checkWindow('Page title appears');
case 23:
case 'end':
return _context2.stop();
}
}
}, _callee2, _this);
})));
};
describe('Header + Tail + Content', function () {
var dataHook = 'story-page';
var storyUrl = createStoryUrl({
kind: category,
story: storyName,
withExamples: false
});
describe('With Background-Image', function () {
runTestCases({ storyUrl: storyUrl, dataHook: dataHook });
});
describe('With gradientCoverTail', function () {
runTestCases({ storyUrl: storyUrl, dataHook: dataHook, props: { backgroundImageUrl: '' } });
});
});
describe('Header + Content', function () {
var dataHook = 'story-page';
describe('With Background-Image', function () {
var storyUrl = testStoryUrl('1. Image');
runTestCases({ storyUrl: storyUrl, dataHook: dataHook });
});
describe('With Gradient', function () {
var storyUrl = testStoryUrl('2. Gradient');
runTestCases({ storyUrl: storyUrl, dataHook: dataHook });
});
});
describe('Header + FixedContent + Content', function () {
var dataHook = 'story-page';
describe('With Background-Image', function () {
var storyUrl = testStoryUrl('3. FC-Image');
runTestCases({ storyUrl: storyUrl, dataHook: dataHook });
});
describe('With Gradient', function () {
var storyUrl = testStoryUrl('4. FC-Gradient');
runTestCases({ storyUrl: storyUrl, dataHook: dataHook });
});
});
describe('With EmptyState', function () {
var storyUrl = createStoryUrl({ kind: category, story: storyName });
it('should not break design', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
var _dataHook, element;
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_dataHook = 'story-page-empty-state';
element = $('[data-hook="' + _dataHook + '"]');
_context3.next = 4;
return browser.get(storyUrl);
case 4:
_context3.next = 6;
return waitForVisibilityOf(element, 'Cannot find ' + _dataHook);
case 6:
_context3.next = 8;
return scrollToElement(element);
case 8:
case 'end':
return _context3.stop();
}
}
}, _callee3, _this);
})));
});
});