forked from woocommerce/woocommerce-blocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add e2e tests for attributes count (woocommerce#9500)
* Add e2e tests for attributes count * Add test with pricing filter and turn on debug to prevent cache * Prevent tests from passing if test page is not loaded * Use WP wrapper to call WC CLI * Refactor to use more of PW methods * Use existing active filters block post for testing * Move prepareAttributes function to global setup
- Loading branch information
1 parent
7007582
commit 2b71014
Showing
3 changed files
with
128 additions
and
15 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
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
75 changes: 75 additions & 0 deletions
75
tests/e2e-pw/tests/attributes-filter/filter-products-by-attributes-count.block_theme.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,75 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { test, expect } from '@woocommerce/e2e-playwright-utils'; | ||
|
||
test.describe( 'Filter by Attributes Block - with All products Block', () => { | ||
test( 'should show correct attrs count (color=blue|query_type_color=or)', async ( { | ||
page, | ||
} ) => { | ||
await page.goto( | ||
'/active-filters-block/?filter_color=blue&query_type_color=or' | ||
); | ||
await page.waitForLoadState( 'networkidle' ); | ||
|
||
// Check if the page has loaded successfully. | ||
await expect( page.getByText( 'Active Filters block' ) ).toBeVisible(); | ||
|
||
const expectedValues = [ '4', '0', '2', '2', '0' ]; | ||
|
||
await expect( | ||
page | ||
.locator( 'ul.wc-block-attribute-filter-list' ) | ||
.first() | ||
.locator( | ||
'> li:not([class^="is-loading"]) .wc-filter-element-label-list-count > span:not([class^="screen-reader"])' | ||
) | ||
).toHaveText( expectedValues ); | ||
} ); | ||
|
||
test( 'should show correct attrs count (color=blue,gray|query_type_color=or)', async ( { | ||
page, | ||
} ) => { | ||
await page.goto( | ||
'/active-filters-block/?filter_color=blue,gray&query_type_color=or' | ||
); | ||
await page.waitForLoadState( 'networkidle' ); | ||
|
||
// Check if the page has loaded successfully. | ||
await expect( page.getByText( 'Active Filters block' ) ).toBeVisible(); | ||
|
||
const expectedValues = [ '4', '3', '2', '2', '0' ]; | ||
|
||
await expect( | ||
page | ||
.locator( 'ul.wc-block-attribute-filter-list' ) | ||
.first() | ||
.locator( | ||
'> li:not([class^="is-loading"]) .wc-filter-element-label-list-count > span:not([class^="screen-reader"])' | ||
) | ||
).toHaveText( expectedValues ); | ||
} ); | ||
|
||
test( 'should show correct attrs count (color=blue|query_type_color=or|min_price=15|max_price=40)', async ( { | ||
page, | ||
} ) => { | ||
await page.goto( | ||
'/active-filters-block/?filter_color=blue&query_type_color=or&min_price=15&max_price=40' | ||
); | ||
await page.waitForLoadState( 'networkidle' ); | ||
|
||
// Check if the page has loaded successfully. | ||
await expect( page.getByText( 'Active Filters block' ) ).toBeVisible(); | ||
|
||
const expectedValues = [ '2', '0', '1', '1', '0' ]; | ||
|
||
await expect( | ||
page | ||
.locator( 'ul.wc-block-attribute-filter-list' ) | ||
.first() | ||
.locator( | ||
'> li:not([class^="is-loading"]) .wc-filter-element-label-list-count > span:not([class^="screen-reader"])' | ||
) | ||
).toHaveText( expectedValues ); | ||
} ); | ||
} ); |