UNPKG

wc-e2e-page-objects

Version:

WooCommerce Page Objects to be used on end-to-end tests with Selenium WebDriver

88 lines (61 loc) 4.62 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _seleniumWebdriver = require('selenium-webdriver'); var _wpE2eWebdriver = require('wp-e2e-webdriver'); var _componentMetaBoxCouponData = require('../../components/wp-admin/component-meta-box-coupon-data'); var _componentMetaBoxCouponData2 = _interopRequireDefault(_componentMetaBoxCouponData); var _wpAdminClassicPostEdit = require('./wp-admin-classic-post-edit'); var _wpAdminClassicPostEdit2 = _interopRequireDefault(_wpAdminClassicPostEdit); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @module WPAdminCouponEdit */ /** * External dependencies */ /** * Internal dependencies */ var DESCRIPTION_SELECTOR = _seleniumWebdriver.By.css('#woocommerce-coupon-description'); /** * The admin Edit Coupon page * * @extends WPAdminPostEdit */ var WPAdminCouponEdit = function (_WPAdminClassicPostEd) { _inherits(WPAdminCouponEdit, _WPAdminClassicPostEd); /** * @param {WebDriver} driver - Instance of WebDriver. * @param {object} args - Configuration arguments. */ function WPAdminCouponEdit(driver) { var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _classCallCheck(this, WPAdminCouponEdit); args = Object.assign({ components: { metaBoxCouponData: _componentMetaBoxCouponData2.default } }, args); return _possibleConstructorReturn(this, (WPAdminCouponEdit.__proto__ || Object.getPrototypeOf(WPAdminCouponEdit)).call(this, driver, args)); } /** * Set the coupon description. * * @param {string} description - Text to enter in the description field. * @return {Promise} Promise that evaluates to `true` if description set successfully, `false` otherwise. */ _createClass(WPAdminCouponEdit, [{ key: 'setDescription', value: function setDescription(description) { return _wpE2eWebdriver.WebDriverHelper.setWhenSettable(this.driver, DESCRIPTION_SELECTOR, description); } }]); return WPAdminCouponEdit; }(_wpAdminClassicPostEdit2.default); exports.default = WPAdminCouponEdit; module.exports = exports['default'];