Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[e2e] Check email for cancelled order #43985

Merged
merged 6 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions plugins/woocommerce/changelog/43985-e2e-email-cancelled-order
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Add new "can receive cancelled order email" test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
const { test, expect } = require( '@playwright/test' );
const { admin } = require( '../../test-data/data' );
const wcApi = require( '@woocommerce/woocommerce-rest-api' ).default;
Expand All @@ -10,7 +11,7 @@ test.describe( 'Merchant > Order Action emails received', () => {
};

const storeName = 'WooCommerce Core E2E Test Suite';
let orderId, newOrderId;
let orderId, newOrderId, cancelledOrderId;

test.beforeAll( async ( { baseURL } ) => {
const api = new wcApi( {
Expand Down Expand Up @@ -60,7 +61,9 @@ test.describe( 'Merchant > Order Action emails received', () => {
version: 'wc/v3',
} );

await api.post( `orders/batch`, { delete: [ orderId, newOrderId ] } );
await api.post( `orders/batch`, {
delete: [ orderId, newOrderId, cancelledOrderId ],
} );
} );

test( 'can receive new order email', async ( { page, baseURL } ) => {
Expand Down Expand Up @@ -94,6 +97,38 @@ test.describe( 'Merchant > Order Action emails received', () => {
).toContainText( `[${ storeName }]: New order #${ newOrderId }` );
} );

test( 'can receive cancelled order email', async ( { page, baseURL } ) => {
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 ) => {
cancelledOrderId = response.data.id;
api.put( `orders/${ cancelledOrderId }`, {
status: 'cancelled',
} );
} );
await page.waitForTimeout( 1000 );
// 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.getByText(
`[${ storeName }]: Order #${ cancelledOrderId } has been cancelled`
)
).toBeVisible();
Comment on lines +125 to +129
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lanej0 👋 This same approach can be used in the test above, can receive new order email. If this looks good to you and the team, I can also update other tests.

} );

test( 'can resend new order notification', async ( { page } ) => {
// resend the new order notification
await page.goto( `wp-admin/post.php?post=${ orderId }&action=edit` );
Expand Down