Add e2e tests for password-protected Single Product block template (#44304)

* Add e2e tests for password-protected Single Product block template

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Fix tests

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Albert Juhé Lluveras 2024-02-05 10:47:18 +01:00 committed by GitHub
parent 497d4b8a25
commit 097bd5c8f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 2 deletions

View File

@ -34,6 +34,11 @@ wp post meta update $beanie_product_id _crosssell_ids "$cap_product_id"
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
# Make a product visible only with password.
sunglasses_product_id=$(wp post list --post_type=product --field=ID --name="Sunglasses" --format=ids)
wp post update $sunglasses_product_id --post_password="password" --user=1
# Enable attribute archives.
attribute_ids=$(wp wc product_attribute list --fields=id --format=ids --user=1)
if [ -n "$attribute_ids" ]; then

View File

@ -78,8 +78,12 @@ test.describe( 'Product Collection', () => {
await pageObject.publishAndGoToFrontend();
const frontendTitles =
await pageObject.productTitles.allInnerTexts();
expect(
await pageObject.productTitles.allInnerTexts()
frontendTitles.map( ( title ) =>
title.replace( 'Protected: ', '' )
)
).toStrictEqual( expectedTitles );
} );
@ -181,8 +185,16 @@ test.describe( 'Product Collection', () => {
);
await pageObject.publishAndGoToFrontend();
const frontendAccessoriesProductNames = [
'Beanie',
'Beanie with Logo',
'Belt',
'Cap',
'Protected: Sunglasses',
];
await expect( pageObject.productTitles ).toHaveText(
accessoriesProductNames
frontendAccessoriesProductNames
);
} );

View File

@ -0,0 +1,18 @@
/**
* External dependencies
*/
import { test, expect } from '@woocommerce/e2e-playwright-utils';
// Sunglasses are defined as requering password in /bin/scripts/products.sh.
const productWithPasswordPermalink = '/product/sunglasses/';
test.describe( 'Single Product template', async () => {
test( 'shows password form in products protected with password', async ( {
page,
} ) => {
await page.goto( productWithPasswordPermalink );
await expect(
page.getByText( 'This content is password protected.' ).first()
).toBeVisible();
} );
} );

View File

@ -0,0 +1,4 @@
Significance: patch
Type: add
Comment: Add e2e tests for password-protected Single Product block template