Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions cypress/e2e/homepage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { validateHeaderLinks, validateHeaderLogo, validateModalMenuLinks } from "../util/validateHeader";
import validateFooter from "../util/validateFooter";

describe("Homepage", () => {
Expand All @@ -7,10 +8,23 @@ describe("Homepage", () => {

it("should display the homepage", () => {
cy.title().should("include", "TechIsHiring");
cy.get("header").should("be.visible");
cy.get('.sticky > :nth-child(1) > a > .chakra-heading').contains('TechIsHiring');
cy.get('header > div > nav > ul').should('be.visible');

validateHeaderLogo();
validateHeaderLinks();

validateFooter('desktop')
validateFooter('desktop');
});

it("should display the homepage on mobile", () => {
cy.viewport('iphone-5');

cy.title().should("include", "TechIsHiring");
validateHeaderLogo();
cy.get('[data-cy=header]').within(() => {
cy.get('nav').click();
});
validateModalMenuLinks();

validateFooter('mobile');
})
});
36 changes: 36 additions & 0 deletions cypress/util/validateHeader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export const validateHeaderLogo = () => {

cy.log('-----START HEADER LOGO-----')
// since both mobile and desktop versions are in the DOM as the same time, we scope with [data-cy]
cy.get('[data-cy=header]').within(() => {
cy.validateLink('TechIsHiring', '/')
})
// test the main navigation links for the site
cy.log('-----END HEADER LOGO-----')
}

const validateLinks = () => {
cy.validateLink('Home', '/')
cy.validateLink('Newsletter', 'https://newsletter.techishiring.com/', 'new tab')
cy.validateLink('About', '/about')
cy.validateLink('Contact Us', '/contact')
}

export const validateHeaderLinks = () => {
cy.log('-----START HEADER LINKS-----')
cy.get('[data-cy=header]').within(() => {
validateLinks()
})
// test the main navigation links for the site
cy.log('-----END HEADER LINKS-----')
}

export const validateModalMenuLinks = () => {
cy.log('-----START MODAL MENU LINKS-----')
// since both mobile and desktop versions are in the DOM as the same time, we scope with [data-cy]
cy.get('[role=dialog]').within(() => {
validateLinks()
})
// test the main navigation links for the site
cy.log('-----END MODAL MENU LINKS-----')
}
2 changes: 1 addition & 1 deletion src/components/organisms/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Header = () => {
const navList = useMainNav();

return (
<header className="flex justify-center sticky top-0 z-10 w-full border-b bg-white py-2">
<header data-cy="header" className="flex justify-center sticky top-0 z-10 w-full border-b bg-white py-2">
<div className="flex items-center w-full 3xl:w-max-screen-size justify-between px-4 h-24">
<Logo />
<MainNav navList={navList} />
Expand Down