Merge pull request #29564 from woocommerce/e2e/e2e-shopper-login-checkout

Added new e2e test shopper checkout login account
This commit is contained in:
Greg 2021-04-05 08:34:28 -06:00 committed by GitHub
commit 21647f5251
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 89 additions and 0 deletions

View File

@ -4,6 +4,7 @@
## Added
- Shopper Checkout Login Account
- Shopper My Account Create Account
## Fixed

View File

@ -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)
- `runVariableProductUpdateTest` - Shopper can view and update variations on a variable product
- `runCheckoutCreateAccountTest` - Shopper can create an account during checkout
- `runCheckoutLoginAccountTest` - Shopper can login to an account during checkout
- `runMyAccountCreateAccountTest` - Shopper can create an account via my account page
### REST API

View File

@ -20,6 +20,7 @@ const runMyAccountCreateAccountTest = require( './shopper/front-end-my-account-c
const runSingleProductPageTest = require( './shopper/front-end-single-product.test' );
const runVariableProductUpdateTest = require( './shopper/front-end-variable-product-updates.test' );
const runCheckoutCreateAccountTest = require( './shopper/front-end-checkout-create-account.test' );
const runCheckoutLoginAccountTest = require( './shopper/front-end-checkout-login-account.test' );
// Merchant tests
const runAddNewShippingZoneTest = require ( './merchant/wp-admin-settings-shipping-zones.test' );
@ -65,6 +66,7 @@ const runShopperTests = () => {
runSingleProductPageTest();
runVariableProductUpdateTest();
runCheckoutCreateAccountTest();
runCheckoutLoginAccountTest();
};
const runMerchantTests = () => {
@ -135,5 +137,6 @@ module.exports = {
runApiTests,
runAnalyticsPageLoadsTest,
runCheckoutCreateAccountTest,
runCheckoutLoginAccountTest,
runMyAccountCreateAccountTest,
};

View File

@ -28,10 +28,14 @@ const runCheckoutCreateAccountTest = () => {
beforeAll(async () => {
await merchant.login();
await createSimpleProduct();
// Set checkbox for creating an account during checkout
await merchant.openSettings('account');
await setCheckbox('#woocommerce_enable_signup_and_login_from_checkout');
await settingsPageSaveChanges();
await merchant.logout();
// Add simple product to cart and proceed to checkout
await shopper.goToShop();
await shopper.addToCartFromShopPage(simpleProductName);
await uiUnblocked();

View File

@ -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();
await expect(page.url()).toMatch('my-account/');
await expect(page).toMatchElement('h1', {text: 'My account'});
});
});
};
module.exports = runCheckoutLoginAccountTest;

View File

@ -0,0 +1,6 @@
/*
* Internal dependencies
*/
const { runCheckoutLoginAccountTest } = require( '@woocommerce/e2e-core-tests' );
runCheckoutLoginAccountTest();