[E2E] Stabilize Product Collection "on sale" tests (#44796)

This commit is contained in:
Bart Kalisz 2024-02-21 13:44:07 +01:00 committed by GitHub
parent 6b9e732ebf
commit 045df6f3e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 40 deletions

View File

@ -56,20 +56,20 @@ test.describe( 'Product Collection', () => {
pageObject,
} ) => {
await pageObject.setNumberOfColumns( 2 );
await expect(
await pageObject.productTemplate.getAttribute( 'class' )
).toContain( 'columns-2' );
await expect( pageObject.productTemplate ).toHaveClass(
/columns-2/
);
await pageObject.setNumberOfColumns( 4 );
await expect(
await pageObject.productTemplate.getAttribute( 'class' )
).toContain( 'columns-4' );
await expect( pageObject.productTemplate ).toHaveClass(
/columns-4/
);
await pageObject.publishAndGoToFrontend();
await expect(
await pageObject.productTemplate.getAttribute( 'class' )
).toContain( 'columns-4' );
await expect( pageObject.productTemplate ).toHaveClass(
/columns-4/
);
} );
test( 'Order By - sort products by title in descending order correctly', async ( {
@ -93,39 +93,28 @@ test.describe( 'Product Collection', () => {
} );
// Products can be filtered based on 'on sale' status.
test( 'Products can be filtered based on "on sale" status.', async ( {
test( 'Products can be filtered based on "on sale" status', async ( {
pageObject,
} ) => {
// On each page we show 9 products.
await expect( pageObject.products ).toHaveCount( 9 );
// All products should not be on sale.
await expect(
await pageObject.productImages.filter( {
hasText: 'Product on sale',
} )
).not.toHaveCount( 9 );
const allProducts = pageObject.products;
const salePoducts = pageObject.products.filter( {
hasText: 'Product on sale',
} );
await expect( allProducts ).toHaveCount( 9 );
await expect( salePoducts ).toHaveCount( 6 );
await pageObject.setShowOnlyProductsOnSale( {
onSale: true,
} );
// In test data we have only 6 products on sale
await expect( pageObject.products ).toHaveCount( 6 );
// Expect all shown products to be on sale.
await expect(
await pageObject.productImages.filter( {
hasText: 'Product on sale',
} )
).toHaveCount( await pageObject.productImages.count() );
await expect( allProducts ).toHaveCount( 6 );
await expect( salePoducts ).toHaveCount( 6 );
await pageObject.publishAndGoToFrontend();
await expect( pageObject.products ).toHaveCount( 6 );
await expect(
await pageObject.productImages.filter( {
hasText: 'Product on sale',
} )
).toHaveCount( await pageObject.productImages.count() );
await expect( allProducts ).toHaveCount( 6 );
await expect( salePoducts ).toHaveCount( 6 );
} );
test( 'Products can be filtered based on selection in handpicked products option', async ( {
@ -449,18 +438,18 @@ test.describe( 'Product Collection', () => {
maxPageToShow: 2,
} );
await expect( await pageObject.products ).toHaveCount( 3 );
await expect( pageObject.products ).toHaveCount( 3 );
await pageObject.setDisplaySettings( {
itemsPerPage: 2,
offset: 0,
maxPageToShow: 2,
} );
await expect( await pageObject.products ).toHaveCount( 2 );
await expect( pageObject.products ).toHaveCount( 2 );
await pageObject.publishAndGoToFrontend();
await expect( await pageObject.products ).toHaveCount( 2 );
await expect( pageObject.products ).toHaveCount( 2 );
const paginationNumbers =
pageObject.pagination.locator( '.page-numbers' );
@ -959,13 +948,13 @@ test.describe( 'Product Collection', () => {
collection: 'productCatalog',
} );
await expect(
expect(
url.searchParams.has( 'productCollectionQueryContext[id]' )
).toBeTruthy();
// There shouldn't be collection in the query context
// Because Product Catalog isn't a collection
await expect(
expect(
url.searchParams.has(
'productCollectionQueryContext[collection]'
)
@ -982,8 +971,8 @@ test.describe( 'Product Collection', () => {
const collectionName = url.searchParams.get(
'productCollectionQueryContext[collection]'
);
await expect( collectionName ).toBeTruthy();
await expect( collectionName ).toBe(
expect( collectionName ).toBeTruthy();
expect( collectionName ).toBe(
'woocommerce/product-collection/on-sale'
);
} );

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Stabilize the 'Products can be filtered based on "on sale" status' E2E test.