[k6 tests] Fix broken perf tests - updated page titles (#51173)
This commit is contained in:
parent
d2fb60a5d1
commit
61d41adf79
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: dev
|
||||
|
||||
|
|
@ -2,6 +2,9 @@
|
|||
export const base_url = __ENV.URL || 'http://localhost:8086';
|
||||
export const base_host = __ENV.HOST || 'localhost:8086';
|
||||
|
||||
export const STORE_NAME = __ENV.STORE_NAME || 'WooCommerce Core E2E Test Suite';
|
||||
export const FOOTER_TEXT = 'Built with WooCommerce';
|
||||
|
||||
export const admin_username = __ENV.A_USER || 'admin';
|
||||
export const admin_password = __ENV.A_PW || 'password';
|
||||
export const admin_acc_login = __ENV.A_ACC_LOGIN || false;
|
||||
|
|
|
@ -1,73 +1,76 @@
|
|||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { base_host, base_url } from './config.js';
|
||||
|
||||
const htmlRequestHeader = {
|
||||
accept:
|
||||
'text/html,application/xhtml+xml,application/xml;' +
|
||||
'q=0.9,image/avif,image/webp,image/apng,*/*;' +
|
||||
'q=0.8,application/signed-exchange;v=b3;q=0.9'
|
||||
};
|
||||
accept:
|
||||
'text/html,application/xhtml+xml,application/xml;' +
|
||||
'q=0.9,image/avif,image/webp,image/apng,*/*;' +
|
||||
'q=0.8,application/signed-exchange;v=b3;q=0.9',
|
||||
};
|
||||
|
||||
const jsonRequestHeader = {
|
||||
accept: 'application/json, text/javascript, */*; q=0.01'
|
||||
};
|
||||
accept: 'application/json, text/javascript, */*; q=0.01',
|
||||
};
|
||||
|
||||
const jsonAPIRequestHeader = {
|
||||
accept: 'application/json, */*;q=0.1'
|
||||
};
|
||||
accept: 'application/json, */*;q=0.1',
|
||||
};
|
||||
|
||||
const allRequestHeader = {
|
||||
accept: '*//*'
|
||||
};
|
||||
accept: '*//*',
|
||||
};
|
||||
|
||||
const commonRequestHeaders = {
|
||||
'accept-language': 'en-US,en;q=0.9'
|
||||
};
|
||||
'accept-language': 'en-US,en;q=0.9',
|
||||
};
|
||||
|
||||
const commonGetRequestHeaders = {
|
||||
connection: 'keep-alive',
|
||||
host: `${base_host}`,
|
||||
'sec-fetch-dest': 'document',
|
||||
'sec-fetch-mode': 'navigate',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
'sec-fetch-user': '?1',
|
||||
'upgrade-insecure-requests': '1'
|
||||
};
|
||||
connection: 'keep-alive',
|
||||
host: `${ base_host }`,
|
||||
'sec-fetch-dest': 'document',
|
||||
'sec-fetch-mode': 'navigate',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
'sec-fetch-user': '?1',
|
||||
'upgrade-insecure-requests': '1',
|
||||
};
|
||||
|
||||
const commonAPIGetRequestHeaders = {
|
||||
connection: 'keep-alive',
|
||||
host: `${base_host}`,
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
};
|
||||
connection: 'keep-alive',
|
||||
host: `${ base_host }`,
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
};
|
||||
|
||||
const contentTypeRequestHeader = {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
};
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
};
|
||||
|
||||
const commonPostRequestHeaders = {
|
||||
origin: `${base_url}`,
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
'x-requested-with': 'XMLHttpRequest'
|
||||
};
|
||||
origin: `${ base_url }`,
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
'x-requested-with': 'XMLHttpRequest',
|
||||
};
|
||||
|
||||
const commonNonStandardHeaders = {
|
||||
'sec-ch-ua':
|
||||
'" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
|
||||
'sec-ch-ua-mobile': '?0'
|
||||
};
|
||||
'sec-ch-ua':
|
||||
'" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
};
|
||||
|
||||
export {
|
||||
htmlRequestHeader,
|
||||
jsonRequestHeader,
|
||||
jsonAPIRequestHeader,
|
||||
allRequestHeader,
|
||||
commonRequestHeaders,
|
||||
commonGetRequestHeaders,
|
||||
commonAPIGetRequestHeaders,
|
||||
contentTypeRequestHeader,
|
||||
commonPostRequestHeaders,
|
||||
commonNonStandardHeaders,
|
||||
htmlRequestHeader,
|
||||
jsonRequestHeader,
|
||||
jsonAPIRequestHeader,
|
||||
allRequestHeader,
|
||||
commonRequestHeaders,
|
||||
commonGetRequestHeaders,
|
||||
commonAPIGetRequestHeaders,
|
||||
contentTypeRequestHeader,
|
||||
commonPostRequestHeaders,
|
||||
commonNonStandardHeaders,
|
||||
};
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable import/no-unresolved */
|
||||
/**
|
||||
* External dependencies
|
||||
|
@ -65,17 +64,15 @@ if ( hpos_status === true ) {
|
|||
} else {
|
||||
admin_new_order_base = 'post-new.php?post_type=shop_order';
|
||||
admin_update_order_base = 'post.php';
|
||||
admin_new_order_assert = 'Add new order</h1>';
|
||||
admin_new_order_assert = 'Add new order';
|
||||
admin_open_order_assert = 'Edit order</h1>';
|
||||
admin_created_order_assert = 'Order updated.';
|
||||
admin_update_order_assert = 'Order updated.';
|
||||
}
|
||||
|
||||
const date = new Date();
|
||||
const order_date = date.toJSON().slice( 0, 10 );
|
||||
const global_order_date = new Date().toJSON().slice( 0, 10 );
|
||||
|
||||
export function addOrder( includeTests = {} ) {
|
||||
let response;
|
||||
let ajax_nonce_add_meta;
|
||||
let wpnonce;
|
||||
let closed_postboxes_nonce;
|
||||
|
@ -87,7 +84,8 @@ export function addOrder( includeTests = {} ) {
|
|||
let api_x_wp_nonce;
|
||||
let apiNonceHeader;
|
||||
let heartbeat_nonce;
|
||||
let includedTests = Object.assign( {
|
||||
const includedTests = Object.assign(
|
||||
{
|
||||
create: true,
|
||||
heartbeat: true,
|
||||
open: true,
|
||||
|
@ -106,7 +104,7 @@ export function addOrder( includeTests = {} ) {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get(
|
||||
const response = http.get(
|
||||
`${ base_url }/wp-admin/${ admin_new_order_base }`,
|
||||
{
|
||||
headers: requestHeaders,
|
||||
|
@ -115,8 +113,8 @@ export function addOrder( includeTests = {} ) {
|
|||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
"body contains: 'Add new order' header": ( response ) =>
|
||||
response.body.includes( `${ admin_new_order_assert }` ),
|
||||
"body contains: 'Add new order' header": ( r ) =>
|
||||
r.body.includes( `${ admin_new_order_assert }` ),
|
||||
} );
|
||||
|
||||
// Correlate nonce values for use in subsequent requests.
|
||||
|
@ -190,18 +188,18 @@ export function addOrder( includeTests = {} ) {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get(
|
||||
const tasksResponse = http.get(
|
||||
`${ base_url }/wp-json/wc-admin/onboarding/tasks?_locale=user`,
|
||||
{
|
||||
headers: requestHeaders,
|
||||
tags: { name: 'Merchant - wc-admin/onboarding/tasks?' },
|
||||
}
|
||||
);
|
||||
check( response, {
|
||||
check( tasksResponse, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
} );
|
||||
|
||||
response = http.get(
|
||||
const notesResponse = http.get(
|
||||
`${ base_url }/wp-json/wc-analytics/admin/notes?page=1&per_page=25&` +
|
||||
`type=error%2Cupdate&status=unactioned&_locale=user`,
|
||||
{
|
||||
|
@ -209,11 +207,11 @@ export function addOrder( includeTests = {} ) {
|
|||
tags: { name: 'Merchant - wc-analytics/admin/notes?' },
|
||||
}
|
||||
);
|
||||
check( response, {
|
||||
check( notesResponse, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
} );
|
||||
|
||||
response = http.get(
|
||||
const optionsResponse = http.get(
|
||||
`${ base_url }/wp-json/wc-admin/options?options=woocommerce_ces_tracks_queue&_locale=user`,
|
||||
{
|
||||
headers: requestHeaders,
|
||||
|
@ -222,7 +220,7 @@ export function addOrder( includeTests = {} ) {
|
|||
},
|
||||
}
|
||||
);
|
||||
check( response, {
|
||||
check( optionsResponse, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
} );
|
||||
} );
|
||||
|
@ -239,7 +237,7 @@ export function addOrder( includeTests = {} ) {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.post(
|
||||
const response = http.post(
|
||||
`${ base_url }/wp-admin/admin-ajax.php`,
|
||||
`_nonce=${ heartbeat_nonce }&action=heartbeat&has_focus=true&interval=15&screen_id=shop_order`,
|
||||
{
|
||||
|
@ -252,7 +250,9 @@ export function addOrder( includeTests = {} ) {
|
|||
} );
|
||||
} );
|
||||
|
||||
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
|
||||
sleep(
|
||||
randomIntBetween( `${ think_time_min }`, `${ think_time_max }` )
|
||||
);
|
||||
}
|
||||
|
||||
if ( includedTests.create ) {
|
||||
|
@ -266,13 +266,18 @@ export function addOrder( includeTests = {} ) {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
const date = new Date();
|
||||
const order_date = date.toJSON().slice( 0, 10 );
|
||||
const order_date = new Date().toJSON().slice( 0, 10 );
|
||||
|
||||
const orderParams = new URLSearchParams( [
|
||||
[ '_ajax_nonce-add-meta', `${ ajax_nonce_add_meta }` ],
|
||||
[ '_billing_address_1', `${ addresses_guest_billing_address_1 }` ],
|
||||
[ '_billing_address_2', `${ addresses_guest_billing_address_2 }` ],
|
||||
[
|
||||
'_billing_address_1',
|
||||
`${ addresses_guest_billing_address_1 }`,
|
||||
],
|
||||
[
|
||||
'_billing_address_2',
|
||||
`${ addresses_guest_billing_address_2 }`,
|
||||
],
|
||||
[ '_billing_city', `${ addresses_guest_billing_city }` ],
|
||||
[ '_billing_company', `${ addresses_guest_billing_company }` ],
|
||||
[ '_billing_country', `${ addresses_guest_billing_country }` ],
|
||||
|
@ -281,12 +286,24 @@ export function addOrder( includeTests = {} ) {
|
|||
'_billing_first_name',
|
||||
`${ addresses_guest_billing_first_name }`,
|
||||
],
|
||||
[ '_billing_last_name', `${ addresses_guest_billing_last_name }` ],
|
||||
[
|
||||
'_billing_last_name',
|
||||
`${ addresses_guest_billing_last_name }`,
|
||||
],
|
||||
[ '_billing_phone', `${ addresses_guest_billing_phone }` ],
|
||||
[ '_billing_postcode', `${ addresses_guest_billing_postcode }` ],
|
||||
[
|
||||
'_billing_postcode',
|
||||
`${ addresses_guest_billing_postcode }`,
|
||||
],
|
||||
[ '_billing_state', `${ addresses_guest_billing_state }` ],
|
||||
[ '_shipping_address_1', `${ addresses_guest_billing_address_1 }` ],
|
||||
[ '_shipping_address_2', `${ addresses_guest_billing_address_2 }` ],
|
||||
[
|
||||
'_shipping_address_1',
|
||||
`${ addresses_guest_billing_address_1 }`,
|
||||
],
|
||||
[
|
||||
'_shipping_address_2',
|
||||
`${ addresses_guest_billing_address_2 }`,
|
||||
],
|
||||
[ '_shipping_city', `${ addresses_guest_billing_city }` ],
|
||||
[ '_shipping_company', `${ addresses_guest_billing_company }` ],
|
||||
[ '_shipping_country', `${ addresses_guest_billing_country }` ],
|
||||
|
@ -294,9 +311,15 @@ export function addOrder( includeTests = {} ) {
|
|||
'_shipping_first_name',
|
||||
`${ addresses_guest_billing_first_name }`,
|
||||
],
|
||||
[ '_shipping_last_name', `${ addresses_guest_billing_last_name }` ],
|
||||
[
|
||||
'_shipping_last_name',
|
||||
`${ addresses_guest_billing_last_name }`,
|
||||
],
|
||||
[ '_shipping_phone', `${ addresses_guest_billing_phone }` ],
|
||||
[ '_shipping_postcode', `${ addresses_guest_billing_postcode }` ],
|
||||
[
|
||||
'_shipping_postcode',
|
||||
`${ addresses_guest_billing_postcode }`,
|
||||
],
|
||||
[ '_shipping_state', `${ addresses_guest_billing_state }` ],
|
||||
[ '_payment_method', `${ payment_method }` ],
|
||||
[ '_transaction_id', '' ],
|
||||
|
@ -337,8 +360,14 @@ export function addOrder( includeTests = {} ) {
|
|||
|
||||
const hposOrderParams = new URLSearchParams( [
|
||||
[ '_ajax_nonce-add-meta', `${ ajax_nonce_add_meta }` ],
|
||||
[ '_billing_address_1', `${ addresses_guest_billing_address_1 }` ],
|
||||
[ '_billing_address_2', `${ addresses_guest_billing_address_2 }` ],
|
||||
[
|
||||
'_billing_address_1',
|
||||
`${ addresses_guest_billing_address_1 }`,
|
||||
],
|
||||
[
|
||||
'_billing_address_2',
|
||||
`${ addresses_guest_billing_address_2 }`,
|
||||
],
|
||||
[ '_billing_city', `${ addresses_guest_billing_city }` ],
|
||||
[ '_billing_company', `${ addresses_guest_billing_company }` ],
|
||||
[ '_billing_country', `${ addresses_guest_billing_country }` ],
|
||||
|
@ -347,12 +376,24 @@ export function addOrder( includeTests = {} ) {
|
|||
'_billing_first_name',
|
||||
`${ addresses_guest_billing_first_name }`,
|
||||
],
|
||||
[ '_billing_last_name', `${ addresses_guest_billing_last_name }` ],
|
||||
[
|
||||
'_billing_last_name',
|
||||
`${ addresses_guest_billing_last_name }`,
|
||||
],
|
||||
[ '_billing_phone', `${ addresses_guest_billing_phone }` ],
|
||||
[ '_billing_postcode', `${ addresses_guest_billing_postcode }` ],
|
||||
[
|
||||
'_billing_postcode',
|
||||
`${ addresses_guest_billing_postcode }`,
|
||||
],
|
||||
[ '_billing_state', `${ addresses_guest_billing_state }` ],
|
||||
[ '_shipping_address_1', `${ addresses_guest_billing_address_1 }` ],
|
||||
[ '_shipping_address_2', `${ addresses_guest_billing_address_2 }` ],
|
||||
[
|
||||
'_shipping_address_1',
|
||||
`${ addresses_guest_billing_address_1 }`,
|
||||
],
|
||||
[
|
||||
'_shipping_address_2',
|
||||
`${ addresses_guest_billing_address_2 }`,
|
||||
],
|
||||
[ '_shipping_city', `${ addresses_guest_billing_city }` ],
|
||||
[ '_shipping_company', `${ addresses_guest_billing_company }` ],
|
||||
[ '_shipping_country', `${ addresses_guest_billing_country }` ],
|
||||
|
@ -360,9 +401,15 @@ export function addOrder( includeTests = {} ) {
|
|||
'_shipping_first_name',
|
||||
`${ addresses_guest_billing_first_name }`,
|
||||
],
|
||||
[ '_shipping_last_name', `${ addresses_guest_billing_last_name }` ],
|
||||
[
|
||||
'_shipping_last_name',
|
||||
`${ addresses_guest_billing_last_name }`,
|
||||
],
|
||||
[ '_shipping_phone', `${ addresses_guest_billing_phone }` ],
|
||||
[ '_shipping_postcode', `${ addresses_guest_billing_postcode }` ],
|
||||
[
|
||||
'_shipping_postcode',
|
||||
`${ addresses_guest_billing_postcode }`,
|
||||
],
|
||||
[ '_shipping_state', `${ addresses_guest_billing_state }` ],
|
||||
[ '_payment_method', `${ payment_method }` ],
|
||||
[ '_transaction_id', '' ],
|
||||
|
@ -397,7 +444,7 @@ export function addOrder( includeTests = {} ) {
|
|||
admin_update_order_params = orderParams.toString();
|
||||
}
|
||||
|
||||
response = http.post(
|
||||
const response = http.post(
|
||||
`${ base_url }/wp-admin/${ admin_update_order }`,
|
||||
admin_update_order_params.toString(),
|
||||
{
|
||||
|
@ -407,14 +454,16 @@ export function addOrder( includeTests = {} ) {
|
|||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
"body contains: 'Edit order' header": ( response ) =>
|
||||
response.body.includes( `${ admin_open_order_assert }` ),
|
||||
"body contains: 'Order updated' confirmation": ( response ) =>
|
||||
response.body.includes( `${ admin_created_order_assert }` ),
|
||||
"body contains: 'Edit order' header": ( r ) =>
|
||||
r.body.includes( `${ admin_open_order_assert }` ),
|
||||
"body contains: 'Order updated' confirmation": ( r ) =>
|
||||
r.body.includes( `${ admin_created_order_assert }` ),
|
||||
} );
|
||||
} );
|
||||
|
||||
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
|
||||
sleep(
|
||||
randomIntBetween( `${ think_time_min }`, `${ think_time_max }` )
|
||||
);
|
||||
}
|
||||
|
||||
if ( includedTests.open ) {
|
||||
|
@ -433,7 +482,7 @@ export function addOrder( includeTests = {} ) {
|
|||
admin_open_order_base = `${ admin_update_order_base }?post=${ post_id }`;
|
||||
}
|
||||
|
||||
response = http.get(
|
||||
const response = http.get(
|
||||
`${ base_url }/wp-admin/${ admin_open_order_base }&action=edit`,
|
||||
{
|
||||
headers: requestHeaders,
|
||||
|
@ -442,12 +491,14 @@ export function addOrder( includeTests = {} ) {
|
|||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
"body contains: 'Edit order' header": ( response ) =>
|
||||
response.body.includes( `${ admin_open_order_assert }` ),
|
||||
"body contains: 'Edit order' header": ( r ) =>
|
||||
r.body.includes( `${ admin_open_order_assert }` ),
|
||||
} );
|
||||
} );
|
||||
|
||||
sleep( randomIntBetween( `${ think_time_min }`, `${ think_time_max }` ) );
|
||||
sleep(
|
||||
randomIntBetween( `${ think_time_min }`, `${ think_time_max }` )
|
||||
);
|
||||
}
|
||||
|
||||
if ( includedTests.update ) {
|
||||
|
@ -463,8 +514,14 @@ export function addOrder( includeTests = {} ) {
|
|||
|
||||
const orderParams = new URLSearchParams( [
|
||||
[ '_ajax_nonce-add-meta', `${ ajax_nonce_add_meta }` ],
|
||||
[ '_billing_address_1', `${ addresses_guest_billing_address_1 }` ],
|
||||
[ '_billing_address_2', `${ addresses_guest_billing_address_2 }` ],
|
||||
[
|
||||
'_billing_address_1',
|
||||
`${ addresses_guest_billing_address_1 }`,
|
||||
],
|
||||
[
|
||||
'_billing_address_2',
|
||||
`${ addresses_guest_billing_address_2 }`,
|
||||
],
|
||||
[ '_billing_city', `${ addresses_guest_billing_city }` ],
|
||||
[ '_billing_company', `${ addresses_guest_billing_company }` ],
|
||||
[ '_billing_country', `${ addresses_guest_billing_country }` ],
|
||||
|
@ -473,12 +530,24 @@ export function addOrder( includeTests = {} ) {
|
|||
'_billing_first_name',
|
||||
`${ addresses_guest_billing_first_name }`,
|
||||
],
|
||||
[ '_billing_last_name', `${ addresses_guest_billing_last_name }` ],
|
||||
[
|
||||
'_billing_last_name',
|
||||
`${ addresses_guest_billing_last_name }`,
|
||||
],
|
||||
[ '_billing_phone', `${ addresses_guest_billing_phone }` ],
|
||||
[ '_billing_postcode', `${ addresses_guest_billing_postcode }` ],
|
||||
[
|
||||
'_billing_postcode',
|
||||
`${ addresses_guest_billing_postcode }`,
|
||||
],
|
||||
[ '_billing_state', `${ addresses_guest_billing_state }` ],
|
||||
[ '_shipping_address_1', `${ addresses_guest_billing_address_1 }` ],
|
||||
[ '_shipping_address_2', `${ addresses_guest_billing_address_2 }` ],
|
||||
[
|
||||
'_shipping_address_1',
|
||||
`${ addresses_guest_billing_address_1 }`,
|
||||
],
|
||||
[
|
||||
'_shipping_address_2',
|
||||
`${ addresses_guest_billing_address_2 }`,
|
||||
],
|
||||
[ '_shipping_city', `${ addresses_guest_billing_city }` ],
|
||||
[ '_shipping_company', `${ addresses_guest_billing_company }` ],
|
||||
[ '_shipping_country', `${ addresses_guest_billing_country }` ],
|
||||
|
@ -486,9 +555,15 @@ export function addOrder( includeTests = {} ) {
|
|||
'_shipping_first_name',
|
||||
`${ addresses_guest_billing_first_name }`,
|
||||
],
|
||||
[ '_shipping_last_name', `${ addresses_guest_billing_last_name }` ],
|
||||
[
|
||||
'_shipping_last_name',
|
||||
`${ addresses_guest_billing_last_name }`,
|
||||
],
|
||||
[ '_shipping_phone', `${ addresses_guest_billing_phone }` ],
|
||||
[ '_shipping_postcode', `${ addresses_guest_billing_postcode }` ],
|
||||
[
|
||||
'_shipping_postcode',
|
||||
`${ addresses_guest_billing_postcode }`,
|
||||
],
|
||||
[ '_shipping_state', `${ addresses_guest_billing_state }` ],
|
||||
[ '_payment_method', `${ payment_method }` ],
|
||||
[ '_transaction_id', '' ],
|
||||
|
@ -503,7 +578,7 @@ export function addOrder( includeTests = {} ) {
|
|||
[ 'metakeyinput', '' ],
|
||||
[ 'metakeyselect', '%23NONE%23' ],
|
||||
[ 'metavalue', '' ],
|
||||
[ 'order_date', `${ order_date }` ],
|
||||
[ 'order_date', `${ global_order_date }` ],
|
||||
[ 'order_date_hour', '01' ],
|
||||
[ 'order_date_minute', '01' ],
|
||||
[ 'order_date_second', '01' ],
|
||||
|
@ -528,8 +603,14 @@ export function addOrder( includeTests = {} ) {
|
|||
|
||||
const hposOrderParams = new URLSearchParams( [
|
||||
[ '_ajax_nonce-add-meta', `${ ajax_nonce_add_meta }` ],
|
||||
[ '_billing_address_1', `${ addresses_guest_billing_address_1 }` ],
|
||||
[ '_billing_address_2', `${ addresses_guest_billing_address_2 }` ],
|
||||
[
|
||||
'_billing_address_1',
|
||||
`${ addresses_guest_billing_address_1 }`,
|
||||
],
|
||||
[
|
||||
'_billing_address_2',
|
||||
`${ addresses_guest_billing_address_2 }`,
|
||||
],
|
||||
[ '_billing_city', `${ addresses_guest_billing_city }` ],
|
||||
[ '_billing_company', `${ addresses_guest_billing_company }` ],
|
||||
[ '_billing_country', `${ addresses_guest_billing_country }` ],
|
||||
|
@ -538,12 +619,24 @@ export function addOrder( includeTests = {} ) {
|
|||
'_billing_first_name',
|
||||
`${ addresses_guest_billing_first_name }`,
|
||||
],
|
||||
[ '_billing_last_name', `${ addresses_guest_billing_last_name }` ],
|
||||
[
|
||||
'_billing_last_name',
|
||||
`${ addresses_guest_billing_last_name }`,
|
||||
],
|
||||
[ '_billing_phone', `${ addresses_guest_billing_phone }` ],
|
||||
[ '_billing_postcode', `${ addresses_guest_billing_postcode }` ],
|
||||
[
|
||||
'_billing_postcode',
|
||||
`${ addresses_guest_billing_postcode }`,
|
||||
],
|
||||
[ '_billing_state', `${ addresses_guest_billing_state }` ],
|
||||
[ '_shipping_address_1', `${ addresses_guest_billing_address_1 }` ],
|
||||
[ '_shipping_address_2', `${ addresses_guest_billing_address_2 }` ],
|
||||
[
|
||||
'_shipping_address_1',
|
||||
`${ addresses_guest_billing_address_1 }`,
|
||||
],
|
||||
[
|
||||
'_shipping_address_2',
|
||||
`${ addresses_guest_billing_address_2 }`,
|
||||
],
|
||||
[ '_shipping_city', `${ addresses_guest_billing_city }` ],
|
||||
[ '_shipping_company', `${ addresses_guest_billing_company }` ],
|
||||
[ '_shipping_country', `${ addresses_guest_billing_country }` ],
|
||||
|
@ -551,9 +644,15 @@ export function addOrder( includeTests = {} ) {
|
|||
'_shipping_first_name',
|
||||
`${ addresses_guest_billing_first_name }`,
|
||||
],
|
||||
[ '_shipping_last_name', `${ addresses_guest_billing_last_name }` ],
|
||||
[
|
||||
'_shipping_last_name',
|
||||
`${ addresses_guest_billing_last_name }`,
|
||||
],
|
||||
[ '_shipping_phone', `${ addresses_guest_billing_phone }` ],
|
||||
[ '_shipping_postcode', `${ addresses_guest_billing_postcode }` ],
|
||||
[
|
||||
'_shipping_postcode',
|
||||
`${ addresses_guest_billing_postcode }`,
|
||||
],
|
||||
[ '_shipping_state', `${ addresses_guest_billing_state }` ],
|
||||
[ '_payment_method', `${ payment_method }` ],
|
||||
[ '_transaction_id', '' ],
|
||||
|
@ -564,7 +663,7 @@ export function addOrder( includeTests = {} ) {
|
|||
[ 'excerpt', '' ],
|
||||
[ 'metakeyinput', '' ],
|
||||
[ 'metavalue', '' ],
|
||||
[ 'order_date', `${ order_date }` ],
|
||||
[ 'order_date', `${ global_order_date }` ],
|
||||
[ 'order_date_hour', '01' ],
|
||||
[ 'order_date_minute', '01' ],
|
||||
[ 'order_date_second', '01' ],
|
||||
|
@ -588,7 +687,7 @@ export function addOrder( includeTests = {} ) {
|
|||
admin_update_order_id = `${ admin_open_order_base }`;
|
||||
}
|
||||
|
||||
response = http.post(
|
||||
const response = http.post(
|
||||
`${ base_url }/wp-admin/${ admin_update_order_id }`,
|
||||
admin_update_order_params.toString(),
|
||||
{
|
||||
|
@ -598,8 +697,8 @@ export function addOrder( includeTests = {} ) {
|
|||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
"body contains: 'Order updated' confirmation": ( response ) =>
|
||||
response.body.includes( `${ admin_update_order_assert }` ),
|
||||
"body contains: 'Order updated' confirmation": ( r ) =>
|
||||
r.body.includes( `${ admin_update_order_assert }` ),
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
@ -616,8 +715,7 @@ export function addOrder( includeTests = {} ) {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
const date = new Date();
|
||||
const order_date = date.toJSON().slice( 0, 10 );
|
||||
const order_date = new Date().toJSON().slice( 0, 10 );
|
||||
|
||||
const orderParams = new URLSearchParams( [
|
||||
[ '_ajax_nonce-add-meta', `${ ajax_nonce_add_meta }` ],
|
||||
|
@ -747,7 +845,7 @@ export function addOrder( includeTests = {} ) {
|
|||
admin_update_order_params = orderParams.toString();
|
||||
}
|
||||
|
||||
response = http.post(
|
||||
const response = http.post(
|
||||
`${ base_url }/wp-admin/${ admin_update_order }`,
|
||||
admin_update_order_params.toString(),
|
||||
{
|
||||
|
@ -757,10 +855,10 @@ export function addOrder( includeTests = {} ) {
|
|||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
"body contains: 'Edit order' header": ( response ) =>
|
||||
response.body.includes( `${ admin_open_order_assert }` ),
|
||||
"body contains: 'Order updated' confirmation": ( response ) =>
|
||||
response.body.includes( `${ admin_created_order_assert }` ),
|
||||
"body contains: 'Edit order' header": ( r ) =>
|
||||
r.body.includes( `${ admin_open_order_assert }` ),
|
||||
"body contains: 'Order updated' confirmation": ( r ) =>
|
||||
r.body.includes( `${ admin_created_order_assert }` ),
|
||||
} );
|
||||
} );
|
||||
|
||||
|
@ -781,7 +879,7 @@ export function addOrder( includeTests = {} ) {
|
|||
admin_open_order_base = `${ admin_update_order_base }?post=${ post_id }`;
|
||||
}
|
||||
|
||||
response = http.get(
|
||||
const response = http.get(
|
||||
`${ base_url }/wp-admin/${ admin_open_order_base }&action=edit`,
|
||||
{
|
||||
headers: requestHeaders,
|
||||
|
@ -790,8 +888,8 @@ export function addOrder( includeTests = {} ) {
|
|||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
"body contains: 'Edit order' header": ( response ) =>
|
||||
response.body.includes( `${ admin_open_order_assert }` ),
|
||||
"body contains: 'Edit order' header": ( r ) =>
|
||||
r.body.includes( `${ admin_open_order_assert }` ),
|
||||
} );
|
||||
} );
|
||||
|
||||
|
@ -849,7 +947,7 @@ export function addOrder( includeTests = {} ) {
|
|||
[ 'metakeyinput', '' ],
|
||||
[ 'metakeyselect', '%23NONE%23' ],
|
||||
[ 'metavalue', '' ],
|
||||
[ 'order_date', `${ order_date }` ],
|
||||
[ 'order_date', `${ global_order_date }` ],
|
||||
[ 'order_date_hour', '01' ],
|
||||
[ 'order_date_minute', '01' ],
|
||||
[ 'order_date_second', '01' ],
|
||||
|
@ -910,7 +1008,7 @@ export function addOrder( includeTests = {} ) {
|
|||
[ 'excerpt', '' ],
|
||||
[ 'metakeyinput', '' ],
|
||||
[ 'metavalue', '' ],
|
||||
[ 'order_date', `${ order_date }` ],
|
||||
[ 'order_date', `${ global_order_date }` ],
|
||||
[ 'order_date_hour', '01' ],
|
||||
[ 'order_date_minute', '01' ],
|
||||
[ 'order_date_second', '01' ],
|
||||
|
@ -934,7 +1032,7 @@ export function addOrder( includeTests = {} ) {
|
|||
admin_update_order_id = `${ admin_open_order_base }`;
|
||||
}
|
||||
|
||||
response = http.post(
|
||||
const response = http.post(
|
||||
`${ base_url }/wp-admin/${ admin_update_order_id }`,
|
||||
admin_update_order_params.toString(),
|
||||
{
|
||||
|
@ -944,11 +1042,11 @@ export function addOrder( includeTests = {} ) {
|
|||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
"body contains: 'Order updated' confirmation": ( response ) =>
|
||||
response.body.includes( `${ admin_update_order_assert }` ),
|
||||
"body contains: 'Order updated' confirmation": ( r ) =>
|
||||
r.body.includes( `${ admin_update_order_assert }` ),
|
||||
} );
|
||||
} );
|
||||
};
|
||||
}
|
||||
|
||||
export default function () {
|
||||
addOrder();
|
||||
|
|
|
@ -27,7 +27,8 @@ export function homeWCAdmin( includeTests = {} ) {
|
|||
let response;
|
||||
let api_x_wp_nonce;
|
||||
let apiNonceHeader;
|
||||
let includedTests = Object.assign( {
|
||||
const includedTests = Object.assign(
|
||||
{
|
||||
orders: true,
|
||||
other: true,
|
||||
products: true,
|
||||
|
@ -51,8 +52,8 @@ export function homeWCAdmin( includeTests = {} ) {
|
|||
} );
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
"body contains: current page is 'Home'": ( response ) =>
|
||||
response.body.includes( 'aria-current="page">Home' ),
|
||||
"body contains: current page is 'Home'": ( r ) =>
|
||||
r.body.includes( 'aria-current="page">Home' ),
|
||||
} );
|
||||
|
||||
// Correlate nonce values for use in subsequent requests.
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable import/no-unresolved */
|
||||
/**
|
||||
* External dependencies
|
||||
|
@ -32,7 +31,6 @@ import {
|
|||
} from '../../headers.js';
|
||||
|
||||
export function cartApplyCoupon() {
|
||||
let response;
|
||||
let apply_coupon_nonce;
|
||||
// let item_name;
|
||||
let woocommerce_cart_nonce;
|
||||
|
@ -46,7 +44,7 @@ export function cartApplyCoupon() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.post(
|
||||
const response = http.post(
|
||||
`${ base_url }/?wc-ajax=add_to_cart`,
|
||||
{
|
||||
product_sku: `${ product_sku }`,
|
||||
|
@ -74,15 +72,14 @@ export function cartApplyCoupon() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get( `${ base_url }/cart`, {
|
||||
const response = http.get( `${ base_url }/cart`, {
|
||||
headers: requestheaders,
|
||||
tags: { name: 'Shopper - View Cart' },
|
||||
} );
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
"body does not contain: 'your cart is currently empty'": (
|
||||
response
|
||||
) => ! response.body.includes( 'Your cart is currently empty.' ),
|
||||
"body does not contain: 'your cart is currently empty'": ( r ) =>
|
||||
! r.body.includes( 'Your cart is currently empty.' ),
|
||||
} );
|
||||
|
||||
// Correlate cart item value for use in subsequent requests.
|
||||
|
@ -111,7 +108,7 @@ export function cartApplyCoupon() {
|
|||
contentTypeRequestHeader
|
||||
);
|
||||
|
||||
response = http.post(
|
||||
const response = http.post(
|
||||
`${ base_url }/?wc-ajax=apply_coupon`,
|
||||
{
|
||||
coupon_code: `${ coupon_code }`,
|
||||
|
@ -125,11 +122,11 @@ export function cartApplyCoupon() {
|
|||
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
"body contains: 'Coupon code applied successfully'": ( response ) =>
|
||||
response.body.includes( 'Coupon code applied successfully' ),
|
||||
"body contains: 'Coupon code applied successfully'": ( r ) =>
|
||||
r.body.includes( 'Coupon code applied successfully' ),
|
||||
} );
|
||||
|
||||
response = http.post(
|
||||
const cartResponse = http.post(
|
||||
`${ base_url }/cart`,
|
||||
{
|
||||
_wp_http_referer: '%2Fcart',
|
||||
|
@ -142,10 +139,10 @@ export function cartApplyCoupon() {
|
|||
tags: { name: 'Shopper - Update Cart' },
|
||||
}
|
||||
);
|
||||
check( response, {
|
||||
check( cartResponse, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
"body contains: 'woocommerce-remove-coupon' class": ( response ) =>
|
||||
response.body.includes( 'class="woocommerce-remove-coupon"' ),
|
||||
"body contains: 'woocommerce-remove-coupon' class": ( r ) =>
|
||||
r.body.includes( 'class="woocommerce-remove-coupon"' ),
|
||||
} );
|
||||
} );
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable import/no-unresolved */
|
||||
// eslint-disable import/no-unresolved
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
@ -30,7 +29,6 @@ import {
|
|||
} from '../../headers.js';
|
||||
|
||||
export function cartRemoveItem() {
|
||||
let response;
|
||||
let item_to_remove;
|
||||
let wpnonce;
|
||||
|
||||
|
@ -43,7 +41,7 @@ export function cartRemoveItem() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.post(
|
||||
const response = http.post(
|
||||
`${ base_url }/?wc-ajax=add_to_cart`,
|
||||
{
|
||||
product_sku: `${ product_sku }`,
|
||||
|
@ -71,15 +69,14 @@ export function cartRemoveItem() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get( `${ base_url }/cart`, {
|
||||
const response = http.get( `${ base_url }/cart`, {
|
||||
headers: requestheaders,
|
||||
tags: { name: 'Shopper - View Cart' },
|
||||
} );
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
"body does not contain: 'your cart is currently empty'": (
|
||||
response
|
||||
) => ! response.body.includes( 'Your cart is currently empty.' ),
|
||||
"body does not contain: 'your cart is currently empty'": ( r ) =>
|
||||
! r.body.includes( 'Your cart is currently empty.' ),
|
||||
} );
|
||||
|
||||
// Correlate cart item value for use in subsequent requests.
|
||||
|
@ -98,7 +95,7 @@ export function cartRemoveItem() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get(
|
||||
const response = http.get(
|
||||
`${ base_url }/cart?remove_item=${ item_to_remove }&_wpnonce=${ wpnonce }`,
|
||||
{
|
||||
headers: requestheaders,
|
||||
|
@ -107,8 +104,7 @@ export function cartRemoveItem() {
|
|||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
"body contains: 'removed'": ( response ) =>
|
||||
response.body.includes( ' removed.' ),
|
||||
"body contains: 'removed'": ( r ) => r.body.includes( ' removed.' ),
|
||||
} );
|
||||
} );
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable import/no-unresolved */
|
||||
/**
|
||||
* External dependencies
|
||||
|
@ -16,6 +15,8 @@ import {
|
|||
product_id,
|
||||
think_time_min,
|
||||
think_time_max,
|
||||
STORE_NAME,
|
||||
FOOTER_TEXT,
|
||||
} from '../../config.js';
|
||||
import {
|
||||
htmlRequestHeader,
|
||||
|
@ -27,8 +28,6 @@ import {
|
|||
} from '../../headers.js';
|
||||
|
||||
export function cart() {
|
||||
let response;
|
||||
|
||||
group( 'Product Page Add to cart', function () {
|
||||
const requestheaders = Object.assign(
|
||||
{},
|
||||
|
@ -38,7 +37,7 @@ export function cart() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.post(
|
||||
const response = http.post(
|
||||
`${ base_url }/?wc-ajax=add_to_cart`,
|
||||
{
|
||||
product_sku: `${ product_sku }`,
|
||||
|
@ -66,26 +65,19 @@ export function cart() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get( `${ base_url }/cart`, {
|
||||
const response = http.get( `${ base_url }/cart`, {
|
||||
headers: requestheaders,
|
||||
tags: { name: 'Shopper - View Cart' },
|
||||
} );
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'title is: "Cart – WooCommerce Core E2E Test Suite"': (
|
||||
response
|
||||
) =>
|
||||
response.html().find( 'head title' ).text() ===
|
||||
'Cart – WooCommerce Core E2E Test Suite',
|
||||
"body does not contain: 'your cart is currently empty'": (
|
||||
response
|
||||
) => ! response.body.includes( 'Your cart is currently empty.' ),
|
||||
'footer contains: Built with WooCommerce': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( 'body footer' )
|
||||
.text()
|
||||
.includes( 'Built with WooCommerce' ),
|
||||
[ `title is: "Cart – ${ STORE_NAME }"` ]: ( r ) =>
|
||||
r.html().find( 'head title' ).text() ===
|
||||
`Cart – ${ STORE_NAME }`,
|
||||
"body does not contain: 'your cart is currently empty'": ( r ) =>
|
||||
! r.body.includes( 'Your cart is currently empty.' ),
|
||||
'footer contains: Built with WooCommerce': ( r ) =>
|
||||
r.html().find( 'body footer' ).text().includes( FOOTER_TEXT ),
|
||||
} );
|
||||
} );
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable import/no-unresolved */
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { sleep, check, group } from 'k6';
|
||||
import { sleep, group } from 'k6';
|
||||
import http from 'k6/http';
|
||||
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
|
||||
|
||||
|
@ -15,6 +14,8 @@ import {
|
|||
think_time_min,
|
||||
think_time_max,
|
||||
product_category,
|
||||
FOOTER_TEXT,
|
||||
STORE_NAME,
|
||||
} from '../../config.js';
|
||||
import {
|
||||
htmlRequestHeader,
|
||||
|
@ -22,6 +23,7 @@ import {
|
|||
commonGetRequestHeaders,
|
||||
commonNonStandardHeaders,
|
||||
} from '../../headers.js';
|
||||
import { checkResponse } from '../../utils.js';
|
||||
|
||||
export function categoryPage() {
|
||||
let response;
|
||||
|
@ -42,23 +44,10 @@ export function categoryPage() {
|
|||
tags: { name: 'Shopper - Category Page' },
|
||||
}
|
||||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'title is: "Accessories – WooCommerce Core E2E Test Suite"': (
|
||||
response
|
||||
) =>
|
||||
response.html().find( 'head title' ).text() ===
|
||||
'Accessories – WooCommerce Core E2E Test Suite',
|
||||
"body contains: Category's title": ( response ) =>
|
||||
response.body.includes(
|
||||
`<h1 class="woocommerce-products-header__title page-title">${ product_category }</h1>`
|
||||
),
|
||||
'footer contains: Built with WooCommerce': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( 'body footer' )
|
||||
.text()
|
||||
.includes( 'Built with WooCommerce' ),
|
||||
checkResponse( response, 200, {
|
||||
title: `Accessories – ${ STORE_NAME }`,
|
||||
body: `<h1 class="woocommerce-products-header__title page-title">${ product_category }</h1>`,
|
||||
footer: FOOTER_TEXT,
|
||||
} );
|
||||
} );
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable import/no-unresolved */
|
||||
/**
|
||||
* External dependencies
|
||||
|
@ -37,6 +36,8 @@ import {
|
|||
payment_method,
|
||||
think_time_min,
|
||||
think_time_max,
|
||||
FOOTER_TEXT,
|
||||
STORE_NAME,
|
||||
} from '../../config.js';
|
||||
import {
|
||||
htmlRequestHeader,
|
||||
|
@ -47,9 +48,9 @@ import {
|
|||
commonPostRequestHeaders,
|
||||
commonNonStandardHeaders,
|
||||
} from '../../headers.js';
|
||||
import { checkResponse } from '../../utils.js';
|
||||
|
||||
export function checkoutCustomerLogin() {
|
||||
let response;
|
||||
let woocommerce_process_checkout_nonce_customer;
|
||||
let woocommerce_login_nonce;
|
||||
let update_order_review_nonce_guest;
|
||||
|
@ -64,27 +65,15 @@ export function checkoutCustomerLogin() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get( `${ base_url }/checkout`, {
|
||||
const response = http.get( `${ base_url }/checkout`, {
|
||||
headers: requestHeaders,
|
||||
tags: { name: 'Shopper - View Checkout' },
|
||||
} );
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'title is: "Checkout – WooCommerce Core E2E Test Suite"': (
|
||||
response
|
||||
) =>
|
||||
response.html().find( 'head title' ).text() ===
|
||||
'Checkout – WooCommerce Core E2E Test Suite',
|
||||
'body contains checkout class': ( response ) =>
|
||||
response.body.includes(
|
||||
'class="checkout woocommerce-checkout"'
|
||||
),
|
||||
'footer contains: Built with WooCommerce': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( 'body footer' )
|
||||
.text()
|
||||
.includes( 'Built with WooCommerce' ),
|
||||
|
||||
checkResponse( response, 200, {
|
||||
title: `Checkout – ${ STORE_NAME }`,
|
||||
body: 'class="checkout woocommerce-checkout"',
|
||||
footer: FOOTER_TEXT,
|
||||
} );
|
||||
|
||||
// Correlate nonce values for use in subsequent requests.
|
||||
|
@ -107,7 +96,7 @@ export function checkoutCustomerLogin() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.post(
|
||||
const updateResponse = http.post(
|
||||
`${ base_url }/?wc-ajax=update_order_review`,
|
||||
{
|
||||
security: `${ update_order_review_nonce_guest }`,
|
||||
|
@ -131,7 +120,7 @@ export function checkoutCustomerLogin() {
|
|||
tags: { name: 'Shopper - wc-ajax=update_order_review' },
|
||||
}
|
||||
);
|
||||
check( response, {
|
||||
check( updateResponse, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
} );
|
||||
} );
|
||||
|
@ -147,7 +136,7 @@ export function checkoutCustomerLogin() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.post(
|
||||
const response = http.post(
|
||||
`${ base_url }/checkout`,
|
||||
{
|
||||
username: `${ customer_username }`,
|
||||
|
@ -186,7 +175,7 @@ export function checkoutCustomerLogin() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.post(
|
||||
const updateResponse = http.post(
|
||||
`${ base_url }/?wc-ajax=update_order_review`,
|
||||
{
|
||||
security: `${ update_order_review_nonce_customer }`,
|
||||
|
@ -210,7 +199,7 @@ export function checkoutCustomerLogin() {
|
|||
tags: { name: 'Shopper - wc-ajax=update_order_review' },
|
||||
}
|
||||
);
|
||||
check( response, {
|
||||
check( updateResponse, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
} );
|
||||
} );
|
||||
|
@ -226,7 +215,7 @@ export function checkoutCustomerLogin() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.post(
|
||||
const response = http.post(
|
||||
`${ base_url }/?wc-ajax=checkout`,
|
||||
{
|
||||
billing_first_name: `${ addresses_customer_billing_first_name }`,
|
||||
|
@ -252,8 +241,8 @@ export function checkoutCustomerLogin() {
|
|||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'body contains: order-received': ( response ) =>
|
||||
response.body.includes( 'order-received' ),
|
||||
'body contains: order-received': ( r ) =>
|
||||
r.body.includes( 'order-received' ),
|
||||
} );
|
||||
} );
|
||||
|
||||
|
@ -268,28 +257,14 @@ export function checkoutCustomerLogin() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get( `${ base_url }/checkout/order-received/`, {
|
||||
const response = http.get( `${ base_url }/checkout/order-received/`, {
|
||||
headers: requestHeaders,
|
||||
tags: { name: 'Shopper - Order Received' },
|
||||
} );
|
||||
check( response, {
|
||||
'title is: "Checkout – WooCommerce Core E2E Test Suite"': (
|
||||
response
|
||||
) =>
|
||||
response.html().find( 'head title' ).text() ===
|
||||
'Checkout – WooCommerce Core E2E Test Suite',
|
||||
"body contains: 'Thank you. Your order has been received.'": (
|
||||
response
|
||||
) =>
|
||||
response.body.includes(
|
||||
'Thank you. Your order has been received.'
|
||||
),
|
||||
'footer contains: Built with WooCommerce': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( 'body footer' )
|
||||
.text()
|
||||
.includes( 'Built with WooCommerce' ),
|
||||
checkResponse( response, 200, {
|
||||
title: `Order received – ${ STORE_NAME }`,
|
||||
body: 'Thank you. Your order has been received.',
|
||||
footer: FOOTER_TEXT,
|
||||
} );
|
||||
|
||||
const requestHeadersPost = Object.assign(
|
||||
|
@ -300,14 +275,14 @@ export function checkoutCustomerLogin() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.post(
|
||||
const refreshResponse = http.post(
|
||||
`${ base_url }/?wc-ajax=get_refreshed_fragments`,
|
||||
{
|
||||
headers: requestHeadersPost,
|
||||
tags: { name: 'Shopper - wc-ajax=get_refreshed_fragments' },
|
||||
}
|
||||
);
|
||||
check( response, {
|
||||
check( refreshResponse, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable import/no-unresolved */
|
||||
/**
|
||||
* External dependencies
|
||||
|
@ -29,6 +28,8 @@ import {
|
|||
payment_method,
|
||||
think_time_min,
|
||||
think_time_max,
|
||||
FOOTER_TEXT,
|
||||
STORE_NAME,
|
||||
} from '../../config.js';
|
||||
import {
|
||||
htmlRequestHeader,
|
||||
|
@ -39,9 +40,9 @@ import {
|
|||
commonPostRequestHeaders,
|
||||
commonNonStandardHeaders,
|
||||
} from '../../headers.js';
|
||||
import { checkResponse } from '../../utils.js';
|
||||
|
||||
export function checkoutGuest() {
|
||||
let response;
|
||||
let woocommerce_process_checkout_nonce_guest;
|
||||
let update_order_review_nonce_guest;
|
||||
|
||||
|
@ -54,27 +55,14 @@ export function checkoutGuest() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get( `${ base_url }/checkout`, {
|
||||
const response = http.get( `${ base_url }/checkout`, {
|
||||
headers: requestHeaders,
|
||||
tags: { name: 'Shopper - View Checkout' },
|
||||
} );
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'title is: "Checkout – WooCommerce Core E2E Test Suite"': (
|
||||
response
|
||||
) =>
|
||||
response.html().find( 'head title' ).text() ===
|
||||
'Checkout – WooCommerce Core E2E Test Suite',
|
||||
"body contains: 'woocommerce-checkout' class": ( response ) =>
|
||||
response.body.includes(
|
||||
'class="checkout woocommerce-checkout"'
|
||||
),
|
||||
'footer contains: Built with WooCommerce': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( 'body footer' )
|
||||
.text()
|
||||
.includes( 'Built with WooCommerce' ),
|
||||
checkResponse( response, 200, {
|
||||
title: `Checkout – ${ STORE_NAME }`,
|
||||
body: 'class="checkout woocommerce-checkout"',
|
||||
footer: FOOTER_TEXT,
|
||||
} );
|
||||
|
||||
// Correlate nonce values for use in subsequent requests.
|
||||
|
@ -97,7 +85,7 @@ export function checkoutGuest() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.post(
|
||||
const updateResponse = http.post(
|
||||
`${ base_url }/?wc-ajax=update_order_review`,
|
||||
{
|
||||
security: `${ update_order_review_nonce_guest }`,
|
||||
|
@ -121,7 +109,7 @@ export function checkoutGuest() {
|
|||
tags: { name: 'Shopper - wc-ajax=update_order_review' },
|
||||
}
|
||||
);
|
||||
check( response, {
|
||||
check( updateResponse, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
} );
|
||||
} );
|
||||
|
@ -137,7 +125,7 @@ export function checkoutGuest() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.post(
|
||||
const response = http.post(
|
||||
`${ base_url }/?wc-ajax=checkout`,
|
||||
{
|
||||
billing_first_name: `${ addresses_guest_billing_first_name }`,
|
||||
|
@ -163,8 +151,8 @@ export function checkoutGuest() {
|
|||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'body contains: order-received': ( response ) =>
|
||||
response.body.includes( 'order-received' ),
|
||||
'body contains: order-received': ( r ) =>
|
||||
r.body.includes( 'order-received' ),
|
||||
} );
|
||||
} );
|
||||
|
||||
|
@ -179,28 +167,14 @@ export function checkoutGuest() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get( `${ base_url }/checkout/order-received/`, {
|
||||
const response = http.get( `${ base_url }/checkout/order-received/`, {
|
||||
headers: requestHeaders,
|
||||
tags: { name: 'Shopper - Order Received' },
|
||||
} );
|
||||
check( response, {
|
||||
'title is: "Checkout – WooCommerce Core E2E Test Suite"': (
|
||||
response
|
||||
) =>
|
||||
response.html().find( 'head title' ).text() ===
|
||||
'Checkout – WooCommerce Core E2E Test Suite',
|
||||
"body contains: 'Thank you. Your order has been received.'": (
|
||||
response
|
||||
) =>
|
||||
response.body.includes(
|
||||
'Thank you. Your order has been received.'
|
||||
),
|
||||
'footer contains: Built with WooCommerce': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( 'body footer' )
|
||||
.text()
|
||||
.includes( 'Built with WooCommerce' ),
|
||||
checkResponse( response, 200, {
|
||||
title: `Order received – ${ STORE_NAME }`,
|
||||
body: 'Thank you. Your order has been received.',
|
||||
footer: FOOTER_TEXT,
|
||||
} );
|
||||
|
||||
const requestHeadersPost = Object.assign(
|
||||
|
@ -211,14 +185,14 @@ export function checkoutGuest() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.post(
|
||||
const refreshResponse = http.post(
|
||||
`${ base_url }/?wc-ajax=get_refreshed_fragments`,
|
||||
{
|
||||
headers: requestHeadersPost,
|
||||
tags: { name: 'Shopper - wc-ajax=get_refreshed_fragments' },
|
||||
}
|
||||
);
|
||||
check( response, {
|
||||
check( refreshResponse, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable import/no-unresolved */
|
||||
/**
|
||||
* External dependencies
|
||||
|
@ -10,7 +9,13 @@ import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
|
|||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { base_url, think_time_min, think_time_max } from '../../config.js';
|
||||
import {
|
||||
base_url,
|
||||
think_time_min,
|
||||
think_time_max,
|
||||
FOOTER_TEXT,
|
||||
STORE_NAME,
|
||||
} from '../../config.js';
|
||||
import {
|
||||
htmlRequestHeader,
|
||||
commonRequestHeaders,
|
||||
|
@ -34,17 +39,13 @@ export function homePage() {
|
|||
headers: requestHeaders,
|
||||
tags: { name: 'Shopper - Site Root' },
|
||||
} );
|
||||
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'title is: "WooCommerce Core E2E Test Suite"': ( response ) =>
|
||||
response.html().find( 'head title' ).text() ===
|
||||
'WooCommerce Core E2E Test Suite',
|
||||
'footer contains: Built with WooCommerce': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( 'body footer' )
|
||||
.text()
|
||||
.includes( 'Built with WooCommerce' ),
|
||||
[ `title is: "${ STORE_NAME }"` ]: ( r ) =>
|
||||
r.html().find( 'head title' ).text() === STORE_NAME,
|
||||
'footer contains: Built with WooCommerce': ( r ) =>
|
||||
r.html().find( 'body footer' ).text().includes( FOOTER_TEXT ),
|
||||
} );
|
||||
} );
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable import/no-unresolved */
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { sleep, check, group } from 'k6';
|
||||
import { sleep, group } from 'k6';
|
||||
import http from 'k6/http';
|
||||
import {
|
||||
randomIntBetween,
|
||||
|
@ -13,16 +12,22 @@ import {
|
|||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { base_url, think_time_min, think_time_max } from '../../config.js';
|
||||
import {
|
||||
base_url,
|
||||
think_time_min,
|
||||
think_time_max,
|
||||
STORE_NAME,
|
||||
FOOTER_TEXT,
|
||||
} from '../../config.js';
|
||||
import {
|
||||
htmlRequestHeader,
|
||||
commonRequestHeaders,
|
||||
commonGetRequestHeaders,
|
||||
commonNonStandardHeaders,
|
||||
} from '../../headers.js';
|
||||
import { checkResponse } from '../../utils.js';
|
||||
|
||||
export function myAccountOrders() {
|
||||
let response;
|
||||
let my_account_order_id;
|
||||
|
||||
group( 'My Account', function () {
|
||||
|
@ -34,27 +39,14 @@ export function myAccountOrders() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get( `${ base_url }/my-account`, {
|
||||
const response = http.get( `${ base_url }/my-account`, {
|
||||
headers: requestHeaders,
|
||||
tags: { name: 'Shopper - My Account' },
|
||||
} );
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'title is: "My account – WooCommerce Core E2E Test Suite"': (
|
||||
response
|
||||
) =>
|
||||
response.html().find( 'head title' ).text() ===
|
||||
'My account – WooCommerce Core E2E Test Suite',
|
||||
'body contains: my account welcome message': ( response ) =>
|
||||
response.body.includes(
|
||||
'From your account dashboard you can view'
|
||||
),
|
||||
'footer contains: Built with WooCommerce': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( 'body footer' )
|
||||
.text()
|
||||
.includes( 'Built with WooCommerce' ),
|
||||
checkResponse( response, 200, {
|
||||
title: `My account – ${ STORE_NAME }`,
|
||||
body: 'From your account dashboard you can view',
|
||||
footer: FOOTER_TEXT,
|
||||
} );
|
||||
} );
|
||||
|
||||
|
@ -69,26 +61,17 @@ export function myAccountOrders() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get( `${ base_url }/my-account/orders/`, {
|
||||
const response = http.get( `${ base_url }/my-account/orders/`, {
|
||||
headers: requestHeaders,
|
||||
tags: { name: 'Shopper - My Account Orders' },
|
||||
} );
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'title is: "My account – WooCommerce Core E2E Test Suite"': (
|
||||
response
|
||||
) =>
|
||||
response.html().find( 'head title' ).text() ===
|
||||
'My account – WooCommerce Core E2E Test Suite',
|
||||
"body contains: 'Orders' title": ( response ) =>
|
||||
response.body.includes( '>Orders</h1>' ),
|
||||
'footer contains: Built with WooCommerce': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( 'body footer' )
|
||||
.text()
|
||||
.includes( 'Built with WooCommerce' ),
|
||||
|
||||
checkResponse( response, 200, {
|
||||
title: `Orders – ${ STORE_NAME }`,
|
||||
body: '>Orders</h1>',
|
||||
footer: FOOTER_TEXT,
|
||||
} );
|
||||
|
||||
my_account_order_id = findBetween(
|
||||
response.body,
|
||||
'my-account/view-order/',
|
||||
|
@ -107,28 +90,18 @@ export function myAccountOrders() {
|
|||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get(
|
||||
const response = http.get(
|
||||
`${ base_url }/my-account/view-order/${ my_account_order_id }`,
|
||||
{
|
||||
headers: requestHeaders,
|
||||
tags: { name: 'Shopper - My Account Open Order' },
|
||||
}
|
||||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'title is: "My account – WooCommerce Core E2E Test Suite"': (
|
||||
response
|
||||
) =>
|
||||
response.html().find( 'head title' ).text() ===
|
||||
'My account – WooCommerce Core E2E Test Suite',
|
||||
"body contains: 'Order number' title": ( response ) =>
|
||||
response.body.includes( `${ my_account_order_id }</h1>` ),
|
||||
'footer contains: Built with WooCommerce': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( 'body footer' )
|
||||
.text()
|
||||
.includes( 'Built with WooCommerce' ),
|
||||
|
||||
checkResponse( response, 200, {
|
||||
title: `My account – ${ STORE_NAME }`,
|
||||
body: my_account_order_id,
|
||||
footer: FOOTER_TEXT,
|
||||
} );
|
||||
} );
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable import/no-unresolved */
|
||||
/**
|
||||
* External dependencies
|
||||
|
@ -16,6 +15,8 @@ import {
|
|||
customer_password,
|
||||
think_time_min,
|
||||
think_time_max,
|
||||
FOOTER_TEXT,
|
||||
STORE_NAME,
|
||||
} from '../../config.js';
|
||||
import {
|
||||
htmlRequestHeader,
|
||||
|
@ -25,6 +26,7 @@ import {
|
|||
commonPostRequestHeaders,
|
||||
commonNonStandardHeaders,
|
||||
} from '../../headers.js';
|
||||
import { checkResponse } from '../../utils.js';
|
||||
|
||||
export function myAccount() {
|
||||
let response;
|
||||
|
@ -43,21 +45,11 @@ export function myAccount() {
|
|||
headers: requestHeaders,
|
||||
tags: { name: 'Shopper - My Account Login Page' },
|
||||
} );
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'title is: "My account – WooCommerce Core E2E Test Suite"': (
|
||||
response
|
||||
) =>
|
||||
response.html().find( 'head title' ).text() ===
|
||||
'My account – WooCommerce Core E2E Test Suite',
|
||||
"body contains: 'My account' title": ( response ) =>
|
||||
response.body.includes( '>My account</h1>' ),
|
||||
'footer contains: Built with WooCommerce': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( 'body footer' )
|
||||
.text()
|
||||
.includes( 'Built with WooCommerce' ),
|
||||
|
||||
checkResponse( response, 200, {
|
||||
title: `My account – ${ STORE_NAME }`,
|
||||
body: '>My account</h1>',
|
||||
footer: FOOTER_TEXT,
|
||||
} );
|
||||
|
||||
// Correlate nonce value for use in subsequent requests.
|
||||
|
@ -95,10 +87,8 @@ export function myAccount() {
|
|||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'body contains: my account welcome message': ( response ) =>
|
||||
response.body.includes(
|
||||
'From your account dashboard you can view'
|
||||
),
|
||||
'body contains: my account welcome message': ( r ) =>
|
||||
r.body.includes( 'From your account dashboard you can view' ),
|
||||
} );
|
||||
|
||||
const requestHeadersPost = Object.assign(
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable import/no-unresolved */
|
||||
/**
|
||||
* External dependencies
|
||||
|
@ -15,6 +14,8 @@ import {
|
|||
product_search_term,
|
||||
think_time_min,
|
||||
think_time_max,
|
||||
FOOTER_TEXT,
|
||||
STORE_NAME,
|
||||
} from '../../config.js';
|
||||
import {
|
||||
htmlRequestHeader,
|
||||
|
@ -44,25 +45,18 @@ export function searchProduct() {
|
|||
);
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'title matches: Search Results for {product_search_term} – WooCommerce Core E2E Test Suite':
|
||||
( response ) => {
|
||||
const title_actual = response
|
||||
.html()
|
||||
.find( 'head title' )
|
||||
.text();
|
||||
[ `title matches: Search Results for {product_search_term} – ${ STORE_NAME }` ]:
|
||||
( r ) => {
|
||||
const title_actual = r.html().find( 'head title' ).text();
|
||||
const title_expected = new RegExp(
|
||||
`Search Results for .${ product_search_term }. – WooCommerce Core E2E Test Suite`
|
||||
`Search Results for .${ product_search_term }. – ${ STORE_NAME }`
|
||||
);
|
||||
return title_actual.match( title_expected );
|
||||
},
|
||||
"body contains: 'Search results' title": ( response ) =>
|
||||
response.body.includes( 'Search results:' ),
|
||||
'footer contains: Built with WooCommerce': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( 'body footer' )
|
||||
.text()
|
||||
.includes( 'Built with WooCommerce' ),
|
||||
"body contains: 'Search results' title": ( r ) =>
|
||||
r.body.includes( 'Search results:' ),
|
||||
'footer contains: Built with WooCommerce': ( r ) =>
|
||||
r.html().find( 'body footer' ).text().includes( FOOTER_TEXT ),
|
||||
} );
|
||||
} );
|
||||
|
||||
|
|
|
@ -1,22 +1,28 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable import/no-unresolved */
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { sleep, check, group } from 'k6';
|
||||
import { sleep, group } from 'k6';
|
||||
import http from 'k6/http';
|
||||
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { base_url, think_time_min, think_time_max } from '../../config.js';
|
||||
import {
|
||||
base_url,
|
||||
think_time_min,
|
||||
think_time_max,
|
||||
FOOTER_TEXT,
|
||||
STORE_NAME,
|
||||
} from '../../config.js';
|
||||
import {
|
||||
htmlRequestHeader,
|
||||
commonRequestHeaders,
|
||||
commonGetRequestHeaders,
|
||||
commonNonStandardHeaders,
|
||||
} from '../../headers.js';
|
||||
import { checkResponse } from '../../utils.js';
|
||||
|
||||
export function shopPage() {
|
||||
let response;
|
||||
|
@ -34,22 +40,10 @@ export function shopPage() {
|
|||
headers: requestHeaders,
|
||||
tags: { name: 'Shopper - Shop Page' },
|
||||
} );
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'title equals: Shop – WooCommerce Core E2E Test Suite': (
|
||||
response
|
||||
) =>
|
||||
response.html().find( 'head title' ).text() ===
|
||||
'Shop – WooCommerce Core E2E Test Suite',
|
||||
'body contains: woocommerce-products-header': ( response ) =>
|
||||
response.body.includes(
|
||||
'<header class="woocommerce-products-header">'
|
||||
),
|
||||
'body contains: woocommerce-loop-product__title': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( '.woocommerce-loop-product__title' )
|
||||
.toArray().length > 0,
|
||||
checkResponse( response, 200, {
|
||||
title: `Shop – ${ STORE_NAME }`,
|
||||
body: '<header class="woocommerce-products-header">',
|
||||
footer: FOOTER_TEXT,
|
||||
} );
|
||||
} );
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable no-shadow */
|
||||
/* eslint-disable import/no-unresolved */
|
||||
/**
|
||||
* External dependencies
|
||||
|
@ -16,6 +15,8 @@ import {
|
|||
product_sku,
|
||||
think_time_min,
|
||||
think_time_max,
|
||||
FOOTER_TEXT,
|
||||
STORE_NAME,
|
||||
} from '../../config.js';
|
||||
import {
|
||||
htmlRequestHeader,
|
||||
|
@ -42,27 +43,18 @@ export function singleProduct() {
|
|||
} );
|
||||
check( response, {
|
||||
'is status 200': ( r ) => r.status === 200,
|
||||
'title is: {product_url} – WooCommerce Core E2E Test Suite': (
|
||||
response
|
||||
) => {
|
||||
const title_actual = response
|
||||
.html()
|
||||
.find( 'head title' )
|
||||
.text();
|
||||
[ `title is: ${ product_url } – ${ STORE_NAME }` ]: ( r ) => {
|
||||
const title_actual = r.html().find( 'head title' ).text();
|
||||
const title_expected = new RegExp(
|
||||
`${ product_url } – WooCommerce Core E2E Test Suite`,
|
||||
`${ product_url } – ${ STORE_NAME }`,
|
||||
'i'
|
||||
);
|
||||
return title_actual.match( title_expected );
|
||||
},
|
||||
'body contains: product SKU': ( response ) =>
|
||||
response.body.includes( `class="sku">${ product_sku }` ),
|
||||
'footer contains: Built with WooCommerce': ( response ) =>
|
||||
response
|
||||
.html()
|
||||
.find( 'body footer' )
|
||||
.text()
|
||||
.includes( 'Built with WooCommerce' ),
|
||||
'body contains: product SKU': ( r ) =>
|
||||
r.body.includes( `class="sku">${ product_sku }` ),
|
||||
'footer contains: Built with WooCommerce': ( r ) =>
|
||||
r.html().find( 'body footer' ).text().includes( FOOTER_TEXT ),
|
||||
} );
|
||||
} );
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { check } from 'k6';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
const checkResponse = (
|
||||
response,
|
||||
statusCode,
|
||||
page = {
|
||||
title: '',
|
||||
body: '',
|
||||
footer: '',
|
||||
}
|
||||
) => {
|
||||
check( response, {
|
||||
[ `is status ${ statusCode }` ]: ( r ) => r.status === statusCode,
|
||||
[ `title is: "${ page.title }"` ]: ( r ) =>
|
||||
r.html().find( 'head title' ).text() === page.title,
|
||||
[ `body contains: ${ page.body }` ]: ( r ) =>
|
||||
r.body.includes( page.body ),
|
||||
[ `footer contains: ${ page.footer }` ]: ( r ) =>
|
||||
r.html().find( 'body footer' ).text().includes( page.footer ),
|
||||
} );
|
||||
};
|
||||
|
||||
export { checkResponse };
|
Loading…
Reference in New Issue