woocommerce/tests/e2e-tests/wp-admin/wp-admin-coupon-new.js

54 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-02-28 20:00:12 +00:00
import config from 'config';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import test from 'selenium-webdriver/testing';
import { WebDriverManager, WebDriverHelper as helper } from 'wp-e2e-webdriver';
import { StoreOwnerFlow } from 'wc-e2e-page-objects';
chai.use( chaiAsPromised );
const assert = chai.assert;
let manager;
let driver;
test.describe( 'Add New Coupon Page', function() {
// open browser
test.before( function() {
2017-02-28 20:00:12 +00:00
this.timeout( config.get( 'startBrowserTimeoutMs' ) );
manager = new WebDriverManager( 'chrome', { baseUrl: config.get( 'url' ) } );
driver = manager.getDriver();
helper.clearCookiesAndDeleteLocalStorage( driver );
} );
this.timeout( config.get( 'mochaTimeoutMs' ) );
test.it( 'can create new coupon', () => {
const flowArgs = {
baseUrl: config.get( 'url' ),
username: config.get( 'users.admin.username' ),
password: config.get( 'users.admin.password' )
};
const storeOwner = new StoreOwnerFlow( driver, flowArgs );
const couponPage = storeOwner.openNewCoupon();
couponPage.setTitle( 'code-' + new Date().getTime().toString() );
couponPage.setDescription( 'test coupon' );
const couponData = couponPage.components.metaBoxCouponData;
const generalPanel = couponData.clickTab( 'General' );
generalPanel.selectDiscountType( 'Cart Discount' );
generalPanel.setCouponAmount( '100' );
couponPage.publish();
assert.eventually.ok( couponPage.hasNotice( 'Coupon updated.' ) );
} );
// quit browser
test.after( () => {
2017-02-28 20:00:12 +00:00
manager.quitBrowser();
} );
} );