diff --git a/tests/e2e-tests/config-setup.js b/tests/e2e-tests/config-setup.js new file mode 100644 index 00000000000..630a61c4bd3 --- /dev/null +++ b/tests/e2e-tests/config-setup.js @@ -0,0 +1,62 @@ +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 { WPLogin, WPAdmin } from 'wp-e2e-page-objects'; + +chai.use( chaiAsPromised ); +const assert = chai.assert; + +let manager; +let driver; + +test.describe( 'Check for functional WordPress installation', function() { + // open browser + test.before( 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' ) ); + + // login + test.before( () => { + const wpLogin = new WPLogin( driver, { url: manager.getPageUrl( '/wp-login.php' ) } ); + wpLogin.login( config.get( 'users.admin.username' ), config.get( 'users.admin.password' ) ); + } ); + + // Update the database to the current version of WP + test.it( 'update WordPress database', () => { + const updateArgs = { url: manager.getPageUrl( '/wp-admin/upgrade.php?step=upgrade_db' ), visit: true }; + const update = new WPAdmin( driver, updateArgs ); + + } ); + + // Check theme status after conditionally attempting to revert to the default theme + test.it( 'have working theme', () => { + const themesArgs = { url: manager.getPageUrl( '/wp-admin/themes.php' ), visit: true }; + const themes = new WPAdmin( driver, themesArgs ); + + driver.navigate().refresh(); + assert.eventually.notEqual( themes.hasNotice( 'The active theme is broken.' ) ); + assert.eventually.notEqual( themes.hasNotice( 'No themes found.' ) ); + assert.eventually.notEqual( themes.hasNotice( 'ERROR:' ) ); + } ); + + // take screenshot + test.afterEach( function() { + if ( this.currentTest.state === 'failed' ) { + helper.takeScreenshot( manager, this.currentTest ); + } + } ); + + // quit browser + test.after( () => { + manager.quitBrowser(); + } ); +} ); diff --git a/tests/e2e-tests/cart-page.js b/tests/e2e-tests/front-end/cart-page.js similarity index 99% rename from tests/e2e-tests/cart-page.js rename to tests/e2e-tests/front-end/cart-page.js index 970a0644864..a0fd6cb1436 100644 --- a/tests/e2e-tests/cart-page.js +++ b/tests/e2e-tests/front-end/cart-page.js @@ -51,7 +51,6 @@ test.describe( 'Cart page', function() { test.it( 'should updates qty when updated via qty input', () => { const cartPage = new CartPage( driver, { url: manager.getPageUrl( '/cart' ) } ); cartPage.getItem( 'Album', { qty: 2 } ).setQty( 4 ); - cartPage.update(); cartPage.getItem( 'Polo', { qty: 1 } ).setQty( 3 ); cartPage.update(); diff --git a/tests/e2e-tests/checkout-page.js b/tests/e2e-tests/front-end/checkout-page.js similarity index 97% rename from tests/e2e-tests/checkout-page.js rename to tests/e2e-tests/front-end/checkout-page.js index cae53389982..347a4973434 100644 --- a/tests/e2e-tests/checkout-page.js +++ b/tests/e2e-tests/front-end/checkout-page.js @@ -143,10 +143,8 @@ test.describe( 'Checkout Page', function() { checkoutPage.placeOrder(); Helper.waitTillUIBlockNotPresent( driver ); - const orderReceivedPage = new CheckoutOrderReceivedPage( driver, { visit: false } ); - assert.eventually.ok( - orderReceivedPage.hasText( 'Order received' ) + checkoutPage.hasText( 'Order received' ) ); } ); diff --git a/tests/e2e-tests/my-account-page.js b/tests/e2e-tests/front-end/my-account-page.js similarity index 100% rename from tests/e2e-tests/my-account-page.js rename to tests/e2e-tests/front-end/my-account-page.js diff --git a/tests/e2e-tests/single-product.js b/tests/e2e-tests/front-end/single-product.js similarity index 100% rename from tests/e2e-tests/single-product.js rename to tests/e2e-tests/front-end/single-product.js