-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Playwright tests for All Reviews, Reviews by Product and Reviews …
…by Category blocks (#42903) * Remove Reviews blocks Puppeteer tests * Minor code cleanup * Typos * Create publishAndVisitPost() editor util * Fix subcategories when importing products in Playwright and add reviews * Add Reviews blocks tests in Playwright * More typos * Add changefile(s) from automation for the following project(s): woocommerce-blocks * Create a 'reviews' object in data.ts so we can store reviews data in one single place * Update test so instead of creating a new post in each test, we go to the already-created post * Add source comments to reviews data to match it with the script --------- Co-authored-by: github-actions <github-actions@github.com>
- Loading branch information
Showing
19 changed files
with
239 additions
and
174 deletions.
There are no files selected for viewing
35 changes: 0 additions & 35 deletions
35
plugins/woocommerce-blocks/tests/e2e-jest/specs/backend/all-reviews.test.js
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
plugins/woocommerce-blocks/tests/e2e-jest/specs/backend/reviews-by-category.test.js
This file was deleted.
Oops, something went wrong.
62 changes: 0 additions & 62 deletions
62
plugins/woocommerce-blocks/tests/e2e-jest/specs/backend/reviews-by-product.test.js
This file was deleted.
Oops, something went wrong.
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
4 changes: 2 additions & 2 deletions
4
plugins/woocommerce-blocks/tests/e2e/bin/posts/reviews-by-category.html
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<!-- wp:woocommerce/reviews-by-category {"editMode":false,"categoryIds":[14]} --> | ||
<div class="wp-block-woocommerce-reviews-by-category wc-block-reviews-by-category has-image has-name has-date has-rating has-content has-product-name" data-image-type="reviewer" data-orderby="most-recent" data-reviews-on-page-load="10" data-reviews-on-load-more="10" data-show-load-more="true" data-show-orderby="true" data-category-ids="14,20,22,11,18,10"></div> | ||
<!-- wp:woocommerce/reviews-by-category {"editMode":false,"categoryIds":[20]} --> | ||
<div class="wp-block-woocommerce-reviews-by-category wc-block-reviews-by-category has-image has-name has-date has-rating has-content has-product-name" data-image-type="reviewer" data-orderby="most-recent" data-reviews-on-page-load="10" data-reviews-on-load-more="10" data-show-load-more="true" data-show-orderby="true" data-category-ids="20"></div> | ||
<!-- /wp:woocommerce/reviews-by-category --> |
4 changes: 2 additions & 2 deletions
4
plugins/woocommerce-blocks/tests/e2e/bin/posts/reviews-by-product.html
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<!-- wp:woocommerce/reviews-by-product {"editMode":false,"productId":10} --> | ||
<div class="wp-block-woocommerce-reviews-by-product wc-block-reviews-by-product has-image has-name has-date has-rating has-content" data-image-type="reviewer" data-orderby="most-recent" data-reviews-on-page-load="10" data-reviews-on-load-more="10" data-show-load-more="true" data-show-orderby="true" data-product-id="10"></div> | ||
<!-- wp:woocommerce/reviews-by-product {"editMode":false,"productId":7} --> | ||
<div class="wp-block-woocommerce-reviews-by-product wc-block-reviews-by-product has-image has-name has-date has-rating has-content" data-image-type="reviewer" data-orderby="most-recent" data-reviews-on-page-load="10" data-reviews-on-load-more="10" data-show-load-more="true" data-show-orderby="true" data-product-id="7"></div> | ||
<!-- /wp:woocommerce/reviews-by-product --> |
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
6 changes: 6 additions & 0 deletions
6
plugins/woocommerce-blocks/tests/e2e/bin/scripts/parallel/reviews.sh
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,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Add a couple of reviews to Hoodie. | ||
post_id=$(wp post list --post_type=product --field=ID --name="Hoodie" --format=ids) | ||
wp wc product_review create $post_id --name="Jane Smith" --email="customer@woocommerceblockse2etestsuite.com" --review="Nice album!" --rating=5 --user=1 | ||
wp wc product_review create $post_id --name="Jane Smith" --email="customer@woocommerceblockse2etestsuite.com" --review="Not bad." --rating=4 --user=1 |
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
55 changes: 55 additions & 0 deletions
55
plugins/woocommerce-blocks/tests/e2e/tests/all-reviews/all-reviews.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,55 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { expect, test } from '@woocommerce/e2e-playwright-utils'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { reviews } from '../../test-data/data/data'; | ||
|
||
const blockData = { | ||
name: 'woocommerce/all-reviews', | ||
selectors: { | ||
frontend: { | ||
firstReview: | ||
'.wc-block-review-list-item__item:first-child .wc-block-review-list-item__text p', | ||
}, | ||
}, | ||
}; | ||
|
||
test.describe( `${ blockData.name } Block`, () => { | ||
test( 'block can be inserted and it successfully renders a review in the editor and the frontend', async ( { | ||
admin, | ||
editor, | ||
page, | ||
editorUtils, | ||
} ) => { | ||
await admin.createNewPost(); | ||
await editor.insertBlock( { name: blockData.name } ); | ||
|
||
await expect( page.getByText( reviews[ 0 ].review ) ).toBeVisible(); | ||
|
||
await editorUtils.publishAndVisitPost(); | ||
|
||
await expect( page.getByText( reviews[ 0 ].review ) ).toBeVisible(); | ||
} ); | ||
|
||
test( 'can change sort order in the frontend', async ( { | ||
page, | ||
frontendUtils, | ||
} ) => { | ||
await page.goto( '/all-reviews-block/' ); | ||
|
||
const block = await frontendUtils.getBlockByName( blockData.name ); | ||
let firstReview; | ||
firstReview = block.locator( blockData.selectors.frontend.firstReview ); | ||
await expect( firstReview ).toHaveText( reviews[ 1 ].review ); | ||
|
||
const select = page.getByLabel( 'Order by' ); | ||
select.selectOption( 'Highest rating' ); | ||
|
||
firstReview = block.locator( blockData.selectors.frontend.firstReview ); | ||
await expect( firstReview ).toHaveText( reviews[ 0 ].review ); | ||
} ); | ||
} ); |
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
Oops, something went wrong.