UNPKG

wc-e2e-page-objects

Version:

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

121 lines (89 loc) 5.68 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 _wpAdminWcSettings = require('./wp-admin-wc-settings'); var _wpAdminWcSettings2 = _interopRequireDefault(_wpAdminWcSettings); 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 WPAdminWCSettingsCheckout */ /** * External dependencies */ /** * Internal Dependencies */ var defaultArgs = { url: '', visit: true }; var ENABLE_COUPONS_SELECTOR = _seleniumWebdriver.By.css('#woocommerce_enable_coupons'); var CALC_DISCOUNTS_SEQUENTIALLY = _seleniumWebdriver.By.css('#calc_discounts_sequentially'); /** * The admin Checkout: Checkout Options screen * * @extends WPAdminWCSettings */ var WPAdminWCSettingsCheckout = function (_WPAdminWCSettings) { _inherits(WPAdminWCSettingsCheckout, _WPAdminWCSettings); /** * @param {WebDriver} driver - Instance of WebDriver. * @param {object} args - Configuration arguments. */ function WPAdminWCSettingsCheckout(driver) { var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _classCallCheck(this, WPAdminWCSettingsCheckout); args = Object.assign(defaultArgs, args); return _possibleConstructorReturn(this, (WPAdminWCSettingsCheckout.__proto__ || Object.getPrototypeOf(WPAdminWCSettingsCheckout)).call(this, driver, args)); } /** * Check the "Enable the use of coupons" checkbox. * * @return {Promise} Promise that evaluates to `true` if box is/gets checked successfully, `false` otherwise. */ _createClass(WPAdminWCSettingsCheckout, [{ key: 'checkEnableCoupons', value: function checkEnableCoupons() { return _wpE2eWebdriver.WebDriverHelper.setCheckbox(this.driver, ENABLE_COUPONS_SELECTOR); } /** * Uncheck the "Enable the use of coupons" checkbox. * * @return {Promise} Promise that evaluates to `true` if box is/gets unchecked successfully, `false` otherwise. */ }, { key: 'uncheckEnableCoupons', value: function uncheckEnableCoupons() { return _wpE2eWebdriver.WebDriverHelper.unsetCheckbox(this.driver, ENABLE_COUPONS_SELECTOR); } /** * Check the "Calculate coupon discounts sequentially" checkbox. * * @return {Promise} Promise that evaluates to `true` if box is/gets checked successfully, `false` otherwise. */ }, { key: 'checkCalculateDiscountsSequentially', value: function checkCalculateDiscountsSequentially() { return _wpE2eWebdriver.WebDriverHelper.setCheckbox(this.driver, CALC_DISCOUNTS_SEQUENTIALLY); } /** * Uncheck the "Calculate coupon discounts sequentially" checkbox. * * @return {Promise} Promise that evaluates to `true` if box is/gets unchecked successfully, `false` otherwise. */ }, { key: 'uncheckCalculateDiscountsSequentially', value: function uncheckCalculateDiscountsSequentially() { return _wpE2eWebdriver.WebDriverHelper.unsetCheckbox(this.driver, CALC_DISCOUNTS_SEQUENTIALLY); } }]); return WPAdminWCSettingsCheckout; }(_wpAdminWcSettings2.default); exports.default = WPAdminWCSettingsCheckout; module.exports = exports['default'];