skip k6 api order RUD tests on non-existant order when C test fails (#37739)

This commit is contained in:
nigeljamesstevenson 2023-04-18 16:58:44 +01:00 committed by GitHub
commit 4a6b5ac0cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 47 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
skip k6 api order RUD tests on non-existant order when C test fails

View File

@ -92,62 +92,70 @@ export function ordersAPI() {
} );
group( 'API Retrieve Order', function () {
response = http.get(
`${ base_url }/wp-json/wc/v3/orders/${ post_id }`,
{
headers: requestHeaders,
tags: { name: 'API - Retrieve Order' },
}
);
check( response, {
'status is 200': ( r ) => r.status === 200,
'body contains: Order ID': ( response ) =>
response.body.includes( `"id":${ post_id }` ),
} );
if ( post_id ) {
response = http.get(
`${ base_url }/wp-json/wc/v3/orders/${ post_id }`,
{
headers: requestHeaders,
tags: { name: 'API - Retrieve Order' },
}
);
check( response, {
'status is 200': ( r ) => r.status === 200,
'body contains: Order ID': ( response ) =>
response.body.includes( `"id":${ post_id }` ),
} );
}
} );
group( 'API List Orders', function () {
response = http.get( `${ base_url }/wp-json/wc/v3/orders`, {
headers: requestHeaders,
tags: { name: 'API - List Orders' },
} );
check( response, {
'status is 200': ( r ) => r.status === 200,
'body contains: Order ID': ( response ) =>
response.body.includes( '[{"id":' ),
} );
if ( post_id ) {
response = http.get( `${ base_url }/wp-json/wc/v3/orders`, {
headers: requestHeaders,
tags: { name: 'API - List Orders' },
} );
check( response, {
'status is 200': ( r ) => r.status === 200,
'body contains: Order ID': ( response ) =>
response.body.includes( '[{"id":' ),
} );
}
} );
group( 'API Update Order', function () {
response = http.put(
`${ base_url }/wp-json/wc/v3/orders/${ post_id }`,
JSON.stringify( updateData ),
{
headers: requestHeaders,
tags: { name: 'API - Update Order (Status)' },
}
);
check( response, {
'status is 200': ( r ) => r.status === 200,
"body contains: 'Completed' Status": ( response ) =>
response.body.includes( '"status":"completed"' ),
} );
if ( post_id ) {
response = http.put(
`${ base_url }/wp-json/wc/v3/orders/${ post_id }`,
JSON.stringify( updateData ),
{
headers: requestHeaders,
tags: { name: 'API - Update Order (Status)' },
}
);
check( response, {
'status is 200': ( r ) => r.status === 200,
"body contains: 'Completed' Status": ( response ) =>
response.body.includes( '"status":"completed"' ),
} );
}
} );
group( 'API Delete Order', function () {
response = http.del(
`${ base_url }/wp-json/wc/v3/orders/${ post_id }`,
JSON.stringify( { force: true } ),
{
headers: requestHeaders,
tags: { name: 'API - Delete Order' },
}
);
check( response, {
'status is 200': ( r ) => r.status === 200,
'body contains: Order ID': ( response ) =>
response.body.includes( `"id":${ post_id }` ),
} );
if ( post_id ) {
response = http.del(
`${ base_url }/wp-json/wc/v3/orders/${ post_id }`,
JSON.stringify( { force: true } ),
{
headers: requestHeaders,
tags: { name: 'API - Delete Order' },
}
);
check( response, {
'status is 200': ( r ) => r.status === 200,
'body contains: Order ID': ( response ) =>
response.body.includes( `"id":${ post_id }` ),
} );
}
} );
group( 'API Batch Create Orders', function () {