Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinhenderson committed Aug 23, 2024
1 parent ae4ff13 commit c0ddb9f
Show file tree
Hide file tree
Showing 27 changed files with 1,065 additions and 1,138 deletions.
20 changes: 8 additions & 12 deletions cypress/e2e/blog-search.spec.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
28 changes: 12 additions & 16 deletions cypress/e2e/checkout.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("/");
});
});
4 changes: 2 additions & 2 deletions cypress/e2e/free-resource.spec.js
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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"
);
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/newsletter-signup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
context("Newsletter Sign Up", () => {
it(["pre-deploy"], "Signs up for the newsletter", () => {
it("Signs up for the newsletter", () => {
const email = "[email protected]";

cy.visit("/");
Expand Down
158 changes: 77 additions & 81 deletions cypress/e2e/paid-resources/checkout-new-account.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
Loading

0 comments on commit c0ddb9f

Please sign in to comment.