Added new tests for the merchant order refund flow
This commit is contained in:
parent
1add2556d6
commit
2caac87d03
|
@ -2,6 +2,7 @@
|
|||
|
||||
## Added
|
||||
- Merchant Order Status Filter tests
|
||||
- Merchant Order Refund tests
|
||||
|
||||
## Fixed
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ The functions to access the core tests are:
|
|||
- `runProductSettingsTest` - Merchant can update product settings
|
||||
- `runTaxSettingsTest` - Merchant can update tax settings
|
||||
- `runOrderStatusFilterTest` - Merchant can filter orders by order status
|
||||
- `runOrderRefundTest` - Merchant can refund an order
|
||||
|
||||
### Shopper
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ const runUpdateGeneralSettingsTest = require( './merchant/wp-admin-settings-gene
|
|||
const runProductSettingsTest = require( './merchant/wp-admin-settings-product.test' );
|
||||
const runTaxSettingsTest = require( './merchant/wp-admin-settings-tax.test' );
|
||||
const runOrderStatusFiltersTest = require( './merchant/wp-admin-order-status-filters.test' );
|
||||
const runOrderRefundTest = require( './merchant/wp-admin-order-refund.test' );
|
||||
|
||||
const runSetupOnboardingTests = () => {
|
||||
runActivationTest();
|
||||
|
@ -46,6 +47,7 @@ const runMerchantTests = () => {
|
|||
runProductSettingsTest();
|
||||
runTaxSettingsTest();
|
||||
runOrderStatusFiltersTest();
|
||||
runOrderRefundTest();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
@ -67,5 +69,6 @@ module.exports = {
|
|||
runProductSettingsTest,
|
||||
runTaxSettingsTest,
|
||||
runOrderStatusFiltersTest,
|
||||
runOrderRefundTest,
|
||||
runMerchantTests,
|
||||
};
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests, jest/no-standalone-expect */
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
StoreOwnerFlow,
|
||||
createSimpleProduct,
|
||||
createSimpleOrder,
|
||||
verifyCheckboxIsSet,
|
||||
verifyValueOfInputField,
|
||||
uiUnblocked,
|
||||
addProductToOrder,
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
const config = require( 'config' );
|
||||
const simpleProductName = config.get( 'products.simple.name' );
|
||||
|
||||
let orderId;
|
||||
|
||||
const runRefundOrderTest = () => {
|
||||
describe('WooCommerce Orders > Refund an order', () => {
|
||||
beforeAll(async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
|
||||
await createSimpleProduct();
|
||||
orderId = await createSimpleOrder();
|
||||
await addProductToOrder(orderId, simpleProductName);
|
||||
|
||||
// Update order status to `Completed` so we can issue a refund
|
||||
await StoreOwnerFlow.updateOrderStatus(orderId, 'Completed');
|
||||
});
|
||||
|
||||
it('can issue a refund by quantity', async () => {
|
||||
// Click the Refund button
|
||||
await expect(page).toClick('button.refund-items');
|
||||
|
||||
// Verify the refund section shows
|
||||
await page.waitForSelector('div.wc-order-refund-items', { visible: true });
|
||||
await verifyCheckboxIsSet('#restock_refunded_items');
|
||||
|
||||
// Initiate a refund
|
||||
await expect(page).toFill('.refund_order_item_qty', '1');
|
||||
await expect(page).toFill('#refund_reason', 'No longer wanted');
|
||||
|
||||
await Promise.all([
|
||||
verifyValueOfInputField('.refund_line_total', '9.99'),
|
||||
verifyValueOfInputField('#refund_amount', '9.99'),
|
||||
expect(page).toMatchElement('.do-manual-refund', { text: 'Refund £9.99 manually' }),
|
||||
]);
|
||||
|
||||
await expect(page).toClick('.do-manual-refund');
|
||||
|
||||
await uiUnblocked();
|
||||
|
||||
await Promise.all([
|
||||
// Verify the product line item shows the refunded quantity and amount
|
||||
expect(page).toMatchElement('.quantity .refunded', { text: '-1' }),
|
||||
expect(page).toMatchElement('.line_cost .refunded', { text: '-£9.99' }),
|
||||
|
||||
// Verify the refund shows in the list with the amount
|
||||
expect(page).toMatchElement('.refund .description', { text: 'No longer wanted' }),
|
||||
expect(page).toMatchElement('.refund > .line_cost', { text: '-£9.99' }),
|
||||
]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
module.exports = runRefundOrderTest;
|
|
@ -0,0 +1,6 @@
|
|||
/*
|
||||
* Internal dependencies
|
||||
*/
|
||||
const { runOrderRefundTest } = require( '@woocommerce/e2e-core-tests' );
|
||||
|
||||
runOrderRefundTest();
|
|
@ -9,6 +9,11 @@
|
|||
- `clickFilter()` util helper method that clicks on a list page filter
|
||||
- `moveAllItemsToTrash()` util helper method that checks every item in a list page and moves them to the trash
|
||||
- `createSimpleOrder( status )` component which accepts an order status string and creates a basic order with that status
|
||||
- `addProductToOrder( orderId, productName )` component which adds the provided productName to the passed in orderId
|
||||
|
||||
## Changes
|
||||
|
||||
- `createSimpleOrder( status )` returns the ID of the order that was created
|
||||
|
||||
# 0.1.1
|
||||
|
||||
|
|
|
@ -38,20 +38,22 @@ describe( 'Cart page', () => {
|
|||
|
||||
### Merchant `StoreOwnerFlow`
|
||||
|
||||
| Function | Description |
|
||||
|----------|-------------|
|
||||
| `login` | Log in as merchant |
|
||||
| `logout` | log out of merchant account |
|
||||
| `openAllOrdersView` | Go to the orders listing |
|
||||
| `openDashboard` | Go to the WordPress dashboard |
|
||||
| `openNewCoupon` | Go to the new coupon editor |
|
||||
| `openNewOrder` | Go to the new order editor |
|
||||
| `openNewProduct` | Go to the new product editor |
|
||||
| `openPermalinkSettings` | Go to Settings -> Permalinks |
|
||||
| `openPlugins` | Go to the Plugins screen |
|
||||
| `openSettings` | Go to WooCommerce -> Settings |
|
||||
| `runSetupWizard` | Open the onboarding profiler |
|
||||
|----------|-------------|
|
||||
| Function | Parameters | Description |
|
||||
|----------|-------------|------------|
|
||||
| `login` | | Log in as merchant |
|
||||
| `logout` | | Log out of merchant account |
|
||||
| `openAllOrdersView` | | Go to the orders listing |
|
||||
| `openDashboard` | | Go to the WordPress dashboard |
|
||||
| `openNewCoupon` | | Go to the new coupon editor |
|
||||
| `openNewOrder` | | Go to the new order editor |
|
||||
| `openNewProduct` | | Go to the new product editor |
|
||||
| `openPermalinkSettings` | | Go to Settings -> Permalinks |
|
||||
| `openPlugins` | | Go to the Plugins screen |
|
||||
| `openSettings` | | Go to WooCommerce -> Settings |
|
||||
| `runSetupWizard` | | Open the onboarding profiler |
|
||||
| `goToOrder` | `orderId` | Go to view a single order |
|
||||
| `updateOrderStatus` | `orderId, status` | Update the status of an order |
|
||||
|----------|-------------|-------------|
|
||||
|
||||
### Shopper `CustomerFlow`
|
||||
|
||||
|
|
|
@ -368,12 +368,41 @@ const createSimpleOrder = async ( orderStatus = 'Pending payment' ) => {
|
|||
|
||||
// Verify
|
||||
await expect( page ).toMatchElement( '#message', { text: 'Order updated.' } );
|
||||
|
||||
const variablePostId = await page.$( '#post_ID' );
|
||||
let variablePostIdValue = ( await ( await variablePostId.getProperty( 'value' ) ).jsonValue() );
|
||||
return variablePostIdValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a product to an order in the StoreOwnerFlow.
|
||||
*
|
||||
* @param orderId ID of the order to add the product to.
|
||||
* @param productName Name of the product being added to the order.
|
||||
*/
|
||||
const addProductToOrder = async ( orderId, productName ) => {
|
||||
await StoreOwnerFlow.goToOrder( orderId );
|
||||
|
||||
// Add a product to the order
|
||||
await expect( page ).toClick( 'button.add-line-item' );
|
||||
await expect( page ).toClick( 'button.add-order-item' );
|
||||
await page.waitForSelector( '.wc-backbone-modal-header' );
|
||||
await expect( page ).toClick( '.wc-backbone-modal-content .wc-product-search' );
|
||||
await expect( page ).toFill( '#wc-backbone-modal-dialog + .select2-container .select2-search__field', productName );
|
||||
await expect( page ).toClick( 'li[aria-selected="true"]' );
|
||||
await page.click( '.wc-backbone-modal-content #btn-ok' );
|
||||
|
||||
await uiUnblocked();
|
||||
|
||||
// Verify the product we added shows as a line item now
|
||||
await expect( page ).toMatchElement( '.wc-order-item-name', { text: productName } );
|
||||
}
|
||||
|
||||
export {
|
||||
completeOnboardingWizard,
|
||||
createSimpleProduct,
|
||||
createVariableProduct,
|
||||
createSimpleOrder,
|
||||
verifyAndPublish,
|
||||
addProductToOrder,
|
||||
};
|
||||
|
|
|
@ -25,6 +25,7 @@ const WP_ADMIN_NEW_ORDER = baseUrl + 'wp-admin/post-new.php?post_type=shop_order
|
|||
const WP_ADMIN_NEW_PRODUCT = baseUrl + 'wp-admin/post-new.php?post_type=product';
|
||||
const WP_ADMIN_WC_SETTINGS = baseUrl + 'wp-admin/admin.php?page=wc-settings&tab=';
|
||||
const WP_ADMIN_PERMALINK_SETTINGS = baseUrl + 'wp-admin/options-permalink.php';
|
||||
const WP_ADMIN_SINGLE_CPT_VIEW = ( postId ) => baseUrl + `wp-admin/post.php?post=${ postId }&action=edit`;
|
||||
|
||||
const SHOP_PAGE = baseUrl + 'shop';
|
||||
const SHOP_PRODUCT_PAGE = baseUrl + '?p=';
|
||||
|
@ -310,6 +311,23 @@ const StoreOwnerFlow = {
|
|||
waitUntil: 'networkidle0',
|
||||
} );
|
||||
},
|
||||
|
||||
goToOrder: async ( orderId ) => {
|
||||
await page.goto( WP_ADMIN_SINGLE_CPT_VIEW( orderId ), {
|
||||
waitUntil: 'networkidle0',
|
||||
} );
|
||||
},
|
||||
|
||||
updateOrderStatus: async ( orderId, status ) => {
|
||||
await page.goto( WP_ADMIN_SINGLE_CPT_VIEW( orderId ), {
|
||||
waitUntil: 'networkidle0',
|
||||
} );
|
||||
await expect( page ).toSelect( '#order_status', status );
|
||||
await page.waitFor( 2000 );
|
||||
await expect( page ).toClick( 'button.save_order' );
|
||||
await page.waitForSelector( '#message' );
|
||||
await expect( page ).toMatchElement( '#message', { text: 'Order updated.' } );
|
||||
}
|
||||
};
|
||||
|
||||
export { CustomerFlow, StoreOwnerFlow };
|
||||
|
|
Loading…
Reference in New Issue