Added new e2e test shopper login checkout
This commit is contained in:
parent
8b6e4ac519
commit
eb6572fec0
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
# 0.1.3
|
# 0.1.3
|
||||||
|
|
||||||
|
## Added
|
||||||
|
|
||||||
|
- Shopper Checkout Login Account
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
- removed use of ES6 `import`
|
- removed use of ES6 `import`
|
||||||
|
|
|
@ -77,6 +77,7 @@ The functions to access the core tests are:
|
||||||
- `runSingleProductPageTest` - Shopper can view single product page in many variations (simple, variable, grouped)
|
- `runSingleProductPageTest` - Shopper can view single product page in many variations (simple, variable, grouped)
|
||||||
- `runVariableProductUpdateTest` - Shopper can view and update variations on a variable product
|
- `runVariableProductUpdateTest` - Shopper can view and update variations on a variable product
|
||||||
- `runCheckoutCreateAccountTest` - Shopper can create an account during checkout
|
- `runCheckoutCreateAccountTest` - Shopper can create an account during checkout
|
||||||
|
- `runCheckoutLoginAccountTest` - Shopper can login to an account during checkout
|
||||||
|
|
||||||
### REST API
|
### REST API
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ const runMyAccountPayOrderTest = require( './shopper/front-end-my-account-pay-or
|
||||||
const runSingleProductPageTest = require( './shopper/front-end-single-product.test' );
|
const runSingleProductPageTest = require( './shopper/front-end-single-product.test' );
|
||||||
const runVariableProductUpdateTest = require( './shopper/front-end-variable-product-updates.test' );
|
const runVariableProductUpdateTest = require( './shopper/front-end-variable-product-updates.test' );
|
||||||
const runCheckoutCreateAccountTest = require( './shopper/front-end-checkout-create-account.test' );
|
const runCheckoutCreateAccountTest = require( './shopper/front-end-checkout-create-account.test' );
|
||||||
|
const runCheckoutLoginAccountTest = require( './shopper/front-end-checkout-login-account.test' );
|
||||||
|
|
||||||
// Merchant tests
|
// Merchant tests
|
||||||
const runAddNewShippingZoneTest = require ( './merchant/wp-admin-settings-shipping-zones.test' );
|
const runAddNewShippingZoneTest = require ( './merchant/wp-admin-settings-shipping-zones.test' );
|
||||||
|
@ -63,6 +64,7 @@ const runShopperTests = () => {
|
||||||
runSingleProductPageTest();
|
runSingleProductPageTest();
|
||||||
runVariableProductUpdateTest();
|
runVariableProductUpdateTest();
|
||||||
runCheckoutCreateAccountTest();
|
runCheckoutCreateAccountTest();
|
||||||
|
runCheckoutLoginAccountTest();
|
||||||
};
|
};
|
||||||
|
|
||||||
const runMerchantTests = () => {
|
const runMerchantTests = () => {
|
||||||
|
@ -133,4 +135,5 @@ module.exports = {
|
||||||
runApiTests,
|
runApiTests,
|
||||||
runAnalyticsPageLoadsTest,
|
runAnalyticsPageLoadsTest,
|
||||||
runCheckoutCreateAccountTest,
|
runCheckoutCreateAccountTest,
|
||||||
|
runCheckoutLoginAccountTest,
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,10 +28,14 @@ const runCheckoutCreateAccountTest = () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await merchant.login();
|
await merchant.login();
|
||||||
await createSimpleProduct();
|
await createSimpleProduct();
|
||||||
|
|
||||||
|
// Set checkbox for creating an account during checkout
|
||||||
await merchant.openSettings('account');
|
await merchant.openSettings('account');
|
||||||
await setCheckbox('#woocommerce_enable_signup_and_login_from_checkout');
|
await setCheckbox('#woocommerce_enable_signup_and_login_from_checkout');
|
||||||
await settingsPageSaveChanges();
|
await settingsPageSaveChanges();
|
||||||
await merchant.logout();
|
await merchant.logout();
|
||||||
|
|
||||||
|
// Add simple product to cart and proceed to checkout
|
||||||
await shopper.goToShop();
|
await shopper.goToShop();
|
||||||
await shopper.addToCartFromShopPage(simpleProductName);
|
await shopper.addToCartFromShopPage(simpleProductName);
|
||||||
await uiUnblocked();
|
await uiUnblocked();
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
/* eslint-disable jest/no-export, jest/no-disabled-tests, jest/expect-expect */
|
||||||
|
/**
|
||||||
|
* Internal dependencies
|
||||||
|
*/
|
||||||
|
const {
|
||||||
|
shopper,
|
||||||
|
merchant,
|
||||||
|
createSimpleProduct,
|
||||||
|
uiUnblocked,
|
||||||
|
setCheckbox,
|
||||||
|
settingsPageSaveChanges,
|
||||||
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* External dependencies
|
||||||
|
*/
|
||||||
|
const {
|
||||||
|
it,
|
||||||
|
describe,
|
||||||
|
beforeAll,
|
||||||
|
} = require( '@jest/globals' );
|
||||||
|
|
||||||
|
const config = require('config');
|
||||||
|
const simpleProductName = config.get('products.simple.name');
|
||||||
|
|
||||||
|
const runCheckoutLoginAccountTest = () => {
|
||||||
|
describe('Shopper Checkout Login Account', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
await merchant.login();
|
||||||
|
await createSimpleProduct();
|
||||||
|
|
||||||
|
// Set checkbox for logging to account during checkout
|
||||||
|
await merchant.openSettings('account');
|
||||||
|
await setCheckbox('#woocommerce_enable_checkout_login_reminder');
|
||||||
|
await settingsPageSaveChanges();
|
||||||
|
await merchant.logout();
|
||||||
|
|
||||||
|
// Add simple product to cart and proceed to checkout
|
||||||
|
await shopper.goToShop();
|
||||||
|
await shopper.addToCartFromShopPage(simpleProductName);
|
||||||
|
await uiUnblocked();
|
||||||
|
await shopper.goToCheckout();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can login to an existing account during checkout', async () => {
|
||||||
|
// Click to login during checkout
|
||||||
|
await page.waitForSelector('.woocommerce-form-login-toggle');
|
||||||
|
await expect(page).toClick('.woocommerce-info > a.showlogin');
|
||||||
|
|
||||||
|
// Fill shopper's login credentials and proceed further
|
||||||
|
await page.type( '#username', config.get('users.customer.username') );
|
||||||
|
await page.type( '#password', config.get('users.customer.password') );
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForNavigation({waitUntil: 'networkidle0'}),
|
||||||
|
page.click('button[name="login"]'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Place an order
|
||||||
|
await shopper.placeOrder();
|
||||||
|
await expect(page).toMatchElement('h1.entry-title', {text: 'Order received'});
|
||||||
|
|
||||||
|
// Verify the email of a logged in user
|
||||||
|
await expect(page).toMatchElement('ul > li.email', {text: 'Email: john.doe@example.com'});
|
||||||
|
|
||||||
|
// Verify the user is logged in on my account page
|
||||||
|
await shopper.gotoMyAccount();
|
||||||
|
expect(page.url()).toMatch('my-account/');
|
||||||
|
await expect(page).toMatchElement('h1', {text: 'My account'});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = runCheckoutLoginAccountTest;
|
|
@ -0,0 +1,6 @@
|
||||||
|
/*
|
||||||
|
* Internal dependencies
|
||||||
|
*/
|
||||||
|
const { runCheckoutLoginAccountTest } = require( '@woocommerce/e2e-core-tests' );
|
||||||
|
|
||||||
|
runCheckoutLoginAccountTest();
|
Loading…
Reference in New Issue