Add checks for page title and footer (#46485)
This commit is contained in:
parent
8653d4c4fe
commit
522c8893a5
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Add k6 perf test assertions to check for the correct page title and presence of footer.
|
|
@ -72,9 +72,20 @@ export function cart() {
|
||||||
} );
|
} );
|
||||||
check( response, {
|
check( response, {
|
||||||
'is status 200': ( r ) => r.status === 200,
|
'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'": (
|
"body does not contain: 'your cart is currently empty'": (
|
||||||
response
|
response
|
||||||
) => ! response.body.includes( 'Your cart is currently empty.' ),
|
) => ! response.body.includes( 'Your cart is currently empty.' ),
|
||||||
|
'footer contains: Built with WooCommerce': ( response ) =>
|
||||||
|
response
|
||||||
|
.html()
|
||||||
|
.find( 'body footer' )
|
||||||
|
.text()
|
||||||
|
.includes( 'Built with WooCommerce' ),
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,21 @@ export function categoryPage() {
|
||||||
);
|
);
|
||||||
check( response, {
|
check( response, {
|
||||||
'is status 200': ( r ) => r.status === 200,
|
'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 ) =>
|
"body contains: Category's title": ( response ) =>
|
||||||
response.body.includes(
|
response.body.includes(
|
||||||
`<h1 class="woocommerce-products-header__title page-title">${ product_category }</h1>`
|
`<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' ),
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
|
@ -70,10 +70,21 @@ export function checkoutCustomerLogin() {
|
||||||
} );
|
} );
|
||||||
check( response, {
|
check( response, {
|
||||||
'is status 200': ( r ) => r.status === 200,
|
'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 ) =>
|
'body contains checkout class': ( response ) =>
|
||||||
response.body.includes(
|
response.body.includes(
|
||||||
'class="checkout woocommerce-checkout"'
|
'class="checkout woocommerce-checkout"'
|
||||||
),
|
),
|
||||||
|
'footer contains: Built with WooCommerce': ( response ) =>
|
||||||
|
response
|
||||||
|
.html()
|
||||||
|
.find( 'body footer' )
|
||||||
|
.text()
|
||||||
|
.includes( 'Built with WooCommerce' ),
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// Correlate nonce values for use in subsequent requests.
|
// Correlate nonce values for use in subsequent requests.
|
||||||
|
@ -262,12 +273,23 @@ export function checkoutCustomerLogin() {
|
||||||
tags: { name: 'Shopper - Order Received' },
|
tags: { name: 'Shopper - Order Received' },
|
||||||
} );
|
} );
|
||||||
check( response, {
|
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.'": (
|
"body contains: 'Thank you. Your order has been received.'": (
|
||||||
response
|
response
|
||||||
) =>
|
) =>
|
||||||
response.body.includes(
|
response.body.includes(
|
||||||
'Thank you. Your order has been received.'
|
'Thank you. Your order has been received.'
|
||||||
),
|
),
|
||||||
|
'footer contains: Built with WooCommerce': ( response ) =>
|
||||||
|
response
|
||||||
|
.html()
|
||||||
|
.find( 'body footer' )
|
||||||
|
.text()
|
||||||
|
.includes( 'Built with WooCommerce' ),
|
||||||
} );
|
} );
|
||||||
|
|
||||||
const requestHeadersPost = Object.assign(
|
const requestHeadersPost = Object.assign(
|
||||||
|
|
|
@ -60,10 +60,21 @@ export function checkoutGuest() {
|
||||||
} );
|
} );
|
||||||
check( response, {
|
check( response, {
|
||||||
'is status 200': ( r ) => r.status === 200,
|
'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 ) =>
|
"body contains: 'woocommerce-checkout' class": ( response ) =>
|
||||||
response.body.includes(
|
response.body.includes(
|
||||||
'class="checkout woocommerce-checkout"'
|
'class="checkout woocommerce-checkout"'
|
||||||
),
|
),
|
||||||
|
'footer contains: Built with WooCommerce': ( response ) =>
|
||||||
|
response
|
||||||
|
.html()
|
||||||
|
.find( 'body footer' )
|
||||||
|
.text()
|
||||||
|
.includes( 'Built with WooCommerce' ),
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// Correlate nonce values for use in subsequent requests.
|
// Correlate nonce values for use in subsequent requests.
|
||||||
|
@ -173,12 +184,23 @@ export function checkoutGuest() {
|
||||||
tags: { name: 'Shopper - Order Received' },
|
tags: { name: 'Shopper - Order Received' },
|
||||||
} );
|
} );
|
||||||
check( response, {
|
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.'": (
|
"body contains: 'Thank you. Your order has been received.'": (
|
||||||
response
|
response
|
||||||
) =>
|
) =>
|
||||||
response.body.includes(
|
response.body.includes(
|
||||||
'Thank you. Your order has been received.'
|
'Thank you. Your order has been received.'
|
||||||
),
|
),
|
||||||
|
'footer contains: Built with WooCommerce': ( response ) =>
|
||||||
|
response
|
||||||
|
.html()
|
||||||
|
.find( 'body footer' )
|
||||||
|
.text()
|
||||||
|
.includes( 'Built with WooCommerce' ),
|
||||||
} );
|
} );
|
||||||
|
|
||||||
const requestHeadersPost = Object.assign(
|
const requestHeadersPost = Object.assign(
|
||||||
|
|
|
@ -36,6 +36,15 @@ export function homePage() {
|
||||||
} );
|
} );
|
||||||
check( response, {
|
check( response, {
|
||||||
'is status 200': ( r ) => r.status === 200,
|
'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' ),
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,21 @@ export function myAccountOrders() {
|
||||||
} );
|
} );
|
||||||
check( response, {
|
check( response, {
|
||||||
'is status 200': ( r ) => r.status === 200,
|
'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 ) =>
|
'body contains: my account welcome message': ( response ) =>
|
||||||
response.body.includes(
|
response.body.includes(
|
||||||
'From your account dashboard you can view'
|
'From your account dashboard you can view'
|
||||||
),
|
),
|
||||||
|
'footer contains: Built with WooCommerce': ( response ) =>
|
||||||
|
response
|
||||||
|
.html()
|
||||||
|
.find( 'body footer' )
|
||||||
|
.text()
|
||||||
|
.includes( 'Built with WooCommerce' ),
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -64,8 +75,19 @@ export function myAccountOrders() {
|
||||||
} );
|
} );
|
||||||
check( response, {
|
check( response, {
|
||||||
'is status 200': ( r ) => r.status === 200,
|
'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 ) =>
|
"body contains: 'Orders' title": ( response ) =>
|
||||||
response.body.includes( '>Orders</h1>' ),
|
response.body.includes( '>Orders</h1>' ),
|
||||||
|
'footer contains: Built with WooCommerce': ( response ) =>
|
||||||
|
response
|
||||||
|
.html()
|
||||||
|
.find( 'body footer' )
|
||||||
|
.text()
|
||||||
|
.includes( 'Built with WooCommerce' ),
|
||||||
} );
|
} );
|
||||||
my_account_order_id = findBetween(
|
my_account_order_id = findBetween(
|
||||||
response.body,
|
response.body,
|
||||||
|
@ -94,8 +116,19 @@ export function myAccountOrders() {
|
||||||
);
|
);
|
||||||
check( response, {
|
check( response, {
|
||||||
'is status 200': ( r ) => r.status === 200,
|
'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 ) =>
|
"body contains: 'Order number' title": ( response ) =>
|
||||||
response.body.includes( `${ my_account_order_id }</h1>` ),
|
response.body.includes( `${ my_account_order_id }</h1>` ),
|
||||||
|
'footer contains: Built with WooCommerce': ( response ) =>
|
||||||
|
response
|
||||||
|
.html()
|
||||||
|
.find( 'body footer' )
|
||||||
|
.text()
|
||||||
|
.includes( 'Built with WooCommerce' ),
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,19 @@ export function myAccount() {
|
||||||
} );
|
} );
|
||||||
check( response, {
|
check( response, {
|
||||||
'is status 200': ( r ) => r.status === 200,
|
'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 ) =>
|
"body contains: 'My account' title": ( response ) =>
|
||||||
response.body.includes( '>My account</h1>' ),
|
response.body.includes( '>My account</h1>' ),
|
||||||
|
'footer contains: Built with WooCommerce': ( response ) =>
|
||||||
|
response
|
||||||
|
.html()
|
||||||
|
.find( 'body footer' )
|
||||||
|
.text()
|
||||||
|
.includes( 'Built with WooCommerce' ),
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// Correlate nonce value for use in subsequent requests.
|
// Correlate nonce value for use in subsequent requests.
|
||||||
|
|
|
@ -44,8 +44,25 @@ export function searchProduct() {
|
||||||
);
|
);
|
||||||
check( response, {
|
check( response, {
|
||||||
'is status 200': ( r ) => r.status === 200,
|
'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();
|
||||||
|
const title_expected = new RegExp(
|
||||||
|
`Search Results for .${ product_search_term }. – WooCommerce Core E2E Test Suite`
|
||||||
|
);
|
||||||
|
return title_actual.match( title_expected );
|
||||||
|
},
|
||||||
"body contains: 'Search results' title": ( response ) =>
|
"body contains: 'Search results' title": ( response ) =>
|
||||||
response.body.includes( 'Search results:' ),
|
response.body.includes( 'Search results:' ),
|
||||||
|
'footer contains: Built with WooCommerce': ( response ) =>
|
||||||
|
response
|
||||||
|
.html()
|
||||||
|
.find( 'body footer' )
|
||||||
|
.text()
|
||||||
|
.includes( 'Built with WooCommerce' ),
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,27 @@ export function singleProduct() {
|
||||||
} );
|
} );
|
||||||
check( response, {
|
check( response, {
|
||||||
'is status 200': ( r ) => r.status === 200,
|
'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();
|
||||||
|
const title_expected = new RegExp(
|
||||||
|
`${ product_url } – WooCommerce Core E2E Test Suite`,
|
||||||
|
'i'
|
||||||
|
);
|
||||||
|
return title_actual.match( title_expected );
|
||||||
|
},
|
||||||
'body contains: product SKU': ( response ) =>
|
'body contains: product SKU': ( response ) =>
|
||||||
response.body.includes( `class="sku">${ product_sku }` ),
|
response.body.includes( `class="sku">${ product_sku }` ),
|
||||||
|
'footer contains: Built with WooCommerce': ( response ) =>
|
||||||
|
response
|
||||||
|
.html()
|
||||||
|
.find( 'body footer' )
|
||||||
|
.text()
|
||||||
|
.includes( 'Built with WooCommerce' ),
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue