Dynamically pull the currency symbol instead of hard-coding it

This commit is contained in:
zhongruige 2020-12-11 10:48:20 -07:00
parent 4ca6114476
commit 88ddefbcb3
1 changed files with 12 additions and 4 deletions

View File

@ -17,16 +17,21 @@ const config = require( 'config' );
const simpleProductName = config.get( 'products.simple.name' );
let orderId;
let currencySymbol;
const runRefundOrderTest = () => {
describe('WooCommerce Orders > Refund an order', () => {
beforeAll(async () => {
await StoreOwnerFlow.login();
await createSimpleProduct();
orderId = await createSimpleOrder();
await addProductToOrder(orderId, simpleProductName);
// Get the currency symbol for the store's selected currency
await page.waitForSelector('.woocommerce-Price-currencySymbol')
let currencyElement = await page.$('.woocommerce-Price-currencySymbol')
currencySymbol = await page.evaluate(el => el.textContent, currencyElement)
// Update order status to `Completed` so we can issue a refund
await StoreOwnerFlow.updateOrderStatus(orderId, 'Completed');
});
@ -46,7 +51,7 @@ const runRefundOrderTest = () => {
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' }),
expect(page).toMatchElement('.do-manual-refund', { text: `Refund ${currencySymbol}9.99 manually` }),
]);
await expect(page).toClick('.do-manual-refund');
@ -56,11 +61,14 @@ const runRefundOrderTest = () => {
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' }),
expect(page).toMatchElement('.line_cost .refunded', { text: `-${currencySymbol}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' }),
expect(page).toMatchElement('.refund > .line_cost', { text: `-${currencySymbol}9.99` }),
// Verify system note was added
expect(page).toMatchElement('.system-note', { text: 'Order status changed from Completed to Refunded.' }),
]);
});