Merge pull request #17095 from woocommerce/update/e2e
Update chromedriver version and add singles tests
This commit is contained in:
commit
734357aa3e
|
@ -23,7 +23,7 @@
|
|||
"babel-preset-stage-2": "^6.13.0",
|
||||
"chai": "^3.5.0",
|
||||
"chai-as-promised": "^6.0.0",
|
||||
"chromedriver": "^2.25.0",
|
||||
"chromedriver": "2.33.0",
|
||||
"config": "^1.24.0",
|
||||
"cross-env": "^3.0.0",
|
||||
"grunt": "~1.0.1",
|
||||
|
@ -43,7 +43,7 @@
|
|||
"grunt-wp-i18n": "~1.0.0",
|
||||
"istanbul": "^1.0.0-alpha",
|
||||
"mocha": "^3.0.2",
|
||||
"wc-e2e-page-objects": "0.3.0"
|
||||
"wc-e2e-page-objects": "0.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.4",
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
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 { SingleProductPage, CartPage } from 'wc-e2e-page-objects';
|
||||
|
||||
chai.use( chaiAsPromised );
|
||||
|
||||
const assert = chai.assert;
|
||||
|
||||
let manager;
|
||||
let driver;
|
||||
|
||||
test.describe( 'Single Product Page', function() {
|
||||
test.before( 'open browser', function() {
|
||||
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( 'should be able to add simple products to the cart', () => {
|
||||
const productPage = new SingleProductPage( driver, { url: manager.getPageUrl( '/product/happy-ninja' ) } );
|
||||
productPage.setQuantity( 5 );
|
||||
productPage.addToCart();
|
||||
|
||||
const cartPage = new CartPage( driver, { url: manager.getPageUrl( '/cart' ) } );
|
||||
assert.eventually.equal( cartPage.hasItem( 'Happy Ninja', { qty: 5 } ), true );
|
||||
} );
|
||||
|
||||
test.it( 'should be able to add variation products to the cart', () => {
|
||||
const variableProductPage = new SingleProductPage( driver, { url: manager.getPageUrl( '/product/ship-your-idea-3/' ) } );
|
||||
variableProductPage.selectVariation( 'Color', 'Black' );
|
||||
variableProductPage.addToCart();
|
||||
|
||||
// Pause for a half-second. Driver goes to fast and makes wrong selections otherwise.
|
||||
driver.sleep( 500 );
|
||||
|
||||
variableProductPage.selectVariation( 'Color', 'Green' );
|
||||
variableProductPage.addToCart();
|
||||
|
||||
const cartPage = new CartPage( driver, { url: manager.getPageUrl( '/cart' ) } );
|
||||
assert.eventually.equal( cartPage.hasItem( 'Ship Your Idea - Black' ), true );
|
||||
assert.eventually.equal( cartPage.hasItem( 'Ship Your Idea - Green' ), true );
|
||||
} );
|
||||
|
||||
test.after( 'quit browser', () => {
|
||||
manager.quitBrowser();
|
||||
} );
|
||||
} );
|
Loading…
Reference in New Issue