move front end tests to package
This commit is contained in:
parent
27e79f465f
commit
76f591251a
|
@ -7,6 +7,11 @@ const {
|
||||||
runTaskListTest,
|
runTaskListTest,
|
||||||
runInitialStoreSettingsTest,
|
runInitialStoreSettingsTest,
|
||||||
runSetupOnboardingTests,
|
runSetupOnboardingTests,
|
||||||
|
runCartPageTest,
|
||||||
|
runCheckoutPageTest,
|
||||||
|
runMyAccountPageTest,
|
||||||
|
runSingleProductPageTest,
|
||||||
|
runFrontEndTests,
|
||||||
} = require( './specs' );
|
} = require( './specs' );
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -15,4 +20,9 @@ module.exports = {
|
||||||
runTaskListTest,
|
runTaskListTest,
|
||||||
runInitialStoreSettingsTest,
|
runInitialStoreSettingsTest,
|
||||||
runSetupOnboardingTests,
|
runSetupOnboardingTests,
|
||||||
|
runCartPageTest,
|
||||||
|
runCheckoutPageTest,
|
||||||
|
runMyAccountPageTest,
|
||||||
|
runSingleProductPageTest,
|
||||||
|
runFrontEndTests,
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
/* eslint-disable jest/no-export, jest/no-disabled-tests, jest/expect-expect */
|
||||||
|
/**
|
||||||
|
* Internal dependencies
|
||||||
|
*/
|
||||||
|
const {
|
||||||
|
CustomerFlow,
|
||||||
|
StoreOwnerFlow,
|
||||||
|
createSimpleProduct,
|
||||||
|
uiUnblocked
|
||||||
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* External dependencies
|
||||||
|
*/
|
||||||
|
const {
|
||||||
|
it,
|
||||||
|
describe,
|
||||||
|
beforeAll,
|
||||||
|
} = require( '@jest/globals' );
|
||||||
|
|
||||||
|
const runCartPageTest = () => {
|
||||||
|
describe('Cart page', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
await StoreOwnerFlow.login();
|
||||||
|
await createSimpleProduct();
|
||||||
|
await StoreOwnerFlow.logout();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should display no item in the cart', async () => {
|
||||||
|
await CustomerFlow.goToCart();
|
||||||
|
await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add the product to the cart when "Add to cart" is clicked', async () => {
|
||||||
|
await CustomerFlow.goToShop();
|
||||||
|
await CustomerFlow.addToCartFromShopPage('Simple product');
|
||||||
|
|
||||||
|
await CustomerFlow.goToCart();
|
||||||
|
await CustomerFlow.productIsInCart('Simple product');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should increase item qty when "Add to cart" of the same product is clicked', async () => {
|
||||||
|
await CustomerFlow.goToShop();
|
||||||
|
await CustomerFlow.addToCartFromShopPage('Simple product');
|
||||||
|
|
||||||
|
await CustomerFlow.goToCart();
|
||||||
|
await CustomerFlow.productIsInCart('Simple product', 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update qty when updated via qty input', async () => {
|
||||||
|
await CustomerFlow.goToCart();
|
||||||
|
await CustomerFlow.setCartQuantity('Simple product', 4);
|
||||||
|
await expect(page).toClick('button', {text: 'Update cart'});
|
||||||
|
await uiUnblocked();
|
||||||
|
|
||||||
|
await CustomerFlow.productIsInCart('Simple product', 4);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should remove the item from the cart when remove is clicked', async () => {
|
||||||
|
await CustomerFlow.goToCart();
|
||||||
|
await CustomerFlow.removeFromCart('Simple product');
|
||||||
|
await uiUnblocked();
|
||||||
|
|
||||||
|
await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update subtotal in cart totals when adding product to the cart', async () => {
|
||||||
|
await CustomerFlow.goToShop();
|
||||||
|
await CustomerFlow.addToCartFromShopPage('Simple product');
|
||||||
|
|
||||||
|
await CustomerFlow.goToCart();
|
||||||
|
await CustomerFlow.productIsInCart('Simple product', 1);
|
||||||
|
await expect(page).toMatchElement('.cart-subtotal .amount', {text: '$9.99'});
|
||||||
|
|
||||||
|
await CustomerFlow.setCartQuantity('Simple product', 2);
|
||||||
|
await expect(page).toClick('button', {text: 'Update cart'});
|
||||||
|
await uiUnblocked();
|
||||||
|
|
||||||
|
await expect(page).toMatchElement('.cart-subtotal .amount', {text: '$19.98'});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should go to the checkout page when "Proceed to Checkout" is clicked', async () => {
|
||||||
|
await CustomerFlow.goToCart();
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForNavigation({waitUntil: 'networkidle0'}),
|
||||||
|
expect(page).toClick('.checkout-button', {text: 'Proceed to checkout'}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await expect(page).toMatchElement('#order_review');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = runCartPageTest;
|
|
@ -0,0 +1,165 @@
|
||||||
|
/* eslint-disable jest/no-export, jest/no-disabled-tests, jest/expect-expect, jest/no-standalone-expect */
|
||||||
|
/**
|
||||||
|
* Internal dependencies
|
||||||
|
*/
|
||||||
|
const {
|
||||||
|
CustomerFlow,
|
||||||
|
StoreOwnerFlow,
|
||||||
|
createSimpleProduct,
|
||||||
|
setCheckbox,
|
||||||
|
settingsPageSaveChanges,
|
||||||
|
uiUnblocked,
|
||||||
|
verifyCheckboxIsSet
|
||||||
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
|
const config = require( 'config' );
|
||||||
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
|
let orderId;
|
||||||
|
|
||||||
|
const runCheckoutPageTest = () => {
|
||||||
|
describe('Checkout page', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
await StoreOwnerFlow.login();
|
||||||
|
await createSimpleProduct();
|
||||||
|
|
||||||
|
// Go to general settings page
|
||||||
|
await StoreOwnerFlow.openSettings('general');
|
||||||
|
|
||||||
|
// Set base location with state CA.
|
||||||
|
await expect(page).toSelect('select[name="woocommerce_default_country"]', 'United States (US) — California');
|
||||||
|
// Sell to all countries
|
||||||
|
await expect(page).toSelect('#woocommerce_allowed_countries', 'Sell to all countries');
|
||||||
|
// Set currency to USD
|
||||||
|
await expect(page).toSelect('#woocommerce_currency', 'United States (US) dollar ($)');
|
||||||
|
// Tax calculation should have been enabled by another test - no-op
|
||||||
|
// Save
|
||||||
|
await settingsPageSaveChanges();
|
||||||
|
|
||||||
|
// Verify that settings have been saved
|
||||||
|
await Promise.all([
|
||||||
|
expect(page).toMatchElement('#message', {text: 'Your settings have been saved.'}),
|
||||||
|
expect(page).toMatchElement('select[name="woocommerce_default_country"]', {text: 'United States (US) — California'}),
|
||||||
|
expect(page).toMatchElement('#woocommerce_allowed_countries', {text: 'Sell to all countries'}),
|
||||||
|
expect(page).toMatchElement('#woocommerce_currency', {text: 'United States (US) dollar ($)'}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Enable BACS payment method
|
||||||
|
await StoreOwnerFlow.openSettings('checkout', 'bacs');
|
||||||
|
await setCheckbox('#woocommerce_bacs_enabled');
|
||||||
|
await settingsPageSaveChanges();
|
||||||
|
|
||||||
|
// Verify that settings have been saved
|
||||||
|
await verifyCheckboxIsSet('#woocommerce_bacs_enabled');
|
||||||
|
|
||||||
|
// Enable COD payment method
|
||||||
|
await StoreOwnerFlow.openSettings('checkout', 'cod');
|
||||||
|
await setCheckbox('#woocommerce_cod_enabled');
|
||||||
|
await settingsPageSaveChanges();
|
||||||
|
|
||||||
|
// Verify that settings have been saved
|
||||||
|
await verifyCheckboxIsSet('#woocommerce_cod_enabled');
|
||||||
|
|
||||||
|
// Enable PayPal payment method
|
||||||
|
await StoreOwnerFlow.openSettings('checkout', 'paypal');
|
||||||
|
await setCheckbox('#woocommerce_paypal_enabled');
|
||||||
|
await settingsPageSaveChanges();
|
||||||
|
|
||||||
|
// Verify that settings have been saved
|
||||||
|
await verifyCheckboxIsSet('#woocommerce_paypal_enabled');
|
||||||
|
|
||||||
|
await StoreOwnerFlow.logout();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should display cart items in order review', async () => {
|
||||||
|
await CustomerFlow.goToShop();
|
||||||
|
await CustomerFlow.addToCartFromShopPage(simpleProductName);
|
||||||
|
await CustomerFlow.goToCheckout();
|
||||||
|
await CustomerFlow.productIsInCheckout(simpleProductName, `1`, `9.99`, `9.99`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows customer to choose available payment methods', async () => {
|
||||||
|
await CustomerFlow.goToShop();
|
||||||
|
await CustomerFlow.addToCartFromShopPage(simpleProductName);
|
||||||
|
await CustomerFlow.goToCheckout();
|
||||||
|
await CustomerFlow.productIsInCheckout(simpleProductName, `2`, `19.98`, `19.98`);
|
||||||
|
|
||||||
|
await expect(page).toClick('.wc_payment_method label', {text: 'PayPal'});
|
||||||
|
await expect(page).toClick('.wc_payment_method label', {text: 'Direct bank transfer'});
|
||||||
|
await expect(page).toClick('.wc_payment_method label', {text: 'Cash on delivery'});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows customer to fill billing details', async () => {
|
||||||
|
await CustomerFlow.goToShop();
|
||||||
|
await CustomerFlow.addToCartFromShopPage(simpleProductName);
|
||||||
|
await CustomerFlow.goToCheckout();
|
||||||
|
await CustomerFlow.productIsInCheckout(simpleProductName, `3`, `29.97`, `29.97`);
|
||||||
|
await CustomerFlow.fillBillingDetails(config.get('addresses.customer.billing'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows customer to fill shipping details', async () => {
|
||||||
|
await CustomerFlow.goToShop();
|
||||||
|
await CustomerFlow.addToCartFromShopPage(simpleProductName);
|
||||||
|
await CustomerFlow.goToCheckout();
|
||||||
|
await CustomerFlow.productIsInCheckout(simpleProductName, `4`, `39.96`, `39.96`);
|
||||||
|
|
||||||
|
// Select checkbox to ship to a different address
|
||||||
|
await page.evaluate(() => {
|
||||||
|
document.querySelector('#ship-to-different-address-checkbox').click();
|
||||||
|
});
|
||||||
|
await uiUnblocked();
|
||||||
|
|
||||||
|
await CustomerFlow.fillShippingDetails(config.get('addresses.customer.shipping'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows guest customer to place order', async () => {
|
||||||
|
await CustomerFlow.goToShop();
|
||||||
|
await CustomerFlow.addToCartFromShopPage(simpleProductName);
|
||||||
|
await CustomerFlow.goToCheckout();
|
||||||
|
await CustomerFlow.productIsInCheckout(simpleProductName, `5`, `49.95`, `49.95`);
|
||||||
|
await CustomerFlow.fillBillingDetails(config.get('addresses.customer.billing'));
|
||||||
|
|
||||||
|
await uiUnblocked();
|
||||||
|
|
||||||
|
await expect(page).toClick('.wc_payment_method label', {text: 'Cash on delivery'});
|
||||||
|
await expect(page).toMatchElement('.payment_method_cod', {text: 'Pay with cash upon delivery.'});
|
||||||
|
await uiUnblocked();
|
||||||
|
await CustomerFlow.placeOrder();
|
||||||
|
|
||||||
|
await expect(page).toMatch('Order received');
|
||||||
|
|
||||||
|
// Get order ID from the order received html element on the page
|
||||||
|
let orderReceivedHtmlElement = await page.$('.woocommerce-order-overview__order.order');
|
||||||
|
let orderReceivedText = await page.evaluate(element => element.textContent, orderReceivedHtmlElement);
|
||||||
|
return orderId = orderReceivedText.split(/(\s+)/)[6].toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('store owner can confirm the order was received', async () => {
|
||||||
|
await StoreOwnerFlow.login();
|
||||||
|
await StoreOwnerFlow.openAllOrdersView();
|
||||||
|
|
||||||
|
// Click on the order which was placed in the previous step
|
||||||
|
await Promise.all([
|
||||||
|
page.click('#post-' + orderId),
|
||||||
|
page.waitForNavigation({waitUntil: 'networkidle0'}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Verify that the order page is indeed of the order that was placed
|
||||||
|
// Verify order number
|
||||||
|
await expect(page).toMatchElement('.woocommerce-order-data__heading', {text: 'Order #' + orderId + ' details'});
|
||||||
|
|
||||||
|
// Verify product name
|
||||||
|
await expect(page).toMatchElement('.wc-order-item-name', {text: simpleProductName});
|
||||||
|
|
||||||
|
// Verify product cost
|
||||||
|
await expect(page).toMatchElement('.woocommerce-Price-amount.amount', {text: '9.99'});
|
||||||
|
|
||||||
|
// Verify product quantity
|
||||||
|
await expect(page).toMatchElement('.quantity', {text: '5'});
|
||||||
|
|
||||||
|
// Verify total order amount without shipping
|
||||||
|
await expect(page).toMatchElement('.line_cost', {text: '49.95'});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = runCheckoutPageTest;
|
|
@ -0,0 +1,50 @@
|
||||||
|
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
||||||
|
/**
|
||||||
|
* Internal dependencies
|
||||||
|
*/
|
||||||
|
const {
|
||||||
|
CustomerFlow,
|
||||||
|
StoreOwnerFlow
|
||||||
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
|
const runMyAccountPageTest = () => {
|
||||||
|
describe('My account page', () => {
|
||||||
|
it('allows customer to login', async () => {
|
||||||
|
await StoreOwnerFlow.logout();
|
||||||
|
await CustomerFlow.login();
|
||||||
|
await expect(page).toMatch('Hello');
|
||||||
|
await expect(page).toMatchElement('.woocommerce-MyAccount-navigation-link', {text: 'Dashboard'});
|
||||||
|
await expect(page).toMatchElement('.woocommerce-MyAccount-navigation-link', {text: 'Orders'});
|
||||||
|
await expect(page).toMatchElement('.woocommerce-MyAccount-navigation-link', {text: 'Downloads'});
|
||||||
|
await expect(page).toMatchElement('.woocommerce-MyAccount-navigation-link', {text: 'Addresses'});
|
||||||
|
await expect(page).toMatchElement('.woocommerce-MyAccount-navigation-link', {text: 'Account details'});
|
||||||
|
await expect(page).toMatchElement('.woocommerce-MyAccount-navigation-link', {text: 'Logout'});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows customer to see orders', async () => {
|
||||||
|
await CustomerFlow.goToOrders();
|
||||||
|
await expect(page.url()).toMatch('my-account/orders');
|
||||||
|
await expect(page).toMatchElement('h1', {text: 'Orders'});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows customer to see downloads', async () => {
|
||||||
|
await CustomerFlow.goToDownloads();
|
||||||
|
expect(page.url()).toMatch('my-account/downloads');
|
||||||
|
await expect(page).toMatchElement('h1', {text: 'Downloads'});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows customer to see addresses', async () => {
|
||||||
|
await CustomerFlow.goToAddresses();
|
||||||
|
expect(page.url()).toMatch('my-account/edit-address');
|
||||||
|
await expect(page).toMatchElement('h1', {text: 'Addresses'});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows customer to see account details', async () => {
|
||||||
|
await CustomerFlow.goToAccountDetails();
|
||||||
|
expect(page.url()).toMatch('my-account/edit-account');
|
||||||
|
await expect(page).toMatchElement('h1', {text: 'Account details'});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = runMyAccountPageTest;
|
|
@ -0,0 +1,72 @@
|
||||||
|
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
||||||
|
/**
|
||||||
|
* Internal dependencies
|
||||||
|
*/
|
||||||
|
const {
|
||||||
|
CustomerFlow,
|
||||||
|
StoreOwnerFlow,
|
||||||
|
createSimpleProduct,
|
||||||
|
createVariableProduct,
|
||||||
|
uiUnblocked
|
||||||
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
|
let simplePostIdValue;
|
||||||
|
let variablePostIdValue;
|
||||||
|
const config = require( 'config' );
|
||||||
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
|
|
||||||
|
const runSingleProductPageTest = () => {
|
||||||
|
describe('Single Product Page', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
await StoreOwnerFlow.login();
|
||||||
|
simplePostIdValue = await createSimpleProduct();
|
||||||
|
await StoreOwnerFlow.logout();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be able to add simple products to the cart', async () => {
|
||||||
|
// Add 5 simple products to cart
|
||||||
|
await CustomerFlow.goToProduct(simplePostIdValue);
|
||||||
|
await expect(page).toFill('div.quantity input.qty', '5');
|
||||||
|
await CustomerFlow.addToCart();
|
||||||
|
await expect(page).toMatchElement('.woocommerce-message', {text: 'have been added to your cart.'});
|
||||||
|
|
||||||
|
// Verify cart contents
|
||||||
|
await CustomerFlow.goToCart();
|
||||||
|
await CustomerFlow.productIsInCart(simpleProductName, 5);
|
||||||
|
|
||||||
|
// Remove items from cart
|
||||||
|
await CustomerFlow.removeFromCart(simpleProductName);
|
||||||
|
await uiUnblocked();
|
||||||
|
await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe.skip('Variable Product Page', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
await StoreOwnerFlow.login();
|
||||||
|
variablePostIdValue = await createVariableProduct();
|
||||||
|
await StoreOwnerFlow.logout();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be able to add variation products to the cart', async () => {
|
||||||
|
// Add a product with one set of variations to cart
|
||||||
|
await CustomerFlow.goToProduct(variablePostIdValue);
|
||||||
|
await expect(page).toSelect('#attr-1', 'val1');
|
||||||
|
await expect(page).toSelect('#attr-2', 'val1');
|
||||||
|
await expect(page).toSelect('#attr-3', 'val1');
|
||||||
|
await CustomerFlow.addToCart();
|
||||||
|
await expect(page).toMatchElement('.woocommerce-message', {text: 'has been added to your cart.'});
|
||||||
|
|
||||||
|
// Verify cart contents
|
||||||
|
await CustomerFlow.goToCart();
|
||||||
|
await CustomerFlow.productIsInCart('Variable Product with Three Variations');
|
||||||
|
|
||||||
|
// Remove items from cart
|
||||||
|
await CustomerFlow.removeFromCart('Variable Product with Three Variations');
|
||||||
|
await uiUnblocked();
|
||||||
|
await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = runSingleProductPageTest;
|
|
@ -2,9 +2,13 @@
|
||||||
/*
|
/*
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
const runActivationTest = require( './activate-and-setup/activate.test.js' );
|
const runActivationTest = require( './activate-and-setup/activate.test' );
|
||||||
const { runOnboardingFlowTest, runTaskListTest } = require( './activate-and-setup/onboarding-tasklist.test.js' );
|
const { runOnboardingFlowTest, runTaskListTest } = require( './activate-and-setup/onboarding-tasklist.test' );
|
||||||
const runInitialStoreSettingsTest = require( './activate-and-setup/setup.test.js' );
|
const runInitialStoreSettingsTest = require( './activate-and-setup/setup.test' );
|
||||||
|
const runCartPageTest = require( './front-end/front-end-cart.test' );
|
||||||
|
const runCheckoutPageTest = require( './front-end/front-end-checkout.test' );
|
||||||
|
const runMyAccountPageTest = require( './front-end/front-end-my-account.test' );
|
||||||
|
const runSingleProductPageTest = require( './front-end/front-end-single-product.test' );
|
||||||
|
|
||||||
const runSetupOnboardingTests = () => {
|
const runSetupOnboardingTests = () => {
|
||||||
runActivationTest();
|
runActivationTest();
|
||||||
|
@ -13,10 +17,22 @@ const runSetupOnboardingTests = () => {
|
||||||
runInitialStoreSettingsTest();
|
runInitialStoreSettingsTest();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const runFrontEndTests = () => {
|
||||||
|
runCartPageTest();
|
||||||
|
runCheckoutPageTest();
|
||||||
|
runMyAccountPageTest();
|
||||||
|
runSingleProductPageTest();
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
runActivationTest,
|
runActivationTest,
|
||||||
runOnboardingFlowTest,
|
runOnboardingFlowTest,
|
||||||
runTaskListTest,
|
runTaskListTest,
|
||||||
runInitialStoreSettingsTest,
|
runInitialStoreSettingsTest,
|
||||||
runSetupOnboardingTests,
|
runSetupOnboardingTests,
|
||||||
|
runCartPageTest,
|
||||||
|
runCheckoutPageTest,
|
||||||
|
runMyAccountPageTest,
|
||||||
|
runSingleProductPageTest,
|
||||||
|
runFrontEndTests,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
/**
|
|
||||||
* @format
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal dependencies
|
|
||||||
*/
|
|
||||||
import {
|
|
||||||
CustomerFlow,
|
|
||||||
StoreOwnerFlow,
|
|
||||||
createSimpleProduct,
|
|
||||||
uiUnblocked
|
|
||||||
} from '@woocommerce/e2e-utils';
|
|
||||||
|
|
||||||
describe( 'Cart page', () => {
|
|
||||||
beforeAll( async () => {
|
|
||||||
await StoreOwnerFlow.login();
|
|
||||||
await createSimpleProduct();
|
|
||||||
await StoreOwnerFlow.logout();
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'should display no item in the cart', async () => {
|
|
||||||
await CustomerFlow.goToCart();
|
|
||||||
await expect( page ).toMatchElement( '.cart-empty', { text: 'Your cart is currently empty.' } );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'should add the product to the cart when "Add to cart" is clicked', async () => {
|
|
||||||
await CustomerFlow.goToShop();
|
|
||||||
await CustomerFlow.addToCartFromShopPage( 'Simple product' );
|
|
||||||
|
|
||||||
await CustomerFlow.goToCart();
|
|
||||||
await CustomerFlow.productIsInCart( 'Simple product' );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'should increase item qty when "Add to cart" of the same product is clicked', async () => {
|
|
||||||
await CustomerFlow.goToShop();
|
|
||||||
await CustomerFlow.addToCartFromShopPage( 'Simple product' );
|
|
||||||
|
|
||||||
await CustomerFlow.goToCart();
|
|
||||||
await CustomerFlow.productIsInCart( 'Simple product', 2 );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'should update qty when updated via qty input', async () => {
|
|
||||||
await CustomerFlow.goToCart();
|
|
||||||
await CustomerFlow.setCartQuantity( 'Simple product', 4 );
|
|
||||||
await expect( page ).toClick( 'button', { text: 'Update cart' } );
|
|
||||||
await uiUnblocked();
|
|
||||||
|
|
||||||
await CustomerFlow.productIsInCart( 'Simple product', 4 );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'should remove the item from the cart when remove is clicked', async () => {
|
|
||||||
await CustomerFlow.goToCart();
|
|
||||||
await CustomerFlow.removeFromCart( 'Simple product' );
|
|
||||||
await uiUnblocked();
|
|
||||||
|
|
||||||
await expect( page ).toMatchElement( '.cart-empty', { text: 'Your cart is currently empty.' } );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'should update subtotal in cart totals when adding product to the cart', async () => {
|
|
||||||
await CustomerFlow.goToShop();
|
|
||||||
await CustomerFlow.addToCartFromShopPage( 'Simple product' );
|
|
||||||
|
|
||||||
await CustomerFlow.goToCart();
|
|
||||||
await CustomerFlow.productIsInCart( 'Simple product', 1 );
|
|
||||||
await expect( page ).toMatchElement( '.cart-subtotal .amount', { text: '$9.99' } );
|
|
||||||
|
|
||||||
await CustomerFlow.setCartQuantity( 'Simple product', 2 );
|
|
||||||
await expect( page ).toClick( 'button', { text: 'Update cart' } );
|
|
||||||
await uiUnblocked();
|
|
||||||
|
|
||||||
await expect( page ).toMatchElement( '.cart-subtotal .amount', { text: '$19.98' } );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'should go to the checkout page when "Proceed to Checkout" is clicked', async () => {
|
|
||||||
await CustomerFlow.goToCart();
|
|
||||||
await Promise.all( [
|
|
||||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
|
||||||
expect( page ).toClick( '.checkout-button', { text: 'Proceed to checkout' } ),
|
|
||||||
] );
|
|
||||||
|
|
||||||
await expect( page ).toMatchElement( '#order_review' );
|
|
||||||
} );
|
|
||||||
} );
|
|
|
@ -1,164 +0,0 @@
|
||||||
/**
|
|
||||||
* @format
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal dependencies
|
|
||||||
*/
|
|
||||||
import {
|
|
||||||
CustomerFlow,
|
|
||||||
StoreOwnerFlow,
|
|
||||||
createSimpleProduct,
|
|
||||||
setCheckbox,
|
|
||||||
settingsPageSaveChanges,
|
|
||||||
uiUnblocked,
|
|
||||||
verifyCheckboxIsSet
|
|
||||||
} from '@woocommerce/e2e-utils';
|
|
||||||
|
|
||||||
const config = require( 'config' );
|
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
|
||||||
let orderId;
|
|
||||||
|
|
||||||
describe( 'Checkout page', () => {
|
|
||||||
beforeAll( async () => {
|
|
||||||
await StoreOwnerFlow.login();
|
|
||||||
await createSimpleProduct();
|
|
||||||
|
|
||||||
// Go to general settings page
|
|
||||||
await StoreOwnerFlow.openSettings( 'general' );
|
|
||||||
|
|
||||||
// Set base location with state CA.
|
|
||||||
await expect( page ).toSelect( 'select[name="woocommerce_default_country"]', 'United States (US) — California' );
|
|
||||||
// Sell to all countries
|
|
||||||
await expect( page ).toSelect( '#woocommerce_allowed_countries', 'Sell to all countries' );
|
|
||||||
// Set currency to USD
|
|
||||||
await expect( page ).toSelect( '#woocommerce_currency', 'United States (US) dollar ($)' );
|
|
||||||
// Tax calculation should have been enabled by another test - no-op
|
|
||||||
// Save
|
|
||||||
await settingsPageSaveChanges();
|
|
||||||
|
|
||||||
// Verify that settings have been saved
|
|
||||||
await Promise.all( [
|
|
||||||
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
|
||||||
expect( page ).toMatchElement( 'select[name="woocommerce_default_country"]', { text: 'United States (US) — California' } ),
|
|
||||||
expect( page ).toMatchElement( '#woocommerce_allowed_countries', { text: 'Sell to all countries' } ),
|
|
||||||
expect( page ).toMatchElement( '#woocommerce_currency', { text: 'United States (US) dollar ($)' } ),
|
|
||||||
] );
|
|
||||||
|
|
||||||
// Enable BACS payment method
|
|
||||||
await StoreOwnerFlow.openSettings( 'checkout', 'bacs' );
|
|
||||||
await setCheckbox( '#woocommerce_bacs_enabled' );
|
|
||||||
await settingsPageSaveChanges();
|
|
||||||
|
|
||||||
// Verify that settings have been saved
|
|
||||||
await verifyCheckboxIsSet( '#woocommerce_bacs_enabled' );
|
|
||||||
|
|
||||||
// Enable COD payment method
|
|
||||||
await StoreOwnerFlow.openSettings( 'checkout', 'cod' );
|
|
||||||
await setCheckbox( '#woocommerce_cod_enabled' );
|
|
||||||
await settingsPageSaveChanges();
|
|
||||||
|
|
||||||
// Verify that settings have been saved
|
|
||||||
await verifyCheckboxIsSet( '#woocommerce_cod_enabled' );
|
|
||||||
|
|
||||||
// Enable PayPal payment method
|
|
||||||
await StoreOwnerFlow.openSettings( 'checkout', 'paypal' );
|
|
||||||
await setCheckbox( '#woocommerce_paypal_enabled' );
|
|
||||||
await settingsPageSaveChanges();
|
|
||||||
|
|
||||||
// Verify that settings have been saved
|
|
||||||
await verifyCheckboxIsSet( '#woocommerce_paypal_enabled' );
|
|
||||||
|
|
||||||
await StoreOwnerFlow.logout();
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'should display cart items in order review', async () => {
|
|
||||||
await CustomerFlow.goToShop();
|
|
||||||
await CustomerFlow.addToCartFromShopPage( simpleProductName );
|
|
||||||
await CustomerFlow.goToCheckout();
|
|
||||||
await CustomerFlow.productIsInCheckout( simpleProductName, `1`, `9.99`, `9.99` );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'allows customer to choose available payment methods', async () => {
|
|
||||||
await CustomerFlow.goToShop();
|
|
||||||
await CustomerFlow.addToCartFromShopPage( simpleProductName );
|
|
||||||
await CustomerFlow.goToCheckout();
|
|
||||||
await CustomerFlow.productIsInCheckout( simpleProductName, `2`, `19.98`, `19.98` );
|
|
||||||
|
|
||||||
await expect( page ).toClick( '.wc_payment_method label', { text: 'PayPal' } );
|
|
||||||
await expect( page ).toClick( '.wc_payment_method label', { text: 'Direct bank transfer' } );
|
|
||||||
await expect( page ).toClick( '.wc_payment_method label', { text: 'Cash on delivery' } );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'allows customer to fill billing details', async () => {
|
|
||||||
await CustomerFlow.goToShop();
|
|
||||||
await CustomerFlow.addToCartFromShopPage( simpleProductName );
|
|
||||||
await CustomerFlow.goToCheckout();
|
|
||||||
await CustomerFlow.productIsInCheckout( simpleProductName, `3`, `29.97`, `29.97` );
|
|
||||||
await CustomerFlow.fillBillingDetails( config.get( 'addresses.customer.billing' ) );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'allows customer to fill shipping details', async () => {
|
|
||||||
await CustomerFlow.goToShop();
|
|
||||||
await CustomerFlow.addToCartFromShopPage( simpleProductName );
|
|
||||||
await CustomerFlow.goToCheckout();
|
|
||||||
await CustomerFlow.productIsInCheckout( simpleProductName, `4`, `39.96`, `39.96` );
|
|
||||||
|
|
||||||
// Select checkbox to ship to a different address
|
|
||||||
await page.evaluate( () => {
|
|
||||||
document.querySelector( '#ship-to-different-address-checkbox' ).click();
|
|
||||||
} );
|
|
||||||
await uiUnblocked();
|
|
||||||
|
|
||||||
await CustomerFlow.fillShippingDetails( config.get( 'addresses.customer.shipping' ) );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'allows guest customer to place order', async () => {
|
|
||||||
await CustomerFlow.goToShop();
|
|
||||||
await CustomerFlow.addToCartFromShopPage( simpleProductName );
|
|
||||||
await CustomerFlow.goToCheckout();
|
|
||||||
await CustomerFlow.productIsInCheckout( simpleProductName, `5`, `49.95`, `49.95` );
|
|
||||||
await CustomerFlow.fillBillingDetails( config.get( 'addresses.customer.billing' ) );
|
|
||||||
|
|
||||||
await uiUnblocked();
|
|
||||||
|
|
||||||
await expect( page ).toClick( '.wc_payment_method label', { text: 'Cash on delivery' } );
|
|
||||||
await expect( page ).toMatchElement( '.payment_method_cod', { text: 'Pay with cash upon delivery.' } );
|
|
||||||
await uiUnblocked();
|
|
||||||
await CustomerFlow.placeOrder();
|
|
||||||
|
|
||||||
await expect( page ).toMatch( 'Order received' );
|
|
||||||
|
|
||||||
// Get order ID from the order received html element on the page
|
|
||||||
let orderReceivedHtmlElement = await page.$( '.woocommerce-order-overview__order.order' );
|
|
||||||
let orderReceivedText = await page.evaluate( element => element.textContent, orderReceivedHtmlElement );
|
|
||||||
return orderId = orderReceivedText.split( /(\s+)/ )[6].toString();
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'store owner can confirm the order was received', async () => {
|
|
||||||
await StoreOwnerFlow.login();
|
|
||||||
await StoreOwnerFlow.openAllOrdersView();
|
|
||||||
|
|
||||||
// Click on the order which was placed in the previous step
|
|
||||||
await Promise.all( [
|
|
||||||
page.click( '#post-' + orderId ),
|
|
||||||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
|
||||||
] );
|
|
||||||
|
|
||||||
// Verify that the order page is indeed of the order that was placed
|
|
||||||
// Verify order number
|
|
||||||
await expect( page ).toMatchElement( '.woocommerce-order-data__heading', { text: 'Order #' + orderId + ' details' } );
|
|
||||||
|
|
||||||
// Verify product name
|
|
||||||
await expect( page ).toMatchElement( '.wc-order-item-name', { text: simpleProductName } );
|
|
||||||
|
|
||||||
// Verify product cost
|
|
||||||
await expect( page ).toMatchElement( '.woocommerce-Price-amount.amount', { text: '9.99' } );
|
|
||||||
|
|
||||||
// Verify product quantity
|
|
||||||
await expect( page ).toMatchElement( '.quantity', { text: '5' } );
|
|
||||||
|
|
||||||
// Verify total order amount without shipping
|
|
||||||
await expect( page ).toMatchElement( '.line_cost', { text: '49.95' } );
|
|
||||||
} );
|
|
||||||
} );
|
|
|
@ -1,49 +0,0 @@
|
||||||
/**
|
|
||||||
* @format
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal dependencies
|
|
||||||
*/
|
|
||||||
import {
|
|
||||||
CustomerFlow,
|
|
||||||
StoreOwnerFlow
|
|
||||||
} from '@woocommerce/e2e-utils';
|
|
||||||
|
|
||||||
describe( 'My account page', () => {
|
|
||||||
it( 'allows customer to login', async () => {
|
|
||||||
await StoreOwnerFlow.logout();
|
|
||||||
await CustomerFlow.login();
|
|
||||||
await expect( page ).toMatch( 'Hello' );
|
|
||||||
await expect( page ).toMatchElement( '.woocommerce-MyAccount-navigation-link', { text: 'Dashboard' } );
|
|
||||||
await expect( page ).toMatchElement( '.woocommerce-MyAccount-navigation-link', { text: 'Orders' } );
|
|
||||||
await expect( page ).toMatchElement( '.woocommerce-MyAccount-navigation-link', { text: 'Downloads' } );
|
|
||||||
await expect( page ).toMatchElement( '.woocommerce-MyAccount-navigation-link', { text: 'Addresses' } );
|
|
||||||
await expect( page ).toMatchElement( '.woocommerce-MyAccount-navigation-link', { text: 'Account details' } );
|
|
||||||
await expect( page ).toMatchElement( '.woocommerce-MyAccount-navigation-link', { text: 'Logout' } );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'allows customer to see orders', async () => {
|
|
||||||
await CustomerFlow.goToOrders();
|
|
||||||
await expect( page.url() ).toMatch( 'my-account/orders' );
|
|
||||||
await expect( page ).toMatchElement( 'h1', { text: 'Orders' } );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'allows customer to see downloads', async () => {
|
|
||||||
await CustomerFlow.goToDownloads();
|
|
||||||
expect( page.url() ).toMatch( 'my-account/downloads' );
|
|
||||||
await expect( page ).toMatchElement( 'h1', { text: 'Downloads' } );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'allows customer to see addresses', async () => {
|
|
||||||
await CustomerFlow.goToAddresses();
|
|
||||||
expect( page.url() ).toMatch( 'my-account/edit-address' );
|
|
||||||
await expect( page ).toMatchElement( 'h1', { text: 'Addresses' } );
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'allows customer to see account details', async () => {
|
|
||||||
await CustomerFlow.goToAccountDetails();
|
|
||||||
expect( page.url() ).toMatch( 'my-account/edit-account' );
|
|
||||||
await expect( page ).toMatchElement( 'h1', { text: 'Account details' } );
|
|
||||||
} );
|
|
||||||
} );
|
|
|
@ -1,71 +0,0 @@
|
||||||
/**
|
|
||||||
* @format
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal dependencies
|
|
||||||
*/
|
|
||||||
import {
|
|
||||||
CustomerFlow,
|
|
||||||
StoreOwnerFlow,
|
|
||||||
createSimpleProduct,
|
|
||||||
createVariableProduct,
|
|
||||||
uiUnblocked
|
|
||||||
} from '@woocommerce/e2e-utils';
|
|
||||||
|
|
||||||
let simplePostIdValue;
|
|
||||||
let variablePostIdValue;
|
|
||||||
const config = require( 'config' );
|
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
|
||||||
|
|
||||||
describe( 'Single Product Page', () => {
|
|
||||||
beforeAll( async () => {
|
|
||||||
await StoreOwnerFlow.login();
|
|
||||||
simplePostIdValue = await createSimpleProduct();
|
|
||||||
await StoreOwnerFlow.logout();
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'should be able to add simple products to the cart', async () => {
|
|
||||||
// Add 5 simple products to cart
|
|
||||||
await CustomerFlow.goToProduct( simplePostIdValue );
|
|
||||||
await expect( page ).toFill( 'div.quantity input.qty', '5' );
|
|
||||||
await CustomerFlow.addToCart();
|
|
||||||
await expect( page ).toMatchElement( '.woocommerce-message', { text: 'have been added to your cart.' } );
|
|
||||||
|
|
||||||
// Verify cart contents
|
|
||||||
await CustomerFlow.goToCart();
|
|
||||||
await CustomerFlow.productIsInCart( simpleProductName, 5 );
|
|
||||||
|
|
||||||
// Remove items from cart
|
|
||||||
await CustomerFlow.removeFromCart( simpleProductName );
|
|
||||||
await uiUnblocked();
|
|
||||||
await expect( page ).toMatchElement( '.cart-empty', { text: 'Your cart is currently empty.' } );
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
|
|
||||||
describe.skip( 'Variable Product Page', () => {
|
|
||||||
beforeAll( async () => {
|
|
||||||
await StoreOwnerFlow.login();
|
|
||||||
variablePostIdValue = await createVariableProduct();
|
|
||||||
await StoreOwnerFlow.logout();
|
|
||||||
} );
|
|
||||||
|
|
||||||
it( 'should be able to add variation products to the cart', async () => {
|
|
||||||
// Add a product with one set of variations to cart
|
|
||||||
await CustomerFlow.goToProduct( variablePostIdValue );
|
|
||||||
await expect( page ).toSelect( '#attr-1', 'val1' );
|
|
||||||
await expect( page ).toSelect( '#attr-2', 'val1' );
|
|
||||||
await expect( page ).toSelect( '#attr-3', 'val1' );
|
|
||||||
await CustomerFlow.addToCart();
|
|
||||||
await expect( page ).toMatchElement( '.woocommerce-message', { text: 'has been added to your cart.' } );
|
|
||||||
|
|
||||||
// Verify cart contents
|
|
||||||
await CustomerFlow.goToCart();
|
|
||||||
await CustomerFlow.productIsInCart( 'Variable Product with Three Variations' );
|
|
||||||
|
|
||||||
// Remove items from cart
|
|
||||||
await CustomerFlow.removeFromCart( 'Variable Product with Three Variations' );
|
|
||||||
await uiUnblocked();
|
|
||||||
await expect( page ).toMatchElement( '.cart-empty', { text: 'Your cart is currently empty.' } );
|
|
||||||
} );
|
|
||||||
} );
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
/*
|
||||||
|
* Internal dependencies
|
||||||
|
*/
|
||||||
|
const { runFrontEndTests } = require( '@woocommerce/e2e-core-tests' );
|
||||||
|
|
||||||
|
runFrontEndTests();
|
Loading…
Reference in New Issue