Add checks for page title and footer (#46485)

This commit is contained in:
rodelgc 2024-04-12 20:01:39 +08:00 committed by GitHub
parent 8653d4c4fe
commit 522c8893a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 159 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Add k6 perf test assertions to check for the correct page title and presence of footer.

View File

@ -72,9 +72,20 @@ export function 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' ),
} );
} );

View File

@ -44,10 +44,21 @@ export function categoryPage() {
);
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' ),
} );
} );

View File

@ -70,10 +70,21 @@ export function checkoutCustomerLogin() {
} );
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' ),
} );
// Correlate nonce values for use in subsequent requests.
@ -262,12 +273,23 @@ export function checkoutCustomerLogin() {
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' ),
} );
const requestHeadersPost = Object.assign(

View File

@ -60,10 +60,21 @@ export function checkoutGuest() {
} );
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' ),
} );
// Correlate nonce values for use in subsequent requests.
@ -173,12 +184,23 @@ export function checkoutGuest() {
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' ),
} );
const requestHeadersPost = Object.assign(

View File

@ -36,6 +36,15 @@ export function homePage() {
} );
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' ),
} );
} );

View File

@ -40,10 +40,21 @@ export function myAccountOrders() {
} );
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' ),
} );
} );
@ -64,8 +75,19 @@ export function myAccountOrders() {
} );
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' ),
} );
my_account_order_id = findBetween(
response.body,
@ -94,8 +116,19 @@ export function myAccountOrders() {
);
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' ),
} );
} );

View File

@ -45,8 +45,19 @@ export function myAccount() {
} );
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' ),
} );
// Correlate nonce value for use in subsequent requests.

View File

@ -44,8 +44,25 @@ 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();
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 ) =>
response.body.includes( 'Search results:' ),
'footer contains: Built with WooCommerce': ( response ) =>
response
.html()
.find( 'body footer' )
.text()
.includes( 'Built with WooCommerce' ),
} );
} );

View File

@ -42,8 +42,27 @@ 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();
const title_expected = new RegExp(
`${ product_url } WooCommerce Core E2E Test Suite`,
'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' ),
} );
} );