Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugins/woocommerce-blocks/tests/e2e/bin/scripts/products.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**

Check failure on line 1 in plugins/woocommerce-blocks/tests/e2e/tests/product-collection/product-collection.block_theme.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright E2E tests - Normal

[blockTheme] › product-collection/product-collection.block_theme.spec.ts:691:3 › Product Collection › With other blocks › In Single Product block

2) [blockTheme] › product-collection/product-collection.block_theme.spec.ts:691:3 › Product Collection › With other blocks › In Single Product block Test timeout of 90000ms exceeded.

Check failure on line 1 in plugins/woocommerce-blocks/tests/e2e/tests/product-collection/product-collection.block_theme.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright E2E tests - Normal

[blockTheme] › product-collection/product-collection.block_theme.spec.ts:691:3 › Product Collection › With other blocks › In Single Product block

2) [blockTheme] › product-collection/product-collection.block_theme.spec.ts:691:3 › Product Collection › With other blocks › In Single Product block Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Test timeout of 90000ms exceeded.
* External dependencies
*/
import { test as base, expect } from '@woocommerce/e2e-playwright-utils';
Expand Down Expand Up @@ -78,8 +78,12 @@

await pageObject.publishAndGoToFrontend();

const frontendTitles =
await pageObject.productTitles.allInnerTexts();
expect(
await pageObject.productTitles.allInnerTexts()
frontendTitles.map( ( title ) =>
title.replace( 'Protected: ', '' )
)
).toStrictEqual( expectedTitles );
} );

Expand Down Expand Up @@ -108,7 +112,7 @@
await pageObject.productImages.filter( {
hasText: 'Product on sale',
} )
).toHaveCount( await pageObject.productImages.count() );

Check failure on line 115 in plugins/woocommerce-blocks/tests/e2e/tests/product-collection/product-collection.block_theme.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright E2E tests - Normal

[blockTheme] › product-collection/product-collection.block_theme.spec.ts:91:3 › Product Collection › Product Collection Sidebar Settings › Products can be filtered based on "on sale" status.

1) [blockTheme] › product-collection/product-collection.block_theme.spec.ts:91:3 › Product Collection › Product Collection Sidebar Settings › Products can be filtered based on "on sale" status. Error: Timed out 20000ms waiting for expect(received).toHaveCount(expected) // deep equality Expected: 4 Received: 6 Call log: - expect.toHaveCount with timeout 20000ms - waiting for locator('[data-type="woocommerce/product-image"]').locator('visible=true').filter({ hasText: 'Product on sale' }) - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" - locator resolved to 6 elements - unexpected value "6" 113 | hasText: 'Product on sale', 114 | } ) > 115 | ).toHaveCount( await pageObject.productImages.count() ); | ^ 116 | 117 | await pageObject.publishAndGoToFrontend(); 118 | await expect( pageObject.products ).toHaveCount( 6 ); at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce-blocks/tests/e2e/tests/product-collection/product-collection.block_theme.spec.ts:115:6

await pageObject.publishAndGoToFrontend();
await expect( pageObject.products ).toHaveCount( 6 );
Expand Down Expand Up @@ -181,8 +185,16 @@
);

await pageObject.publishAndGoToFrontend();

const frontendAccessoriesProductNames = [
'Beanie',
'Beanie with Logo',
'Belt',
'Cap',
'Protected: Sunglasses',
];
await expect( pageObject.productTitles ).toHaveText(
accessoriesProductNames
frontendAccessoriesProductNames
);
} );

Expand Down Expand Up @@ -688,7 +700,7 @@

// Prepare Single Product block
await editor.insertBlock( { name: 'woocommerce/single-product' } );
await page.waitForResponse(

Check failure on line 703 in plugins/woocommerce-blocks/tests/e2e/tests/product-collection/product-collection.block_theme.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright E2E tests - Normal

[blockTheme] › product-collection/product-collection.block_theme.spec.ts:691:3 › Product Collection › With other blocks › In Single Product block

2) [blockTheme] › product-collection/product-collection.block_theme.spec.ts:691:3 › Product Collection › With other blocks › In Single Product block Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: page.waitForResponse: Page closed 701 | // Prepare Single Product block 702 | await editor.insertBlock( { name: 'woocommerce/single-product' } ); > 703 | await page.waitForResponse( | ^ 704 | ( response ) => 705 | response.url().includes( 'wc/store/v1/products' ) && 706 | response.status() === 200 at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce-blocks/tests/e2e/tests/product-collection/product-collection.block_theme.spec.ts:703:15
( response ) =>
response.url().includes( 'wc/store/v1/products' ) &&
response.status() === 200
Expand All @@ -714,7 +726,7 @@
exact: true,
} )
.first()
.click();

Check failure on line 729 in plugins/woocommerce-blocks/tests/e2e/tests/product-collection/product-collection.block_theme.spec.ts

View workflow job for this annotation

GitHub Actions / Playwright E2E tests - Normal

[blockTheme] › product-collection/product-collection.block_theme.spec.ts:691:3 › Product Collection › With other blocks › In Single Product block

2) [blockTheme] › product-collection/product-collection.block_theme.spec.ts:691:3 › Product Collection › With other blocks › In Single Product block Error: locator.click: Page closed =========================== logs =========================== waiting for getByRole('option', { name: 'Product Collection (Beta)', exact: true }).first() ============================================================ 727 | } ) 728 | .first() > 729 | .click(); | ^ 730 | await pageObject.chooseCollectionInPost( 'featured' ); 731 | 732 | const featuredProducts = [ at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce-blocks/tests/e2e/tests/product-collection/product-collection.block_theme.spec.ts:729:6
await pageObject.chooseCollectionInPost( 'featured' );

const featuredProducts = [
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
} );
} );
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: add
Comment: Add e2e tests for password-protected Single Product block template