Update playwright api-core-tests to associate orders with real products to prevent extension issues for those that validate product ids (#37243)

* Update playwright api-core-tests to associate orders with real products to prevent extension issues for those that validate product ids

* add newline at end of file

* add comment
This commit is contained in:
nigeljamesstevenson 2023-03-20 20:23:23 +00:00 committed by GitHub
parent ae92dafea3
commit 185cd3dcaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Update playwright api-core-tests to associate orders with real products to prevent extension issues for those that validate product ids

View File

@ -2,6 +2,9 @@ const { test, expect } = require( '@playwright/test' );
const { getOrderExampleSearchTest } = require( '../../data/order' );
const { customerShippingSearchTest } = require( '../../data/shared/customer' );
const {
simpleProduct,
} = require('../../data/products-crud');
/**
* Order to be searched
@ -55,6 +58,15 @@ const searchParams = [
*/
test.describe( 'Order Search API tests', () => {
test.beforeAll( async ( { request } ) => {
// Create a product to be associated with the order
const productResponse = await request.post('wp-json/wc/v3/products', {
data: simpleProduct,
});
const productResponseJSON = await productResponse.json();
// Save the created product id against the order line_items
order.line_items[0].product_id = productResponseJSON.id;
// Create an order and save its ID
const response = await request.post( '/wp-json/wc/v3/orders', {
data: order,
@ -64,6 +76,10 @@ test.describe( 'Order Search API tests', () => {
} );
test.afterAll( async ( { request } ) => {
// Cleanup: Delete the product
await request.delete( `/wp-json/wc/v3/products/${ order.line_items[0].product_id }`, {
data: { force: true },
} );
// Cleanup: Delete the order
await request.delete( `/wp-json/wc/v3/orders/${ order.id }`, {
data: { force: true },