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:
parent
ae92dafea3
commit
185cd3dcaa
|
@ -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
|
|
@ -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 },
|
||||
|
|
Loading…
Reference in New Issue