Improve cart util and update relevant e2e tests (#48475)
* Improve cart util and update relevant tests * Add changelog * Remove focused test
This commit is contained in:
parent
29ee0ab6cf
commit
a7fc9afa8e
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: dev
|
||||
|
||||
E2E tests: improving cart util and updating relevant tests
|
|
@ -293,8 +293,7 @@ test.describe( 'Shopper Cart & Checkout Block Tax Rounding', () => {
|
|||
|
||||
// all tests use the same products
|
||||
await addAProductToCart( page, productId );
|
||||
await addAProductToCart( page, productId2 );
|
||||
await addAProductToCart( page, productId2 );
|
||||
await addAProductToCart( page, productId2, 2 );
|
||||
} );
|
||||
|
||||
test.afterAll( async ( { baseURL } ) => {
|
||||
|
|
|
@ -235,9 +235,8 @@ test.describe( 'Cart & Checkout Restricted Coupons', () => {
|
|||
).toBeVisible();
|
||||
|
||||
// add a couple more in order to hit minimum spend
|
||||
for ( let i = 0; i < 2; i++ ) {
|
||||
await addAProductToCart( page, firstProductId );
|
||||
}
|
||||
await addAProductToCart( page, firstProductId, 2 );
|
||||
|
||||
// passed because we're between 50 and 200 dollars
|
||||
await page.goto( '/cart/' );
|
||||
await page
|
||||
|
@ -280,9 +279,8 @@ test.describe( 'Cart & Checkout Restricted Coupons', () => {
|
|||
).toBeVisible();
|
||||
|
||||
// add a couple more in order to hit minimum spend
|
||||
for ( let i = 0; i < 2; i++ ) {
|
||||
await addAProductToCart( page, firstProductId );
|
||||
}
|
||||
await addAProductToCart( page, firstProductId, 2 );
|
||||
|
||||
// passed because we're between 50 and 200 dollars
|
||||
await page.goto( '/checkout/' );
|
||||
await page
|
||||
|
|
|
@ -57,6 +57,10 @@ test.describe( 'Checkout Block page', () => {
|
|||
consumerSecret: process.env.CONSUMER_SECRET,
|
||||
version: 'wc/v3',
|
||||
} );
|
||||
// make sure the currency is USD
|
||||
await api.put( 'settings/general/woocommerce_currency', {
|
||||
value: 'USD',
|
||||
} );
|
||||
// add product
|
||||
await api
|
||||
.post( 'products', {
|
||||
|
@ -287,8 +291,7 @@ test.describe( 'Checkout Block page', () => {
|
|||
testPage,
|
||||
} ) => {
|
||||
// this time we're going to add two products to the cart
|
||||
await addAProductToCart( page, productId );
|
||||
await addAProductToCart( page, productId );
|
||||
await addAProductToCart( page, productId, 2 );
|
||||
await page.goto( testPage.slug );
|
||||
|
||||
await expect(
|
||||
|
@ -325,9 +328,7 @@ test.describe( 'Checkout Block page', () => {
|
|||
testPage,
|
||||
} ) => {
|
||||
// this time we're going to add three products to the cart
|
||||
await addAProductToCart( page, productId );
|
||||
await addAProductToCart( page, productId );
|
||||
await addAProductToCart( page, productId );
|
||||
await addAProductToCart( page, productId, 3 );
|
||||
await page.goto( testPage.slug );
|
||||
|
||||
await expect(
|
||||
|
@ -601,8 +602,7 @@ test.describe( 'Checkout Block page', () => {
|
|||
testPage,
|
||||
} ) => {
|
||||
// adding 2 products to the cart
|
||||
await addAProductToCart( page, productId );
|
||||
await addAProductToCart( page, productId );
|
||||
await addAProductToCart( page, productId, 2 );
|
||||
await page.goto( testPage.slug );
|
||||
|
||||
await expect(
|
||||
|
@ -727,8 +727,7 @@ test.describe( 'Checkout Block page', () => {
|
|||
page,
|
||||
testPage,
|
||||
} ) => {
|
||||
await addAProductToCart( page, productId );
|
||||
await addAProductToCart( page, productId );
|
||||
await addAProductToCart( page, productId, 2 );
|
||||
await page.goto( testPage.slug );
|
||||
|
||||
await expect(
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
const addAProductToCart = async ( page, productId ) => {
|
||||
const addAProductToCart = async ( page, productId, quantity = 1 ) => {
|
||||
for ( let i = 0; i < quantity; i++ ) {
|
||||
const responsePromise = page.waitForResponse(
|
||||
'**/wp-json/wc/store/v1/cart?**'
|
||||
);
|
||||
await page.goto( `/shop/?add-to-cart=${ productId }` );
|
||||
await responsePromise;
|
||||
await page.getByRole( 'alert' ).waitFor( { state: 'visible' } );
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Reference in New Issue