Merge pull request #31007 from woocommerce/performance/newest-test-category-page
Add new performance test Shopper / Browse products by category
This commit is contained in:
commit
67a81463e4
|
@ -82,6 +82,7 @@ product_sku | SKU of product to be used in cart and checkout flow | yes `__ENV.P
|
|||
product_url | the `product-name` portion of product permalink of the product to be used in cart and checkout flow | yes `__ENV.P_URL`
|
||||
product_id | the product ID of of product to be used in cart and checkout flow | yes `__ENV.P_ID`
|
||||
product_search_term | search term to return product to be used in cart and checkout flow | yes `__ENV.P_TERM`
|
||||
product_category | category of product to be used for browsing category products | yes `__ENV.P_CAT`
|
||||
coupon_code | coupon code to be used in applying coupon flow | yes `__ENV.P_COUPON`
|
||||
add_product_title | title of product to be added in merchant add product flow | no
|
||||
add_product_regular_price | regular price of product to be added in merchant add product flow | no
|
||||
|
@ -102,7 +103,7 @@ To execute an individual test file (for example `requests/shopper/shop-page.js`)
|
|||
|
||||
CLI `k6 run requests/shopper/shop-page.js`
|
||||
|
||||
Docker `docker run --network="host" -v /[YOUR LOCAL WC DIRECTORY FULL PATH]/requests:/requests -it loadimpact/k6 run /requests/shopper/shop-page.js`
|
||||
Docker `docker run --network="host" -v /[YOUR LOCAL WC DIRECTORY FULL PATH]/tests:/tests -it loadimpact/k6 run /tests/performance/requests/shopper/shop-page.js`
|
||||
|
||||
This will run the individual test for 1 iteration.
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ export const product_sku = __ENV.P_SKU || 'woo-beanie';
|
|||
export const product_url = __ENV.P_URL || 'beanie';
|
||||
export const product_id = __ENV.P_ID || '13';
|
||||
export const product_search_term = __ENV.P_TERM || 'beanie';
|
||||
export const product_category = __ENV.P_CAT || 'Accessories';
|
||||
|
||||
export const coupon_code = __ENV.P_COUPON || 'testing';
|
||||
|
||||
|
|
|
@ -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, product_category } 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_product_category_name");
|
||||
|
||||
export function categoryPage() {
|
||||
let response;
|
||||
|
||||
group("Category Page", function () {
|
||||
var requestHeaders = Object.assign({},
|
||||
htmlRequestHeader,
|
||||
commonRequestHeaders,
|
||||
commonGetRequestHeaders,
|
||||
commonNonStandardHeaders
|
||||
);
|
||||
|
||||
response = http.get(`${base_url}/product-category/${product_category}/`, {
|
||||
headers: requestHeaders,
|
||||
});
|
||||
categoryPageTrend.add(response.timings.duration);
|
||||
check(response, {
|
||||
"is status 200": (r) => r.status === 200,
|
||||
"body contains: Category's title": (response) =>
|
||||
response.body.includes(
|
||||
`<h1 class="woocommerce-products-header__title page-title">${product_category}</h1>`
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
sleep(randomIntBetween(`${think_time_min}`, `${think_time_max}`));
|
||||
}
|
||||
|
||||
export default function () {
|
||||
categoryPage();
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue