This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor E2E price filter tests and update test scripts in global-setup
Here are the key changes: 1. Refactored the way the 'wp action-scheduler run' command is run in the 'global-setup.ts' script. Now, it correctly separates the wp command from the arguments passed to it. 2. Consolidated the 'price-filter-with-all-products.block_theme.side_effects.spec.ts' and 'price-filter-with-classic-template.block_theme.side_effects.spec.ts' tests into a single 'price-filter.block_theme.side_effects.spec.ts' file. The new file contains tests for both scenarios: with all products block and with PHP classic template. Also, updated the product locator function to distinguish between classic templates and products beta block. 3. Deleted the original 'price-filter-with-all-products.block_theme.side_effects.spec.ts' and 'price-filter-with-classic-template.block_theme.side_effects.spec.ts' test files as they are no longer needed. 4. Updated the 'price-filter.page.ts' file to remove the 'waitForLoadState' method call after inserting the block in the editor and added logic to handle locating products in different scenarios (classic template vs products beta block).
- Loading branch information
1 parent
8c3efcb
commit de415ce
Showing
5 changed files
with
117 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
...e2e-pw/tests/price-filter/price-filter-with-all-products.block_theme.side_effects.spec.ts
This file was deleted.
Oops, something went wrong.
60 changes: 0 additions & 60 deletions
60
...pw/tests/price-filter/price-filter-with-classic-template.block_theme.side_effects.spec.ts
This file was deleted.
Oops, something went wrong.
103 changes: 103 additions & 0 deletions
103
tests/e2e-pw/tests/price-filter/price-filter.block_theme.side_effects.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { test as base, expect } from '@woocommerce/e2e-playwright-utils'; | ||
import { cli } from '@woocommerce/e2e-utils'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import PriceFilterPage, { blockData } from './price-filter.page'; | ||
|
||
const test = base.extend< { pageObject: PriceFilterPage } >( { | ||
pageObject: async ( { page, admin, editor, templateApiUtils }, use ) => { | ||
const pageObject = new PriceFilterPage( { | ||
page, | ||
editor, | ||
admin, | ||
templateApiUtils, | ||
} ); | ||
await use( pageObject ); | ||
}, | ||
} ); | ||
/** | ||
* It's taking lot of time to load Product catalog template page on slow machines. | ||
* Therefore, increasing the timeout to 3 minutes. | ||
*/ | ||
test.setTimeout( 3 * 60 * 1000 ); | ||
|
||
test.describe( `${ blockData.name } Block - with All products Block`, () => { | ||
test( 'should show all products', async ( { pageObject } ) => { | ||
await pageObject.addPriceFilterBlockToNewPostAndGoToFrontend(); | ||
|
||
const firstProductImage = await pageObject.locateFirstImage(); | ||
await expect( firstProductImage ).not.toHaveAttribute( | ||
'src', | ||
blockData.placeholderUrl | ||
); | ||
|
||
const allProductsBlock = await pageObject.locateAllProductsBlock(); | ||
const products = await allProductsBlock.getByRole( 'listitem' ).all(); | ||
expect( products ).toHaveLength( 9 ); | ||
} ); | ||
|
||
test( 'should show only products that match the filter', async ( { | ||
pageObject, | ||
} ) => { | ||
await pageObject.addPriceFilterBlockToNewPostAndGoToFrontend(); | ||
await pageObject.setPriceFilterRange( 2, 3 ); | ||
|
||
const firstProductImage = await pageObject.locateFirstImage(); | ||
await expect( firstProductImage ).not.toHaveAttribute( | ||
'src', | ||
blockData.placeholderUrl | ||
); | ||
|
||
const allProductsBlock = await pageObject.locateAllProductsBlock(); | ||
const products = await allProductsBlock.getByRole( 'listitem' ).all(); | ||
expect( products ).toHaveLength( 1 ); | ||
} ); | ||
} ); | ||
|
||
test.describe( `${ blockData.name } Block - with PHP classic template`, () => { | ||
test.beforeAll( async () => { | ||
await cli( | ||
'npm run wp-env run tests-cli -- wp option update wc_blocks_use_blockified_product_grid_block_as_template false' | ||
); | ||
} ); | ||
|
||
test.beforeEach( async ( { pageObject } ) => { | ||
await pageObject.revertArchiveProductTemplate(); | ||
} ); | ||
|
||
test.afterEach( async ( { pageObject } ) => { | ||
await pageObject.revertArchiveProductTemplate(); | ||
} ); | ||
|
||
test( 'should show all products', async ( { pageObject } ) => { | ||
await pageObject.addPriceFilterBlockToProductCatalogAndGoToShop(); | ||
|
||
const products = await pageObject.locateAllProducts( { | ||
isClassicTemplate: true, | ||
} ); | ||
expect( products ).toHaveCount( 16 ); | ||
} ); | ||
|
||
test( 'should show only products that match the filter', async ( { | ||
pageObject, | ||
} ) => { | ||
await pageObject.addPriceFilterBlockToProductCatalogAndGoToShop(); | ||
await pageObject.setPriceFilterRange( 2, 3 ); | ||
|
||
const products = await pageObject.locateAllProducts( { | ||
isClassicTemplate: true, | ||
} ); | ||
expect( products ).toHaveCount( 1 ); | ||
} ); | ||
|
||
test.afterAll( async () => { | ||
await cli( | ||
'npm run wp-env run tests-cli -- wp option update wc_blocks_use_blockified_product_grid_block_as_template true' | ||
); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters