diff --git a/plugins/woocommerce/changelog/add-k6-shopper-pages-title-footer b/plugins/woocommerce/changelog/add-k6-shopper-pages-title-footer new file mode 100644 index 00000000000..3f7050595f0 --- /dev/null +++ b/plugins/woocommerce/changelog/add-k6-shopper-pages-title-footer @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Add k6 perf test assertions to check for the correct page title and presence of footer. diff --git a/plugins/woocommerce/tests/performance/requests/shopper/cart.js b/plugins/woocommerce/tests/performance/requests/shopper/cart.js index 794e750929c..21f38e2956b 100644 --- a/plugins/woocommerce/tests/performance/requests/shopper/cart.js +++ b/plugins/woocommerce/tests/performance/requests/shopper/cart.js @@ -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' ), } ); } ); diff --git a/plugins/woocommerce/tests/performance/requests/shopper/category-page.js b/plugins/woocommerce/tests/performance/requests/shopper/category-page.js index 666299da8ee..e5be767659b 100644 --- a/plugins/woocommerce/tests/performance/requests/shopper/category-page.js +++ b/plugins/woocommerce/tests/performance/requests/shopper/category-page.js @@ -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( `

${ product_category }

` ), + 'footer contains: Built with WooCommerce': ( response ) => + response + .html() + .find( 'body footer' ) + .text() + .includes( 'Built with WooCommerce' ), } ); } ); diff --git a/plugins/woocommerce/tests/performance/requests/shopper/checkout-customer-login.js b/plugins/woocommerce/tests/performance/requests/shopper/checkout-customer-login.js index 47a1d03fe68..57b4c898c0e 100644 --- a/plugins/woocommerce/tests/performance/requests/shopper/checkout-customer-login.js +++ b/plugins/woocommerce/tests/performance/requests/shopper/checkout-customer-login.js @@ -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( diff --git a/plugins/woocommerce/tests/performance/requests/shopper/checkout-guest.js b/plugins/woocommerce/tests/performance/requests/shopper/checkout-guest.js index 1a7ff0676aa..ef41cce033c 100644 --- a/plugins/woocommerce/tests/performance/requests/shopper/checkout-guest.js +++ b/plugins/woocommerce/tests/performance/requests/shopper/checkout-guest.js @@ -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( diff --git a/plugins/woocommerce/tests/performance/requests/shopper/home.js b/plugins/woocommerce/tests/performance/requests/shopper/home.js index 175141375b1..7a7b8ba0498 100644 --- a/plugins/woocommerce/tests/performance/requests/shopper/home.js +++ b/plugins/woocommerce/tests/performance/requests/shopper/home.js @@ -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' ), } ); } ); diff --git a/plugins/woocommerce/tests/performance/requests/shopper/my-account-orders.js b/plugins/woocommerce/tests/performance/requests/shopper/my-account-orders.js index 3ec046b709e..20fee989208 100644 --- a/plugins/woocommerce/tests/performance/requests/shopper/my-account-orders.js +++ b/plugins/woocommerce/tests/performance/requests/shopper/my-account-orders.js @@ -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' ), + '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 }` ), + 'footer contains: Built with WooCommerce': ( response ) => + response + .html() + .find( 'body footer' ) + .text() + .includes( 'Built with WooCommerce' ), } ); } ); diff --git a/plugins/woocommerce/tests/performance/requests/shopper/my-account.js b/plugins/woocommerce/tests/performance/requests/shopper/my-account.js index b3b805eee5b..c39626fa5af 100644 --- a/plugins/woocommerce/tests/performance/requests/shopper/my-account.js +++ b/plugins/woocommerce/tests/performance/requests/shopper/my-account.js @@ -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' ), + 'footer contains: Built with WooCommerce': ( response ) => + response + .html() + .find( 'body footer' ) + .text() + .includes( 'Built with WooCommerce' ), } ); // Correlate nonce value for use in subsequent requests. diff --git a/plugins/woocommerce/tests/performance/requests/shopper/search-product.js b/plugins/woocommerce/tests/performance/requests/shopper/search-product.js index 4be4b226c23..edbdd662266 100644 --- a/plugins/woocommerce/tests/performance/requests/shopper/search-product.js +++ b/plugins/woocommerce/tests/performance/requests/shopper/search-product.js @@ -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' ), } ); } ); diff --git a/plugins/woocommerce/tests/performance/requests/shopper/single-product.js b/plugins/woocommerce/tests/performance/requests/shopper/single-product.js index 62c99023dc9..fa90b42a9be 100644 --- a/plugins/woocommerce/tests/performance/requests/shopper/single-product.js +++ b/plugins/woocommerce/tests/performance/requests/shopper/single-product.js @@ -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' ), } ); } );