Blocks E2E: Clean up eslint comments after rules update (#47875)
This commit is contained in:
parent
b67ffdecad
commit
df7bb8d7b9
|
@ -11,8 +11,12 @@ import { REGULAR_PRICED_PRODUCT_NAME } from './constants';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
wcSettings: {
|
||||||
wcSettings: { storePages: any };
|
storePages: {
|
||||||
|
terms: { permalink: string };
|
||||||
|
privacy: { permalink: string };
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const blockData: BlockData = {
|
const blockData: BlockData = {
|
||||||
|
@ -99,6 +103,7 @@ test.describe( 'Merchant → Checkout', () => {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test( 'Merchant can see T&S and Privacy Policy links without checkbox', async ( {
|
test( 'Merchant can see T&S and Privacy Policy links without checkbox', async ( {
|
||||||
|
page,
|
||||||
frontendUtils,
|
frontendUtils,
|
||||||
checkoutPageObject,
|
checkoutPageObject,
|
||||||
} ) => {
|
} ) => {
|
||||||
|
@ -120,15 +125,16 @@ test.describe( 'Merchant → Checkout', () => {
|
||||||
.getByText( 'Privacy Policy' )
|
.getByText( 'Privacy Policy' )
|
||||||
.first();
|
.first();
|
||||||
|
|
||||||
const { termsPageUrl, privacyPageUrl } =
|
const { termsPageUrl, privacyPageUrl } = await page.evaluate(
|
||||||
await frontendUtils.page.evaluate( () => {
|
() => {
|
||||||
|
const { terms, privacy } = window.wcSettings.storePages;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
termsPageUrl:
|
termsPageUrl: terms.permalink,
|
||||||
window.wcSettings.storePages.terms.permalink,
|
privacyPageUrl: privacy.permalink,
|
||||||
privacyPageUrl:
|
|
||||||
window.wcSettings.storePages.privacy.permalink,
|
|
||||||
};
|
};
|
||||||
} );
|
}
|
||||||
|
);
|
||||||
await expect( termsAndConditions ).toHaveAttribute(
|
await expect( termsAndConditions ).toHaveAttribute(
|
||||||
'href',
|
'href',
|
||||||
termsPageUrl
|
termsPageUrl
|
||||||
|
|
|
@ -41,15 +41,11 @@ test.describe( `${ blockData.name } Block`, () => {
|
||||||
.locator( '[data-product_id]' )
|
.locator( '[data-product_id]' )
|
||||||
.getAttribute( 'data-product_id' );
|
.getAttribute( 'data-product_id' );
|
||||||
|
|
||||||
const productName = await page
|
const productNameLocator = page.locator( `li.post-${ productId } h3` );
|
||||||
.locator( `li.post-${ productId } h3` )
|
await expect( productNameLocator ).not.toBeEmpty();
|
||||||
.textContent();
|
|
||||||
|
|
||||||
// We want to fail the test if the product name is not found.
|
const productName =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
( await productNameLocator.textContent() ) as string;
|
||||||
if ( ! productName ) {
|
|
||||||
return test.fail( ! productName, 'Product name was not found' );
|
|
||||||
}
|
|
||||||
|
|
||||||
await block.locator( 'loading' ).waitFor( {
|
await block.locator( 'loading' ).waitFor( {
|
||||||
state: 'detached',
|
state: 'detached',
|
||||||
|
@ -82,15 +78,11 @@ test.describe( `${ blockData.name } Block`, () => {
|
||||||
|
|
||||||
const productId = await button.getAttribute( 'data-product_id' );
|
const productId = await button.getAttribute( 'data-product_id' );
|
||||||
|
|
||||||
const productName = await page
|
const productNameLocator = page.locator( `li.post-${ productId } h3` );
|
||||||
.locator( `li.post-${ productId } h3` )
|
await expect( productNameLocator ).not.toBeEmpty();
|
||||||
.textContent();
|
|
||||||
|
|
||||||
// We want to fail the test if the product name is not found.
|
const productName =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
( await productNameLocator.textContent() ) as string;
|
||||||
if ( ! productName ) {
|
|
||||||
return test.fail( ! productName, 'Product name was not found' );
|
|
||||||
}
|
|
||||||
|
|
||||||
await block.click();
|
await block.click();
|
||||||
|
|
||||||
|
|
|
@ -47,15 +47,11 @@ test.describe( `${ blockData.name } Block`, () => {
|
||||||
.locator( '[data-product_id]' )
|
.locator( '[data-product_id]' )
|
||||||
.getAttribute( 'data-product_id' );
|
.getAttribute( 'data-product_id' );
|
||||||
|
|
||||||
const productName = await page
|
const productNameLocator = page.locator( `li.post-${ productId } h3` );
|
||||||
.locator( `li.post-${ productId } h3` )
|
await expect( productNameLocator ).not.toBeEmpty();
|
||||||
.textContent();
|
|
||||||
|
|
||||||
// We want to fail the test if the product name is not found.
|
const productName =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
( await productNameLocator.textContent() ) as string;
|
||||||
if ( ! productName ) {
|
|
||||||
return test.fail( ! productName, 'Product name was not found' );
|
|
||||||
}
|
|
||||||
|
|
||||||
await block.locator( 'loading' ).waitFor( {
|
await block.locator( 'loading' ).waitFor( {
|
||||||
state: 'detached',
|
state: 'detached',
|
||||||
|
|
|
@ -183,10 +183,8 @@ test.describe( `${ blockData.name }`, () => {
|
||||||
'woocommerce/product-image-gallery'
|
'woocommerce/product-image-gallery'
|
||||||
);
|
);
|
||||||
const clientId =
|
const clientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
||||||
const parentClientId =
|
const parentClientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
||||||
|
|
||||||
await editor.selectBlocks( parentBlock );
|
await editor.selectBlocks( parentBlock );
|
||||||
|
@ -255,10 +253,8 @@ test.describe( `${ blockData.name }`, () => {
|
||||||
'woocommerce/product-image-gallery'
|
'woocommerce/product-image-gallery'
|
||||||
);
|
);
|
||||||
const clientId =
|
const clientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
||||||
const parentClientId =
|
const parentClientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
||||||
|
|
||||||
await editor.selectBlocks( parentBlock );
|
await editor.selectBlocks( parentBlock );
|
||||||
|
@ -327,10 +323,8 @@ test.describe( `${ blockData.name }`, () => {
|
||||||
'woocommerce/product-image-gallery'
|
'woocommerce/product-image-gallery'
|
||||||
);
|
);
|
||||||
const clientId =
|
const clientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
||||||
const parentClientId =
|
const parentClientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
||||||
|
|
||||||
await editor.selectBlocks( parentBlock );
|
await editor.selectBlocks( parentBlock );
|
||||||
|
@ -382,10 +376,8 @@ test.describe( `${ blockData.name }`, () => {
|
||||||
'woocommerce/product-image-gallery'
|
'woocommerce/product-image-gallery'
|
||||||
);
|
);
|
||||||
const clientId =
|
const clientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
||||||
const parentClientId =
|
const parentClientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
||||||
|
|
||||||
await editor.selectBlocks( parentBlock );
|
await editor.selectBlocks( parentBlock );
|
||||||
|
@ -434,10 +426,8 @@ test.describe( `${ blockData.name }`, () => {
|
||||||
'woocommerce/product-image-gallery'
|
'woocommerce/product-image-gallery'
|
||||||
);
|
);
|
||||||
const clientId =
|
const clientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
||||||
const parentClientId =
|
const parentClientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
||||||
|
|
||||||
await editor.selectBlocks( parentBlock );
|
await editor.selectBlocks( parentBlock );
|
||||||
|
|
|
@ -160,10 +160,8 @@ test.describe( `${ blockData.name }`, () => {
|
||||||
'woocommerce/product-image-gallery'
|
'woocommerce/product-image-gallery'
|
||||||
);
|
);
|
||||||
const clientId =
|
const clientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
||||||
const parentClientId =
|
const parentClientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
||||||
|
|
||||||
await editor.selectBlocks( parentBlock );
|
await editor.selectBlocks( parentBlock );
|
||||||
|
@ -239,10 +237,8 @@ test.describe( `${ blockData.name }`, () => {
|
||||||
'woocommerce/product-image-gallery'
|
'woocommerce/product-image-gallery'
|
||||||
);
|
);
|
||||||
const clientId =
|
const clientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
||||||
const parentClientId =
|
const parentClientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
||||||
|
|
||||||
await editor.selectBlocks( parentBlock );
|
await editor.selectBlocks( parentBlock );
|
||||||
|
@ -319,10 +315,8 @@ test.describe( `${ blockData.name }`, () => {
|
||||||
'woocommerce/product-image-gallery'
|
'woocommerce/product-image-gallery'
|
||||||
);
|
);
|
||||||
const clientId =
|
const clientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
|
||||||
const parentClientId =
|
const parentClientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
||||||
|
|
||||||
await editor.selectBlocks( parentBlock );
|
await editor.selectBlocks( parentBlock );
|
||||||
|
|
|
@ -133,10 +133,8 @@ for ( const {
|
||||||
|
|
||||||
await editor.canvas.locator( 'body' ).click();
|
await editor.canvas.locator( 'body' ).click();
|
||||||
const block = await editor.getBlockByName( blockData.name );
|
const block = await editor.getBlockByName( blockData.name );
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
const clientId = ( await block.getAttribute( 'data-block' ) ) ?? '';
|
const clientId = ( await block.getAttribute( 'data-block' ) ) ?? '';
|
||||||
const parentClientId =
|
const parentClientId =
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
|
||||||
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
( await editor.getBlockRootClientId( clientId ) ) ?? '';
|
||||||
await editor.selectBlocks( block );
|
await editor.selectBlocks( block );
|
||||||
await editor.insertBlock(
|
await editor.insertBlock(
|
||||||
|
|
|
@ -90,7 +90,6 @@ test.describe( 'Compatibility Layer with Product Collection block', () => {
|
||||||
);
|
);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// eslint-disable-next-line playwright/valid-describe-callback
|
|
||||||
test.describe( 'Product Archive with Product Collection block', () => {
|
test.describe( 'Product Archive with Product Collection block', () => {
|
||||||
for ( const scenario of singleOccurranceScenarios ) {
|
for ( const scenario of singleOccurranceScenarios ) {
|
||||||
test( `${ scenario.title } is attached to the page`, async ( {
|
test( `${ scenario.title } is attached to the page`, async ( {
|
||||||
|
|
|
@ -8,15 +8,13 @@ test.describe( 'Shop page', () => {
|
||||||
admin,
|
admin,
|
||||||
page,
|
page,
|
||||||
} ) => {
|
} ) => {
|
||||||
// Get Shop page ID.
|
|
||||||
const cliOutput = await wpCLI( 'option get woocommerce_shop_page_id' );
|
const cliOutput = await wpCLI( 'option get woocommerce_shop_page_id' );
|
||||||
const numberMatch = cliOutput.stdout.match( /\d+/ );
|
const shopPageId = cliOutput.stdout.match( /\d+/ )?.pop();
|
||||||
// eslint-disable-next-line playwright/no-conditional-in-test
|
if ( ! shopPageId ) {
|
||||||
if ( numberMatch === null ) {
|
|
||||||
throw new Error( 'Shop page ID not found' );
|
throw new Error( 'Shop page ID not found' );
|
||||||
}
|
}
|
||||||
|
|
||||||
await admin.editPost( numberMatch[ 0 ] );
|
await admin.editPost( shopPageId );
|
||||||
|
|
||||||
await expect( page.getByText( 'Template' ) ).toBeHidden();
|
await expect( page.getByText( 'Template' ) ).toBeHidden();
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Clean up eslint comments after rules update in Blocks E2E tests.
|
Loading…
Reference in New Issue