Skip to content

Commit

Permalink
Fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdperez86 committed Mar 13, 2024
1 parent 6a7584a commit 4eec0bc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 32 deletions.
Expand Up @@ -50,18 +50,22 @@ test.describe( 'General tab', () => {
)
.last()
.fill( productData.summary );
await page
.locator(
'[id^="wp-block-woocommerce-product-regular-price-field"]'
)
.first()
.fill( productData.productPrice );
await page
.locator(
'[id^="wp-block-woocommerce-product-sale-price-field"]'
)
.first()
.fill( productData.salePrice );

await clickOnTab( 'Pricing', page );

const regularPrice = page
.locator( 'input[name="regular_price"]' )
.first();
await regularPrice.waitFor( { state: 'visible' } );
await regularPrice.click();
await regularPrice.fill( productData.productPrice );

const salePrice = page
.locator( 'input[name="sale_price"]' )
.first();
await salePrice.waitFor( { state: 'visible' } );
await salePrice.click();
await salePrice.fill( productData.salePrice );

await page
.locator( '.woocommerce-product-header__actions' )
Expand All @@ -86,6 +90,7 @@ test.describe( 'General tab', () => {
await expect( productId ).toBeDefined();
await expect( title ).toHaveText( productData.name );
} );

test( 'can not create a product with duplicated SKU', async ( {
page,
} ) => {
Expand All @@ -99,6 +104,8 @@ test.describe( 'General tab', () => {
'[data-template-block-id="basic-details"] .components-summary-control'
)
.fill( productData.summary );

await clickOnTab( 'Pricing', page );
await page
.locator(
'[id^="wp-block-woocommerce-product-regular-price-field"]'
Expand All @@ -117,6 +124,7 @@ test.describe( 'General tab', () => {

await expect( textContent ).toMatch( /Invalid or duplicated SKU./ );
} );

test( 'can a shopper add the simple product to the cart', async ( {
page,
} ) => {
Expand Down
Expand Up @@ -37,8 +37,6 @@ test( 'can update the general information of a product', async ( {
name: `Product ${ Date.now() }`,
description: `Updated description for the awesome product ${ Date.now() }`,
short_description: `Updated summary for the awesome product ${ Date.now() }`,
regularPrice: '100.05',
salePrice: '99.05',
};

const nameTextbox = page.getByLabel( 'Name' ).getByRole( 'textbox' );
Expand All @@ -48,22 +46,11 @@ test( 'can update the general information of a product', async ( {
const descriptionTextbox = page
.getByLabel( 'Block: Product description' )
.getByRole( 'textbox' );
const listPriceTextbox = page.getByRole( 'textbox', {
name: 'List price',
} );
const salePriceTextbox = page.getByRole( 'textbox', {
name: 'Sale price',
} );

await test.step( 'edit the product name', async () => {
await nameTextbox.fill( updatedProduct.name );
} );

await test.step( 'edit the product price', async () => {
await listPriceTextbox.fill( updatedProduct.regularPrice );
await salePriceTextbox.fill( updatedProduct.salePrice );
} );

await test.step( 'edit the product description and summary', async () => {
// Need to clear the textbox before filling it, otherwise the text will be appended.
await descriptionTextbox.clear();
Expand Down Expand Up @@ -91,12 +78,5 @@ test( 'can update the general information of a product', async ( {
await expect
.soft( descriptionTextbox )
.toHaveText( updatedProduct.description );

await expect
.soft( listPriceTextbox )
.toHaveValue( updatedProduct.regularPrice );
await expect
.soft( salePriceTextbox )
.toHaveValue( updatedProduct.salePrice );
} );
} );

0 comments on commit 4eec0bc

Please sign in to comment.