diff --git a/app/about/page.tsx b/app/about/page.tsx index cda9eea..8cd2b45 100644 --- a/app/about/page.tsx +++ b/app/about/page.tsx @@ -1,6 +1,6 @@ import Layout from "@/components/Layout"; -export default function Home() { +export default function About() { return (
diff --git a/app/contact/page.tsx b/app/contact/page.tsx index 52f9ee8..a54c9fb 100644 --- a/app/contact/page.tsx +++ b/app/contact/page.tsx @@ -1,6 +1,6 @@ import Layout from "@/components/Layout"; -export default function Home() { +export default function Contact() { return (
diff --git a/cypress.config.ts b/cypress.config.ts index 78eed99..7e41a64 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -7,4 +7,11 @@ export default defineConfig({ // implement node event listeners here }, }, + + component: { + devServer: { + framework: "next", + bundler: "webpack", + }, + }, }); diff --git a/cypress/component/mounting.cy.tsx b/cypress/component/mounting.cy.tsx new file mode 100644 index 0000000..9935ccd --- /dev/null +++ b/cypress/component/mounting.cy.tsx @@ -0,0 +1,49 @@ +import Home from "@/app/page"; +import About from "@/app/about/page"; +import Contact from "@/app/contact/page"; + +const navbarFooterCheck = () => { + it("includes navbar", () => { + cy.get("nav"); + }); + + it("includes footer", () => { + cy.get("footer"); + }); +}; + +describe("Verify home page", () => { + beforeEach(() => { + cy.mount(); + }); + + it("should have the correct h1 tags with website name included", () => { + cy.get("h1").contains("echecs france", { matchCase: false }); + }); + + navbarFooterCheck(); +}); + +describe("Verify about page", () => { + beforeEach(() => { + cy.mount(); + }); + + it("should have the correct h1 tags with page title included", () => { + cy.get("h1").contains("about", { matchCase: false }); + }); + + navbarFooterCheck(); +}); + +describe("Verify contact page", () => { + beforeEach(() => { + cy.mount(); + }); + + it("should have the correct h1 tags with page title included", () => { + cy.get("h1").contains("contact", { matchCase: false }); + }); + + navbarFooterCheck(); +}); diff --git a/cypress/e2e/links.cy.ts b/cypress/e2e/links.cy.ts new file mode 100644 index 0000000..1a21ca7 --- /dev/null +++ b/cypress/e2e/links.cy.ts @@ -0,0 +1,31 @@ +describe("Test all links", () => { + const pages = ["tournois", "about", "contact"]; + + it("Check navbar links point to correct pathname", () => { + cy.visit("/"); + pages.forEach((page) => { + cy.contains(page, { matchCase: false }).click(); + cy.location("pathname").should("eq", `/${page}`); // url path matches link name + cy.go("back"); + }); + }); + + it("Check dead links", () => { + pages.forEach((page) => { + cy.visit(`/${page}`); + cy.get("a:not([href*='mailto:']").each((link) => { + if ( + !link + .prop("href") + .includes("http://www.echecs.asso.fr/FicheTournoi.aspx") // ignore every external FFE tournament link + ) { + cy.request({ + url: link.prop("href"), + failOnStatusCode: false, + }); + cy.log(link.prop("href")); + } + }); + }); + }); +}); diff --git a/cypress/e2e/spec.cy.ts b/cypress/e2e/spec.cy.ts deleted file mode 100644 index 2dc430c..0000000 --- a/cypress/e2e/spec.cy.ts +++ /dev/null @@ -1,21 +0,0 @@ -describe("Test all links", () => { - // TODO traverse entire site - it("Test all links on homepage return 200 status", () => { - cy.visit("/"); - cy.get("a").each((page) => { - cy.request(page.prop("href")); - }); - }); - - it("Check navbar links point to correct pathname", () => { - const pages = ["tournois", "about", "contact"]; - - cy.visit("/"); - - pages.forEach((page) => { - cy.contains(page, { matchCase: false }).click(); - cy.location("pathname").should("eq", `/${page}`); // url path matches link name - cy.go("back"); - }); - }); -}); diff --git a/cypress/fixtures/tournamentData.json b/cypress/fixtures/tournamentData.json new file mode 100644 index 0000000..c715f2f --- /dev/null +++ b/cypress/fixtures/tournamentData.json @@ -0,0 +1,32 @@ +[ + { + "_id": "1", + "town": "Testville", + "department": "55", + "tournament": "Test Tournament 1", + "url": "https://www.google.com", + "time_control": "Cadence Lente", + "date": "01/01/29", + "coordinates": [55, 1] + }, + { + "_id": "2", + "town": "Testville 2", + "department": "55", + "tournament": "Test Tournament 2", + "url": "https://www.google.com", + "time_control": "Rapide", + "date": "01/01/29", + "coordinates": [55, 0.5] + }, + { + "_id": "3", + "town": "Testville 3", + "department": "55", + "tournament": "Test Tournament 3", + "url": "https://www.google.com", + "time_control": "BLitz", + "date": "01/01/28", + "coordinates": [55.5, 0.5] + } +] diff --git a/cypress/support/component-index.html b/cypress/support/component-index.html new file mode 100644 index 0000000..3e16e9b --- /dev/null +++ b/cypress/support/component-index.html @@ -0,0 +1,14 @@ + + + + + + + Components App + +
+ + +
+ + \ No newline at end of file diff --git a/cypress/support/component.ts b/cypress/support/component.ts new file mode 100644 index 0000000..37f59ed --- /dev/null +++ b/cypress/support/component.ts @@ -0,0 +1,39 @@ +// *********************************************************** +// This example support/component.ts is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +import './commands' + +// Alternatively you can use CommonJS syntax: +// require('./commands') + +import { mount } from 'cypress/react18' + +// Augment the Cypress namespace to include type definitions for +// your custom command. +// Alternatively, can be defined in cypress/support/component.d.ts +// with a at the top of your spec. +declare global { + namespace Cypress { + interface Chainable { + mount: typeof mount + } + } +} + +Cypress.Commands.add('mount', mount) + +// Example use: +// cy.mount() \ No newline at end of file diff --git a/cypress/videos/links.cy.ts.mp4 b/cypress/videos/links.cy.ts.mp4 new file mode 100644 index 0000000..84d07c0 Binary files /dev/null and b/cypress/videos/links.cy.ts.mp4 differ diff --git a/cypress/videos/spec.cy.ts.mp4 b/cypress/videos/spec.cy.ts.mp4 deleted file mode 100644 index af79032..0000000 Binary files a/cypress/videos/spec.cy.ts.mp4 and /dev/null differ diff --git a/package.json b/package.json index cdcdb65..fbae213 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,9 @@ "build": "next build", "start": "next start", "lint": "next lint", - "jest": "jest", - "jest:watch": "jest --watch", + "test": "jest", "cypress:open": "cypress open", - "cypress:run": "cypress run", - "test": "npm run cypress:run && npm run jest", - "test:watch": "npm run cypress:open && npm run jest:watch" + "cypress:run": "cypress run" }, "dependencies": { "@types/node": "20.2.3",