Improve e2e stability (#41345)
* Clean up created pages and posts * Move tax tests so that they run last * Improve locators * Changelog * Improve locators * Improve locator on heading * Change assertions to look for alert text * Change assertion to look for text * Update locators * Update locator * Update alternate elements * Specify first order amount * Update locator * Changelog * Increase reliability of checkout test * Update a few locators * Remove .slice() --------- Co-authored-by: Jon Lane <jon.lane@automattic.com>
This commit is contained in:
parent
8f5f3bbf87
commit
34acf8cbcb
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Additional improvements to e2e tests to improve reliability
|
|
@ -70,20 +70,20 @@ const wcPages = [
|
|||
{
|
||||
name: 'Categories',
|
||||
heading: 'Product categories',
|
||||
element: '.row-title',
|
||||
text: 'Uncategorized',
|
||||
element: '#submit',
|
||||
text: 'Add new category',
|
||||
},
|
||||
{
|
||||
name: 'Tags',
|
||||
heading: 'Product tags',
|
||||
element: '.no-items > td',
|
||||
text: 'No tags found',
|
||||
element: '#submit',
|
||||
text: 'Add new tag',
|
||||
},
|
||||
{
|
||||
name: 'Attributes',
|
||||
heading: 'Attributes',
|
||||
element: '.alternate > td',
|
||||
text: 'No attributes currently exist.',
|
||||
element: '#submit',
|
||||
text: 'Add attribute',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -138,14 +138,12 @@ test.describe( 'Update variations', () => {
|
|||
} );
|
||||
|
||||
await test.step( 'Click on the "Variations" tab.', async () => {
|
||||
await page.locator( 'a[href="#variable_product_options"]' ).click();
|
||||
await page.getByRole('link', { name: 'Variations' }).click();
|
||||
} );
|
||||
|
||||
await test.step( 'Expand all variations.', async () => {
|
||||
await page
|
||||
.locator(
|
||||
'#variable_product_options .toolbar-top a.expand_all'
|
||||
)
|
||||
.getByRole('link', { name: 'Expand' }).first()
|
||||
.click();
|
||||
} );
|
||||
|
||||
|
@ -231,14 +229,12 @@ test.describe( 'Update variations', () => {
|
|||
} );
|
||||
|
||||
await test.step( 'Click on the "Variations" tab.', async () => {
|
||||
await page.locator( 'a[href="#variable_product_options"]' ).click();
|
||||
await page.getByRole('link', { name: 'Variations' }).click();
|
||||
} );
|
||||
|
||||
await test.step( 'Expand all variations.', async () => {
|
||||
await page
|
||||
.locator(
|
||||
'#variable_product_options .toolbar-top a.expand_all'
|
||||
)
|
||||
.getByRole('link', { name: 'Expand' }).first()
|
||||
.click();
|
||||
} );
|
||||
|
||||
|
@ -344,7 +340,7 @@ test.describe( 'Update variations', () => {
|
|||
} );
|
||||
|
||||
await test.step( 'Click on the "Variations" tab.', async () => {
|
||||
await page.locator( 'a[href="#variable_product_options"]' ).click();
|
||||
await page.getByRole( 'link', { name: 'Variations' } ).click();
|
||||
} );
|
||||
|
||||
await test.step(
|
||||
|
@ -358,9 +354,7 @@ test.describe( 'Update variations', () => {
|
|||
|
||||
await test.step( 'Expand all variations.', async () => {
|
||||
await page
|
||||
.locator(
|
||||
'#variable_product_options .toolbar-top a.expand_all'
|
||||
)
|
||||
.getByRole('link', { name: 'Expand' }).first()
|
||||
.click();
|
||||
} );
|
||||
|
||||
|
@ -387,7 +381,7 @@ test.describe( 'Update variations', () => {
|
|||
} );
|
||||
|
||||
await test.step( 'Click on the "Variations" tab.', async () => {
|
||||
await page.locator( 'a[href="#variable_product_options"]' ).click();
|
||||
await page.getByRole( 'link', { name: 'Variations' } ).click();
|
||||
} );
|
||||
|
||||
await test.step(
|
||||
|
@ -418,14 +412,12 @@ test.describe( 'Update variations', () => {
|
|||
} );
|
||||
|
||||
await test.step( 'Click on the "Variations" tab.', async () => {
|
||||
await page.locator( 'a[href="#variable_product_options"]' ).click();
|
||||
await page.getByRole( 'link', { name: 'Variations' } ).click();
|
||||
} );
|
||||
|
||||
await test.step( 'Expand all variations', async () => {
|
||||
await page
|
||||
.locator(
|
||||
'#variable_product_options .toolbar-top a.expand_all'
|
||||
)
|
||||
.getByRole('link', { name: 'Expand' }).first()
|
||||
.click();
|
||||
} );
|
||||
|
||||
|
@ -485,14 +477,12 @@ test.describe( 'Update variations', () => {
|
|||
);
|
||||
|
||||
await test.step( 'Click "Save changes"', async () => {
|
||||
await page.locator( 'button.save-variation-changes' ).click();
|
||||
await page.getByRole('button', { name: 'Save changes' }).click();
|
||||
} );
|
||||
|
||||
await test.step( 'Expand all variations', async () => {
|
||||
await page
|
||||
.locator(
|
||||
'#variable_product_options .toolbar-top a.expand_all'
|
||||
)
|
||||
.getByRole('link', { name: 'Expand' }).first()
|
||||
.click();
|
||||
} );
|
||||
|
||||
|
@ -538,7 +528,7 @@ test.describe( 'Update variations', () => {
|
|||
} );
|
||||
|
||||
await test.step( 'Click on the "Variations" tab.', async () => {
|
||||
await page.locator( 'a[href="#variable_product_options"]' ).click();
|
||||
await page.getByRole( 'link', { name: 'Variations' } ).click();
|
||||
} );
|
||||
|
||||
await test.step( 'Wait for block overlay to disappear.', async () => {
|
||||
|
@ -602,7 +592,7 @@ test.describe( 'Update variations', () => {
|
|||
} );
|
||||
|
||||
await test.step( 'Click on the "Variations" tab.', async () => {
|
||||
await page.locator( 'a[href="#variable_product_options"]' ).click();
|
||||
await page.getByRole( 'link', { name: 'Variations' } ).click();
|
||||
} );
|
||||
|
||||
await test.step( 'Click "Remove" on a variation', async () => {
|
||||
|
|
|
@ -167,7 +167,7 @@ test.describe( 'Cart Calculate Shipping', () => {
|
|||
await page.locator( 'text=Local pickup' ).click();
|
||||
|
||||
// Verify updated shipping costs
|
||||
await expect( page.locator( '.order-total .amount' ) ).toContainText(
|
||||
await expect( page.locator( '.order-total .amount' ).first() ).toContainText(
|
||||
`$${ firstProductPrice }`
|
||||
);
|
||||
} );
|
||||
|
|
|
@ -172,8 +172,6 @@ test.describe( 'Shopper Checkout Login Account', () => {
|
|||
// check my account page
|
||||
await page.goto( '/my-account/' );
|
||||
await expect( page.url() ).toContain( 'my-account/' );
|
||||
await expect( page.locator( 'h1.entry-title' ) ).toContainText(
|
||||
'My account'
|
||||
);
|
||||
await expect( page.getByRole( 'heading', { name: 'My account' } ) ).toBeVisible();
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -68,13 +68,6 @@ test.describe( 'Checkout page', () => {
|
|||
await api.post( `shipping/zones/${ shippingZoneId }/methods`, {
|
||||
method_id: 'free_shipping',
|
||||
} );
|
||||
// enable bank transfers and COD for payment
|
||||
await api.put( 'payment_gateways/bacs', {
|
||||
enabled: true,
|
||||
} );
|
||||
await api.put( 'payment_gateways/cod', {
|
||||
enabled: true,
|
||||
} );
|
||||
} );
|
||||
|
||||
test.afterAll( async ( { baseURL } ) => {
|
||||
|
@ -105,9 +98,23 @@ test.describe( 'Checkout page', () => {
|
|||
}
|
||||
} );
|
||||
|
||||
test.beforeEach( async ( { context } ) => {
|
||||
test.beforeEach( async ( { context, baseURL } ) => {
|
||||
// Shopping cart is very sensitive to cookies, so be explicit
|
||||
await context.clearCookies();
|
||||
const api = new wcApi( {
|
||||
url: baseURL,
|
||||
consumerKey: process.env.CONSUMER_KEY,
|
||||
consumerSecret: process.env.CONSUMER_SECRET,
|
||||
version: 'wc/v3',
|
||||
} );
|
||||
// enable bank transfers and COD for payment
|
||||
await api.put( 'payment_gateways/bacs', {
|
||||
enabled: true,
|
||||
} );
|
||||
await api.put( 'payment_gateways/cod', {
|
||||
enabled: true,
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
test( 'should display cart items in order review', async ( { page } ) => {
|
||||
|
@ -122,8 +129,10 @@ test.describe( 'Checkout page', () => {
|
|||
await expect( page.locator( 'strong.product-quantity' ) ).toContainText(
|
||||
'1'
|
||||
);
|
||||
await expect( page.locator( 'td.product-total' ) ).toContainText(
|
||||
singleProductPrice
|
||||
let totalPrice = await page.getByRole( 'row', { name: 'Total' } ).last().locator( 'td' ).textContent();
|
||||
totalPrice = Number( totalPrice.replace( /[^\d.-]/g, '' ) );
|
||||
await expect( totalPrice ).toBeGreaterThanOrEqual(
|
||||
Number( singleProductPrice )
|
||||
);
|
||||
} );
|
||||
|
||||
|
@ -140,8 +149,10 @@ test.describe( 'Checkout page', () => {
|
|||
await expect( page.locator( 'strong.product-quantity' ) ).toContainText(
|
||||
'2'
|
||||
);
|
||||
await expect( page.locator( 'td.product-total' ) ).toContainText(
|
||||
twoProductPrice
|
||||
let totalPrice = await page.getByRole( 'row', { name: 'Total' } ).last().locator( 'td' ).textContent();
|
||||
totalPrice = Number( totalPrice.replace( /[^\d.-]/g, '' ) );
|
||||
await expect( totalPrice ).toBeGreaterThanOrEqual(
|
||||
Number( twoProductPrice )
|
||||
);
|
||||
|
||||
// check the payment methods
|
||||
|
@ -160,8 +171,10 @@ test.describe( 'Checkout page', () => {
|
|||
await expect( page.locator( 'strong.product-quantity' ) ).toContainText(
|
||||
'3'
|
||||
);
|
||||
await expect( page.locator( 'td.product-total' ) ).toContainText(
|
||||
threeProductPrice
|
||||
let totalPrice = await page.getByRole( 'row', { name: 'Total' } ).last().locator( 'td' ).textContent();
|
||||
totalPrice = Number( totalPrice.replace( /[^\d.-]/g, '' ) );
|
||||
await expect( totalPrice ).toBeGreaterThanOrEqual(
|
||||
Number( threeProductPrice )
|
||||
);
|
||||
|
||||
// asserting that you can fill in the billing details
|
||||
|
@ -227,8 +240,10 @@ test.describe( 'Checkout page', () => {
|
|||
await expect( page.locator( 'strong.product-quantity' ) ).toContainText(
|
||||
'2'
|
||||
);
|
||||
await expect( page.locator( 'td.product-total' ) ).toContainText(
|
||||
twoProductPrice
|
||||
let totalPrice = await page.getByRole( 'row', { name: 'Total' } ).last().locator( 'td' ).textContent();
|
||||
totalPrice = Number( totalPrice.replace( /[^\d.-]/g, '' ) );
|
||||
await expect( totalPrice ).toBeGreaterThanOrEqual(
|
||||
Number( twoProductPrice )
|
||||
);
|
||||
|
||||
await page.locator( '#ship-to-different-address' ).click();
|
||||
|
@ -255,8 +270,10 @@ test.describe( 'Checkout page', () => {
|
|||
await expect( page.locator( 'strong.product-quantity' ) ).toContainText(
|
||||
'2'
|
||||
);
|
||||
await expect( page.locator( 'td.product-total' ) ).toContainText(
|
||||
twoProductPrice
|
||||
let totalPrice = await page.getByRole( 'row', { name: 'Total' } ).last().locator( 'td' ).textContent();
|
||||
totalPrice = Number( totalPrice.replace( /[^\d.-]/g, '' ) );
|
||||
await expect( totalPrice ).toBeGreaterThanOrEqual(
|
||||
Number( twoProductPrice )
|
||||
);
|
||||
|
||||
await page.locator( '#billing_first_name' ).fill( 'Lisa' );
|
||||
|
@ -364,8 +381,10 @@ test.describe( 'Checkout page', () => {
|
|||
await expect( page.locator( 'strong.product-quantity' ) ).toContainText(
|
||||
'2'
|
||||
);
|
||||
await expect( page.locator( 'td.product-total' ) ).toContainText(
|
||||
twoProductPrice
|
||||
let totalPrice = await page.getByRole( 'row', { name: 'Total' } ).last().locator( 'td' ).textContent();
|
||||
totalPrice = Number( totalPrice.replace( /[^\d.-]/g, '' ) );
|
||||
await expect( totalPrice ).toBeGreaterThanOrEqual(
|
||||
Number( twoProductPrice )
|
||||
);
|
||||
|
||||
await page.locator( '#billing_first_name' ).fill( 'Homer' );
|
||||
|
|
Loading…
Reference in New Issue