Skip to content

Commit

Permalink
[e2e] Check email for cancelled order (#43985)
Browse files Browse the repository at this point in the history
* Add new "can receive cancelled order email" test

* Add new "can receive cancelled order email" test

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

* temp: wait for 1s

* temp: wait for 1s

* Revert changes introduced in 5aa5013

---------

Co-authored-by: github-actions <github-actions@github.com>
  • Loading branch information
Stojdza and github-actions committed Jan 26, 2024
1 parent 5e87527 commit 324b816
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
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();
} );

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

0 comments on commit 324b816

Please sign in to comment.