diff --git a/plugins/woocommerce/tests/performance/requests/shopper/category-page.js b/plugins/woocommerce/tests/performance/requests/shopper/category-page.js new file mode 100644 index 00000000000..42d5f83ffd0 --- /dev/null +++ b/plugins/woocommerce/tests/performance/requests/shopper/category-page.js @@ -0,0 +1,45 @@ +import { sleep, check, group } from "k6"; +import http from "k6/http"; +import { Trend } from "k6/metrics"; +import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js"; +import { base_url, think_time_min, think_time_max } from "../../config.js"; +import { + htmlRequestHeader, + commonRequestHeaders, + commonGetRequestHeaders, + commonNonStandardHeaders, +} from "../../headers.js"; + +// Custom metric to add to standard results output. +let categoryPageTrend = new Trend("wc_get_site_root"); + +export function categoryPage() { + let response; + + group("Category Page", function () { + var requestHeaders = Object.assign({}, + htmlRequestHeader, + commonRequestHeaders, + commonGetRequestHeaders, + commonNonStandardHeaders + ); + + response = http.get(`${base_url}/product-category/accessories/`, { + headers: requestHeaders, + }); + categoryPageTrend.add(response.timings.duration); + check(response, { + "is status 200": (r) => r.status === 200, + "body contains: 'Accessories' title": (response) => + response.body.includes( + '

Accessories

' + ), + }); + }); + + sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`)); +} + +export default function () { + categoryPage(); +} \ No newline at end of file diff --git a/plugins/woocommerce/tests/performance/tests/example-all-requests-arrival-rate.js b/plugins/woocommerce/tests/performance/tests/example-all-requests-arrival-rate.js index 1fd9716c9bc..a39bee87810 100644 --- a/plugins/woocommerce/tests/performance/tests/example-all-requests-arrival-rate.js +++ b/plugins/woocommerce/tests/performance/tests/example-all-requests-arrival-rate.js @@ -15,6 +15,7 @@ import { orders } from '../requests/merchant/orders.js'; import { ordersHeartbeat } from '../requests/merchant/orders-heartbeat.js'; import { homeWCAdmin } from '../requests/merchant/home-wc-admin.js'; import { myAccountMerchantLogin } from '../requests/merchant/my-account-merchant.js'; +import { categoryPage } from '../requests/shopper/category-page.js'; export let options = { scenarios: { @@ -124,6 +125,7 @@ export function shopperBrowsingFlows() { cartRemoveItem(); cartApplyCoupon(); myAccount(); + categoryPage(); } export function checkoutGuestFlow() { cart(); diff --git a/plugins/woocommerce/tests/performance/tests/example-all-requests-ramping-vus.js b/plugins/woocommerce/tests/performance/tests/example-all-requests-ramping-vus.js index 470458b809e..704025821c7 100644 --- a/plugins/woocommerce/tests/performance/tests/example-all-requests-ramping-vus.js +++ b/plugins/woocommerce/tests/performance/tests/example-all-requests-ramping-vus.js @@ -15,6 +15,7 @@ import { orders } from '../requests/merchant/orders.js'; import { ordersHeartbeat } from '../requests/merchant/orders-heartbeat.js'; import { homeWCAdmin } from '../requests/merchant/home-wc-admin.js'; import { myAccountMerchantLogin } from '../requests/merchant/my-account-merchant.js'; +import { categoryPage } from '../requests/shopper/category-page.js'; export let options = { scenarios: { @@ -114,6 +115,7 @@ export function shopperBrowsingFlows() { cartRemoveItem(); cartApplyCoupon(); myAccount(); + categoryPage(); } export function checkoutGuestFlow() { cart(); diff --git a/plugins/woocommerce/tests/performance/tests/simple-all-shopper-requests.js b/plugins/woocommerce/tests/performance/tests/simple-all-shopper-requests.js index 85e38418852..c98c2db22f7 100644 --- a/plugins/woocommerce/tests/performance/tests/simple-all-shopper-requests.js +++ b/plugins/woocommerce/tests/performance/tests/simple-all-shopper-requests.js @@ -8,6 +8,7 @@ import { cartApplyCoupon } from '../requests/shopper/cart-apply-coupon.js'; import { checkoutGuest } from '../requests/shopper/checkout-guest.js'; import { checkoutCustomerLogin } from '../requests/shopper/checkout-customer-login.js'; import { myAccount } from '../requests/shopper/my-account.js'; +import { categoryPage } from '../requests/shopper/category-page.js'; export let options = { scenarios: { @@ -88,6 +89,7 @@ export function searchProductFlow() { } export function singleProductFlow() { singleProduct(); + categoryPage(); } export function checkoutGuestFlow() { cart();