navbar tests

This commit is contained in:
Owen Rees
2023-06-16 15:15:17 +02:00
parent 7450bc82e3
commit e2d99d8f5a
12 changed files with 184 additions and 97 deletions
+2
View File
@@ -6,8 +6,10 @@ describe("Test all links", () => {
};
it("Check navbar links point to correct pathname as a slug", () => {
cy.viewport(600, 600);
cy.visit("/");
pages.forEach((page) => {
cy.get(".hamburger-button").click();
cy.contains(page, { matchCase: false }).click();
cy.location("pathname").should("eq", `/${navLinkToSlug(page)}`); // url path matches link name, replacing whitespace with hyphens
cy.go("back");
+31
View File
@@ -0,0 +1,31 @@
describe("Mobile Navbar", () => {
beforeEach(() => {
cy.viewport(600, 600);
cy.visit("/");
});
it("hamburger menu on mobile screens", () => {
cy.get(".mobile-menu").should("be.not.hidden");
cy.get(".desktop-menu").should("be.hidden");
});
it("hamburger button available", () => {
cy.get(".hamburger-button").should("be.visible");
});
});
describe("Desktop Navbar", () => {
beforeEach(() => {
cy.viewport("macbook-15");
cy.visit("/");
});
it("desktop menu on larger screens", () => {
cy.get(".mobile-menu").should("be.hidden");
cy.get(".desktop-menu").should("be.not.hidden");
});
it("hamburger button hidden", () => {
cy.get(".hamburger-button").should("be.not.visible");
});
});