Merge pull request #28575 from woocommerce/add/e2e-simple-price-config-variable
Add config variable for simple product price to default.json
This commit is contained in:
commit
91e39b70c3
|
@ -4,6 +4,7 @@
|
||||||
- Merchant Order Status Filter tests
|
- Merchant Order Status Filter tests
|
||||||
- Merchant Order Refund tests
|
- Merchant Order Refund tests
|
||||||
- Merchant Apply Coupon tests
|
- Merchant Apply Coupon tests
|
||||||
|
- Added new config variable for Simple Product price to `tests/e2e/env/config/default.json`. Defaults to 9.99
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* eslint-disable jest/no-export */
|
/* eslint-disable jest/no-export, jest/no-standalone-expect */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
@ -14,6 +14,8 @@ const {
|
||||||
|
|
||||||
const config = require( 'config' );
|
const config = require( 'config' );
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
|
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
||||||
|
const discountedPrice = simpleProductPrice - 5.00;
|
||||||
|
|
||||||
const couponDialogMessage = 'Enter a coupon code to apply. Discounts are applied to line totals, before taxes.';
|
const couponDialogMessage = 'Enter a coupon code to apply. Discounts are applied to line totals, before taxes.';
|
||||||
|
|
||||||
|
@ -33,6 +35,9 @@ const runOrderApplyCouponTest = () => {
|
||||||
// We need to remove any listeners on the `dialog` event otherwise we can't catch the dialog below
|
// We need to remove any listeners on the `dialog` event otherwise we can't catch the dialog below
|
||||||
page.removeAllListeners('dialog'),
|
page.removeAllListeners('dialog'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Make sure the simple product price is greater than the coupon amount
|
||||||
|
await expect(Number(simpleProductPrice)).toBeGreaterThan(5.00);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
it('can apply a coupon', async () => {
|
it('can apply a coupon', async () => {
|
||||||
|
@ -54,7 +59,7 @@ const runOrderApplyCouponTest = () => {
|
||||||
|
|
||||||
// Check that the coupon has been applied
|
// Check that the coupon has been applied
|
||||||
await expect(page).toMatchElement('.wc-order-item-discount', { text: '5.00' });
|
await expect(page).toMatchElement('.wc-order-item-discount', { text: '5.00' });
|
||||||
await expect(page).toMatchElement('.line_cost > .view > .woocommerce-Price-amount', { text: '4.99' });
|
await expect(page).toMatchElement('.line_cost > .view > .woocommerce-Price-amount', { text: discountedPrice });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can remove a coupon', async () => {
|
it('can remove a coupon', async () => {
|
||||||
|
@ -71,10 +76,10 @@ const runOrderApplyCouponTest = () => {
|
||||||
// Verify the coupon pricing has been removed
|
// Verify the coupon pricing has been removed
|
||||||
await expect(page).not.toMatchElement('.wc_coupon_list li.code.editable', { text: couponCode });
|
await expect(page).not.toMatchElement('.wc_coupon_list li.code.editable', { text: couponCode });
|
||||||
await expect(page).not.toMatchElement('.wc-order-item-discount', { text: '5.00' });
|
await expect(page).not.toMatchElement('.wc-order-item-discount', { text: '5.00' });
|
||||||
await expect(page).not.toMatchElement('.line-cost .view .woocommerce-Price-amount', { text: '4.99' });
|
await expect(page).not.toMatchElement('.line-cost .view .woocommerce-Price-amount', { text: discountedPrice });
|
||||||
|
|
||||||
// Verify the original price is the order total
|
// Verify the original price is the order total
|
||||||
await expect(page).toMatchElement('.line_cost > .view > .woocommerce-Price-amount', { text: '9.99' });
|
await expect(page).toMatchElement('.line_cost > .view > .woocommerce-Price-amount', { text: simpleProductPrice });
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,6 +15,7 @@ const {
|
||||||
|
|
||||||
const config = require( 'config' );
|
const config = require( 'config' );
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
|
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
||||||
|
|
||||||
let orderId;
|
let orderId;
|
||||||
let currencySymbol;
|
let currencySymbol;
|
||||||
|
@ -49,9 +50,9 @@ const runRefundOrderTest = () => {
|
||||||
await expect(page).toFill('#refund_reason', 'No longer wanted');
|
await expect(page).toFill('#refund_reason', 'No longer wanted');
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
verifyValueOfInputField('.refund_line_total', '9.99'),
|
verifyValueOfInputField('.refund_line_total', simpleProductPrice),
|
||||||
verifyValueOfInputField('#refund_amount', '9.99'),
|
verifyValueOfInputField('#refund_amount', simpleProductPrice),
|
||||||
expect(page).toMatchElement('.do-manual-refund', { text: `Refund ${currencySymbol}9.99 manually` }),
|
expect(page).toMatchElement('.do-manual-refund', { text: `Refund ${currencySymbol + simpleProductPrice} manually` }),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await expect(page).toClick('.do-manual-refund');
|
await expect(page).toClick('.do-manual-refund');
|
||||||
|
@ -61,11 +62,11 @@ const runRefundOrderTest = () => {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
// Verify the product line item shows the refunded quantity and amount
|
// Verify the product line item shows the refunded quantity and amount
|
||||||
expect(page).toMatchElement('.quantity .refunded', { text: '-1' }),
|
expect(page).toMatchElement('.quantity .refunded', { text: '-1' }),
|
||||||
expect(page).toMatchElement('.line_cost .refunded', { text: `-${currencySymbol}9.99` }),
|
expect(page).toMatchElement('.line_cost .refunded', { text: `-${currencySymbol + simpleProductPrice}` }),
|
||||||
|
|
||||||
// Verify the refund shows in the list with the amount
|
// Verify the refund shows in the list with the amount
|
||||||
expect(page).toMatchElement('.refund .description', { text: 'No longer wanted' }),
|
expect(page).toMatchElement('.refund .description', { text: 'No longer wanted' }),
|
||||||
expect(page).toMatchElement('.refund > .line_cost', { text: `-${currencySymbol}9.99` }),
|
expect(page).toMatchElement('.refund > .line_cost', { text: `-${currencySymbol + simpleProductPrice}` }),
|
||||||
|
|
||||||
// Verify system note was added
|
// Verify system note was added
|
||||||
expect(page).toMatchElement('.system-note', { text: 'Order status changed from Completed to Refunded.' }),
|
expect(page).toMatchElement('.system-note', { text: 'Order status changed from Completed to Refunded.' }),
|
||||||
|
@ -86,11 +87,11 @@ const runRefundOrderTest = () => {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
// Verify the product line item shows the refunded quantity and amount
|
// Verify the product line item shows the refunded quantity and amount
|
||||||
expect(page).not.toMatchElement('.quantity .refunded', { text: '-1' }),
|
expect(page).not.toMatchElement('.quantity .refunded', { text: '-1' }),
|
||||||
expect(page).not.toMatchElement('.line_cost .refunded', { text: `-${currencySymbol}9.99` }),
|
expect(page).not.toMatchElement('.line_cost .refunded', { text: `-${currencySymbol + simpleProductPrice}` }),
|
||||||
|
|
||||||
// Verify the refund shows in the list with the amount
|
// Verify the refund shows in the list with the amount
|
||||||
expect(page).not.toMatchElement('.refund .description', { text: 'No longer wanted' }),
|
expect(page).not.toMatchElement('.refund .description', { text: 'No longer wanted' }),
|
||||||
expect(page).not.toMatchElement('.refund > .line_cost', { text: `-${currencySymbol}9.99` }),
|
expect(page).not.toMatchElement('.refund > .line_cost', { text: `-${currencySymbol + simpleProductPrice}` }),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ const {
|
||||||
const config = require( 'config' );
|
const config = require( 'config' );
|
||||||
|
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
|
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
||||||
|
|
||||||
const verifyPublishAndTrash = async () => {
|
const verifyPublishAndTrash = async () => {
|
||||||
// Wait for auto save
|
// Wait for auto save
|
||||||
|
@ -57,7 +58,7 @@ const runAddSimpleProductTest = () => {
|
||||||
await expect(page).toFill('#title', simpleProductName);
|
await expect(page).toFill('#title', simpleProductName);
|
||||||
await expect(page).toClick('#_virtual');
|
await expect(page).toClick('#_virtual');
|
||||||
await clickTab('General');
|
await clickTab('General');
|
||||||
await expect(page).toFill('#_regular_price', '9.99');
|
await expect(page).toFill('#_regular_price', simpleProductPrice);
|
||||||
|
|
||||||
// Publish product, verify that it was published. Trash product, verify that it was trashed.
|
// Publish product, verify that it was published. Trash product, verify that it was trashed.
|
||||||
await verifyPublishAndTrash(
|
await verifyPublishAndTrash(
|
||||||
|
|
|
@ -18,6 +18,11 @@ const {
|
||||||
beforeAll,
|
beforeAll,
|
||||||
} = require( '@jest/globals' );
|
} = require( '@jest/globals' );
|
||||||
|
|
||||||
|
const config = require( 'config' );
|
||||||
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
|
const singleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
||||||
|
const twoProductPrice = singleProductPrice * 2;
|
||||||
|
|
||||||
const runCartPageTest = () => {
|
const runCartPageTest = () => {
|
||||||
describe('Cart page', () => {
|
describe('Cart page', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
@ -33,32 +38,32 @@ const runCartPageTest = () => {
|
||||||
|
|
||||||
it('should add the product to the cart when "Add to cart" is clicked', async () => {
|
it('should add the product to the cart when "Add to cart" is clicked', async () => {
|
||||||
await shopper.goToShop();
|
await shopper.goToShop();
|
||||||
await shopper.addToCartFromShopPage('Simple product');
|
await shopper.addToCartFromShopPage(simpleProductName);
|
||||||
|
|
||||||
await shopper.goToCart();
|
await shopper.goToCart();
|
||||||
await shopper.productIsInCart('Simple product');
|
await shopper.productIsInCart(simpleProductName);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should increase item qty when "Add to cart" of the same product is clicked', async () => {
|
it('should increase item qty when "Add to cart" of the same product is clicked', async () => {
|
||||||
await shopper.goToShop();
|
await shopper.goToShop();
|
||||||
await shopper.addToCartFromShopPage('Simple product');
|
await shopper.addToCartFromShopPage(simpleProductName);
|
||||||
|
|
||||||
await shopper.goToCart();
|
await shopper.goToCart();
|
||||||
await shopper.productIsInCart('Simple product', 2);
|
await shopper.productIsInCart(simpleProductName, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update qty when updated via qty input', async () => {
|
it('should update qty when updated via qty input', async () => {
|
||||||
await shopper.goToCart();
|
await shopper.goToCart();
|
||||||
await shopper.setCartQuantity('Simple product', 4);
|
await shopper.setCartQuantity(simpleProductName, 4);
|
||||||
await expect(page).toClick('button', {text: 'Update cart'});
|
await expect(page).toClick('button', {text: 'Update cart'});
|
||||||
await uiUnblocked();
|
await uiUnblocked();
|
||||||
|
|
||||||
await shopper.productIsInCart('Simple product', 4);
|
await shopper.productIsInCart(simpleProductName, 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should remove the item from the cart when remove is clicked', async () => {
|
it('should remove the item from the cart when remove is clicked', async () => {
|
||||||
await shopper.goToCart();
|
await shopper.goToCart();
|
||||||
await shopper.removeFromCart('Simple product');
|
await shopper.removeFromCart(simpleProductName);
|
||||||
await uiUnblocked();
|
await uiUnblocked();
|
||||||
|
|
||||||
await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'});
|
await expect(page).toMatchElement('.cart-empty', {text: 'Your cart is currently empty.'});
|
||||||
|
@ -66,17 +71,17 @@ const runCartPageTest = () => {
|
||||||
|
|
||||||
it('should update subtotal in cart totals when adding product to the cart', async () => {
|
it('should update subtotal in cart totals when adding product to the cart', async () => {
|
||||||
await shopper.goToShop();
|
await shopper.goToShop();
|
||||||
await shopper.addToCartFromShopPage('Simple product');
|
await shopper.addToCartFromShopPage(simpleProductName);
|
||||||
|
|
||||||
await shopper.goToCart();
|
await shopper.goToCart();
|
||||||
await shopper.productIsInCart('Simple product', 1);
|
await shopper.productIsInCart(simpleProductName, 1);
|
||||||
await expect(page).toMatchElement('.cart-subtotal .amount', {text: '$9.99'});
|
await expect(page).toMatchElement('.cart-subtotal .amount', {text: `$${ singleProductPrice }`});
|
||||||
|
|
||||||
await shopper.setCartQuantity('Simple product', 2);
|
await shopper.setCartQuantity(simpleProductName, 2);
|
||||||
await expect(page).toClick('button', {text: 'Update cart'});
|
await expect(page).toClick('button', {text: 'Update cart'});
|
||||||
await uiUnblocked();
|
await uiUnblocked();
|
||||||
|
|
||||||
await expect(page).toMatchElement('.cart-subtotal .amount', {text: '$19.98'});
|
await expect(page).toMatchElement('.cart-subtotal .amount', {text: `$${ twoProductPrice }`});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should go to the checkout page when "Proceed to Checkout" is clicked', async () => {
|
it('should go to the checkout page when "Proceed to Checkout" is clicked', async () => {
|
||||||
|
|
|
@ -14,6 +14,12 @@ const {
|
||||||
|
|
||||||
const config = require( 'config' );
|
const config = require( 'config' );
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
|
const singleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
||||||
|
const twoProductPrice = singleProductPrice * 2;
|
||||||
|
const threeProductPrice = singleProductPrice * 3;
|
||||||
|
const fourProductPrice = singleProductPrice * 4;
|
||||||
|
const fiveProductPrice = singleProductPrice * 5;
|
||||||
|
|
||||||
let orderId;
|
let orderId;
|
||||||
|
|
||||||
const runCheckoutPageTest = () => {
|
const runCheckoutPageTest = () => {
|
||||||
|
@ -74,14 +80,14 @@ const runCheckoutPageTest = () => {
|
||||||
await shopper.goToShop();
|
await shopper.goToShop();
|
||||||
await shopper.addToCartFromShopPage(simpleProductName);
|
await shopper.addToCartFromShopPage(simpleProductName);
|
||||||
await shopper.goToCheckout();
|
await shopper.goToCheckout();
|
||||||
await shopper.productIsInCheckout(simpleProductName, `1`, `9.99`, `9.99`);
|
await shopper.productIsInCheckout(simpleProductName, `1`, singleProductPrice, singleProductPrice);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows customer to choose available payment methods', async () => {
|
it('allows customer to choose available payment methods', async () => {
|
||||||
await shopper.goToShop();
|
await shopper.goToShop();
|
||||||
await shopper.addToCartFromShopPage(simpleProductName);
|
await shopper.addToCartFromShopPage(simpleProductName);
|
||||||
await shopper.goToCheckout();
|
await shopper.goToCheckout();
|
||||||
await shopper.productIsInCheckout(simpleProductName, `2`, `19.98`, `19.98`);
|
await shopper.productIsInCheckout(simpleProductName, `2`, twoProductPrice, twoProductPrice);
|
||||||
|
|
||||||
await expect(page).toClick('.wc_payment_method label', {text: 'PayPal'});
|
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: 'Direct bank transfer'});
|
||||||
|
@ -92,7 +98,7 @@ const runCheckoutPageTest = () => {
|
||||||
await shopper.goToShop();
|
await shopper.goToShop();
|
||||||
await shopper.addToCartFromShopPage(simpleProductName);
|
await shopper.addToCartFromShopPage(simpleProductName);
|
||||||
await shopper.goToCheckout();
|
await shopper.goToCheckout();
|
||||||
await shopper.productIsInCheckout(simpleProductName, `3`, `29.97`, `29.97`);
|
await shopper.productIsInCheckout(simpleProductName, `3`, threeProductPrice, threeProductPrice);
|
||||||
await shopper.fillBillingDetails(config.get('addresses.customer.billing'));
|
await shopper.fillBillingDetails(config.get('addresses.customer.billing'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -100,7 +106,7 @@ const runCheckoutPageTest = () => {
|
||||||
await shopper.goToShop();
|
await shopper.goToShop();
|
||||||
await shopper.addToCartFromShopPage(simpleProductName);
|
await shopper.addToCartFromShopPage(simpleProductName);
|
||||||
await shopper.goToCheckout();
|
await shopper.goToCheckout();
|
||||||
await shopper.productIsInCheckout(simpleProductName, `4`, `39.96`, `39.96`);
|
await shopper.productIsInCheckout(simpleProductName, `4`, fourProductPrice, fourProductPrice);
|
||||||
|
|
||||||
// Select checkbox to ship to a different address
|
// Select checkbox to ship to a different address
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
|
@ -115,7 +121,7 @@ const runCheckoutPageTest = () => {
|
||||||
await shopper.goToShop();
|
await shopper.goToShop();
|
||||||
await shopper.addToCartFromShopPage(simpleProductName);
|
await shopper.addToCartFromShopPage(simpleProductName);
|
||||||
await shopper.goToCheckout();
|
await shopper.goToCheckout();
|
||||||
await shopper.productIsInCheckout(simpleProductName, `5`, `49.95`, `49.95`);
|
await shopper.productIsInCheckout(simpleProductName, `5`, fiveProductPrice, fiveProductPrice);
|
||||||
await shopper.fillBillingDetails(config.get('addresses.customer.billing'));
|
await shopper.fillBillingDetails(config.get('addresses.customer.billing'));
|
||||||
|
|
||||||
await uiUnblocked();
|
await uiUnblocked();
|
||||||
|
@ -151,13 +157,13 @@ const runCheckoutPageTest = () => {
|
||||||
await expect(page).toMatchElement('.wc-order-item-name', {text: simpleProductName});
|
await expect(page).toMatchElement('.wc-order-item-name', {text: simpleProductName});
|
||||||
|
|
||||||
// Verify product cost
|
// Verify product cost
|
||||||
await expect(page).toMatchElement('.woocommerce-Price-amount.amount', {text: '9.99'});
|
await expect(page).toMatchElement('.woocommerce-Price-amount.amount', {text: singleProductPrice});
|
||||||
|
|
||||||
// Verify product quantity
|
// Verify product quantity
|
||||||
await expect(page).toMatchElement('.quantity', {text: '5'});
|
await expect(page).toMatchElement('.quantity', {text: '5'});
|
||||||
|
|
||||||
// Verify total order amount without shipping
|
// Verify total order amount without shipping
|
||||||
await expect(page).toMatchElement('.line_cost', {text: '49.95'});
|
await expect(page).toMatchElement('.line_cost', {text: fiveProductPrice});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
},
|
},
|
||||||
"products": {
|
"products": {
|
||||||
"simple": {
|
"simple": {
|
||||||
"name": "Simple product"
|
"name": "Simple product",
|
||||||
|
"price": "9.99"
|
||||||
},
|
},
|
||||||
"variable": {
|
"variable": {
|
||||||
"name": "Variable Product with Three Variations"
|
"name": "Variable Product with Three Variations"
|
||||||
|
|
|
@ -11,6 +11,7 @@ import factories from './factories';
|
||||||
|
|
||||||
const config = require( 'config' );
|
const config = require( 'config' );
|
||||||
const simpleProductName = config.get( 'products.simple.name' );
|
const simpleProductName = config.get( 'products.simple.name' );
|
||||||
|
const simpleProductPrice = config.has('products.simple.price') ? config.get('products.simple.price') : '9.99';
|
||||||
|
|
||||||
const verifyAndPublish = async () => {
|
const verifyAndPublish = async () => {
|
||||||
// Wait for auto save
|
// Wait for auto save
|
||||||
|
@ -208,7 +209,7 @@ const completeOnboardingWizard = async () => {
|
||||||
const createSimpleProduct = async () => {
|
const createSimpleProduct = async () => {
|
||||||
const product = await factories.products.simple.create( {
|
const product = await factories.products.simple.create( {
|
||||||
name: simpleProductName,
|
name: simpleProductName,
|
||||||
regularPrice: '9.99'
|
regularPrice: simpleProductPrice
|
||||||
} );
|
} );
|
||||||
return product.id;
|
return product.id;
|
||||||
} ;
|
} ;
|
||||||
|
|
Loading…
Reference in New Issue