diff --git a/plugins/woocommerce-blocks/tests/e2e/tests/single-product-template/single-product-template-protected-product.block_theme.side_effects.spec.ts b/plugins/woocommerce-blocks/tests/e2e/tests/single-product-template/single-product-template-protected-product.block_theme.side_effects.spec.ts deleted file mode 100644 index 84f67dc67ad..00000000000 --- a/plugins/woocommerce-blocks/tests/e2e/tests/single-product-template/single-product-template-protected-product.block_theme.side_effects.spec.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * External dependencies - */ -import { test, expect } from '@woocommerce/e2e-playwright-utils'; -import { cli } from '@woocommerce/e2e-utils'; - -const product = { - name: 'Protected Product', - slug: 'protected-product', - password: 'password', -}; - -test.describe( 'Single Product Template', () => { - let id: null | string = null; - test.beforeEach( async ( { admin, page } ) => { - await admin.visitAdminPage( `/post-new.php?post_type=product` ); - - const input = page.locator( '#title' ); - await input.fill( product.name ); - await page.getByRole( 'button', { name: 'Edit visibility' } ).click(); - - await page.locator( '#visibility-radio-password' ).click(); - await page.locator( '#post_password' ).fill( product.password ); - await page.waitForResponse( ( response ) => - response.url().includes( 'admin-ajax.php' ) - ); - await page.locator( '#publish.button-primary' ).click(); - await page.waitForSelector( - '#woocommerce-product-updated-message-view-product__link' - ); - const url = new URL( page.url() ); - const queryParams = new URLSearchParams( url.search ); - id = queryParams.get( 'post' ); - } ); - - test.afterAll( async () => { - await cli( - `npm run wp-env run tests-cli -- wp post delete ${ id } --force` - ); - } ); - - test.describe( `should render a password input when the product is protected `, () => - test( 'add product specific classes to the body', async ( { - page, - } ) => { - await page.goto( `/product/${ product.slug }` ); - const placeholder = page.getByText( - 'This content is password protected. To view it please enter your password below:' - ); - - await expect( placeholder ).toBeVisible(); - - await page.getByLabel( 'Password' ).fill( 'password' ); - - await page.getByRole( 'button', { name: 'Enter' } ).click(); - - await expect( placeholder ).toBeHidden(); - } ) ); -} ); diff --git a/plugins/woocommerce-blocks/tests/e2e/tests/single-product-template/single-product-template.block_theme.spec.ts b/plugins/woocommerce-blocks/tests/e2e/tests/single-product-template/single-product-template.block_theme.spec.ts index 074e2f78be4..20d6da84917 100644 --- a/plugins/woocommerce-blocks/tests/e2e/tests/single-product-template/single-product-template.block_theme.spec.ts +++ b/plugins/woocommerce-blocks/tests/e2e/tests/single-product-template/single-product-template.block_theme.spec.ts @@ -54,3 +54,20 @@ for ( const { classes, product, frontendPage } of products ) { } ); } ) ); } + +test( 'shows password form in products protected with password', async ( { + page, +} ) => { + // Sunglasses are defined as requiring password in /bin/scripts/products.sh. + await page.goto( '/product/sunglasses/' ); + await expect( + page.getByText( 'This content is password protected.' ).first() + ).toBeVisible(); + + // Verify after introducing the password, the page is visible. + await page.getByLabel( 'Password:' ).fill( 'password' ); + await page.getByRole( 'button', { name: 'Enter' } ).click(); + await expect( + page.getByRole( 'link', { name: 'Description' } ) + ).toBeVisible(); +} ); diff --git a/plugins/woocommerce-blocks/tests/e2e/tests/templates/single-product-template.block_theme.spec.ts b/plugins/woocommerce-blocks/tests/e2e/tests/templates/single-product-template.block_theme.spec.ts index c3fba7d44ce..bd4f1079bc5 100644 --- a/plugins/woocommerce-blocks/tests/e2e/tests/templates/single-product-template.block_theme.spec.ts +++ b/plugins/woocommerce-blocks/tests/e2e/tests/templates/single-product-template.block_theme.spec.ts @@ -8,23 +8,6 @@ test.describe( 'Single Product template', async () => { await requestUtils.deleteAllTemplates( 'wp_template' ); } ); - test( 'shows password form in products protected with password', async ( { - page, - } ) => { - // Sunglasses are defined as requiring password in /bin/scripts/products.sh. - await page.goto( '/product/sunglasses/' ); - await expect( - page.getByText( 'This content is password protected.' ).first() - ).toBeVisible(); - - // Verify after introducing the password, the page is visible. - await page.getByLabel( 'Password:' ).fill( 'password' ); - await page.getByRole( 'button', { name: 'Enter' } ).click(); - await expect( - page.getByRole( 'link', { name: 'Description' } ) - ).toBeVisible(); - } ); - test( 'loads the Single Product template for a specific product', async ( { admin, editorUtils, diff --git a/plugins/woocommerce/changelog/45752-tests-remove-password-protected-product b/plugins/woocommerce/changelog/45752-tests-remove-password-protected-product new file mode 100644 index 00000000000..1a5c35cfb86 --- /dev/null +++ b/plugins/woocommerce/changelog/45752-tests-remove-password-protected-product @@ -0,0 +1,4 @@ +Significance: patch +Type: dev +Comment: Consolidates/moves the redundant test for password protected product. +