Product Collection: add E2E tests to Editor filters - by tag and by stock status (#43548)
* Add test to check Product Collection filtering by tags * Set single product out of stock and unskip the test for stock status * Add changelog * Use more specific selector * Update variables holding products in products.sh to keep the same convention
This commit is contained in:
parent
89cb0f7cef
commit
2c628a2938
|
@ -15,20 +15,24 @@ wp wc product_cat update $hoodies_category_id --parent=$clothing_category_id --u
|
|||
|
||||
# This is a hacky work around to fix product gallery images not being imported
|
||||
# This sets up the product Hoodie to have product gallery images for e2e testing
|
||||
post_id=$(wp post list --post_type=product --field=ID --name="Hoodie" --format=ids)
|
||||
hoodie_product_id=$(wp post list --post_type=product --field=ID --name="Hoodie" --format=ids)
|
||||
image1=$(wp post list --post_type=attachment --field=ID --name="hoodie-with-logo-2.jpg" --format=ids)
|
||||
image2=$(wp post list --post_type=attachment --field=ID --name="hoodie-green-1.jpg" --format=ids)
|
||||
image3=$(wp post list --post_type=attachment --field=ID --name="hoodie-2.jpg" --format=ids)
|
||||
wp post meta update $post_id _product_image_gallery "$image1,$image2,$image3"
|
||||
wp post meta update $hoodie_product_id _product_image_gallery "$image1,$image2,$image3"
|
||||
|
||||
# Create a tag, so we can add tests for tag-related blocks and templates.
|
||||
tag_id=$(wp wc product_tag create --name="Recommended" --slug="recommended" --description="Curated products selected by our experts" --porcelain --user=1)
|
||||
wp wc product update $post_id --tags="[ { \"id\": $tag_id } ]" --user=1
|
||||
wp wc product update $hoodie_product_id --tags="[ { \"id\": $tag_id } ]" --user=1
|
||||
|
||||
# This is a non-hacky work around to set up the cross sells product.
|
||||
product_id=$(wp post list --post_type=product --field=ID --name="Cap" --format=ids)
|
||||
crossell_id=$(wp post list --post_type=product --field=ID --name="Beanie" --format=ids)
|
||||
wp post meta update $crossell_id _crosssell_ids "$product_id"
|
||||
cap_product_id=$(wp post list --post_type=product --field=ID --name="Cap" --format=ids)
|
||||
beanie_product_id=$(wp post list --post_type=product --field=ID --name="Beanie" --format=ids)
|
||||
wp post meta update $beanie_product_id _crosssell_ids "$cap_product_id"
|
||||
|
||||
# Set a product out of stock
|
||||
tshirt_with_logo_product_id=$(wp post list --post_type=product --field=ID --name="T-Shirt with Logo" --format=ids)
|
||||
wp wc product update $tshirt_with_logo_product_id --in_stock=false --user=1
|
||||
|
||||
# Enable attribute archives.
|
||||
attribute_ids=$(wp wc product_attribute list --fields=id --format=ids --user=1)
|
||||
|
|
|
@ -186,6 +186,20 @@ test.describe( 'Product Collection', () => {
|
|||
);
|
||||
} );
|
||||
|
||||
test( 'Products can be filtered based on tags.', async ( {
|
||||
pageObject,
|
||||
} ) => {
|
||||
const filterName = 'Product tags';
|
||||
await pageObject.addFilter( 'Show Taxonomies' );
|
||||
await pageObject.setFilterComboboxValue( filterName, [
|
||||
'Recommended',
|
||||
] );
|
||||
await expect( pageObject.productTitles ).toHaveText( [ 'Hoodie' ] );
|
||||
|
||||
await pageObject.publishAndGoToFrontend();
|
||||
await expect( pageObject.productTitles ).toHaveText( [ 'Hoodie' ] );
|
||||
} );
|
||||
|
||||
test( 'Products can be filtered based on product attributes like color, size etc.', async ( {
|
||||
pageObject,
|
||||
} ) => {
|
||||
|
@ -203,20 +217,22 @@ test.describe( 'Product Collection', () => {
|
|||
await expect( pageObject.products ).toHaveCount( 1 );
|
||||
} );
|
||||
|
||||
// TODO There are no products with stock status 'Out of stock' in test data.
|
||||
// eslint-disable-next-line playwright/no-skipped-test
|
||||
test.skip( 'Products can be filtered based on stock status (in stock, out of stock, or backorder).', async ( {
|
||||
test( 'Products can be filtered based on stock status (in stock, out of stock, or backorder).', async ( {
|
||||
pageObject,
|
||||
} ) => {
|
||||
await pageObject.setFilterComboboxValue( 'Stock status', [
|
||||
'Out of stock',
|
||||
] );
|
||||
|
||||
await expect( pageObject.products ).toHaveCount( 1 );
|
||||
await expect( pageObject.productTitles ).toHaveText( [
|
||||
'T-Shirt with Logo',
|
||||
] );
|
||||
|
||||
await pageObject.publishAndGoToFrontend();
|
||||
|
||||
await expect( pageObject.products ).toHaveCount( 1 );
|
||||
await expect( pageObject.productTitles ).toHaveText( [
|
||||
'T-Shirt with Logo',
|
||||
] );
|
||||
} );
|
||||
|
||||
test.describe( 'Inherit query from template', () => {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: dev
|
||||
|
||||
Product Collection: Add E2E tests for Editor filters: by tag and by stock status
|
Loading…
Reference in New Issue