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
Changes from 2 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
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 @@
};

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 @@
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,37 @@
).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',
} );
} );
// 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();

Check failure on line 128 in plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js

View workflow job for this annotation

GitHub Actions / Runs E2E tests with HPOS disabled. (2, 2/5)

[Chrome] › merchant/order-emails.spec.js:100:2 › Merchant > Order Action emails received › can receive cancelled order email

1) [Chrome] › merchant/order-emails.spec.js:100:2 › Merchant > Order Action emails received › can receive cancelled order email Error: Timed out 20000ms waiting for expect(locator).toBeVisible() Locator: getByText('[WooCommerce Core E2E Test Suite]: Order #54 has been cancelled') Expected: visible Received: hidden Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByText('[WooCommerce Core E2E Test Suite]: Order #54 has been cancelled') 126 | `[${ storeName }]: Order #${ cancelledOrderId } has been cancelled` 127 | ) > 128 | ).toBeVisible(); | ^ 129 | } ); 130 | 131 | test( 'can resend new order notification', async ( { page } ) => { at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js:128:5

Check failure on line 128 in plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js

View workflow job for this annotation

GitHub Actions / Runs E2E tests with HPOS disabled. (2, 2/5)

[Chrome] › merchant/order-emails.spec.js:100:2 › Merchant > Order Action emails received › can receive cancelled order email

1) [Chrome] › merchant/order-emails.spec.js:100:2 › Merchant > Order Action emails received › can receive cancelled order email Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 20000ms waiting for expect(locator).toBeVisible() Locator: getByText('[WooCommerce Core E2E Test Suite]: Order #56 has been cancelled') Expected: visible Received: hidden Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByText('[WooCommerce Core E2E Test Suite]: Order #56 has been cancelled') 126 | `[${ storeName }]: Order #${ cancelledOrderId } has been cancelled` 127 | ) > 128 | ).toBeVisible(); | ^ 129 | } ); 130 | 131 | test( 'can resend new order notification', async ( { page } ) => { at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js:128:5

Check failure on line 128 in plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js

View workflow job for this annotation

GitHub Actions / Runs E2E tests with HPOS disabled. (2, 2/5)

[Chrome] › merchant/order-emails.spec.js:100:2 › Merchant > Order Action emails received › can receive cancelled order email

1) [Chrome] › merchant/order-emails.spec.js:100:2 › Merchant > Order Action emails received › can receive cancelled order email Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 20000ms waiting for expect(locator).toBeVisible() Locator: getByText('[WooCommerce Core E2E Test Suite]: Order #58 has been cancelled') Expected: visible Received: hidden Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByText('[WooCommerce Core E2E Test Suite]: Order #58 has been cancelled') 126 | `[${ storeName }]: Order #${ cancelledOrderId } has been cancelled` 127 | ) > 128 | ).toBeVisible(); | ^ 129 | } ); 130 | 131 | test( 'can resend new order notification', async ( { page } ) => { at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js:128:5

Check failure on line 128 in plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js

View workflow job for this annotation

GitHub Actions / Runs E2E tests in matrix. (2, 2/5)

[Chrome] › merchant/order-emails.spec.js:100:2 › Merchant > Order Action emails received › can receive cancelled order email

1) [Chrome] › merchant/order-emails.spec.js:100:2 › Merchant > Order Action emails received › can receive cancelled order email Error: Timed out 20000ms waiting for expect(locator).toBeVisible() Locator: getByText('[WooCommerce Core E2E Test Suite]: Order #54 has been cancelled') Expected: visible Received: hidden Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByText('[WooCommerce Core E2E Test Suite]: Order #54 has been cancelled') 126 | `[${ storeName }]: Order #${ cancelledOrderId } has been cancelled` 127 | ) > 128 | ).toBeVisible(); | ^ 129 | } ); 130 | 131 | test( 'can resend new order notification', async ( { page } ) => { at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js:128:5

Check failure on line 128 in plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js

View workflow job for this annotation

GitHub Actions / Runs E2E tests in matrix. (2, 2/5)

[Chrome] › merchant/order-emails.spec.js:100:2 › Merchant > Order Action emails received › can receive cancelled order email

1) [Chrome] › merchant/order-emails.spec.js:100:2 › Merchant > Order Action emails received › can receive cancelled order email Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 20000ms waiting for expect(locator).toBeVisible() Locator: getByText('[WooCommerce Core E2E Test Suite]: Order #56 has been cancelled') Expected: visible Received: hidden Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByText('[WooCommerce Core E2E Test Suite]: Order #56 has been cancelled') 126 | `[${ storeName }]: Order #${ cancelledOrderId } has been cancelled` 127 | ) > 128 | ).toBeVisible(); | ^ 129 | } ); 130 | 131 | test( 'can resend new order notification', async ( { page } ) => { at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js:128:5

Check failure on line 128 in plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js

View workflow job for this annotation

GitHub Actions / Runs E2E tests in matrix. (2, 2/5)

[Chrome] › merchant/order-emails.spec.js:100:2 › Merchant > Order Action emails received › can receive cancelled order email

1) [Chrome] › merchant/order-emails.spec.js:100:2 › Merchant > Order Action emails received › can receive cancelled order email Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 20000ms waiting for expect(locator).toBeVisible() Locator: getByText('[WooCommerce Core E2E Test Suite]: Order #58 has been cancelled') Expected: visible Received: hidden Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByText('[WooCommerce Core E2E Test Suite]: Order #58 has been cancelled') 126 | `[${ storeName }]: Order #${ cancelledOrderId } has been cancelled` 127 | ) > 128 | ).toBeVisible(); | ^ 129 | } ); 130 | 131 | test( 'can resend new order notification', async ( { page } ) => { at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/order-emails.spec.js:128:5
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