Add new e2e test merchant order searching
This commit is contained in:
parent
03ba8838b1
commit
a77a4f264e
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"url": "http://localhost:8084/",
|
||||
"appName": "woocommerce_e2e",
|
||||
"users": {
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
- Shopper Checkout Apply Coupon
|
||||
- Merchant Orders Customer Checkout Page
|
||||
- Shopper Cart Apply Coupon
|
||||
- Merchant Order Searching
|
||||
|
||||
## Fixed
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ The functions to access the core tests are:
|
|||
- `runOrderRefundTest` - Merchant can refund an order
|
||||
- `runOrderApplyCouponTest` - Merchant can apply a coupon to an order
|
||||
- `runMerchantOrdersCustomerPaymentPage` - Merchant can visit the customer payment page
|
||||
- `runOrderSearchingTest` - Merchant can search for order via different terms
|
||||
|
||||
### Shopper
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ const runOrderStatusFiltersTest = require( './merchant/wp-admin-order-status-fil
|
|||
const runOrderRefundTest = require( './merchant/wp-admin-order-refund.test' );
|
||||
const runOrderApplyCouponTest = require( './merchant/wp-admin-order-apply-coupon.test' );
|
||||
const runMerchantOrdersCustomerPaymentPage = require( './merchant/wp-admin-order-customer-payment-page.test' );
|
||||
const runOrderSearchingTest = require( './merchant/wp-admin-order-searching.test' );
|
||||
|
||||
const runSetupOnboardingTests = () => {
|
||||
runActivationTest();
|
||||
|
@ -56,6 +57,7 @@ const runMerchantTests = () => {
|
|||
runOrderRefundTest();
|
||||
runOrderApplyCouponTest();
|
||||
runMerchantOrdersCustomerPaymentPage();
|
||||
runOrderSearchingTest();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
@ -83,4 +85,5 @@ module.exports = {
|
|||
runOrderApplyCouponTest,
|
||||
runMerchantOrdersCustomerPaymentPage,
|
||||
runMerchantTests,
|
||||
runOrderSearchingTest,
|
||||
};
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests, */
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
merchant,
|
||||
clearAndFillInput,
|
||||
selectOptionInSelect2,
|
||||
searchForOrder,
|
||||
createSimpleProduct,
|
||||
addProductToOrder,
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
let orderId;
|
||||
|
||||
const runOrderSearchingTest = () => {
|
||||
describe('WooCommerce Orders > Search orders', () => {
|
||||
beforeAll(async () => {
|
||||
await merchant.login();
|
||||
|
||||
await createSimpleProduct('Wanted Product');
|
||||
|
||||
// Create new order for testing
|
||||
await merchant.openNewOrder();
|
||||
await page.select('#order_status', 'Pending payment');
|
||||
await page.click('#customer_user');
|
||||
await selectOptionInSelect2('Customer', 'input.select2-search__field');
|
||||
|
||||
// Change the shipping data
|
||||
const input = await page.$('#_shipping_first_name'); // to avoid flakiness
|
||||
await input.click({ clickCount: 3 }); // to avoid flakiness
|
||||
await page.keyboard.press('Backspace'); // to avoid flakiness
|
||||
await clearAndFillInput('#_shipping_first_name', 'Jane');
|
||||
await clearAndFillInput('#_shipping_last_name', 'Doherty');
|
||||
await clearAndFillInput('#_shipping_address_1', 'Oxford Ave');
|
||||
await clearAndFillInput('#_shipping_address_2', 'Linwood Ave');
|
||||
await clearAndFillInput('#_shipping_city', 'Buffalo');
|
||||
await clearAndFillInput('#_shipping_postcode', '14201');
|
||||
await page.select('#_shipping_state', 'NY');
|
||||
|
||||
// Save new order
|
||||
await page.waitFor(2000); // wait for autosave
|
||||
await page.click('button.save_order');
|
||||
await page.waitForSelector('#message');
|
||||
|
||||
// Get the post id
|
||||
const variablePostId = await page.$('#post_ID');
|
||||
orderId = (await(await variablePostId.getProperty('value')).jsonValue());
|
||||
|
||||
await merchant.openAllOrdersView();
|
||||
|
||||
await addProductToOrder(orderId, 'Wanted Product');
|
||||
|
||||
await merchant.openAllOrdersView();
|
||||
});
|
||||
|
||||
it('can search for order by order id', async () => {
|
||||
await searchForOrder(orderId, orderId);
|
||||
});
|
||||
|
||||
it('can search for order by billing first name', async () => {
|
||||
await searchForOrder('John', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by billing last name', async () => {
|
||||
await searchForOrder('Doe', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by billing company name', async () => {
|
||||
await searchForOrder('Automattic', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by billing first address', async () => {
|
||||
await searchForOrder('addr 1', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by billing second address', async () => {
|
||||
await searchForOrder('addr 2', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by billing city name', async () => {
|
||||
await searchForOrder('San Francisco', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by billing post code', async () => {
|
||||
await searchForOrder('94107', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by billing email', async () => {
|
||||
await searchForOrder('john.doe@example.com', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by billing phone', async () => {
|
||||
await searchForOrder('123456789', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by billing state', async () => {
|
||||
await searchForOrder('CA', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by shipping first name', async () => {
|
||||
await searchForOrder('Jane', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by shipping last name', async () => {
|
||||
await searchForOrder('Doherty', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by shipping first address', async () => {
|
||||
await searchForOrder('Oxford Ave', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by shipping second address', async () => {
|
||||
await searchForOrder('Linwood Ave', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by shipping city name', async () => {
|
||||
await searchForOrder('Buffalo', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by shipping postcode name', async () => {
|
||||
await searchForOrder('14201', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by shipping state name', async () => {
|
||||
await searchForOrder('NY', orderId);
|
||||
})
|
||||
|
||||
it('can search for order by item name', async () => {
|
||||
await searchForOrder('Wanted Product', orderId);
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = runOrderSearchingTest;
|
|
@ -0,0 +1,6 @@
|
|||
/*
|
||||
* Internal dependencies
|
||||
*/
|
||||
const { runOrderSearchingTest } = require( '@woocommerce/e2e-core-tests' );
|
||||
|
||||
runOrderSearchingTest();
|
|
@ -16,6 +16,7 @@
|
|||
- `createCoupon( couponAmount )` component which accepts a coupon amount string (it defaults to 5) and creates a basic coupon. Returns the generated coupon code.
|
||||
- `evalAndClick( selector )` use Puppeteer page.$eval to select and click and element.
|
||||
- `selectOptionInSelect2( selector, value )` util helper method that search and select in any select2 type field
|
||||
- `searchForOrder( value, orderId )` util helper method that search order with different terms
|
||||
|
||||
## Changes
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@ describe( 'Cart page', () => {
|
|||
| `clickFilter` | `selector` | Click on a list page filter |
|
||||
| `moveAllItemsToTrash` | | Moves all items in a list view to the Trash |
|
||||
| `selectOptionInSelect2` | `selector, value` | helper method that searchs for select2 type fields and select plus insert value inside
|
||||
| `searchForOrder` | `value, orderId` | helper method that searchs for an order via many different terms
|
||||
|
||||
### Test Utilities
|
||||
|
||||
|
|
|
@ -170,11 +170,13 @@ const completeOnboardingWizard = async () => {
|
|||
|
||||
/**
|
||||
* Create simple product.
|
||||
*
|
||||
* @param simpleProductName - Defaults to Simple Product. Customizable title.
|
||||
*/
|
||||
const createSimpleProduct = async () => {
|
||||
const createSimpleProduct = async ( productTitle = simpleProductName, productPrice = simpleProductPrice ) => {
|
||||
const product = await factories.products.simple.create( {
|
||||
name: simpleProductName,
|
||||
regularPrice: simpleProductPrice
|
||||
name: productTitle,
|
||||
regularPrice: productPrice
|
||||
} );
|
||||
return product.id;
|
||||
} ;
|
||||
|
|
|
@ -209,6 +209,19 @@ const selectOptionInSelect2 = async ( value, selector = 'input.select2-search__f
|
|||
await page.keyboard.press('Enter');
|
||||
};
|
||||
|
||||
/**
|
||||
* Search by any term for an order
|
||||
*
|
||||
* @param {string} value Value to be entered into the search field
|
||||
* @param {string} orderId Order ID
|
||||
*/
|
||||
const searchForOrder = async (value, orderId) => {
|
||||
await clearAndFillInput('#post-search-input', value);
|
||||
await expect(page).toClick('#search-submit');
|
||||
await page.waitForSelector('#the-list');
|
||||
await expect(page).toMatchElement('.order_number > a.order-view', {text: '#'+orderId+' John Doe'});
|
||||
};
|
||||
|
||||
export {
|
||||
clearAndFillInput,
|
||||
clickTab,
|
||||
|
@ -225,4 +238,5 @@ export {
|
|||
moveAllItemsToTrash,
|
||||
evalAndClick,
|
||||
selectOptionInSelect2,
|
||||
searchForOrder,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue