Blocks E2E: Clean up eslint comments after rules update (#47875)

This commit is contained in:
Bart Kalisz 2024-05-28 17:44:06 +02:00 committed by GitHub
parent b67ffdecad
commit df7bb8d7b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 34 additions and 57 deletions

View File

@ -11,8 +11,12 @@ import { REGULAR_PRICED_PRODUCT_NAME } from './constants';
declare global {
interface Window {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
wcSettings: { storePages: any };
wcSettings: {
storePages: {
terms: { permalink: string };
privacy: { permalink: string };
};
};
}
}
const blockData: BlockData = {
@ -99,6 +103,7 @@ test.describe( 'Merchant → Checkout', () => {
} );
test( 'Merchant can see T&S and Privacy Policy links without checkbox', async ( {
page,
frontendUtils,
checkoutPageObject,
} ) => {
@ -120,15 +125,16 @@ test.describe( 'Merchant → Checkout', () => {
.getByText( 'Privacy Policy' )
.first();
const { termsPageUrl, privacyPageUrl } =
await frontendUtils.page.evaluate( () => {
const { termsPageUrl, privacyPageUrl } = await page.evaluate(
() => {
const { terms, privacy } = window.wcSettings.storePages;
return {
termsPageUrl:
window.wcSettings.storePages.terms.permalink,
privacyPageUrl:
window.wcSettings.storePages.privacy.permalink,
termsPageUrl: terms.permalink,
privacyPageUrl: privacy.permalink,
};
} );
}
);
await expect( termsAndConditions ).toHaveAttribute(
'href',
termsPageUrl

View File

@ -41,15 +41,11 @@ test.describe( `${ blockData.name } Block`, () => {
.locator( '[data-product_id]' )
.getAttribute( 'data-product_id' );
const productName = await page
.locator( `li.post-${ productId } h3` )
.textContent();
const productNameLocator = page.locator( `li.post-${ productId } h3` );
await expect( productNameLocator ).not.toBeEmpty();
// We want to fail the test if the product name is not found.
// eslint-disable-next-line playwright/no-conditional-in-test
if ( ! productName ) {
return test.fail( ! productName, 'Product name was not found' );
}
const productName =
( await productNameLocator.textContent() ) as string;
await block.locator( 'loading' ).waitFor( {
state: 'detached',
@ -82,15 +78,11 @@ test.describe( `${ blockData.name } Block`, () => {
const productId = await button.getAttribute( 'data-product_id' );
const productName = await page
.locator( `li.post-${ productId } h3` )
.textContent();
const productNameLocator = page.locator( `li.post-${ productId } h3` );
await expect( productNameLocator ).not.toBeEmpty();
// We want to fail the test if the product name is not found.
// eslint-disable-next-line playwright/no-conditional-in-test
if ( ! productName ) {
return test.fail( ! productName, 'Product name was not found' );
}
const productName =
( await productNameLocator.textContent() ) as string;
await block.click();

View File

@ -47,15 +47,11 @@ test.describe( `${ blockData.name } Block`, () => {
.locator( '[data-product_id]' )
.getAttribute( 'data-product_id' );
const productName = await page
.locator( `li.post-${ productId } h3` )
.textContent();
const productNameLocator = page.locator( `li.post-${ productId } h3` );
await expect( productNameLocator ).not.toBeEmpty();
// We want to fail the test if the product name is not found.
// eslint-disable-next-line playwright/no-conditional-in-test
if ( ! productName ) {
return test.fail( ! productName, 'Product name was not found' );
}
const productName =
( await productNameLocator.textContent() ) as string;
await block.locator( 'loading' ).waitFor( {
state: 'detached',

View File

@ -183,10 +183,8 @@ test.describe( `${ blockData.name }`, () => {
'woocommerce/product-image-gallery'
);
const clientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
const parentClientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await editor.getBlockRootClientId( clientId ) ) ?? '';
await editor.selectBlocks( parentBlock );
@ -255,10 +253,8 @@ test.describe( `${ blockData.name }`, () => {
'woocommerce/product-image-gallery'
);
const clientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
const parentClientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await editor.getBlockRootClientId( clientId ) ) ?? '';
await editor.selectBlocks( parentBlock );
@ -327,10 +323,8 @@ test.describe( `${ blockData.name }`, () => {
'woocommerce/product-image-gallery'
);
const clientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
const parentClientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await editor.getBlockRootClientId( clientId ) ) ?? '';
await editor.selectBlocks( parentBlock );
@ -382,10 +376,8 @@ test.describe( `${ blockData.name }`, () => {
'woocommerce/product-image-gallery'
);
const clientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
const parentClientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await editor.getBlockRootClientId( clientId ) ) ?? '';
await editor.selectBlocks( parentBlock );
@ -434,10 +426,8 @@ test.describe( `${ blockData.name }`, () => {
'woocommerce/product-image-gallery'
);
const clientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
const parentClientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await editor.getBlockRootClientId( clientId ) ) ?? '';
await editor.selectBlocks( parentBlock );

View File

@ -160,10 +160,8 @@ test.describe( `${ blockData.name }`, () => {
'woocommerce/product-image-gallery'
);
const clientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
const parentClientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await editor.getBlockRootClientId( clientId ) ) ?? '';
await editor.selectBlocks( parentBlock );
@ -239,10 +237,8 @@ test.describe( `${ blockData.name }`, () => {
'woocommerce/product-image-gallery'
);
const clientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
const parentClientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await editor.getBlockRootClientId( clientId ) ) ?? '';
await editor.selectBlocks( parentBlock );
@ -319,10 +315,8 @@ test.describe( `${ blockData.name }`, () => {
'woocommerce/product-image-gallery'
);
const clientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await parentBlock.getAttribute( 'data-block' ) ) ?? '';
const parentClientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await editor.getBlockRootClientId( clientId ) ) ?? '';
await editor.selectBlocks( parentBlock );

View File

@ -133,10 +133,8 @@ for ( const {
await editor.canvas.locator( 'body' ).click();
const block = await editor.getBlockByName( blockData.name );
// eslint-disable-next-line playwright/no-conditional-in-test
const clientId = ( await block.getAttribute( 'data-block' ) ) ?? '';
const parentClientId =
// eslint-disable-next-line playwright/no-conditional-in-test
( await editor.getBlockRootClientId( clientId ) ) ?? '';
await editor.selectBlocks( block );
await editor.insertBlock(

View File

@ -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', () => {
for ( const scenario of singleOccurranceScenarios ) {
test( `${ scenario.title } is attached to the page`, async ( {

View File

@ -8,15 +8,13 @@ test.describe( 'Shop page', () => {
admin,
page,
} ) => {
// Get Shop page ID.
const cliOutput = await wpCLI( 'option get woocommerce_shop_page_id' );
const numberMatch = cliOutput.stdout.match( /\d+/ );
// eslint-disable-next-line playwright/no-conditional-in-test
if ( numberMatch === null ) {
const shopPageId = cliOutput.stdout.match( /\d+/ )?.pop();
if ( ! shopPageId ) {
throw new Error( 'Shop page ID not found' );
}
await admin.editPost( numberMatch[ 0 ] );
await admin.editPost( shopPageId );
await expect( page.getByText( 'Template' ) ).toBeHidden();
} );

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Clean up eslint comments after rules update in Blocks E2E tests.