Add product category parameter

This commit is contained in:
Veljko 2021-10-21 14:47:32 +02:00
parent a84ffcc42d
commit a5ef3fecf6
2 changed files with 5 additions and 4 deletions

View File

@ -37,6 +37,7 @@ export const product_sku = __ENV.P_SKU || 'woo-beanie';
export const product_url = __ENV.P_URL || 'beanie'; export const product_url = __ENV.P_URL || 'beanie';
export const product_id = __ENV.P_ID || '13'; export const product_id = __ENV.P_ID || '13';
export const product_search_term = __ENV.P_TERM || 'beanie'; 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'; export const coupon_code = __ENV.P_COUPON || 'testing';

View File

@ -2,7 +2,7 @@ import { sleep, check, group } from "k6";
import http from "k6/http"; import http from "k6/http";
import { Trend } from "k6/metrics"; import { Trend } from "k6/metrics";
import { randomIntBetween } from "https://jslib.k6.io/k6-utils/1.1.0/index.js"; 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 { base_url, think_time_min, think_time_max, product_category } from "../../config.js";
import { import {
htmlRequestHeader, htmlRequestHeader,
commonRequestHeaders, commonRequestHeaders,
@ -11,7 +11,7 @@ import {
} from "../../headers.js"; } from "../../headers.js";
// Custom metric to add to standard results output. // Custom metric to add to standard results output.
let categoryPageTrend = new Trend("wc_get_site_root"); let categoryPageTrend = new Trend("wc_get_product_category_name");
export function categoryPage() { export function categoryPage() {
let response; let response;
@ -24,7 +24,7 @@ export function categoryPage() {
commonNonStandardHeaders commonNonStandardHeaders
); );
response = http.get(`${base_url}/product-category/accessories/`, { response = http.get(`${base_url}/product-category/${product_category}/`, {
headers: requestHeaders, headers: requestHeaders,
}); });
categoryPageTrend.add(response.timings.duration); categoryPageTrend.add(response.timings.duration);
@ -32,7 +32,7 @@ export function categoryPage() {
"is status 200": (r) => r.status === 200, "is status 200": (r) => r.status === 200,
"body contains: 'Accessories' title": (response) => "body contains: 'Accessories' title": (response) =>
response.body.includes( response.body.includes(
'<h1 class="woocommerce-products-header__title page-title">Accessories</h1>' `<h1 class="woocommerce-products-header__title page-title">${product_category}</h1>`
), ),
}); });
}); });