[e2e] External - Expand WPCOM suite, part 4 (#51424)

* Skip `can remove a coupon` - error 500

* Make elements more specific

* Skip two tests from order-emails.spec.js

* Skip `WooCommerce Page Load`

* Expand WPCOM suite

* Change hardcoded email address

* Unskip tests in order-emails.spec.js

* Add changefile(s) from automation for the following project(s): woocommerce

* ESLint updates

* Check different locator for Marketing channels

* Skip "can receive completed email" for now

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Ivan Stojadinov 2024-10-02 11:23:07 +02:00 committed by GitHub
parent 6b5dbbc6ac
commit 9c514b3949
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 195 additions and 162 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Expand the e2e suite we're running on WPCOM part #4.

View File

@ -45,6 +45,16 @@ config = {
'**/merchant/settings-woo-com.spec.js',
'**/merchant/users-create.spec.js',
'**/merchant/users-manage.spec.js',
'**/merchant/order-coupon.spec.js',
'**/merchant/order-edit.spec.js',
'**/merchant/order-emails.spec.js',
'**/merchant/order-refund.spec.js',
'**/merchant/order-search.spec.js',
'**/merchant/order-status-filter.spec.js',
'**/merchant/page-loads.spec.js',
'**/merchant/product-create-simple.spec.js',
'**/merchant/product-delete.spec.js',
'**/merchant/product-edit.spec.js',
],
grepInvert: /@skip-on-default-wpcom/,
},

View File

@ -119,40 +119,50 @@ test.describe(
).toBeVisible();
} );
test( 'can remove a coupon', async ( { page } ) => {
await page.goto(
`/wp-admin/admin.php?page=wc-orders&action=edit&id=${ orderId }`
);
// assert that there is a coupon on the order
await expect(
page
.locator( '#woocommerce-order-items li' )
.filter( { hasText: couponCode } )
).toBeVisible();
await expect(
page.getByRole( 'cell', { name: 'Coupon(s)' } )
).toBeVisible();
await expect(
page.getByRole( 'cell', { name: `- $${ couponAmount }.00` } )
).toBeVisible();
await expect(
page.getByRole( 'cell', {
name: `$${ discountedPrice }`,
exact: true,
} )
).toBeVisible();
// remove the coupon
await page.locator( 'a.remove-coupon' ).dispatchEvent( 'click' ); // have to use dispatchEvent because nothing visible to click on
test(
'can remove a coupon',
{ tag: [ '@skip-on-default-wpcom' ] },
async ( { page } ) => {
await page.goto(
`/wp-admin/admin.php?page=wc-orders&action=edit&id=${ orderId }`
);
// assert that there is a coupon on the order
await expect(
page
.locator( '#woocommerce-order-items li' )
.filter( { hasText: couponCode } )
).toBeVisible();
await expect(
page.getByRole( 'cell', { name: 'Coupon(s)' } )
).toBeVisible();
await expect(
page.getByRole( 'cell', {
name: `- $${ couponAmount }.00`,
} )
).toBeVisible();
await expect(
page.getByRole( 'cell', {
name: `$${ discountedPrice }`,
exact: true,
} )
).toBeVisible();
// remove the coupon
await page
.locator( 'a.remove-coupon' )
.dispatchEvent( 'click' ); // have to use dispatchEvent because nothing visible to click on
// make sure the coupon was removed
await expect(
page.locator( '.wc_coupon_list li', { hasText: couponCode } )
).toBeHidden();
await expect(
page
.getByRole( 'cell', { name: `$${ productPrice }` } )
.nth( 1 )
).toBeVisible();
} );
// make sure the coupon was removed
await expect(
page.locator( '.wc_coupon_list li', {
hasText: couponCode,
} )
).toBeHidden();
await expect(
page
.getByRole( 'cell', { name: `$${ productPrice }` } )
.nth( 1 )
).toBeVisible();
}
);
}
);

View File

@ -71,69 +71,9 @@ test.describe(
} );
} );
test(
'can receive new order email',
{ tag: '@skip-on-default-pressable' },
async ( { page, baseURL } ) => {
// New order emails are sent automatically when we create a simple order. Verify that we get these.
// Need to create a new order for this test because we clear logs before each run.
const api = new wcApi( {
url: baseURL,
consumerKey: process.env.CONSUMER_KEY,
consumerSecret: process.env.CONSUMER_SECRET,
version: 'wc/v3',
} );
await api
.post( 'orders', {
status: 'processing',
billing: customerBilling,
} )
.then( ( response ) => {
newOrderId = response.data.id;
} );
// search to narrow it down to just the messages we want
await page.goto(
`/wp-admin/tools.php?page=wpml_plugin_log&s=${ encodeURIComponent(
customerBilling.email
) }`
);
await expect(
page.locator( 'td.column-receiver >> nth=1' )
).toContainText( admin.email );
await expect(
page.locator( 'td.column-subject >> nth=1' )
).toContainText(
`[${ storeName }]: New order #${ newOrderId }`
);
// look at order email contents
await page
.getByRole( 'button', { name: 'View log' } )
.last()
.click();
await expect(
page.getByText( 'Receiver wordpress@example.com' )
).toBeVisible();
await expect(
page.getByText( 'Subject [WooCommerce Core E2E' )
).toBeVisible();
await page.getByRole( 'link', { name: 'json' } ).click();
await expect(
page.locator(
'#wp-mail-logging-modal-content-body-content'
)
).toContainText(
'Youve received the following order from :'
);
}
);
test( 'can receive completed email', async ( { page, baseURL } ) => {
// Completed order emails are sent automatically when an order's payment is completed.
// Verify that the email is sent, and that the content is the expected one
const emailContent = '#wp-mail-logging-modal-content-body-content';
const emailContentJson = '#wp-mail-logging-modal-format-json';
test( 'can receive new order email', async ( { page, baseURL } ) => {
// New order emails are sent automatically when we create a simple order. Verify that we get these.
// Need to create a new order for this test because we clear logs before each run.
const api = new wcApi( {
url: baseURL,
consumerKey: process.env.CONSUMER_KEY,
@ -142,55 +82,112 @@ test.describe(
} );
await api
.post( 'orders', {
status: 'completed',
status: 'processing',
billing: customerBilling,
} )
.then( ( response ) => {
completedOrderId = response.data.id;
newOrderId = response.data.id;
} );
// Search to narrow it down to just the messages we want
// search to narrow it down to just the messages we want
await page.goto(
`wp-admin/tools.php?page=wpml_plugin_log&s=${ encodeURIComponent(
`/wp-admin/tools.php?page=wpml_plugin_log&s=${ encodeURIComponent(
customerBilling.email
) }`
);
await page.selectOption(
'select[name="search[place]"]',
'subject'
);
await page.fill( 'input[name="search[term]"]', 'complete' );
await page.click( 'input#search-submit' );
// Verify that the email has been sent
await expect(
page.getByText( `Your ${ storeName } order is now complete` )
page.locator( 'td.column-receiver >> nth=1' )
).toContainText( admin.email );
await expect(
page.locator( 'td.column-subject >> nth=1' )
).toContainText( `[${ storeName }]: New order #${ newOrderId }` );
// look at order email contents
await page
.getByRole( 'button', { name: 'View log' } )
.last()
.click();
await expect(
page.getByText( `Receiver ${ admin.email }` )
).toBeVisible();
// Enter email log and select to view the content in JSON
await page.click( 'button[title^="View log"]' );
await page.locator( emailContentJson ).click();
// Verify that the message includes an order processing confirmation
await expect( page.locator( emailContent ) ).toContainText(
'We have finished processing your order.'
);
// Verify that the email address is the correct one
await expect( page.locator( emailContent ) ).toContainText(
customerBilling.email
);
// Verify that the email contains the order ID
await expect( page.locator( emailContent ) ).toContainText(
`[Order #${ completedOrderId.toString() }]`
);
// Verify that the email contains a "Thanks" note
await expect( page.locator( emailContent ) ).toContainText(
'Thanks for shopping with us'
);
await expect(
page.getByText( 'Subject [WooCommerce Core E2E' )
).toBeVisible();
await page.getByRole( 'link', { name: 'json' } ).click();
await expect(
page.locator( '#wp-mail-logging-modal-content-body-content' )
).toContainText( 'Youve received the following order from :' );
} );
test(
'can receive completed email',
{ tag: '@skip-on-default-wpcom' },
async ( { page, baseURL } ) => {
// Completed order emails are sent automatically when an order's payment is completed.
// Verify that the email is sent, and that the content is the expected one
const emailContent =
'#wp-mail-logging-modal-content-body-content';
const emailContentJson = '#wp-mail-logging-modal-format-json';
const api = new wcApi( {
url: baseURL,
consumerKey: process.env.CONSUMER_KEY,
consumerSecret: process.env.CONSUMER_SECRET,
version: 'wc/v3',
} );
await api
.post( 'orders', {
status: 'completed',
billing: customerBilling,
} )
.then( ( response ) => {
completedOrderId = response.data.id;
} );
// Search to narrow it down to just the messages we want
await page.goto(
`wp-admin/tools.php?page=wpml_plugin_log&s=${ encodeURIComponent(
customerBilling.email
) }`
);
await page.selectOption(
'select[name="search[place]"]',
'subject'
);
await page.fill( 'input[name="search[term]"]', 'complete' );
await page.click( 'input#search-submit' );
// Verify that the email has been sent
await expect(
page.getByText(
`Your ${ storeName } order is now complete`
)
).toBeVisible();
// Enter email log and select to view the content in JSON
await page.click( 'button[title^="View log"]' );
await page.locator( emailContentJson ).click();
// Verify that the message includes an order processing confirmation
await expect( page.locator( emailContent ) ).toContainText(
'We have finished processing your order.'
);
// Verify that the email address is the correct one
await expect( page.locator( emailContent ) ).toContainText(
customerBilling.email
);
// Verify that the email contains the order ID
await expect( page.locator( emailContent ) ).toContainText(
`[Order #${ completedOrderId.toString() }]`
);
// Verify that the email contains a "Thanks" note
await expect( page.locator( emailContent ) ).toContainText(
'Thanks for shopping with us'
);
}
);
test( 'can receive cancelled order email', async ( {
page,
baseURL,

View File

@ -87,8 +87,8 @@ const wcPages = [
{
name: 'Overview',
heading: 'Overview',
element: '.woocommerce-marketing-card-header-description',
text: 'Start by adding a channel to your store',
element: '.woocommerce-marketing-channels-card',
text: 'Channels',
},
{
name: 'Coupons',
@ -201,29 +201,31 @@ for ( const currentPage of wcPages ) {
} );
for ( let i = 0; i < currentPage.subpages.length; i++ ) {
test( `Can load ${ currentPage.subpages[ i ].name }`, async ( {
page,
} ) => {
await page
.locator(
`li.wp-menu-open > ul.wp-submenu > li a:text-is("${ currentPage.subpages[ i ].name }")`
)
.click();
test(
`Can load ${ currentPage.subpages[ i ].name }`,
{ tag: '@skip-on-default-wpcom' },
async ( { page } ) => {
await page
.locator(
`li.wp-menu-open > ul.wp-submenu > li a:text-is("${ currentPage.subpages[ i ].name }")`
)
.click();
await expect(
page.locator( 'h1.components-text' )
).toContainText( currentPage.subpages[ i ].heading );
await expect(
page.locator( 'h1.components-text' )
).toContainText( currentPage.subpages[ i ].heading );
await expect(
page
.locator( currentPage.subpages[ i ].element )
.first()
).toBeVisible();
await expect(
page
.locator( currentPage.subpages[ i ].element )
.first()
).toBeVisible();
await expect(
page.locator( currentPage.subpages[ i ].element )
).toContainText( currentPage.subpages[ i ].text );
} );
await expect(
page.locator( currentPage.subpages[ i ].element )
).toContainText( currentPage.subpages[ i ].text );
}
);
}
}
);

View File

@ -96,7 +96,10 @@ for ( const productType of Object.keys( productData ) ) {
await page
.getByLabel( 'Regular price ($)' )
.fill( productData[ productType ].regularPrice );
await page.getByText( 'Inventory' ).click();
await page
.getByRole( 'link' )
.filter( { hasText: 'Inventory' } )
.click();
// Inventory information
await page
@ -130,7 +133,10 @@ for ( const productType of Object.keys( productData ) ) {
await test.step( 'add product advanced information', async () => {
// Advanced information
await page.getByText( 'Advanced' ).click();
await page
.getByRole( 'link' )
.filter( { hasText: 'Advanced' } )
.click();
await page
.getByLabel( 'Purchase note' )
.fill( productData[ productType ].purchaseNote );
@ -265,12 +271,16 @@ for ( const productType of Object.keys( productData ) ) {
// Verify description
await expect(
page.getByText(
productData[ productType ].shortDescription
)
page
.getByText(
productData[ productType ].shortDescription
)
.first()
).toBeVisible();
await expect(
page.getByText( productData[ productType ].description )
page
.getByText( productData[ productType ].description )
.first()
).toBeVisible();
await expect(
page.getByText( `SKU: ${ productData[ productType ].sku }` )