UNPKG

wc-e2e-page-objects

Version:

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

89 lines (66 loc) 4.54 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 _wpE2ePageObjects = require('wp-e2e-page-objects'); 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 */ var TITLE_SELECTOR = _seleniumWebdriver.By.css('#title'); var PUBLISH_SELECTOR = _seleniumWebdriver.By.css('#publish'); var TRASH_SELECTOR = _seleniumWebdriver.By.css('.submitdelete'); /** * The admin Edit page that uses the classic editor * * @extends WPAdminPostEdit */ var WPAdminClassicPostEdit = function (_WPAdminPostEdit) { _inherits(WPAdminClassicPostEdit, _WPAdminPostEdit); function WPAdminClassicPostEdit() { _classCallCheck(this, WPAdminClassicPostEdit); return _possibleConstructorReturn(this, (WPAdminClassicPostEdit.__proto__ || Object.getPrototypeOf(WPAdminClassicPostEdit)).apply(this, arguments)); } _createClass(WPAdminClassicPostEdit, [{ key: 'publish', /** * Publish post. * * @return {Promise} Promise that evaluates to `true` if post was published, `false` otherwise. */ value: function publish() { return _wpE2eWebdriver.WebDriverHelper.clickWhenClickable(this.driver, PUBLISH_SELECTOR); } /** * Trash post. * * @return {Promise} Promise that evaluates to `true` if post was moved to trash, `false` otherwise. */ }, { key: 'moveToTrash', value: function moveToTrash() { return _wpE2eWebdriver.WebDriverHelper.clickWhenClickable(this.driver, TRASH_SELECTOR); } /** * Set the post title. * * @param {string} title - Text to enter in the title field. * @return {Promise} Promise that evaluates to `true` if title set successfully, `false` otherwise. */ }, { key: 'setTitle', value: function setTitle(title) { return _wpE2eWebdriver.WebDriverHelper.setWhenSettable(this.driver, TITLE_SELECTOR, title); } }]); return WPAdminClassicPostEdit; }(_wpE2ePageObjects.WPAdminPostEdit); exports.default = WPAdminClassicPostEdit; module.exports = exports['default'];