Update e2e core tests to pass lint checks (#33928)

Updated to pass lint checks
This commit is contained in:
Jamel Noel Reid 2022-07-18 20:27:05 +02:00 committed by GitHub
parent 282d8daa26
commit 7265fde855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 54 additions and 30 deletions

View File

@ -37,4 +37,5 @@ const runActivationTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runActivationTest; module.exports = runActivationTest;

View File

@ -77,7 +77,7 @@ const runTaskListTest = () => {
expect( taskListItems.length ).toBeInRange( 5, 6 ); expect( taskListItems.length ).toBeInRange( 5, 6 );
// Work around for https://github.com/woocommerce/woocommerce-admin/issues/6761 // Work around for https://github.com/woocommerce/woocommerce-admin/issues/6761
if ( taskListItems.length == 6 ) { if ( taskListItems.length === 6 ) {
// Click on "Set up shipping" task to move to the next step // Click on "Set up shipping" task to move to the next step
const [ setupTaskListItem ] = await page.$x( const [ setupTaskListItem ] = await page.$x(
'//div[contains(text(),"Set up shipping")]' '//div[contains(text(),"Set up shipping")]'
@ -101,6 +101,7 @@ const runTaskListTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = { module.exports = {
runOnboardingFlowTest, runOnboardingFlowTest,
runTaskListTest, runTaskListTest,

View File

@ -108,4 +108,5 @@ const runInitialStoreSettingsTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runInitialStoreSettingsTest; module.exports = runInitialStoreSettingsTest;

View File

@ -87,4 +87,5 @@ const runCouponApiTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runCouponApiTest; module.exports = runCouponApiTest;

View File

@ -80,4 +80,5 @@ const runExternalProductAPITest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runExternalProductAPITest; module.exports = runExternalProductAPITest;

View File

@ -101,4 +101,5 @@ const runGroupedProductAPITest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runGroupedProductAPITest; module.exports = runGroupedProductAPITest;

View File

@ -78,4 +78,5 @@ const runOrderApiTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runOrderApiTest; module.exports = runOrderApiTest;

View File

@ -50,4 +50,5 @@ const runTelemetryAPITest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runTelemetryAPITest; module.exports = runTelemetryAPITest;

View File

@ -16,9 +16,9 @@ import deprecated from '@wordpress/deprecated';
/** /**
* Quick check for page title and no data message. * Quick check for page title and no data message.
* *
* @param pageTitle Page title in H1. * @param {string} pageTitle Page title in H1.
* @param element Defaults to '.d3-chart__empty-message' * @param {string} element Defaults to '.d3-chart__empty-message'
* @param elementText Defaults to 'No data for the selected date range' * @param {string} elementText Defaults to 'No data for the selected date range'
*/ */
const checkHeadingAndElement = async ( const checkHeadingAndElement = async (
pageTitle, pageTitle,

View File

@ -60,4 +60,5 @@ const runCreateCouponTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runCreateCouponTest; module.exports = runCreateCouponTest;

View File

@ -41,4 +41,5 @@ const runInitiateWccomConnectionTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runInitiateWccomConnectionTest; module.exports = runInitiateWccomConnectionTest;

View File

@ -36,6 +36,7 @@ const runOrderApplyCouponTest = () => {
await page.removeAllListeners( 'dialog' ); await page.removeAllListeners( 'dialog' );
// Make sure the simple product price is greater than the coupon amount // Make sure the simple product price is greater than the coupon amount
// eslint-disable-next-line jest/no-standalone-expect
await expect( Number( simpleProductPrice ) ).toBeGreaterThan( 5.0 ); await expect( Number( simpleProductPrice ) ).toBeGreaterThan( 5.0 );
} ); } );
@ -68,9 +69,7 @@ const runOrderApplyCouponTest = () => {
await expect( page ).toMatchElement( '.wc-order-item-discount', { await expect( page ).toMatchElement( '.wc-order-item-discount', {
text: '5.00', text: '5.00',
} ); } );
await expect( await expect( page ).toMatchElement(
page
).toMatchElement(
'.line_cost > .view > .woocommerce-Price-amount', '.line_cost > .view > .woocommerce-Price-amount',
{ text: discountedPrice } { text: discountedPrice }
); );
@ -102,17 +101,13 @@ const runOrderApplyCouponTest = () => {
'.wc-order-item-discount', '.wc-order-item-discount',
{ text: '5.00' } { text: '5.00' }
); );
await expect( await expect( page ).not.toMatchElement(
page
).not.toMatchElement(
'.line-cost .view .woocommerce-Price-amount', '.line-cost .view .woocommerce-Price-amount',
{ text: discountedPrice } { text: discountedPrice }
); );
// Verify the original price is the order total // Verify the original price is the order total
await expect( await expect( page ).toMatchElement(
page
).toMatchElement(
'.line_cost > .view > .woocommerce-Price-amount', '.line_cost > .view > .woocommerce-Price-amount',
{ text: simpleProductPrice } { text: simpleProductPrice }
); );
@ -120,4 +115,5 @@ const runOrderApplyCouponTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runOrderApplyCouponTest; module.exports = runOrderApplyCouponTest;

View File

@ -98,4 +98,5 @@ const runMerchantOrdersCustomerPaymentPage = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runMerchantOrdersCustomerPaymentPage; module.exports = runMerchantOrdersCustomerPaymentPage;

View File

@ -264,4 +264,5 @@ const runEditOrderTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runEditOrderTest; module.exports = runEditOrderTest;

View File

@ -33,6 +33,7 @@ const runMerchantOrderEmailsTest = () => {
await page.click( await page.click(
'div.order_data_column:nth-child(2) > h3:nth-child(1) > a:nth-child(1)' 'div.order_data_column:nth-child(2) > h3:nth-child(1) > a:nth-child(1)'
), ),
// eslint-disable-next-line jest/no-standalone-expect
await expect( page ).toFill( '#_billing_email', customerEmail ), await expect( page ).toFill( '#_billing_email', customerEmail ),
await clickUpdateOrder( 'Order updated.' ), await clickUpdateOrder( 'Order updated.' ),
] ); ] );
@ -82,4 +83,5 @@ const runMerchantOrderEmailsTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runMerchantOrderEmailsTest; module.exports = runMerchantOrderEmailsTest;

View File

@ -201,8 +201,7 @@ const runCreateOrderTest = () => {
await expect( page ).toMatchElement( await expect( page ).toMatchElement(
'#woocommerce-order-notes .note_content', '#woocommerce-order-notes .note_content',
{ {
text: text: 'Order status changed from Pending payment to Processing.',
'Order status changed from Pending payment to Processing.',
} }
); );
} ); } );
@ -285,4 +284,5 @@ const runCreateOrderTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runCreateOrderTest; module.exports = runCreateOrderTest;

View File

@ -114,4 +114,5 @@ const runOrderRefundRestockTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runOrderRefundRestockTest; module.exports = runOrderRefundRestockTest;

View File

@ -129,4 +129,5 @@ const runRefundOrderTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runRefundOrderTest; module.exports = runRefundOrderTest;

View File

@ -42,7 +42,7 @@ const customerShipping = {
/** /**
* Set the billing fields for the customer account for this test suite. * Set the billing fields for the customer account for this test suite.
* *
* @return {Promise<number>} * @return {Promise<number>} Returns the updated customer's ID
*/ */
const updateCustomerBilling = async () => { const updateCustomerBilling = async () => {
const client = factories.api.withDefaultPermalinks; const client = factories.api.withDefaultPermalinks;
@ -130,4 +130,5 @@ const runOrderSearchingTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runOrderSearchingTest; module.exports = runOrderSearchingTest;

View File

@ -63,6 +63,7 @@ const runOrderStatusFiltersTest = () => {
const shownStatus = { text: statusText }; const shownStatus = { text: statusText };
const hiddenStatuses = orderStatus const hiddenStatuses = orderStatus
.filter( ( pair ) => ! pair.includes( statusText ) ) .filter( ( pair ) => ! pair.includes( statusText ) )
// eslint-disable-next-line no-shadow
.map( ( [ statusText ] ) => { .map( ( [ statusText ] ) => {
return { text: statusText }; return { text: statusText };
} ); } );
@ -97,4 +98,5 @@ const runOrderStatusFiltersTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runOrderStatusFiltersTest; module.exports = runOrderStatusFiltersTest;

View File

@ -78,6 +78,7 @@ const runProductEditDetailsTest = () => {
await withRestApi.deleteProduct( productId ); await withRestApi.deleteProduct( productId );
} ); } );
// eslint-disable-next-line jest/expect-expect
it( 'can edit just a single attribute of a product variation', async () => { it( 'can edit just a single attribute of a product variation', async () => {
const expectedVariationDetails = { const expectedVariationDetails = {
regularPrice: '10', regularPrice: '10',
@ -92,6 +93,7 @@ const runProductEditDetailsTest = () => {
await merchant.verifyVariationDetails( expectedVariationDetails ); await merchant.verifyVariationDetails( expectedVariationDetails );
} ); } );
// eslint-disable-next-line jest/expect-expect
it( 'can edit multiple attributes of a product variation', async () => { it( 'can edit multiple attributes of a product variation', async () => {
const expectedVariationDetails = { const expectedVariationDetails = {
sku: 'ABCD0123', sku: 'ABCD0123',

View File

@ -39,7 +39,7 @@ const openNewProductAndVerify = async () => {
/** /**
* Select a variation action from the actions menu. * Select a variation action from the actions menu.
* *
* @param action item you selected from the variation actions menu * @param {string} action item you selected from the variation actions menu
*/ */
const selectVariationAction = async ( action ) => { const selectVariationAction = async ( action ) => {
await waitForSelector( page, 'select.variation_actions:not(:disabled)' ); await waitForSelector( page, 'select.variation_actions:not(:disabled)' );
@ -472,6 +472,7 @@ const runAddVariableProductTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = { module.exports = {
runAddSimpleProductTest, runAddSimpleProductTest,
runAddVariableProductTest, runAddVariableProductTest,

View File

@ -59,9 +59,7 @@ const runUpdateGeneralSettingsTest = () => {
expect( page ).toMatchElement( '#message', { expect( page ).toMatchElement( '#message', {
text: 'Your settings have been saved.', text: 'Your settings have been saved.',
} ), } ),
expect( expect( page ).toMatchElement(
page
).toMatchElement(
'select[name="woocommerce_default_country"]', 'select[name="woocommerce_default_country"]',
{ text: 'United States (US) — California' } { text: 'United States (US) — California' }
), ),
@ -88,9 +86,7 @@ const runUpdateGeneralSettingsTest = () => {
'#woocommerce_allowed_countries', '#woocommerce_allowed_countries',
{ text: 'Sell to specific countries' } { text: 'Sell to specific countries' }
), ),
expect( expect( page ).toMatchElement(
page
).toMatchElement(
'select[name="woocommerce_specific_allowed_countries[]"]', 'select[name="woocommerce_specific_allowed_countries[]"]',
{ text: 'United States (US)' } { text: 'United States (US)' }
), ),

View File

@ -73,4 +73,5 @@ const runAddShippingClassesTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runAddShippingClassesTest; module.exports = runAddShippingClassesTest;

View File

@ -167,4 +167,5 @@ const runAddNewShippingZoneTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runAddNewShippingZoneTest; module.exports = runAddNewShippingZoneTest;

View File

@ -264,4 +264,5 @@ const runTaxSettingsTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runTaxSettingsTest; module.exports = runTaxSettingsTest;

View File

@ -168,8 +168,7 @@ const runCartAndCheckoutConsistentShippingTest = () => {
{ {
// Test fails here because actual text is 'Enter your address to view shipping options.' // Test fails here because actual text is 'Enter your address to view shipping options.'
// Logged in GitHub as issue #33205 // Logged in GitHub as issue #33205
text: text: 'There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.',
'There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.',
} }
); );
} ); } );

View File

@ -174,4 +174,5 @@ const runCartCalculateShippingTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runCartCalculateShippingTest; module.exports = runCartCalculateShippingTest;

View File

@ -91,4 +91,5 @@ const runCartApplyCouponsTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runCartApplyCouponsTest; module.exports = runCartApplyCouponsTest;

View File

@ -69,4 +69,5 @@ const runCartRedirectionTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runCartRedirectionTest; module.exports = runCartRedirectionTest;

View File

@ -106,4 +106,5 @@ const runCartPageTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runCartPageTest; module.exports = runCartPageTest;

View File

@ -95,4 +95,5 @@ const runCheckoutApplyCouponsTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runCheckoutApplyCouponsTest; module.exports = runCheckoutApplyCouponsTest;

View File

@ -78,4 +78,5 @@ const runCheckoutCreateAccountTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runCheckoutCreateAccountTest; module.exports = runCheckoutCreateAccountTest;

View File

@ -86,4 +86,5 @@ const runCheckoutLoginAccountTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runCheckoutLoginAccountTest; module.exports = runCheckoutLoginAccountTest;

View File

@ -259,4 +259,5 @@ const runCheckoutPageTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runCheckoutPageTest; module.exports = runCheckoutPageTest;

View File

@ -55,4 +55,5 @@ const runMyAccountCreateAccountTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runMyAccountCreateAccountTest; module.exports = runMyAccountCreateAccountTest;

View File

@ -116,4 +116,5 @@ const runProductBrowseSearchSortTest = () => {
); );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runProductBrowseSearchSortTest; module.exports = runProductBrowseSearchSortTest;

View File

@ -119,8 +119,7 @@ const runSingleProductPageTest = () => {
await page.waitForSelector( 'form.grouped_form' ); await page.waitForSelector( 'form.grouped_form' );
await shopper.addToCart(); await shopper.addToCart();
await expect( page ).toMatchElement( '.woocommerce-error', { await expect( page ).toMatchElement( '.woocommerce-error', {
text: text: 'Please choose the quantity of items you wish to add to your cart…',
'Please choose the quantity of items you wish to add to your cart…',
} ); } );
const quantityFields = await page.$$( 'div.quantity input.qty' ); const quantityFields = await page.$$( 'div.quantity input.qty' );
await quantityFields[ 0 ].click( { clickCount: 3 } ); await quantityFields[ 0 ].click( { clickCount: 3 } );
@ -167,4 +166,5 @@ const runSingleProductPageTest = () => {
} ); } );
}; };
// eslint-disable-next-line jest/no-export
module.exports = runSingleProductPageTest; module.exports = runSingleProductPageTest;

View File

@ -66,9 +66,7 @@ const runVariableProductUpdateTest = () => {
text: '200 kg', text: '200 kg',
} }
); );
await expect( await expect( page ).toMatchElement(
page
).toMatchElement(
'.woocommerce-product-attributes-item--dimensions', '.woocommerce-product-attributes-item--dimensions',
{ text: '10 × 20 × 15 cm' } { text: '10 × 20 × 15 cm' }
); );