From c0ddb9ff142da1c899e87165e1b472c95ecf53b7 Mon Sep 17 00:00:00 2001 From: Gavin Henderson Date: Fri, 23 Aug 2024 16:59:22 +0100 Subject: [PATCH] Fix tests --- cypress/e2e/blog-search.spec.js | 20 +- cypress/e2e/checkout.spec.js | 28 +- cypress/e2e/free-resource.spec.js | 4 +- cypress/e2e/newsletter-signup.js | 2 +- .../checkout-new-account.spec.js | 158 +++++----- .../checkout-when-signed-in.spec.js | 204 +++++++------ .../paid-resources/decline-3d-auth.spec.js | 182 ++++++----- .../paid-resources/insufficient-funds.spec.js | 134 ++++----- .../item-in-cart-register.spec.js | 218 +++++++------- .../e2e/paid-resources/item-in-cart.spec.js | 271 ++++++++--------- .../e2e/paid-resources/login-then-add.spec.js | 283 +++++++++--------- .../login-then-purchase.spec.js | 251 ++++++++-------- cypress/e2e/paid-resources/navigate.spec.js | 2 +- .../new-account-3d-auth.spec.js | 182 ++++++----- .../new-account-physical.spec.js | 160 +++++----- cypress/e2e/resources-browse.spec.js | 30 +- cypress/e2e/service-finder.spec.js | 24 +- cypress/e2e/smoke.spec.js | 2 +- cypress/e2e/user/login-disabled.spec.js | 2 +- cypress/e2e/user/login-enabled.spec.js | 32 +- cypress/e2e/user/login-no-account.spec.js | 2 +- cypress/e2e/user/login-successs.spec.js | 2 +- cypress/e2e/user/login-wrong-password.spec.js | 2 +- .../e2e/user/register-email-in-use.spec.js | 2 +- .../e2e/user/register-email-not-valid.spec.js | 2 +- .../user/register-password-to-short.spec.js | 2 +- cypress/e2e/user/register-success.spec.js | 2 +- 27 files changed, 1065 insertions(+), 1138 deletions(-) diff --git a/cypress/e2e/blog-search.spec.js b/cypress/e2e/blog-search.spec.js index adaa84039..ad2fce6da 100644 --- a/cypress/e2e/blog-search.spec.js +++ b/cypress/e2e/blog-search.spec.js @@ -1,17 +1,13 @@ context("Blog Search", () => { - it( - ["pre-deploy"], - "Completes a search and has the correct search text on the next page", - () => { - const searchText = "My search text"; + it("Completes a search and has the correct search text on the next page", () => { + const searchText = "My search text"; - cy.visit("/blog"); + cy.visit("/blog"); - cy.findByRole("textbox", { name: "Search blog posts" }).type( - `${searchText}{enter}` - ); + cy.findByRole("textbox", { name: "Search blog posts" }).type( + `${searchText}{enter}` + ); - cy.findByRole("heading", { name: /Results/i }).contains(searchText); - } - ); + cy.findByRole("heading", { name: /Results/i }).contains(searchText); + }); }); diff --git a/cypress/e2e/checkout.spec.js b/cypress/e2e/checkout.spec.js index 1b0e0c758..9b41b236a 100644 --- a/cypress/e2e/checkout.spec.js +++ b/cypress/e2e/checkout.spec.js @@ -14,22 +14,18 @@ context("Checkout", () => { }); }); - it( - ["pre-deploy"], - "Buys a single paid virtual product, on an existing account", - () => { - // Register - newEmail = validEmail(); - const password = "password"; - cy.visit("/login"); + it("Buys a single paid virtual product, on an existing account", () => { + // Register + newEmail = validEmail(); + const password = "password"; + cy.visit("/login"); - cy.wait(20000); + cy.wait(20000); - cy.get("#email").type(newEmail); - cy.get("#register-password").type(password); - cy.findByRole("button", { name: "Register" }).click(); - cy.url({ timeout: 40000 }).should("include", "my-acecentre"); - cy.visit("/"); - } - ); + cy.get("#email").type(newEmail); + cy.get("#register-password").type(password); + cy.findByRole("button", { name: "Register" }).click(); + cy.url({ timeout: 40000 }).should("include", "my-acecentre"); + cy.visit("/"); + }); }); diff --git a/cypress/e2e/free-resource.spec.js b/cypress/e2e/free-resource.spec.js index ea2ebadff..f14006fa8 100644 --- a/cypress/e2e/free-resource.spec.js +++ b/cypress/e2e/free-resource.spec.js @@ -1,5 +1,5 @@ context("Free resources", () => { - it(["pre-deploy"], "can navigate to a free resource", () => { + it("can navigate to a free resource", () => { cy.visit(""); cy.findAllByRole("link", { name: "Resources" }).first().click(); cy.findAllByRole("link", { name: "View all resources" }).first().click(); @@ -16,7 +16,7 @@ context("Free resources", () => { cy.findByRole("main").should("contain", "Free"); }); - it(["pre-deploy"], "can download a simple resource", () => { + it("can download a simple resource", () => { cy.visit( "/resources/high-contrast-listener-mediated-scan-charts-abc-frequency" ); diff --git a/cypress/e2e/newsletter-signup.js b/cypress/e2e/newsletter-signup.js index 4ef295a98..65b1e9417 100644 --- a/cypress/e2e/newsletter-signup.js +++ b/cypress/e2e/newsletter-signup.js @@ -1,5 +1,5 @@ context("Newsletter Sign Up", () => { - it(["pre-deploy"], "Signs up for the newsletter", () => { + it("Signs up for the newsletter", () => { const email = "cypress@gavinhenderson.co.uk"; cy.visit("/"); diff --git a/cypress/e2e/paid-resources/checkout-new-account.spec.js b/cypress/e2e/paid-resources/checkout-new-account.spec.js index 43da2e1ca..d5ac80082 100644 --- a/cypress/e2e/paid-resources/checkout-new-account.spec.js +++ b/cypress/e2e/paid-resources/checkout-new-account.spec.js @@ -16,85 +16,81 @@ context("Paid resources", () => { }); }); - it( - ["pre-deploy"], - "can add product to cart, and checkout with a new account", - () => { - newEmail = validEmail("checkout-new-account"); - - cy.visit("/resources/qwerty-2"); - cy.findByRole("button", { name: "Add to cart" }).click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - cy.findAllByRole("link", { name: "Checkout as New User" }).last().click(); - cy.url({ timeout: 60000 }).should("include", "register-checkout"); - - // Fill in email field - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("textbox", { - name: "Enter your email address", - }) - .type(newEmail); - - // Fill in password field - cy.findAllByRole("form", { name: "Register form" }) - .findByLabelText("Password") - .type(VALID_PASSWORD); - - // Click register - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("button", { name: "Register and checkout" }) - .click(); - - cy.url({ timeout: 60000 }).should("include", "/checkout"); - cy.findByRole("textbox", { name: "First name" }).type("John"); - cy.findByRole("textbox", { name: "Last name" }).type("Smith"); - cy.findByRole("combobox", { name: "Country" }).select( - "United Kingdom (UK)" - ); - cy.findByRole("textbox", { name: "Address Line 1" }).type( - "80 Fake Address" - ); - cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); - cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); - cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); - cy.findByRole("textbox", { name: "Email address" }).should( - "have.value", - newEmail - ); - cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card number" }) - .type("4242424242424242"); - - // data-elements-stable-field-name="cardExpiry" - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { - // Credit or debit card expiry date - // Credit or debit card expiration date - name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, - }) - .type("1224"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) - .type("123"); - - cy.findByRole("checkbox", { - name: "I have read and agree to the website terms and conditions and privacy policy", - }).click({ force: true }); - - cy.findByRole("button", { name: "Place order" }).click(); - cy.wait(1000); - cy.url({ timeout: 60000 }).should("include", "order"); - } - ); + it("can add product to cart, and checkout with a new account", () => { + newEmail = validEmail("checkout-new-account"); + + cy.visit("/resources/qwerty-2"); + cy.findByRole("button", { name: "Add to cart" }).click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + cy.findAllByRole("link", { name: "Checkout as New User" }).last().click(); + cy.url({ timeout: 60000 }).should("include", "register-checkout"); + + // Fill in email field + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("textbox", { + name: "Enter your email address", + }) + .type(newEmail); + + // Fill in password field + cy.findAllByRole("form", { name: "Register form" }) + .findByLabelText("Password") + .type(VALID_PASSWORD); + + // Click register + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("button", { name: "Register and checkout" }) + .click(); + + cy.url({ timeout: 60000 }).should("include", "/checkout"); + cy.findByRole("textbox", { name: "First name" }).type("John"); + cy.findByRole("textbox", { name: "Last name" }).type("Smith"); + cy.findByRole("combobox", { name: "Country" }).select( + "United Kingdom (UK)" + ); + cy.findByRole("textbox", { name: "Address Line 1" }).type( + "80 Fake Address" + ); + cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); + cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); + cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); + cy.findByRole("textbox", { name: "Email address" }).should( + "have.value", + newEmail + ); + cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card number" }) + .type("4242424242424242"); + + // data-elements-stable-field-name="cardExpiry" + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { + // Credit or debit card expiry date + // Credit or debit card expiration date + name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, + }) + .type("1224"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) + .type("123"); + + cy.findByRole("checkbox", { + name: "I have read and agree to the website terms and conditions and privacy policy", + }).click({ force: true }); + + cy.findByRole("button", { name: "Place order" }).click(); + cy.wait(1000); + cy.url({ timeout: 60000 }).should("include", "order"); + }); }); diff --git a/cypress/e2e/paid-resources/checkout-when-signed-in.spec.js b/cypress/e2e/paid-resources/checkout-when-signed-in.spec.js index 713b2ded1..7836ae1c7 100644 --- a/cypress/e2e/paid-resources/checkout-when-signed-in.spec.js +++ b/cypress/e2e/paid-resources/checkout-when-signed-in.spec.js @@ -16,108 +16,104 @@ context("Paid resources", () => { }); }); - it( - ["pre-deploy"], - "Add a product to cart, checkout when already signed in", - () => { - // Register for a new account - newEmail = validEmail("paid-resources"); - cy.visit(""); - cy.findAllByRole("link", { name: "Login" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "login"); - - // Fill in email field - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("textbox", { - name: "Email address", - }) - .type(newEmail); - - // Fill in password field - cy.findAllByRole("form", { name: "Register form" }) - .findByLabelText("Password") - .type(VALID_PASSWORD); - - // Click register - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("button", { name: "Register" }) - .click(); - - // Make sure we we end up on my-acecentre - cy.url({ timeout: 60000 }).should("include", "my-acecentre"); - cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); - - // Add to cart and check its added - cy.visit("/resources/qwerty-2"); - cy.findByRole("button", { name: "Add to cart" }).click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - - // Log back in - cy.findAllByRole("link", { name: "Checkout" }).last().click(); - - // Check we are at checkout - cy.url({ timeout: 60000 }).should("include", "/checkout"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - - // Fill out details - cy.findByRole("textbox", { name: "First name" }).type("John"); - cy.findByRole("textbox", { name: "Last name" }).type("Smith"); - cy.findByRole("combobox", { name: "Country" }).select( - "United Kingdom (UK)" - ); - cy.findByRole("textbox", { name: "Address Line 1" }).type( - "80 Fake Address" - ); - cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); - cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); - cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); - cy.findByRole("textbox", { name: "Email address" }).should( - "have.value", - newEmail - ); - cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card number" }) - .type("4242424242424242"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { - // Credit or debit card expiry date - // Credit or debit card expiration date - name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, - }) - .type("1224"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) - .type("123"); - - cy.findByRole("checkbox", { - name: "I have read and agree to the website terms and conditions and privacy policy", - }).click({ force: true }); - - cy.findByRole("button", { name: "Place order" }).click(); - cy.url({ timeout: 60000 }).should("include", "order"); - - // Check order is in account - cy.wait(2000); // Wait for render - cy.findAllByRole("link", { name: "My Ace Centre" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "my-acecentre"); - cy.findByRole("link", { name: "View your orders >" }).click(); - cy.url({ timeout: 60000 }).should("include", "my-acecentre/orders"); - cy.findAllByRole("button", { name: "Details" }) - .should("have.length", 1) - .first() - .click(); - cy.contains("QWERTY"); - } - ); + it("Add a product to cart, checkout when already signed in", () => { + // Register for a new account + newEmail = validEmail("paid-resources"); + cy.visit(""); + cy.findAllByRole("link", { name: "Login" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "login"); + + // Fill in email field + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("textbox", { + name: "Email address", + }) + .type(newEmail); + + // Fill in password field + cy.findAllByRole("form", { name: "Register form" }) + .findByLabelText("Password") + .type(VALID_PASSWORD); + + // Click register + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("button", { name: "Register" }) + .click(); + + // Make sure we we end up on my-acecentre + cy.url({ timeout: 60000 }).should("include", "my-acecentre"); + cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); + + // Add to cart and check its added + cy.visit("/resources/qwerty-2"); + cy.findByRole("button", { name: "Add to cart" }).click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + + // Log back in + cy.findAllByRole("link", { name: "Checkout" }).last().click(); + + // Check we are at checkout + cy.url({ timeout: 60000 }).should("include", "/checkout"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + + // Fill out details + cy.findByRole("textbox", { name: "First name" }).type("John"); + cy.findByRole("textbox", { name: "Last name" }).type("Smith"); + cy.findByRole("combobox", { name: "Country" }).select( + "United Kingdom (UK)" + ); + cy.findByRole("textbox", { name: "Address Line 1" }).type( + "80 Fake Address" + ); + cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); + cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); + cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); + cy.findByRole("textbox", { name: "Email address" }).should( + "have.value", + newEmail + ); + cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card number" }) + .type("4242424242424242"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { + // Credit or debit card expiry date + // Credit or debit card expiration date + name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, + }) + .type("1224"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) + .type("123"); + + cy.findByRole("checkbox", { + name: "I have read and agree to the website terms and conditions and privacy policy", + }).click({ force: true }); + + cy.findByRole("button", { name: "Place order" }).click(); + cy.url({ timeout: 60000 }).should("include", "order"); + + // Check order is in account + cy.wait(2000); // Wait for render + cy.findAllByRole("link", { name: "My Ace Centre" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "my-acecentre"); + cy.findByRole("link", { name: "View your orders >" }).click(); + cy.url({ timeout: 60000 }).should("include", "my-acecentre/orders"); + cy.findAllByRole("button", { name: "Details" }) + .should("have.length", 1) + .first() + .click(); + cy.contains("QWERTY"); + }); }); diff --git a/cypress/e2e/paid-resources/decline-3d-auth.spec.js b/cypress/e2e/paid-resources/decline-3d-auth.spec.js index 8b2e27f10..60f688f24 100644 --- a/cypress/e2e/paid-resources/decline-3d-auth.spec.js +++ b/cypress/e2e/paid-resources/decline-3d-auth.spec.js @@ -16,97 +16,93 @@ context("Paid resources", () => { }); }); - it( - ["pre-deploy"], - "can add product to cart, and checkout with a new account, decline 3D Auth", - () => { - newEmail = validEmail("decline-3d-auth"); - cy.visit("/resources/qwerty-2"); - cy.findByRole("button", { name: "Add to cart" }).click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - cy.findAllByRole("link", { name: "Checkout as New User" }).last().click(); - cy.url({ timeout: 60000 }).should("include", "register-checkout"); - - // Fill in email field - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("textbox", { - name: "Enter your email address", - }) - .type(newEmail); - - // Fill in password field - cy.findAllByRole("form", { name: "Register form" }) - .findByLabelText("Password") - .type(VALID_PASSWORD); - - // Click register - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("button", { name: "Register and checkout" }) - .click(); - - cy.url({ timeout: 60000 }).should("include", "/checkout"); - cy.findByRole("textbox", { name: "First name" }).type("John"); - cy.findByRole("textbox", { name: "Last name" }).type("Smith"); - cy.findByRole("combobox", { name: "Country" }).select( - "United Kingdom (UK)" - ); - cy.findByRole("textbox", { name: "Address Line 1" }).type( - "80 Fake Address" - ); - cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); - cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); - cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); - cy.findByRole("textbox", { name: "Email address" }).should( - "have.value", - newEmail - ); - cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card number" }) - .type("4000002500003155"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { - // Credit or debit card expiry date - // Credit or debit card expiration date - name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, - }) - .type("1224"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) - .type("123"); - - cy.findByRole("checkbox", { - name: "I have read and agree to the website terms and conditions and privacy policy", - }).click({ force: true }); - - cy.findByRole("button", { name: "Place order" }).click(); - - cy.wait(60000); - - // Huge hack to get into the many iframes for 3D Auth - // Any update to iframe names from stripe will break this - cy.get('iframe[name*="privateStripeFrame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findByRole("document") - .find("#challengeFrame") - .its("0.contentDocument") - .then(cy.wrap) - .findByRole("button", { name: "Fail" }) - .click(); - - cy.url({ timeout: 60000 }).should("include", "order"); - cy.contains("Order failed"); - } - ); + it("can add product to cart, and checkout with a new account, decline 3D Auth", () => { + newEmail = validEmail("decline-3d-auth"); + cy.visit("/resources/qwerty-2"); + cy.findByRole("button", { name: "Add to cart" }).click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + cy.findAllByRole("link", { name: "Checkout as New User" }).last().click(); + cy.url({ timeout: 60000 }).should("include", "register-checkout"); + + // Fill in email field + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("textbox", { + name: "Enter your email address", + }) + .type(newEmail); + + // Fill in password field + cy.findAllByRole("form", { name: "Register form" }) + .findByLabelText("Password") + .type(VALID_PASSWORD); + + // Click register + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("button", { name: "Register and checkout" }) + .click(); + + cy.url({ timeout: 60000 }).should("include", "/checkout"); + cy.findByRole("textbox", { name: "First name" }).type("John"); + cy.findByRole("textbox", { name: "Last name" }).type("Smith"); + cy.findByRole("combobox", { name: "Country" }).select( + "United Kingdom (UK)" + ); + cy.findByRole("textbox", { name: "Address Line 1" }).type( + "80 Fake Address" + ); + cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); + cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); + cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); + cy.findByRole("textbox", { name: "Email address" }).should( + "have.value", + newEmail + ); + cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card number" }) + .type("4000002500003155"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { + // Credit or debit card expiry date + // Credit or debit card expiration date + name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, + }) + .type("1224"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) + .type("123"); + + cy.findByRole("checkbox", { + name: "I have read and agree to the website terms and conditions and privacy policy", + }).click({ force: true }); + + cy.findByRole("button", { name: "Place order" }).click(); + + cy.wait(60000); + + // Huge hack to get into the many iframes for 3D Auth + // Any update to iframe names from stripe will break this + cy.get('iframe[name*="privateStripeFrame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findByRole("document") + .find("#challengeFrame") + .its("0.contentDocument") + .then(cy.wrap) + .findByRole("button", { name: "Fail" }) + .click(); + + cy.url({ timeout: 60000 }).should("include", "order"); + cy.contains("Order failed"); + }); }); diff --git a/cypress/e2e/paid-resources/insufficient-funds.spec.js b/cypress/e2e/paid-resources/insufficient-funds.spec.js index 9033f0d2b..402f689a4 100644 --- a/cypress/e2e/paid-resources/insufficient-funds.spec.js +++ b/cypress/e2e/paid-resources/insufficient-funds.spec.js @@ -16,83 +16,79 @@ context("Paid resources", () => { }); }); - it( - ["pre-deploy"], - "can add product to cart, and checkout without an account, with a card with insufficient funds", - () => { - newEmail = validEmail("insufficient-funds"); - cy.visit("/resources/qwerty-2"); - cy.findByRole("button", { name: "Add to cart" }).click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - cy.findAllByRole("link", { name: "Checkout as New User" }).last().click(); - cy.url({ timeout: 60000 }).should("include", "register-checkout"); + it("can add product to cart, and checkout without an account, with a card with insufficient funds", () => { + newEmail = validEmail("insufficient-funds"); + cy.visit("/resources/qwerty-2"); + cy.findByRole("button", { name: "Add to cart" }).click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + cy.findAllByRole("link", { name: "Checkout as New User" }).last().click(); + cy.url({ timeout: 60000 }).should("include", "register-checkout"); - // Fill in email field - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("textbox", { - name: "Enter your email address", - }) - .type(newEmail); + // Fill in email field + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("textbox", { + name: "Enter your email address", + }) + .type(newEmail); - // Fill in password field - cy.findAllByRole("form", { name: "Register form" }) - .findByLabelText("Password") - .type(VALID_PASSWORD); + // Fill in password field + cy.findAllByRole("form", { name: "Register form" }) + .findByLabelText("Password") + .type(VALID_PASSWORD); - // Click register - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("button", { name: "Register and checkout" }) - .click(); + // Click register + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("button", { name: "Register and checkout" }) + .click(); - cy.url({ timeout: 60000 }).should("include", "/checkout"); - cy.findByRole("textbox", { name: "First name" }).type("John"); - cy.findByRole("textbox", { name: "Last name" }).type("Smith"); - cy.findByRole("combobox", { name: "Country" }).select( - "United Kingdom (UK)" - ); - cy.findByRole("textbox", { name: "Address Line 1" }).type( - "80 Fake Address" - ); - cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); - cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); - cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); - cy.findByRole("textbox", { name: "Email address" }).should( - "have.value", - newEmail - ); - cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); + cy.url({ timeout: 60000 }).should("include", "/checkout"); + cy.findByRole("textbox", { name: "First name" }).type("John"); + cy.findByRole("textbox", { name: "Last name" }).type("Smith"); + cy.findByRole("combobox", { name: "Country" }).select( + "United Kingdom (UK)" + ); + cy.findByRole("textbox", { name: "Address Line 1" }).type( + "80 Fake Address" + ); + cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); + cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); + cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); + cy.findByRole("textbox", { name: "Email address" }).should( + "have.value", + newEmail + ); + cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card number" }) - .type("4000000000009995"); + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card number" }) + .type("4000000000009995"); - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { - // Credit or debit card expiry date - // Credit or debit card expiration date - name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, - }) - .type("1224"); + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { + // Credit or debit card expiry date + // Credit or debit card expiration date + name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, + }) + .type("1224"); - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) - .type("123"); + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) + .type("123"); - cy.findByRole("checkbox", { - name: "I have read and agree to the website terms and conditions and privacy policy", - }).click({ force: true }); + cy.findByRole("checkbox", { + name: "I have read and agree to the website terms and conditions and privacy policy", + }).click({ force: true }); - cy.findByRole("button", { name: "Place order" }).click(); + cy.findByRole("button", { name: "Place order" }).click(); - cy.url({ timeout: 60000 }).should("include", "order"); - cy.contains("Order failed"); - } - ); + cy.url({ timeout: 60000 }).should("include", "order"); + cy.contains("Order failed"); + }); }); diff --git a/cypress/e2e/paid-resources/item-in-cart-register.spec.js b/cypress/e2e/paid-resources/item-in-cart-register.spec.js index 848f4aa88..8f0045e65 100644 --- a/cypress/e2e/paid-resources/item-in-cart-register.spec.js +++ b/cypress/e2e/paid-resources/item-in-cart-register.spec.js @@ -16,115 +16,111 @@ context("Paid resources", () => { }); }); - it( - ["pre-deploy"], - "Add a product to cart, register and then purchase item already in cart", - () => { - // Register for a new account - newEmail = validEmail("item-in-cart-register"); - - // Add to cart and check its added - cy.visit("/resources/qwerty-2"); - cy.findByRole("button", { name: "Add to cart" }).click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - - cy.findAllByRole("link", { name: "Login" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "/login"); - - // Fill in email field - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("textbox", { - name: "Email address", - }) - .type(newEmail); - - // Fill in password field - cy.findAllByRole("form", { name: "Register form" }) - .findByLabelText("Password") - .type(VALID_PASSWORD); - - // Click register - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("button", { name: "Register" }) - .click(); - - // Make sure we we end up on my-acecentre - cy.url({ timeout: 60000 }).should("include", "/my-acecentre"); - cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); - - // Check we are logged in - cy.url({ timeout: 60000 }).should("include", "/my-acecentre"); - cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); - - // Go to cart - cy.wait(2000); // Wait for react render - cy.findAllByRole("link", { name: "Checkout" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - - // Go to checkout - cy.findAllByRole("link", { name: "Checkout" }).last().click(); - cy.url({ timeout: 60000 }).should("include", "/checkout"); - - // Fill out details - cy.findByRole("textbox", { name: "First name" }).type("John"); - cy.findByRole("textbox", { name: "Last name" }).type("Smith"); - cy.findByRole("combobox", { name: "Country" }).select( - "United Kingdom (UK)" - ); - cy.findByRole("textbox", { name: "Address Line 1" }).type( - "80 Fake Address" - ); - cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); - cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); - cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); - cy.findByRole("textbox", { name: "Email address" }).should( - "have.value", - newEmail - ); - cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card number" }) - .type("4242424242424242"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { - // Credit or debit card expiry date - // Credit or debit card expiration date - name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, - }) - .type("1224"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) - .type("123"); - - cy.findByRole("checkbox", { - name: "I have read and agree to the website terms and conditions and privacy policy", - }).click({ force: true }); - - cy.findByRole("button", { name: "Place order" }).click(); - cy.url({ timeout: 60000 }).should("include", "order"); - - // Check order is in account - cy.wait(2000); // Wait for re render - cy.findAllByRole("link", { name: "My Ace Centre" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "my-acecentre"); - cy.findByRole("link", { name: "View your orders >" }).click(); - cy.url({ timeout: 60000 }).should("include", "my-acecentre/orders"); - cy.findAllByRole("button", { name: "Details" }) - .should("have.length", 1) - .first() - .click(); - cy.contains("QWERTY"); - } - ); + it("Add a product to cart, register and then purchase item already in cart", () => { + // Register for a new account + newEmail = validEmail("item-in-cart-register"); + + // Add to cart and check its added + cy.visit("/resources/qwerty-2"); + cy.findByRole("button", { name: "Add to cart" }).click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + + cy.findAllByRole("link", { name: "Login" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "/login"); + + // Fill in email field + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("textbox", { + name: "Email address", + }) + .type(newEmail); + + // Fill in password field + cy.findAllByRole("form", { name: "Register form" }) + .findByLabelText("Password") + .type(VALID_PASSWORD); + + // Click register + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("button", { name: "Register" }) + .click(); + + // Make sure we we end up on my-acecentre + cy.url({ timeout: 60000 }).should("include", "/my-acecentre"); + cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); + + // Check we are logged in + cy.url({ timeout: 60000 }).should("include", "/my-acecentre"); + cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); + + // Go to cart + cy.wait(2000); // Wait for react render + cy.findAllByRole("link", { name: "Checkout" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + + // Go to checkout + cy.findAllByRole("link", { name: "Checkout" }).last().click(); + cy.url({ timeout: 60000 }).should("include", "/checkout"); + + // Fill out details + cy.findByRole("textbox", { name: "First name" }).type("John"); + cy.findByRole("textbox", { name: "Last name" }).type("Smith"); + cy.findByRole("combobox", { name: "Country" }).select( + "United Kingdom (UK)" + ); + cy.findByRole("textbox", { name: "Address Line 1" }).type( + "80 Fake Address" + ); + cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); + cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); + cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); + cy.findByRole("textbox", { name: "Email address" }).should( + "have.value", + newEmail + ); + cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card number" }) + .type("4242424242424242"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { + // Credit or debit card expiry date + // Credit or debit card expiration date + name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, + }) + .type("1224"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) + .type("123"); + + cy.findByRole("checkbox", { + name: "I have read and agree to the website terms and conditions and privacy policy", + }).click({ force: true }); + + cy.findByRole("button", { name: "Place order" }).click(); + cy.url({ timeout: 60000 }).should("include", "order"); + + // Check order is in account + cy.wait(2000); // Wait for re render + cy.findAllByRole("link", { name: "My Ace Centre" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "my-acecentre"); + cy.findByRole("link", { name: "View your orders >" }).click(); + cy.url({ timeout: 60000 }).should("include", "my-acecentre/orders"); + cy.findAllByRole("button", { name: "Details" }) + .should("have.length", 1) + .first() + .click(); + cy.contains("QWERTY"); + }); }); diff --git a/cypress/e2e/paid-resources/item-in-cart.spec.js b/cypress/e2e/paid-resources/item-in-cart.spec.js index 4d8c10ef4..8abd1cd71 100644 --- a/cypress/e2e/paid-resources/item-in-cart.spec.js +++ b/cypress/e2e/paid-resources/item-in-cart.spec.js @@ -16,143 +16,136 @@ context("Paid resources", () => { }); }); - it( - ["pre-deploy"], - "Add a product to cart, login and then purchase item already in cart", - () => { - // Register for a new account - newEmail = validEmail("item-in-cart"); - cy.visit(""); - cy.wait(1000); // Wait for the dom to stabilize - cy.findAllByRole("link", { name: "Login" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "login"); - - // Fill in email field - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("textbox", { - name: "Email address", - }) - .type(newEmail); - - // Fill in password field - cy.findAllByRole("form", { name: "Register form" }) - .findByLabelText("Password") - .type(VALID_PASSWORD); - - // Click register - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("button", { name: "Register" }) - .click(); - - // Make sure we we end up on my-acecentre - cy.url({ timeout: 60000 }).should("include", "my-acecentre"); - cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); - - // Log out - cy.findByRole("button", { name: "Logout" }).click(); - cy.url({ timeout: 60000 }).should( - "equal", - Cypress.config().baseUrl + "/" - ); - cy.findAllByRole("link", { name: "Login" }).should("exist"); - - // Add to cart and check its added - cy.visit("/resources/qwerty-2"); - cy.findByRole("button", { name: "Add to cart" }).click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - - // Log back in - cy.wait(1000); // Wait for the dom to stabilize - cy.findAllByRole("link", { name: "Login" }).first().click(); - - // Type in email - cy.findAllByRole("form", { name: "Login form" }) - .findByRole("textbox", { name: "Username or email address" }) - .type(newEmail); - - // Type in password - cy.findAllByRole("form", { name: "Login form" }) - .findByLabelText("Password") - .type(VALID_PASSWORD); - - // Hit login - cy.findAllByRole("form", { name: "Login form" }) - .findByRole("button", { name: "Log in" }) - .click(); - - // Check we are logged in - cy.url({ timeout: 60000 }).should("include", "/my-acecentre"); - cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); - - // Go to cart - cy.wait(1000); // Wait for the dom to stabilize - cy.findAllByRole("link", { name: "Checkout" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - - // Go to checkout - cy.findAllByRole("link", { name: "Checkout" }).last().click(); - cy.url({ timeout: 60000 }).should("include", "/checkout"); - - // Fill out details - cy.findByRole("textbox", { name: "First name" }).type("John"); - cy.findByRole("textbox", { name: "Last name" }).type("Smith"); - cy.findByRole("combobox", { name: "Country" }).select( - "United Kingdom (UK)" - ); - cy.findByRole("textbox", { name: "Address Line 1" }).type( - "80 Fake Address" - ); - cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); - cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); - cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); - cy.findByRole("textbox", { name: "Email address" }).should( - "have.value", - newEmail - ); - cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card number" }) - .type("4242424242424242"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { - // Credit or debit card expiry date - // Credit or debit card expiration date - name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, - }) - .type("1224"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) - .type("123"); - - cy.findByRole("checkbox", { - name: "I have read and agree to the website terms and conditions and privacy policy", - }).click({ force: true }); - - cy.findByRole("button", { name: "Place order" }).click(); - cy.url({ timeout: 60000 }).should("include", "order"); - - // Check order is in account - cy.wait(1000); // Wait for the dom to stabilize - cy.findAllByRole("link", { name: "My Ace Centre" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "my-acecentre"); - cy.findByRole("link", { name: "View your orders >" }).click(); - cy.wait(1000); // Wait for the dom to stabilize - cy.findAllByRole("button", { name: "Details" }) - .should("have.length", 1) - .first() - .click(); - cy.contains("QWERTY"); - } - ); + it("Add a product to cart, login and then purchase item already in cart", () => { + // Register for a new account + newEmail = validEmail("item-in-cart"); + cy.visit(""); + cy.wait(1000); // Wait for the dom to stabilize + cy.findAllByRole("link", { name: "Login" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "login"); + + // Fill in email field + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("textbox", { + name: "Email address", + }) + .type(newEmail); + + // Fill in password field + cy.findAllByRole("form", { name: "Register form" }) + .findByLabelText("Password") + .type(VALID_PASSWORD); + + // Click register + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("button", { name: "Register" }) + .click(); + + // Make sure we we end up on my-acecentre + cy.url({ timeout: 60000 }).should("include", "my-acecentre"); + cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); + + // Log out + cy.findByRole("button", { name: "Logout" }).click(); + cy.url({ timeout: 60000 }).should("equal", Cypress.config().baseUrl + "/"); + cy.findAllByRole("link", { name: "Login" }).should("exist"); + + // Add to cart and check its added + cy.visit("/resources/qwerty-2"); + cy.findByRole("button", { name: "Add to cart" }).click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + + // Log back in + cy.wait(1000); // Wait for the dom to stabilize + cy.findAllByRole("link", { name: "Login" }).first().click(); + + // Type in email + cy.findAllByRole("form", { name: "Login form" }) + .findByRole("textbox", { name: "Username or email address" }) + .type(newEmail); + + // Type in password + cy.findAllByRole("form", { name: "Login form" }) + .findByLabelText("Password") + .type(VALID_PASSWORD); + + // Hit login + cy.findAllByRole("form", { name: "Login form" }) + .findByRole("button", { name: "Log in" }) + .click(); + + // Check we are logged in + cy.url({ timeout: 60000 }).should("include", "/my-acecentre"); + cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); + + // Go to cart + cy.wait(1000); // Wait for the dom to stabilize + cy.findAllByRole("link", { name: "Checkout" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + + // Go to checkout + cy.findAllByRole("link", { name: "Checkout" }).last().click(); + cy.url({ timeout: 60000 }).should("include", "/checkout"); + + // Fill out details + cy.findByRole("textbox", { name: "First name" }).type("John"); + cy.findByRole("textbox", { name: "Last name" }).type("Smith"); + cy.findByRole("combobox", { name: "Country" }).select( + "United Kingdom (UK)" + ); + cy.findByRole("textbox", { name: "Address Line 1" }).type( + "80 Fake Address" + ); + cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); + cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); + cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); + cy.findByRole("textbox", { name: "Email address" }).should( + "have.value", + newEmail + ); + cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card number" }) + .type("4242424242424242"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { + // Credit or debit card expiry date + // Credit or debit card expiration date + name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, + }) + .type("1224"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) + .type("123"); + + cy.findByRole("checkbox", { + name: "I have read and agree to the website terms and conditions and privacy policy", + }).click({ force: true }); + + cy.findByRole("button", { name: "Place order" }).click(); + cy.url({ timeout: 60000 }).should("include", "order"); + + // Check order is in account + cy.wait(1000); // Wait for the dom to stabilize + cy.findAllByRole("link", { name: "My Ace Centre" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "my-acecentre"); + cy.findByRole("link", { name: "View your orders >" }).click(); + cy.wait(1000); // Wait for the dom to stabilize + cy.findAllByRole("button", { name: "Details" }) + .should("have.length", 1) + .first() + .click(); + cy.contains("QWERTY"); + }); }); diff --git a/cypress/e2e/paid-resources/login-then-add.spec.js b/cypress/e2e/paid-resources/login-then-add.spec.js index 7b036c95c..7a403031d 100644 --- a/cypress/e2e/paid-resources/login-then-add.spec.js +++ b/cypress/e2e/paid-resources/login-then-add.spec.js @@ -16,149 +16,142 @@ context("Paid resources", () => { }); }); - it( - ["pre-deploy"], - "Add a product to cart, login and add another item to cart then purchase items in cart", - () => { - // Register for a new account - newEmail = validEmail("login-then-add"); - cy.visit(""); - cy.wait(1000); // Wait for the dom to stabilize - cy.findAllByRole("link", { name: "Login" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "login"); - - // Fill in email field - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("textbox", { - name: "Email address", - }) - .type(newEmail); - - // Fill in password field - cy.findAllByRole("form", { name: "Register form" }) - .findByLabelText("Password") - .type(VALID_PASSWORD); - - // Click register - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("button", { name: "Register" }) - .click(); - - // Make sure we we end up on my-acecentre - cy.url({ timeout: 60000 }).should("include", "my-acecentre"); - cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); - - // Log out - cy.findByRole("button", { name: "Logout" }).click(); - cy.url({ timeout: 60000 }).should( - "equal", - Cypress.config().baseUrl + "/" - ); - cy.findAllByRole("link", { name: "Login" }).should("exist"); - - // Add to cart and check its added - cy.visit("/resources/qwerty-2"); - cy.findByRole("button", { name: "Add to cart" }).click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - - // Log back in - cy.wait(1000); // Wait for the dom to stabilize - cy.findAllByRole("link", { name: "Login" }).first().click(); - - // Type in email - cy.findAllByRole("form", { name: "Login form" }) - .findByRole("textbox", { name: "Username or email address" }) - .type(newEmail); - - // Type in password - cy.findAllByRole("form", { name: "Login form" }) - .findByLabelText("Password") - .type(VALID_PASSWORD); - - // Hit login - cy.findAllByRole("form", { name: "Login form" }) - .findByRole("button", { name: "Log in" }) - .click(); - - // Check we are logged in - cy.url({ timeout: 60000 }).should("include", "my-acecentre"); - cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); - - // Go to cart - cy.wait(1000); // Wait for the dom to stabilize - cy.findAllByRole("link", { name: "Checkout" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - - cy.visit("/resources/qwerty-2"); - cy.findByRole("button", { name: "Add to cart" }).click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£20.00"); - - // Go to checkout - cy.findAllByRole("link", { name: "Checkout" }).last().click(); - cy.url({ timeout: 60000 }).should("include", "/checkout"); - - // Fill out details - cy.findByRole("textbox", { name: "First name" }).type("John"); - cy.findByRole("textbox", { name: "Last name" }).type("Smith"); - cy.findByRole("combobox", { name: "Country" }).select( - "United Kingdom (UK)" - ); - cy.findByRole("textbox", { name: "Address Line 1" }).type( - "80 Fake Address" - ); - cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); - cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); - cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); - cy.findByRole("textbox", { name: "Email address" }).should( - "have.value", - newEmail - ); - cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card number" }) - .type("4242424242424242"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { - // Credit or debit card expiry date - // Credit or debit card expiration date - name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, - }) - .type("1224"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) - .type("123"); - - cy.findByRole("checkbox", { - name: "I have read and agree to the website terms and conditions and privacy policy", - }).click({ force: true }); - - cy.findByRole("button", { name: "Place order" }).click(); - cy.url({ timeout: 60000 }).should("include", "order"); - - // Check order is in account - cy.wait(1000); // Wait for the dom to stabilize - cy.findAllByRole("link", { name: "My Ace Centre" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "my-acecentre"); - cy.findByRole("link", { name: "View your orders >" }).click(); - cy.url({ timeout: 60000 }).should("include", "my-acecentre/orders"); - cy.wait(1000); // Wait for the dom to stabilize - cy.findAllByRole("button", { name: "Details" }) - .should("have.length", 1) - .first() - .click(); - cy.contains("QWERTY"); - } - ); + it("Add a product to cart, login and add another item to cart then purchase items in cart", () => { + // Register for a new account + newEmail = validEmail("login-then-add"); + cy.visit(""); + cy.wait(1000); // Wait for the dom to stabilize + cy.findAllByRole("link", { name: "Login" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "login"); + + // Fill in email field + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("textbox", { + name: "Email address", + }) + .type(newEmail); + + // Fill in password field + cy.findAllByRole("form", { name: "Register form" }) + .findByLabelText("Password") + .type(VALID_PASSWORD); + + // Click register + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("button", { name: "Register" }) + .click(); + + // Make sure we we end up on my-acecentre + cy.url({ timeout: 60000 }).should("include", "my-acecentre"); + cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); + + // Log out + cy.findByRole("button", { name: "Logout" }).click(); + cy.url({ timeout: 60000 }).should("equal", Cypress.config().baseUrl + "/"); + cy.findAllByRole("link", { name: "Login" }).should("exist"); + + // Add to cart and check its added + cy.visit("/resources/qwerty-2"); + cy.findByRole("button", { name: "Add to cart" }).click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + + // Log back in + cy.wait(1000); // Wait for the dom to stabilize + cy.findAllByRole("link", { name: "Login" }).first().click(); + + // Type in email + cy.findAllByRole("form", { name: "Login form" }) + .findByRole("textbox", { name: "Username or email address" }) + .type(newEmail); + + // Type in password + cy.findAllByRole("form", { name: "Login form" }) + .findByLabelText("Password") + .type(VALID_PASSWORD); + + // Hit login + cy.findAllByRole("form", { name: "Login form" }) + .findByRole("button", { name: "Log in" }) + .click(); + + // Check we are logged in + cy.url({ timeout: 60000 }).should("include", "my-acecentre"); + cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); + + // Go to cart + cy.wait(1000); // Wait for the dom to stabilize + cy.findAllByRole("link", { name: "Checkout" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + + cy.visit("/resources/qwerty-2"); + cy.findByRole("button", { name: "Add to cart" }).click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£20.00"); + + // Go to checkout + cy.findAllByRole("link", { name: "Checkout" }).last().click(); + cy.url({ timeout: 60000 }).should("include", "/checkout"); + + // Fill out details + cy.findByRole("textbox", { name: "First name" }).type("John"); + cy.findByRole("textbox", { name: "Last name" }).type("Smith"); + cy.findByRole("combobox", { name: "Country" }).select( + "United Kingdom (UK)" + ); + cy.findByRole("textbox", { name: "Address Line 1" }).type( + "80 Fake Address" + ); + cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); + cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); + cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); + cy.findByRole("textbox", { name: "Email address" }).should( + "have.value", + newEmail + ); + cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card number" }) + .type("4242424242424242"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { + // Credit or debit card expiry date + // Credit or debit card expiration date + name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, + }) + .type("1224"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) + .type("123"); + + cy.findByRole("checkbox", { + name: "I have read and agree to the website terms and conditions and privacy policy", + }).click({ force: true }); + + cy.findByRole("button", { name: "Place order" }).click(); + cy.url({ timeout: 60000 }).should("include", "order"); + + // Check order is in account + cy.wait(1000); // Wait for the dom to stabilize + cy.findAllByRole("link", { name: "My Ace Centre" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "my-acecentre"); + cy.findByRole("link", { name: "View your orders >" }).click(); + cy.url({ timeout: 60000 }).should("include", "my-acecentre/orders"); + cy.wait(1000); // Wait for the dom to stabilize + cy.findAllByRole("button", { name: "Details" }) + .should("have.length", 1) + .first() + .click(); + cy.contains("QWERTY"); + }); }); diff --git a/cypress/e2e/paid-resources/login-then-purchase.spec.js b/cypress/e2e/paid-resources/login-then-purchase.spec.js index 1a17958cd..6c9159adc 100644 --- a/cypress/e2e/paid-resources/login-then-purchase.spec.js +++ b/cypress/e2e/paid-resources/login-then-purchase.spec.js @@ -16,133 +16,126 @@ context("Paid resources", () => { }); }); - it( - ["pre-deploy"], - "Add a product to cart, login at checkout and then purchase item already in cart", - () => { - // Register for a new account - newEmail = validEmail("login-then-purchase"); - cy.visit(""); - cy.findAllByRole("link", { name: "Login" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "login"); - - // Fill in email field - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("textbox", { - name: "Email address", - }) - .type(newEmail); - - // Fill in password field - cy.findAllByRole("form", { name: "Register form" }) - .findByLabelText("Password") - .type(VALID_PASSWORD); - - // Click register - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("button", { name: "Register" }) - .click(); - - // Make sure we we end up on my-acecentre - cy.url({ timeout: 60000 }).should("include", "my-acecentre"); - cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); - - // Log out - cy.findByRole("button", { name: "Logout" }).click(); - cy.url({ timeout: 60000 }).should( - "equal", - Cypress.config().baseUrl + "/" - ); - cy.findAllByRole("link", { name: "Login" }).should("exist"); - - // Add to cart and check its added - cy.visit("/resources/qwerty-2"); - cy.findByRole("button", { name: "Add to cart" }).click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - - // Log back in - cy.findAllByRole("link", { name: "Checkout as Existing User" }) - .first() - .click(); - - // Type in email - cy.findAllByRole("form", { name: "Login form" }) - .findByRole("textbox", { name: "Username or email address" }) - .type(newEmail); - - // Type in password - cy.findAllByRole("form", { name: "Login form" }) - .findByLabelText("Password") - .type(VALID_PASSWORD); - - // Hit login - cy.findAllByRole("form", { name: "Login form" }) - .findByRole("button", { name: "Log in and checkout" }) - .click(); - - // Check we are at checkout - cy.url({ timeout: 60000 }).should("include", "/checkout"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - - // Fill out details - cy.findByRole("textbox", { name: "First name" }).type("John"); - cy.findByRole("textbox", { name: "Last name" }).type("Smith"); - cy.findByRole("combobox", { name: "Country" }).select( - "United Kingdom (UK)" - ); - cy.findByRole("textbox", { name: "Address Line 1" }).type( - "80 Fake Address" - ); - cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); - cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); - cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); - cy.findByRole("textbox", { name: "Email address" }).should( - "have.value", - newEmail - ); - cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card number" }) - .type("4242424242424242"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { - // Credit or debit card expiry date - // Credit or debit card expiration date - name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, - }) - .type("1224"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) - .type("123"); - - cy.findByRole("checkbox", { - name: "I have read and agree to the website terms and conditions and privacy policy", - }).click({ force: true }); - - cy.findByRole("button", { name: "Place order" }).click(); - cy.url({ timeout: 60000 }).should("include", "order"); - - // Check order is in account - cy.wait(1000); - cy.findAllByRole("link", { name: "My Ace Centre" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "my-acecentre"); - cy.findByRole("link", { name: "View your orders >" }).click(); - cy.url({ timeout: 60000 }).should("include", "my-acecentre/orders"); - cy.findAllByRole("button", { name: "Details" }) - .should("have.length", 1) - .first() - .click(); - cy.contains("QWERTY"); - } - ); + it("Add a product to cart, login at checkout and then purchase item already in cart", () => { + // Register for a new account + newEmail = validEmail("login-then-purchase"); + cy.visit(""); + cy.findAllByRole("link", { name: "Login" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "login"); + + // Fill in email field + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("textbox", { + name: "Email address", + }) + .type(newEmail); + + // Fill in password field + cy.findAllByRole("form", { name: "Register form" }) + .findByLabelText("Password") + .type(VALID_PASSWORD); + + // Click register + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("button", { name: "Register" }) + .click(); + + // Make sure we we end up on my-acecentre + cy.url({ timeout: 60000 }).should("include", "my-acecentre"); + cy.findAllByRole("link", { name: "My Ace Centre" }).should("exist"); + + // Log out + cy.findByRole("button", { name: "Logout" }).click(); + cy.url({ timeout: 60000 }).should("equal", Cypress.config().baseUrl + "/"); + cy.findAllByRole("link", { name: "Login" }).should("exist"); + + // Add to cart and check its added + cy.visit("/resources/qwerty-2"); + cy.findByRole("button", { name: "Add to cart" }).click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + + // Log back in + cy.findAllByRole("link", { name: "Checkout as Existing User" }) + .first() + .click(); + + // Type in email + cy.findAllByRole("form", { name: "Login form" }) + .findByRole("textbox", { name: "Username or email address" }) + .type(newEmail); + + // Type in password + cy.findAllByRole("form", { name: "Login form" }) + .findByLabelText("Password") + .type(VALID_PASSWORD); + + // Hit login + cy.findAllByRole("form", { name: "Login form" }) + .findByRole("button", { name: "Log in and checkout" }) + .click(); + + // Check we are at checkout + cy.url({ timeout: 60000 }).should("include", "/checkout"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + + // Fill out details + cy.findByRole("textbox", { name: "First name" }).type("John"); + cy.findByRole("textbox", { name: "Last name" }).type("Smith"); + cy.findByRole("combobox", { name: "Country" }).select( + "United Kingdom (UK)" + ); + cy.findByRole("textbox", { name: "Address Line 1" }).type( + "80 Fake Address" + ); + cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); + cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); + cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); + cy.findByRole("textbox", { name: "Email address" }).should( + "have.value", + newEmail + ); + cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card number" }) + .type("4242424242424242"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { + // Credit or debit card expiry date + // Credit or debit card expiration date + name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, + }) + .type("1224"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) + .type("123"); + + cy.findByRole("checkbox", { + name: "I have read and agree to the website terms and conditions and privacy policy", + }).click({ force: true }); + + cy.findByRole("button", { name: "Place order" }).click(); + cy.url({ timeout: 60000 }).should("include", "order"); + + // Check order is in account + cy.wait(1000); + cy.findAllByRole("link", { name: "My Ace Centre" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "my-acecentre"); + cy.findByRole("link", { name: "View your orders >" }).click(); + cy.url({ timeout: 60000 }).should("include", "my-acecentre/orders"); + cy.findAllByRole("button", { name: "Details" }) + .should("have.length", 1) + .first() + .click(); + cy.contains("QWERTY"); + }); }); diff --git a/cypress/e2e/paid-resources/navigate.spec.js b/cypress/e2e/paid-resources/navigate.spec.js index d874172b3..3477f764e 100644 --- a/cypress/e2e/paid-resources/navigate.spec.js +++ b/cypress/e2e/paid-resources/navigate.spec.js @@ -1,5 +1,5 @@ context("Paid resources", () => { - it(["pre-deploy"], "can navigate to a paid resource", () => { + it("can navigate to a paid resource", () => { cy.visit(""); cy.findAllByRole("link", { name: "Resources" }).first().click(); cy.url({ timeout: 60000 }).should("include", "resources"); diff --git a/cypress/e2e/paid-resources/new-account-3d-auth.spec.js b/cypress/e2e/paid-resources/new-account-3d-auth.spec.js index ec76dccd0..132c47750 100644 --- a/cypress/e2e/paid-resources/new-account-3d-auth.spec.js +++ b/cypress/e2e/paid-resources/new-account-3d-auth.spec.js @@ -16,97 +16,93 @@ context("Paid resources", () => { }); }); - it( - ["pre-deploy"], - "can add product to cart, and checkout with a new account, with 3D Auth", - () => { - newEmail = validEmail("new-account-3d-auth"); - cy.visit("/resources/qwerty-2"); - cy.findByRole("button", { name: "Add to cart" }).click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); - cy.findAllByRole("link", { name: "Checkout as New User" }).last().click(); - cy.url({ timeout: 60000 }).should("include", "register-checkout"); - - // Fill in email field - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("textbox", { - name: "Enter your email address", - }) - .type(newEmail); - - // Fill in password field - cy.findAllByRole("form", { name: "Register form" }) - .findByLabelText("Password") - .type(VALID_PASSWORD); - - // Click register - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("button", { name: "Register and checkout" }) - .click(); - - cy.url({ timeout: 60000 }).should("include", "/checkout"); - cy.findByRole("textbox", { name: "First name" }).type("John"); - cy.findByRole("textbox", { name: "Last name" }).type("Smith"); - cy.findByRole("combobox", { name: "Country" }).select( - "United Kingdom (UK)" - ); - cy.findByRole("textbox", { name: "Address Line 1" }).type( - "80 Fake Address" - ); - cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); - cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); - cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); - cy.findByRole("textbox", { name: "Email address" }).should( - "have.value", - newEmail - ); - cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card number" }) - .type("4000002500003155"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { - // Credit or debit card expiry date - // Credit or debit card expiration date - name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, - }) - .type("1224"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) - .type("123"); - - cy.findByRole("checkbox", { - name: "I have read and agree to the website terms and conditions and privacy policy", - }).click({ force: true }); - - cy.findByRole("button", { name: "Place order" }).click(); - - cy.wait(60000); - - // Huge hack to get into the many iframes for 3D Auth - // Any update to iframe names from stripe will break this - cy.get('iframe[name*="privateStripeFrame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findByRole("document") - .find("#challengeFrame") - .its("0.contentDocument") - .then(cy.wrap) - - .findByRole("button", { name: "Complete" }) - .click(); - - cy.url({ timeout: 60000 }).should("include", "order"); - } - ); + it("can add product to cart, and checkout with a new account, with 3D Auth", () => { + newEmail = validEmail("new-account-3d-auth"); + cy.visit("/resources/qwerty-2"); + cy.findByRole("button", { name: "Add to cart" }).click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£10.00"); + cy.findAllByRole("link", { name: "Checkout as New User" }).last().click(); + cy.url({ timeout: 60000 }).should("include", "register-checkout"); + + // Fill in email field + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("textbox", { + name: "Enter your email address", + }) + .type(newEmail); + + // Fill in password field + cy.findAllByRole("form", { name: "Register form" }) + .findByLabelText("Password") + .type(VALID_PASSWORD); + + // Click register + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("button", { name: "Register and checkout" }) + .click(); + + cy.url({ timeout: 60000 }).should("include", "/checkout"); + cy.findByRole("textbox", { name: "First name" }).type("John"); + cy.findByRole("textbox", { name: "Last name" }).type("Smith"); + cy.findByRole("combobox", { name: "Country" }).select( + "United Kingdom (UK)" + ); + cy.findByRole("textbox", { name: "Address Line 1" }).type( + "80 Fake Address" + ); + cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); + cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); + cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); + cy.findByRole("textbox", { name: "Email address" }).should( + "have.value", + newEmail + ); + cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card number" }) + .type("4000002500003155"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { + // Credit or debit card expiry date + // Credit or debit card expiration date + name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, + }) + .type("1224"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) + .type("123"); + + cy.findByRole("checkbox", { + name: "I have read and agree to the website terms and conditions and privacy policy", + }).click({ force: true }); + + cy.findByRole("button", { name: "Place order" }).click(); + + cy.wait(60000); + + // Huge hack to get into the many iframes for 3D Auth + // Any update to iframe names from stripe will break this + cy.get('iframe[name*="privateStripeFrame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findByRole("document") + .find("#challengeFrame") + .its("0.contentDocument") + .then(cy.wrap) + + .findByRole("button", { name: "Complete" }) + .click(); + + cy.url({ timeout: 60000 }).should("include", "order"); + }); }); diff --git a/cypress/e2e/paid-resources/new-account-physical.spec.js b/cypress/e2e/paid-resources/new-account-physical.spec.js index 924bc9d09..2d302e1fd 100644 --- a/cypress/e2e/paid-resources/new-account-physical.spec.js +++ b/cypress/e2e/paid-resources/new-account-physical.spec.js @@ -16,87 +16,81 @@ context("Paid resources", () => { }); }); - it( - ["pre-deploy"], - "can add product to cart, and checkout with a new account, physical product", - () => { - newEmail = validEmail("new-account-physical"); - cy.visit("/resources/developing-using-communication-book"); - cy.findByRole("button", { name: "Add to cart" }).click(); - cy.url({ timeout: 60000 }).should("include", "basket"); - cy.findAllByRole("row", { name: /Total/g }).should("contain", "£50.00"); - cy.findAllByRole("link", { name: "Checkout" }).last().click(); - cy.findAllByRole("link", { name: "Checkout as New User" }).last().click(); - cy.url({ timeout: 60000 }).should("include", "register-checkout"); - - // Fill in email field - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("textbox", { - name: "Enter your email address", - }) - .type(newEmail); - - // Fill in password field - cy.findAllByRole("form", { name: "Register form" }) - .findByLabelText("Password") - .type(VALID_PASSWORD); - - // Click register - cy.findAllByRole("form", { name: "Register form" }) - .findByRole("button", { name: "Register and checkout" }) - .click(); - - cy.url({ timeout: 60000 }).should("include", "/checkout"); - - cy.findByRole("textbox", { name: "First name" }).type("John"); - cy.findByRole("textbox", { name: "Last name" }).type("Smith"); - cy.findByRole("combobox", { name: "Country" }).select( - "United Kingdom (UK)" - ); - cy.findByRole("textbox", { name: "Address Line 1" }).type( - "80 Fake Address" - ); - cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); - cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); - cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); - cy.findByRole("textbox", { name: "Email address" }).should( - "have.value", - newEmail - ); - cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card number" }) - .type("4242424242424242"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { - // Credit or debit card expiry date - // Credit or debit card expiration date - name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, - }) - .type("1224"); - - cy.get('iframe[title="Secure card payment input frame"]') - .its("0.contentDocument") - .then(cy.wrap) - .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) - .type("123"); - - cy.findByRole("checkbox", { - name: "I have read and agree to the website terms and conditions and privacy policy", - }).click({ force: true }); - - cy.findByRole("button", { name: "Place order" }).click(); - cy.url({ timeout: 60000 }).should("include", "order"); - - cy.findByRole("heading", { name: "An error occurred" }).should( - "not.exist" - ); - } - ); + it("can add product to cart, and checkout with a new account, physical product", () => { + newEmail = validEmail("new-account-physical"); + cy.visit("/resources/developing-using-communication-book"); + cy.findByRole("button", { name: "Add to cart" }).click(); + cy.url({ timeout: 60000 }).should("include", "basket"); + cy.findAllByRole("row", { name: /Total/g }).should("contain", "£50.00"); + cy.findAllByRole("link", { name: "Checkout" }).last().click(); + cy.findAllByRole("link", { name: "Checkout as New User" }).last().click(); + cy.url({ timeout: 60000 }).should("include", "register-checkout"); + + // Fill in email field + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("textbox", { + name: "Enter your email address", + }) + .type(newEmail); + + // Fill in password field + cy.findAllByRole("form", { name: "Register form" }) + .findByLabelText("Password") + .type(VALID_PASSWORD); + + // Click register + cy.findAllByRole("form", { name: "Register form" }) + .findByRole("button", { name: "Register and checkout" }) + .click(); + + cy.url({ timeout: 60000 }).should("include", "/checkout"); + + cy.findByRole("textbox", { name: "First name" }).type("John"); + cy.findByRole("textbox", { name: "Last name" }).type("Smith"); + cy.findByRole("combobox", { name: "Country" }).select( + "United Kingdom (UK)" + ); + cy.findByRole("textbox", { name: "Address Line 1" }).type( + "80 Fake Address" + ); + cy.findByRole("textbox", { name: "Town / City" }).type("Manchester"); + cy.findByRole("textbox", { name: "Postcode" }).type("OL8 3QL"); + cy.findByRole("textbox", { name: "Phone number" }).type("07545783496"); + cy.findByRole("textbox", { name: "Email address" }).should( + "have.value", + newEmail + ); + cy.findByRole("textbox", { name: "Email address" }).should("be.disabled"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card number" }) + .type("4242424242424242"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { + // Credit or debit card expiry date + // Credit or debit card expiration date + name: /\bCredit\s+or\s+debit\s+card\s+(expiry|expiration)\s+date\b/g, + }) + .type("1224"); + + cy.get('iframe[title="Secure card payment input frame"]') + .its("0.contentDocument") + .then(cy.wrap) + .findAllByRole("textbox", { name: "Credit or debit card CVC/CVV" }) + .type("123"); + + cy.findByRole("checkbox", { + name: "I have read and agree to the website terms and conditions and privacy policy", + }).click({ force: true }); + + cy.findByRole("button", { name: "Place order" }).click(); + cy.url({ timeout: 60000 }).should("include", "order"); + + cy.findByRole("heading", { name: "An error occurred" }).should("not.exist"); + }); }); diff --git a/cypress/e2e/resources-browse.spec.js b/cypress/e2e/resources-browse.spec.js index d3bba8ee7..e7ba3d46f 100644 --- a/cypress/e2e/resources-browse.spec.js +++ b/cypress/e2e/resources-browse.spec.js @@ -1,27 +1,21 @@ context("Resources Browse", () => { - it( - ["pre-deploy"], - "Completes a search and has the correct search text on the next page", - () => { - const searchText = "test"; + it("Completes a search and has the correct search text on the next page", () => { + const searchText = "test"; - cy.visit("/"); + cy.visit("/"); - // Click the resources link in the nav - cy.findByTestId("subnav") - .findByRole("link", { name: "Resources" }) - .click(); + // Click the resources link in the nav + cy.findByTestId("subnav").findByRole("link", { name: "Resources" }).click(); - // Find the search box and then type 'a' - cy.findByRole("textbox", { name: "Search resources" }).type( - `${searchText}{enter}` - ); + // Find the search box and then type 'a' + cy.findByRole("textbox", { name: "Search resources" }).type( + `${searchText}{enter}` + ); - cy.contains("You searched for").contains(searchText); - } - ); + cy.contains("You searched for").contains(searchText); + }); - it(["pre-deploy"], "Make a search from the resources page", () => { + it("Make a search from the resources page", () => { const searchText = "test"; cy.visit("/resources/all"); diff --git a/cypress/e2e/service-finder.spec.js b/cypress/e2e/service-finder.spec.js index 503432700..1410a092a 100644 --- a/cypress/e2e/service-finder.spec.js +++ b/cypress/e2e/service-finder.spec.js @@ -1,5 +1,5 @@ context("Service Finder", () => { - it(["pre-deploy"], "Finds services based on geolocation", () => { + it("Finds services based on geolocation", () => { cy.visit("/nhs-service-finder", { onBeforeLoad(win) { // Force manchester @@ -19,20 +19,16 @@ context("Service Finder", () => { cy.contains("North West AT Service").should("exist"); }); - it( - ["pre-deploy"], - "Shows an error when you given an invalid postcode", - () => { - cy.visit("/nhs-service-finder"); + it("Shows an error when you given an invalid postcode", () => { + cy.visit("/nhs-service-finder"); - cy.findByRole("textbox", { name: "Enter your postcode" }).type("ABCDE"); - cy.findByRole("button", { name: "Find services" }).click(); + cy.findByRole("textbox", { name: "Enter your postcode" }).type("ABCDE"); + cy.findByRole("button", { name: "Find services" }).click(); - cy.contains("Postcode not found").should("exist"); - } - ); + cy.contains("Postcode not found").should("exist"); + }); - it(["pre-deploy"], "Finds services based on postcode", () => { + it("Finds services based on postcode", () => { cy.visit("/nhs-service-finder"); cy.findByRole("textbox", { name: "Enter your postcode" }).type("OL83QL"); @@ -42,7 +38,7 @@ context("Service Finder", () => { cy.contains("North West AT Service").should("exist"); }); - it(["pre-deploy"], "Can click through to service page", () => { + it("Can click through to service page", () => { cy.visit("/nhs-service-finder"); cy.findByRole("textbox", { name: "Enter your postcode" }).type("OL83QL"); @@ -52,7 +48,7 @@ context("Service Finder", () => { cy.contains("Ace Centre North").should("exist"); }); - it(["pre-deploy"], "Can click through to map", () => { + it("Can click through to map", () => { Cypress.on("uncaught:exception", (err) => { if (err.message.includes("L is not defined")) return false; diff --git a/cypress/e2e/smoke.spec.js b/cypress/e2e/smoke.spec.js index 671b6d131..f604e16e8 100644 --- a/cypress/e2e/smoke.spec.js +++ b/cypress/e2e/smoke.spec.js @@ -1,5 +1,5 @@ context("Smoke", () => { - it(["pre-deploy"], "loads the webpage without any issues", () => { + it("loads the webpage without any issues", () => { cy.visit("/"); cy.get("#__next").should("exist"); }); diff --git a/cypress/e2e/user/login-disabled.spec.js b/cypress/e2e/user/login-disabled.spec.js index 192725d42..25ae1d674 100644 --- a/cypress/e2e/user/login-disabled.spec.js +++ b/cypress/e2e/user/login-disabled.spec.js @@ -1,5 +1,5 @@ context("Login", () => { - it(["pre-deploy"], "disables the login button by default", () => { + it("disables the login button by default", () => { cy.visit(""); cy.findAllByRole("link", { name: "Login" }).first().click(); cy.url({ timeout: 60000 }).should("include", "/login"); diff --git a/cypress/e2e/user/login-enabled.spec.js b/cypress/e2e/user/login-enabled.spec.js index 50172b70c..5ff221064 100644 --- a/cypress/e2e/user/login-enabled.spec.js +++ b/cypress/e2e/user/login-enabled.spec.js @@ -1,23 +1,19 @@ context("Login", () => { - it( - ["pre-deploy"], - "enables the login button when you enter text into each field", - () => { - cy.visit(""); - cy.findAllByRole("link", { name: "Login" }).first().click(); - cy.url({ timeout: 60000 }).should("include", "/login"); + it("enables the login button when you enter text into each field", () => { + cy.visit(""); + cy.findAllByRole("link", { name: "Login" }).first().click(); + cy.url({ timeout: 60000 }).should("include", "/login"); - cy.findAllByRole("form", { name: "Login form" }) - .findByRole("textbox", { name: "Username or email address" }) - .type("email@email.com"); + cy.findAllByRole("form", { name: "Login form" }) + .findByRole("textbox", { name: "Username or email address" }) + .type("email@email.com"); - cy.findAllByRole("form", { name: "Login form" }) - .findByLabelText("Password") - .type("password"); + cy.findAllByRole("form", { name: "Login form" }) + .findByLabelText("Password") + .type("password"); - cy.findAllByRole("form", { name: "Login form" }) - .findByRole("button", { name: "Log in" }) - .should("not.be.disabled"); - } - ); + cy.findAllByRole("form", { name: "Login form" }) + .findByRole("button", { name: "Log in" }) + .should("not.be.disabled"); + }); }); diff --git a/cypress/e2e/user/login-no-account.spec.js b/cypress/e2e/user/login-no-account.spec.js index 188236629..9eccddf08 100644 --- a/cypress/e2e/user/login-no-account.spec.js +++ b/cypress/e2e/user/login-no-account.spec.js @@ -1,7 +1,7 @@ const NO_ACC_EMAIL = "thisisnotanaccount@gavin.com"; context("Login", () => { - it(["pre-deploy"], "shows an error when no account exists", () => { + it("shows an error when no account exists", () => { cy.visit(""); cy.findAllByRole("link", { name: "Login" }).first().click(); cy.url({ timeout: 60000 }).should("include", "/login"); diff --git a/cypress/e2e/user/login-successs.spec.js b/cypress/e2e/user/login-successs.spec.js index 42464865a..562a45a52 100644 --- a/cypress/e2e/user/login-successs.spec.js +++ b/cypress/e2e/user/login-successs.spec.js @@ -2,7 +2,7 @@ const TEST_ACC = "cypress@test.com"; const TEST_PASS = "cypresstestpassword"; context("Login", () => { - it(["pre-deploy"], "successfully logs in to a valid account", () => { + it("successfully logs in to a valid account", () => { cy.visit(""); cy.findAllByRole("link", { name: "Login" }).first().click(); cy.url({ timeout: 60000 }).should("include", "/login"); diff --git a/cypress/e2e/user/login-wrong-password.spec.js b/cypress/e2e/user/login-wrong-password.spec.js index ab8e528b8..10b84a020 100644 --- a/cypress/e2e/user/login-wrong-password.spec.js +++ b/cypress/e2e/user/login-wrong-password.spec.js @@ -1,7 +1,7 @@ const ACCOUNT_EXISTS = "ghenderson@acecentre.org.uk"; context("Login", () => { - it(["pre-deploy"], "shows an error when password is wrong", () => { + it("shows an error when password is wrong", () => { cy.visit(""); cy.findAllByRole("link", { name: "Login" }).first().click(); cy.url({ timeout: 60000 }).should("include", "/login"); diff --git a/cypress/e2e/user/register-email-in-use.spec.js b/cypress/e2e/user/register-email-in-use.spec.js index b0dd020c8..9b6b7fc12 100644 --- a/cypress/e2e/user/register-email-in-use.spec.js +++ b/cypress/e2e/user/register-email-in-use.spec.js @@ -2,7 +2,7 @@ const VALID_PASSWORD = "averyvalidpassword"; const EXISTING_EMAIL = "ghenderson@acecentre.org.uk"; context("Register", () => { - it(["pre-deploy"], "Shows an error when the email address is in use", () => { + it("Shows an error when the email address is in use", () => { cy.visit(""); cy.findAllByRole("link", { name: "Login" }).first().click(); cy.url({ timeout: 60000 }).should("include", "/login"); diff --git a/cypress/e2e/user/register-email-not-valid.spec.js b/cypress/e2e/user/register-email-not-valid.spec.js index ed6dd94df..c2f5715b6 100644 --- a/cypress/e2e/user/register-email-not-valid.spec.js +++ b/cypress/e2e/user/register-email-not-valid.spec.js @@ -2,7 +2,7 @@ const VALID_PASSWORD = "averyvalidpassword"; const INVALID_EMAIL = "email@email@email.com"; context("Register", () => { - it(["pre-deploy"], "Shows an error when you email is not valid", () => { + it("Shows an error when you email is not valid", () => { cy.visit(""); cy.findAllByRole("link", { name: "Login" }).first().click(); cy.url({ timeout: 60000 }).should("include", "/login"); diff --git a/cypress/e2e/user/register-password-to-short.spec.js b/cypress/e2e/user/register-password-to-short.spec.js index cbce7b0da..fe223f2e8 100644 --- a/cypress/e2e/user/register-password-to-short.spec.js +++ b/cypress/e2e/user/register-password-to-short.spec.js @@ -3,7 +3,7 @@ import { validEmail } from "../../support/valid-email"; const SHORT_PASSWORD = "short"; context("Register", () => { - it(["pre-deploy"], "Shows an error when you password is to short", () => { + it("Shows an error when you password is to short", () => { cy.visit(""); cy.findAllByRole("link", { name: "Login" }).first().click(); cy.url({ timeout: 60000 }).should("include", "/login"); diff --git a/cypress/e2e/user/register-success.spec.js b/cypress/e2e/user/register-success.spec.js index b925f6f44..395cacfd7 100644 --- a/cypress/e2e/user/register-success.spec.js +++ b/cypress/e2e/user/register-success.spec.js @@ -16,7 +16,7 @@ context("Register", () => { }); }); - it(["pre-deploy"], "Registers in, checks email in details, logs out", () => { + it("Registers in, checks email in details, logs out", () => { // Store email address for later newEmail = validEmail("register-success");