[e2e] External - Expand WPCOM suite, part 2 (#51414)
* Add /merchant tests to the WPCOM suite * Skip "can manually add a variation" on WPCOM * Skip "Coupon management" - API returns 500 on delete * Resolve `wp-block-woocommerce-checkout-order-summary-block` on the first element * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
861bc091d4
commit
acc313a9b2
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: update
|
||||||
|
|
||||||
|
Expand the e2e suite we're running on WPCOM part #2.
|
|
@ -15,6 +15,14 @@ config = {
|
||||||
'**/admin-tasks/**/*.spec.js',
|
'**/admin-tasks/**/*.spec.js',
|
||||||
'**/shopper/**/*.spec.js',
|
'**/shopper/**/*.spec.js',
|
||||||
'**/api-tests/**/*.test.js',
|
'**/api-tests/**/*.test.js',
|
||||||
|
'**/merchant/products/add-variable-product/**/*.spec.js',
|
||||||
|
'**/merchant/command-palette.spec.js',
|
||||||
|
'**/merchant/create-cart-block.spec.js',
|
||||||
|
'**/merchant/create-checkout-block.spec.js',
|
||||||
|
'**/merchant/create-coupon.spec.js',
|
||||||
|
'**/merchant/create-order.spec.js',
|
||||||
|
'**/merchant/create-page.spec.js',
|
||||||
|
'**/merchant/create-post.spec.js',
|
||||||
],
|
],
|
||||||
grepInvert: /@skip-on-default-wpcom/,
|
grepInvert: /@skip-on-default-wpcom/,
|
||||||
},
|
},
|
||||||
|
|
|
@ -149,9 +149,11 @@ test.describe(
|
||||||
.locator( 'legend' )
|
.locator( 'legend' )
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
await expect(
|
await expect(
|
||||||
page.locator(
|
page
|
||||||
'.wp-block-woocommerce-checkout-order-summary-block'
|
.locator(
|
||||||
)
|
'.wp-block-woocommerce-checkout-order-summary-block'
|
||||||
|
)
|
||||||
|
.first()
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
await expect(
|
await expect(
|
||||||
page.locator( '.wc-block-components-address-form' ).first()
|
page.locator( '.wc-block-components-address-form' ).first()
|
||||||
|
|
|
@ -39,102 +39,110 @@ const test = baseTest.extend( {
|
||||||
},
|
},
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test.describe( 'Coupon management', { tag: '@services' }, () => {
|
test.describe(
|
||||||
for ( const couponType of Object.keys( couponData ) ) {
|
'Coupon management',
|
||||||
test( `can create new ${ couponType } coupon`, async ( {
|
{ tag: [ '@services', '@skip-on-default-wpcom' ] },
|
||||||
page,
|
() => {
|
||||||
coupon,
|
for ( const couponType of Object.keys( couponData ) ) {
|
||||||
} ) => {
|
test( `can create new ${ couponType } coupon`, async ( {
|
||||||
await test.step( 'add new coupon', async () => {
|
page,
|
||||||
await page.goto(
|
coupon,
|
||||||
'wp-admin/post-new.php?post_type=shop_coupon'
|
} ) => {
|
||||||
);
|
await test.step( 'add new coupon', async () => {
|
||||||
await page
|
await page.goto(
|
||||||
.getByLabel( 'Coupon code' )
|
'wp-admin/post-new.php?post_type=shop_coupon'
|
||||||
.fill( couponData[ couponType ].code );
|
);
|
||||||
await page
|
await page
|
||||||
.getByPlaceholder( 'Description (optional)' )
|
.getByLabel( 'Coupon code' )
|
||||||
.fill( couponData[ couponType ].description );
|
.fill( couponData[ couponType ].code );
|
||||||
await page
|
await page
|
||||||
.getByPlaceholder( '0' )
|
.getByPlaceholder( 'Description (optional)' )
|
||||||
.fill( couponData[ couponType ].amount );
|
.fill( couponData[ couponType ].description );
|
||||||
|
await page
|
||||||
|
.getByPlaceholder( '0' )
|
||||||
|
.fill( couponData[ couponType ].amount );
|
||||||
|
|
||||||
// set expiry date if it was provided
|
// set expiry date if it was provided
|
||||||
|
if ( couponData[ couponType ].expiryDate ) {
|
||||||
|
await page
|
||||||
|
.getByPlaceholder( 'yyyy-mm-dd' )
|
||||||
|
.fill( couponData[ couponType ].expiryDate );
|
||||||
|
}
|
||||||
|
|
||||||
|
// be explicit about whether free shipping is allowed
|
||||||
|
if ( couponData[ couponType ].freeShipping ) {
|
||||||
|
await page.getByLabel( 'Allow free shipping' ).check();
|
||||||
|
} else {
|
||||||
|
await page
|
||||||
|
.getByLabel( 'Allow free shipping' )
|
||||||
|
.uncheck();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
// publish the coupon and retrieve the id
|
||||||
|
await test.step( 'publish the coupon', async () => {
|
||||||
|
await expect(
|
||||||
|
page.getByRole( 'link', { name: 'Move to Trash' } )
|
||||||
|
).toBeVisible();
|
||||||
|
await page
|
||||||
|
.getByRole( 'button', { name: 'Publish', exact: true } )
|
||||||
|
.click();
|
||||||
|
await expect(
|
||||||
|
page.getByText( 'Coupon updated.' )
|
||||||
|
).toBeVisible();
|
||||||
|
coupon.id = page.url().match( /(?<=post=)\d+/ )[ 0 ];
|
||||||
|
expect( coupon.id ).toBeDefined();
|
||||||
|
} );
|
||||||
|
|
||||||
|
// verify the creation of the coupon and details
|
||||||
|
await test.step( 'verify coupon creation', async () => {
|
||||||
|
await page.goto(
|
||||||
|
'wp-admin/edit.php?post_type=shop_coupon'
|
||||||
|
);
|
||||||
|
await expect(
|
||||||
|
page.getByRole( 'cell', {
|
||||||
|
name: couponData[ couponType ].code,
|
||||||
|
} )
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
page.getByRole( 'cell', {
|
||||||
|
name: couponData[ couponType ].description,
|
||||||
|
} )
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
page.getByRole( 'cell', {
|
||||||
|
name: couponData[ couponType ].amount,
|
||||||
|
exact: true,
|
||||||
|
} )
|
||||||
|
).toBeVisible();
|
||||||
|
} );
|
||||||
|
|
||||||
|
// check expiry date if it was set
|
||||||
if ( couponData[ couponType ].expiryDate ) {
|
if ( couponData[ couponType ].expiryDate ) {
|
||||||
await page
|
await test.step( 'verify coupon expiry date', async () => {
|
||||||
.getByPlaceholder( 'yyyy-mm-dd' )
|
await page
|
||||||
.fill( couponData[ couponType ].expiryDate );
|
.getByText( couponData[ couponType ].code )
|
||||||
|
.last()
|
||||||
|
.click();
|
||||||
|
await expect(
|
||||||
|
page.getByPlaceholder( 'yyyy-mm-dd' )
|
||||||
|
).toHaveValue( couponData[ couponType ].expiryDate );
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
// be explicit about whether free shipping is allowed
|
// if it was a free shipping coupon check that
|
||||||
if ( couponData[ couponType ].freeShipping ) {
|
if ( couponData[ couponType ].freeShipping ) {
|
||||||
await page.getByLabel( 'Allow free shipping' ).check();
|
await test.step( 'verify free shipping', async () => {
|
||||||
} else {
|
await page
|
||||||
await page.getByLabel( 'Allow free shipping' ).uncheck();
|
.getByText( couponData[ couponType ].code )
|
||||||
|
.last()
|
||||||
|
.click();
|
||||||
|
await expect(
|
||||||
|
page.getByLabel( 'Allow free shipping' )
|
||||||
|
).toBeChecked();
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
}
|
||||||
// publish the coupon and retrieve the id
|
|
||||||
await test.step( 'publish the coupon', async () => {
|
|
||||||
await expect(
|
|
||||||
page.getByRole( 'link', { name: 'Move to Trash' } )
|
|
||||||
).toBeVisible();
|
|
||||||
await page
|
|
||||||
.getByRole( 'button', { name: 'Publish', exact: true } )
|
|
||||||
.click();
|
|
||||||
await expect(
|
|
||||||
page.getByText( 'Coupon updated.' )
|
|
||||||
).toBeVisible();
|
|
||||||
coupon.id = page.url().match( /(?<=post=)\d+/ )[ 0 ];
|
|
||||||
expect( coupon.id ).toBeDefined();
|
|
||||||
} );
|
|
||||||
|
|
||||||
// verify the creation of the coupon and details
|
|
||||||
await test.step( 'verify coupon creation', async () => {
|
|
||||||
await page.goto( 'wp-admin/edit.php?post_type=shop_coupon' );
|
|
||||||
await expect(
|
|
||||||
page.getByRole( 'cell', {
|
|
||||||
name: couponData[ couponType ].code,
|
|
||||||
} )
|
|
||||||
).toBeVisible();
|
|
||||||
await expect(
|
|
||||||
page.getByRole( 'cell', {
|
|
||||||
name: couponData[ couponType ].description,
|
|
||||||
} )
|
|
||||||
).toBeVisible();
|
|
||||||
await expect(
|
|
||||||
page.getByRole( 'cell', {
|
|
||||||
name: couponData[ couponType ].amount,
|
|
||||||
exact: true,
|
|
||||||
} )
|
|
||||||
).toBeVisible();
|
|
||||||
} );
|
|
||||||
|
|
||||||
// check expiry date if it was set
|
|
||||||
if ( couponData[ couponType ].expiryDate ) {
|
|
||||||
await test.step( 'verify coupon expiry date', async () => {
|
|
||||||
await page
|
|
||||||
.getByText( couponData[ couponType ].code )
|
|
||||||
.last()
|
|
||||||
.click();
|
|
||||||
await expect(
|
|
||||||
page.getByPlaceholder( 'yyyy-mm-dd' )
|
|
||||||
).toHaveValue( couponData[ couponType ].expiryDate );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
// if it was a free shipping coupon check that
|
|
||||||
if ( couponData[ couponType ].freeShipping ) {
|
|
||||||
await test.step( 'verify free shipping', async () => {
|
|
||||||
await page
|
|
||||||
.getByText( couponData[ couponType ].code )
|
|
||||||
.last()
|
|
||||||
.click();
|
|
||||||
await expect(
|
|
||||||
page.getByLabel( 'Allow free shipping' )
|
|
||||||
).toBeChecked();
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
} );
|
);
|
||||||
|
|
|
@ -84,105 +84,117 @@ test.describe( 'Add variations', { tag: '@gutenberg' }, () => {
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test( 'can manually add a variation', async ( { page } ) => {
|
test(
|
||||||
await test.step( `Open "Edit product" page of product id ${ productId_addManually }`, async () => {
|
'can manually add a variation',
|
||||||
await page.goto(
|
{ tag: '@skip-on-default-wpcom' },
|
||||||
`/wp-admin/post.php?post=${ productId_addManually }&action=edit`
|
async ( { page } ) => {
|
||||||
);
|
await test.step( `Open "Edit product" page of product id ${ productId_addManually }`, async () => {
|
||||||
} );
|
await page.goto(
|
||||||
|
`/wp-admin/post.php?post=${ productId_addManually }&action=edit`
|
||||||
// hook up the woocommerce_variations_added jQuery trigger so we can check if it's fired
|
);
|
||||||
await test.step( 'Hook up the woocommerce_variations_added jQuery trigger', async () => {
|
|
||||||
await page.evaluate( () => {
|
|
||||||
window.woocommerceVariationsAddedFunctionCalls = [];
|
|
||||||
|
|
||||||
window
|
|
||||||
.jQuery( '#variable_product_options' )
|
|
||||||
.on( 'woocommerce_variations_added', ( event, data ) => {
|
|
||||||
window.woocommerceVariationsAddedFunctionCalls.push( [
|
|
||||||
event,
|
|
||||||
data,
|
|
||||||
] );
|
|
||||||
} );
|
|
||||||
} );
|
} );
|
||||||
} );
|
|
||||||
|
|
||||||
await test.step( 'Click on the "Variations" tab.', async () => {
|
// hook up the woocommerce_variations_added jQuery trigger so we can check if it's fired
|
||||||
await page.locator( '.variations_tab' ).click();
|
await test.step( 'Hook up the woocommerce_variations_added jQuery trigger', async () => {
|
||||||
} );
|
await page.evaluate( () => {
|
||||||
|
window.woocommerceVariationsAddedFunctionCalls = [];
|
||||||
|
|
||||||
await test.step( `Manually add ${ variationsToManuallyCreate.length } variations`, async () => {
|
window
|
||||||
const variationRows = page.locator( '.woocommerce_variation h3' );
|
.jQuery( '#variable_product_options' )
|
||||||
let variationRowsCount = await variationRows.count();
|
.on(
|
||||||
const originalVariationRowsCount = variationRowsCount;
|
'woocommerce_variations_added',
|
||||||
|
( event, data ) => {
|
||||||
for ( const variationToCreate of variationsToManuallyCreate ) {
|
window.woocommerceVariationsAddedFunctionCalls.push(
|
||||||
await test.step( 'Click "Add manually"', async () => {
|
[ event, data ]
|
||||||
const addManuallyButton = page.getByRole( 'button', {
|
);
|
||||||
name: 'Add manually',
|
}
|
||||||
} );
|
|
||||||
|
|
||||||
await addManuallyButton.click();
|
|
||||||
|
|
||||||
await expect( variationRows ).toHaveCount(
|
|
||||||
++variationRowsCount
|
|
||||||
);
|
|
||||||
|
|
||||||
// verify that the woocommerce_variations_added jQuery trigger was fired
|
|
||||||
const woocommerceVariationsAddedFunctionCalls =
|
|
||||||
await page.evaluate(
|
|
||||||
() => window.woocommerceVariationsAddedFunctionCalls
|
|
||||||
);
|
);
|
||||||
expect(
|
|
||||||
woocommerceVariationsAddedFunctionCalls.length
|
|
||||||
).toEqual(
|
|
||||||
variationRowsCount - originalVariationRowsCount
|
|
||||||
);
|
|
||||||
} );
|
} );
|
||||||
|
} );
|
||||||
|
|
||||||
for ( const attributeValue of variationToCreate ) {
|
await test.step( 'Click on the "Variations" tab.', async () => {
|
||||||
const attributeName = productAttributes.find(
|
await page.locator( '.variations_tab' ).click();
|
||||||
( { options } ) => options.includes( attributeValue )
|
} );
|
||||||
).name;
|
|
||||||
const addAttributeMenu = variationRows
|
await test.step( `Manually add ${ variationsToManuallyCreate.length } variations`, async () => {
|
||||||
.nth( 0 )
|
const variationRows = page.locator(
|
||||||
.locator( 'select', {
|
'.woocommerce_variation h3'
|
||||||
has: page.locator( 'option', {
|
);
|
||||||
hasText: attributeValue,
|
let variationRowsCount = await variationRows.count();
|
||||||
} ),
|
const originalVariationRowsCount = variationRowsCount;
|
||||||
|
|
||||||
|
for ( const variationToCreate of variationsToManuallyCreate ) {
|
||||||
|
await test.step( 'Click "Add manually"', async () => {
|
||||||
|
const addManuallyButton = page.getByRole( 'button', {
|
||||||
|
name: 'Add manually',
|
||||||
} );
|
} );
|
||||||
|
|
||||||
await test.step( `Select "${ attributeValue }" from the "${ attributeName }" attribute menu`, async () => {
|
await addManuallyButton.click();
|
||||||
await addAttributeMenu.selectOption( attributeValue );
|
|
||||||
|
await expect( variationRows ).toHaveCount(
|
||||||
|
++variationRowsCount
|
||||||
|
);
|
||||||
|
|
||||||
|
// verify that the woocommerce_variations_added jQuery trigger was fired
|
||||||
|
const woocommerceVariationsAddedFunctionCalls =
|
||||||
|
await page.evaluate(
|
||||||
|
() =>
|
||||||
|
window.woocommerceVariationsAddedFunctionCalls
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
woocommerceVariationsAddedFunctionCalls.length
|
||||||
|
).toEqual(
|
||||||
|
variationRowsCount - originalVariationRowsCount
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
}
|
|
||||||
|
|
||||||
await test.step( 'Click "Save changes"', async () => {
|
|
||||||
await page
|
|
||||||
.getByRole( 'button', {
|
|
||||||
name: 'Save changes',
|
|
||||||
} )
|
|
||||||
.click();
|
|
||||||
} );
|
|
||||||
|
|
||||||
await test.step( `Expect the variation ${ variationToCreate.join(
|
|
||||||
', '
|
|
||||||
) } to be successfully saved.`, async () => {
|
|
||||||
let newlyAddedVariationRow;
|
|
||||||
|
|
||||||
for ( const attributeValue of variationToCreate ) {
|
for ( const attributeValue of variationToCreate ) {
|
||||||
newlyAddedVariationRow = (
|
const attributeName = productAttributes.find(
|
||||||
newlyAddedVariationRow || variationRows
|
( { options } ) =>
|
||||||
).filter( {
|
options.includes( attributeValue )
|
||||||
has: page.locator( 'option[selected]', {
|
).name;
|
||||||
hasText: attributeValue,
|
const addAttributeMenu = variationRows
|
||||||
} ),
|
.nth( 0 )
|
||||||
|
.locator( 'select', {
|
||||||
|
has: page.locator( 'option', {
|
||||||
|
hasText: attributeValue,
|
||||||
|
} ),
|
||||||
|
} );
|
||||||
|
|
||||||
|
await test.step( `Select "${ attributeValue }" from the "${ attributeName }" attribute menu`, async () => {
|
||||||
|
await addAttributeMenu.selectOption(
|
||||||
|
attributeValue
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
await expect( newlyAddedVariationRow ).toBeVisible();
|
await test.step( 'Click "Save changes"', async () => {
|
||||||
} );
|
await page
|
||||||
}
|
.getByRole( 'button', {
|
||||||
} );
|
name: 'Save changes',
|
||||||
} );
|
} )
|
||||||
|
.click();
|
||||||
|
} );
|
||||||
|
|
||||||
|
await test.step( `Expect the variation ${ variationToCreate.join(
|
||||||
|
', '
|
||||||
|
) } to be successfully saved.`, async () => {
|
||||||
|
let newlyAddedVariationRow;
|
||||||
|
|
||||||
|
for ( const attributeValue of variationToCreate ) {
|
||||||
|
newlyAddedVariationRow = (
|
||||||
|
newlyAddedVariationRow || variationRows
|
||||||
|
).filter( {
|
||||||
|
has: page.locator( 'option[selected]', {
|
||||||
|
hasText: attributeValue,
|
||||||
|
} ),
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
await expect( newlyAddedVariationRow ).toBeVisible();
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in New Issue