Merge pull request #28631 from woocommerce/add/e2e-merchant-orders-view-update

Add e2e tests for merchant edit order flows
This commit is contained in:
Greg 2021-02-25 11:20:36 -07:00 committed by GitHub
commit 7a10ca652b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 95 additions and 1 deletions

View File

@ -20,6 +20,7 @@ const runVariableProductUpdateTest = require( './shopper/front-end-variable-prod
// Merchant tests
const runCreateCouponTest = require( './merchant/wp-admin-coupon-new.test' );
const runCreateOrderTest = require( './merchant/wp-admin-order-new.test' );
const runEditOrderTest = require( './merchant/wp-admin-order-edit.test' );
const { runAddSimpleProductTest, runAddVariableProductTest } = require( './merchant/wp-admin-product-new.test' );
const runUpdateGeneralSettingsTest = require( './merchant/wp-admin-settings-general.test' );
const runProductSettingsTest = require( './merchant/wp-admin-settings-product.test' );
@ -51,6 +52,7 @@ const runShopperTests = () => {
const runMerchantTests = () => {
runCreateCouponTest();
runCreateOrderTest();
runEditOrderTest();
runAddSimpleProductTest();
runAddVariableProductTest();
runUpdateGeneralSettingsTest();
@ -80,6 +82,7 @@ module.exports = {
runShopperTests,
runCreateCouponTest,
runCreateOrderTest,
runEditOrderTest,
runAddSimpleProductTest,
runAddVariableProductTest,
runUpdateGeneralSettingsTest,

View File

@ -0,0 +1,85 @@
/* eslint-disable jest/no-export, jest/no-disabled-tests */
/**
* Internal dependencies
*/
const {
merchant,
createSimpleOrder,
moveAllItemsToTrash
} = require( '@woocommerce/e2e-utils' );
let orderId;
const runEditOrderTest = () => {
describe('WooCommerce Orders > Edit order', () => {
beforeAll(async () => {
await merchant.login();
orderId = await createSimpleOrder('Processing');
});
afterAll( async () => {
// Make sure we're on the all orders view and cleanup the orders we created
await merchant.openAllOrdersView();
await moveAllItemsToTrash();
});
it('can view single order', async () => {
// Go to "orders" page
await merchant.openAllOrdersView();
// Make sure we're on the orders page
await expect(page.title()).resolves.toMatch('Orders');
//Open order we created
await merchant.goToOrder(orderId);
// Make sure we're on the order details page
await expect(page.title()).resolves.toMatch('Edit order');
});
it('can update order status', async () => {
//Open order we created
await merchant.goToOrder(orderId);
// Make sure we're still on the order details page
await expect(page.title()).resolves.toMatch('Edit order');
// Update order status to `Completed`
await merchant.updateOrderStatus(orderId, 'Completed');
// Verify order status changed note added
await expect( page ).toMatchElement( '#select2-order_status-container', { text: 'Completed' } );
await expect( page ).toMatchElement(
'#woocommerce-order-notes .note_content',
{
text: 'Order status changed from Processing to Completed.',
}
);
});
it('can update order details', async () => {
//Open order we created
await merchant.goToOrder(orderId);
// Make sure we're still on the order details page
await expect(page.title()).resolves.toMatch('Edit order');
// Update order details
await expect(page).toFill('input[name=order_date]', '2018-12-14');
// Wait for auto save
await page.waitFor( 2000 );
// Save the order changes
await expect( page ).toClick( 'button.save_order' );
await page.waitForSelector( '#message' );
// Verify
await expect( page ).toMatchElement( '#message', { text: 'Order updated.' } );
await expect( page ).toMatchElement( 'input[name=order_date]', { value: '2018-12-14' } );
});
});
}
module.exports = runEditOrderTest;

View File

@ -8,7 +8,7 @@ const {
} = require( '@woocommerce/e2e-utils' );
const runCreateOrderTest = () => {
describe('Add New Order Page', () => {
describe('WooCommerce Orders > Add new order', () => {
beforeAll(async () => {
await merchant.login();
});

View File

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