[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:
parent
6b5dbbc6ac
commit
9c514b3949
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: update
|
||||||
|
|
||||||
|
Expand the e2e suite we're running on WPCOM part #4.
|
|
@ -45,6 +45,16 @@ config = {
|
||||||
'**/merchant/settings-woo-com.spec.js',
|
'**/merchant/settings-woo-com.spec.js',
|
||||||
'**/merchant/users-create.spec.js',
|
'**/merchant/users-create.spec.js',
|
||||||
'**/merchant/users-manage.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/,
|
grepInvert: /@skip-on-default-wpcom/,
|
||||||
},
|
},
|
||||||
|
|
|
@ -119,40 +119,50 @@ test.describe(
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test( 'can remove a coupon', async ( { page } ) => {
|
test(
|
||||||
await page.goto(
|
'can remove a coupon',
|
||||||
`/wp-admin/admin.php?page=wc-orders&action=edit&id=${ orderId }`
|
{ tag: [ '@skip-on-default-wpcom' ] },
|
||||||
);
|
async ( { page } ) => {
|
||||||
// assert that there is a coupon on the order
|
await page.goto(
|
||||||
await expect(
|
`/wp-admin/admin.php?page=wc-orders&action=edit&id=${ orderId }`
|
||||||
page
|
);
|
||||||
.locator( '#woocommerce-order-items li' )
|
// assert that there is a coupon on the order
|
||||||
.filter( { hasText: couponCode } )
|
await expect(
|
||||||
).toBeVisible();
|
page
|
||||||
await expect(
|
.locator( '#woocommerce-order-items li' )
|
||||||
page.getByRole( 'cell', { name: 'Coupon(s)' } )
|
.filter( { hasText: couponCode } )
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole( 'cell', { name: `- $${ couponAmount }.00` } )
|
page.getByRole( 'cell', { name: 'Coupon(s)' } )
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole( 'cell', {
|
page.getByRole( 'cell', {
|
||||||
name: `$${ discountedPrice }`,
|
name: `- $${ couponAmount }.00`,
|
||||||
exact: true,
|
} )
|
||||||
} )
|
).toBeVisible();
|
||||||
).toBeVisible();
|
await expect(
|
||||||
// remove the coupon
|
page.getByRole( 'cell', {
|
||||||
await page.locator( 'a.remove-coupon' ).dispatchEvent( 'click' ); // have to use dispatchEvent because nothing visible to click on
|
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
|
// make sure the coupon was removed
|
||||||
await expect(
|
await expect(
|
||||||
page.locator( '.wc_coupon_list li', { hasText: couponCode } )
|
page.locator( '.wc_coupon_list li', {
|
||||||
).toBeHidden();
|
hasText: couponCode,
|
||||||
await expect(
|
} )
|
||||||
page
|
).toBeHidden();
|
||||||
.getByRole( 'cell', { name: `$${ productPrice }` } )
|
await expect(
|
||||||
.nth( 1 )
|
page
|
||||||
).toBeVisible();
|
.getByRole( 'cell', { name: `$${ productPrice }` } )
|
||||||
} );
|
.nth( 1 )
|
||||||
|
).toBeVisible();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -71,69 +71,9 @@ test.describe(
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test(
|
test( 'can receive new order email', async ( { page, baseURL } ) => {
|
||||||
'can receive new order email',
|
// New order emails are sent automatically when we create a simple order. Verify that we get these.
|
||||||
{ tag: '@skip-on-default-pressable' },
|
// Need to create a new order for this test because we clear logs before each run.
|
||||||
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(
|
|
||||||
'You’ve 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';
|
|
||||||
const api = new wcApi( {
|
const api = new wcApi( {
|
||||||
url: baseURL,
|
url: baseURL,
|
||||||
consumerKey: process.env.CONSUMER_KEY,
|
consumerKey: process.env.CONSUMER_KEY,
|
||||||
|
@ -142,55 +82,112 @@ test.describe(
|
||||||
} );
|
} );
|
||||||
await api
|
await api
|
||||||
.post( 'orders', {
|
.post( 'orders', {
|
||||||
status: 'completed',
|
status: 'processing',
|
||||||
billing: customerBilling,
|
billing: customerBilling,
|
||||||
} )
|
} )
|
||||||
.then( ( response ) => {
|
.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(
|
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
|
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(
|
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();
|
).toBeVisible();
|
||||||
|
await expect(
|
||||||
// Enter email log and select to view the content in JSON
|
page.getByText( 'Subject [WooCommerce Core E2E' )
|
||||||
await page.click( 'button[title^="View log"]' );
|
).toBeVisible();
|
||||||
await page.locator( emailContentJson ).click();
|
await page.getByRole( 'link', { name: 'json' } ).click();
|
||||||
|
await expect(
|
||||||
// Verify that the message includes an order processing confirmation
|
page.locator( '#wp-mail-logging-modal-content-body-content' )
|
||||||
await expect( page.locator( emailContent ) ).toContainText(
|
).toContainText( 'You’ve received the following order from :' );
|
||||||
'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 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 ( {
|
test( 'can receive cancelled order email', async ( {
|
||||||
page,
|
page,
|
||||||
baseURL,
|
baseURL,
|
||||||
|
|
|
@ -87,8 +87,8 @@ const wcPages = [
|
||||||
{
|
{
|
||||||
name: 'Overview',
|
name: 'Overview',
|
||||||
heading: 'Overview',
|
heading: 'Overview',
|
||||||
element: '.woocommerce-marketing-card-header-description',
|
element: '.woocommerce-marketing-channels-card',
|
||||||
text: 'Start by adding a channel to your store',
|
text: 'Channels',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Coupons',
|
name: 'Coupons',
|
||||||
|
@ -201,29 +201,31 @@ for ( const currentPage of wcPages ) {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
for ( let i = 0; i < currentPage.subpages.length; i++ ) {
|
for ( let i = 0; i < currentPage.subpages.length; i++ ) {
|
||||||
test( `Can load ${ currentPage.subpages[ i ].name }`, async ( {
|
test(
|
||||||
page,
|
`Can load ${ currentPage.subpages[ i ].name }`,
|
||||||
} ) => {
|
{ tag: '@skip-on-default-wpcom' },
|
||||||
await page
|
async ( { page } ) => {
|
||||||
.locator(
|
await page
|
||||||
`li.wp-menu-open > ul.wp-submenu > li a:text-is("${ currentPage.subpages[ i ].name }")`
|
.locator(
|
||||||
)
|
`li.wp-menu-open > ul.wp-submenu > li a:text-is("${ currentPage.subpages[ i ].name }")`
|
||||||
.click();
|
)
|
||||||
|
.click();
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
page.locator( 'h1.components-text' )
|
page.locator( 'h1.components-text' )
|
||||||
).toContainText( currentPage.subpages[ i ].heading );
|
).toContainText( currentPage.subpages[ i ].heading );
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
page
|
page
|
||||||
.locator( currentPage.subpages[ i ].element )
|
.locator( currentPage.subpages[ i ].element )
|
||||||
.first()
|
.first()
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
page.locator( currentPage.subpages[ i ].element )
|
page.locator( currentPage.subpages[ i ].element )
|
||||||
).toContainText( currentPage.subpages[ i ].text );
|
).toContainText( currentPage.subpages[ i ].text );
|
||||||
} );
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -96,7 +96,10 @@ for ( const productType of Object.keys( productData ) ) {
|
||||||
await page
|
await page
|
||||||
.getByLabel( 'Regular price ($)' )
|
.getByLabel( 'Regular price ($)' )
|
||||||
.fill( productData[ productType ].regularPrice );
|
.fill( productData[ productType ].regularPrice );
|
||||||
await page.getByText( 'Inventory' ).click();
|
await page
|
||||||
|
.getByRole( 'link' )
|
||||||
|
.filter( { hasText: 'Inventory' } )
|
||||||
|
.click();
|
||||||
|
|
||||||
// Inventory information
|
// Inventory information
|
||||||
await page
|
await page
|
||||||
|
@ -130,7 +133,10 @@ for ( const productType of Object.keys( productData ) ) {
|
||||||
|
|
||||||
await test.step( 'add product advanced information', async () => {
|
await test.step( 'add product advanced information', async () => {
|
||||||
// Advanced information
|
// Advanced information
|
||||||
await page.getByText( 'Advanced' ).click();
|
await page
|
||||||
|
.getByRole( 'link' )
|
||||||
|
.filter( { hasText: 'Advanced' } )
|
||||||
|
.click();
|
||||||
await page
|
await page
|
||||||
.getByLabel( 'Purchase note' )
|
.getByLabel( 'Purchase note' )
|
||||||
.fill( productData[ productType ].purchaseNote );
|
.fill( productData[ productType ].purchaseNote );
|
||||||
|
@ -265,12 +271,16 @@ for ( const productType of Object.keys( productData ) ) {
|
||||||
|
|
||||||
// Verify description
|
// Verify description
|
||||||
await expect(
|
await expect(
|
||||||
page.getByText(
|
page
|
||||||
productData[ productType ].shortDescription
|
.getByText(
|
||||||
)
|
productData[ productType ].shortDescription
|
||||||
|
)
|
||||||
|
.first()
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
await expect(
|
await expect(
|
||||||
page.getByText( productData[ productType ].description )
|
page
|
||||||
|
.getByText( productData[ productType ].description )
|
||||||
|
.first()
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
await expect(
|
await expect(
|
||||||
page.getByText( `SKU: ${ productData[ productType ].sku }` )
|
page.getByText( `SKU: ${ productData[ productType ].sku }` )
|
||||||
|
|
Loading…
Reference in New Issue