diff --git a/playwright.config.ts b/playwright.config.ts index 1c00d74..7b9fbf2 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -51,14 +51,14 @@ export default defineConfig({ }, /* Test against mobile viewports. */ - // { - // name: "Mobile Chrome", - // use: { ...devices["Pixel 5"] }, - // }, - // { - // name: "Mobile Safari", - // use: { ...devices["iPhone 12"] }, - // }, + { + name: "Mobile Chrome", + use: { ...devices["Pixel 5"] }, + }, + { + name: "Mobile Safari", + use: { ...devices["iPhone 12"] }, + }, /* Test against branded browsers. */ // { diff --git a/src/app/contact/page.tsx b/src/app/contact/page.tsx index aad5f2e..fec493f 100644 --- a/src/app/contact/page.tsx +++ b/src/app/contact/page.tsx @@ -1,7 +1,6 @@ import BgLayer from "@/components/layout/bg-layer"; import ContactCard from "@/components/contact/card"; import Container from "@/components/layout/container"; -import Header from "@/components/layout/header"; import MainWrapper from "@/components/layout/main-wrapper"; import { Metadata } from "next"; @@ -42,7 +41,6 @@ export const metadata: Metadata = { export default function ContactPage() { return (
-
diff --git a/src/app/features/page.tsx b/src/app/features/page.tsx index 8410fd2..f3ac4a1 100644 --- a/src/app/features/page.tsx +++ b/src/app/features/page.tsx @@ -1,7 +1,6 @@ import BgLayer from "@/components/layout/bg-layer"; import Container from "@/components/layout/container"; import FeatureList from "@/components/features/list"; -import Header from "@/components/layout/header"; import Implementations from "@/components/features/implementations"; import MainWrapper from "@/components/layout/main-wrapper"; import { Metadata } from "next"; @@ -14,7 +13,6 @@ export const metadata: Metadata = { export default async function FeaturesPage() { return (
-
-
-
-
{ const [mobileMenuOpen, setMobileMenuOpen] = useState(false); + const pathname = usePathname(); + + useEffect(() => { + if (mobileMenuOpen) { + setMobileMenuOpen(false); + } + }, [pathname]); return (
@@ -94,9 +102,10 @@ const Header = () => { className="lg:hidden" open={mobileMenuOpen} onClose={setMobileMenuOpen} + data-testid="mobile-menu" >
- +
); diff --git a/src/components/layout/nav.tsx b/src/components/layout/nav.tsx deleted file mode 100644 index 3435a1c..0000000 --- a/src/components/layout/nav.tsx +++ /dev/null @@ -1,234 +0,0 @@ -"use client"; - -import { - ArrowPathIcon, - Bars3Icon, - ChartPieIcon, - CursorArrowRaysIcon, - FingerPrintIcon, - SquaresPlusIcon, - XMarkIcon, -} from "@heroicons/react/24/outline"; -import { - ChevronDownIcon, - PhoneIcon, - PlayCircleIcon, -} from "@heroicons/react/20/solid"; -import { Dialog, Popover, Transition } from "@headlessui/react"; -import { Fragment, useState } from "react"; - -import Image from "next/image"; -import hykuLogo from "../../../public/logo-hyku.png"; - -const callsToAction = [ - { name: "Watch demo", href: "#", icon: PlayCircleIcon }, - { name: "Contact sales", href: "#", icon: PhoneIcon }, -]; -const company = [ - { - name: "About us", - href: "#", - description: - "Learn more about our company values and mission to empower others", - }, - { - name: "Careers", - href: "#", - description: - "Looking for you next career opportunity? See all of our open positions", - }, - { - name: "Support", - href: "#", - description: - "Get in touch with our dedicated support team or reach out on our community forums", - }, - { - name: "Blog", - href: "#", - description: - "Read our latest announcements and get perspectives from our team", - }, -]; - -const nav = [ - { - name: "Features and Implementations", - href: "/features", - }, - { - name: "Getting Started", - href: "/getting-started", - }, - { - name: "News", - href: "/news", - }, - { - name: "Contact", - href: "/contact", - }, -]; - -export default function Nav() { - const [mobileMenuOpen, setMobileMenuOpen] = useState(false); - - return ( -
- - -
- -
-
- - Your Company - - - -
-
-
-
- - Features - - - Marketplace - - - {company.map((item) => ( - - {item.name} - - ))} -
- -
-
-
-
- {callsToAction.map((item) => ( - - {item.name} - - ))} -
-
-
-
- ); -} diff --git a/tests/home.spec.ts b/tests/home.spec.ts index 8ea5e04..1e8abd3 100644 --- a/tests/home.spec.ts +++ b/tests/home.spec.ts @@ -2,6 +2,8 @@ import { expect, test } from "@playwright/test"; test("homepage elements", async ({ page }) => { await page.goto("/"); + await page.waitForURL("**/"); + await expect(page.getByRole("heading")).toContainText( "The Next Generation Repository Solution", ); diff --git a/tests/layout.spec.ts b/tests/layout.spec.ts index 50f567d..9d3a189 100644 --- a/tests/layout.spec.ts +++ b/tests/layout.spec.ts @@ -8,48 +8,103 @@ const links = [ "Contact", ]; -test("has main heading and top level navigation", async ({ page }) => { +test("has main heading and top level navigation", async ({ + page, +}, testInfo) => { + const isMobile = testInfo.project.name.includes("Mobile"); + await page.goto("/"); + await page.waitForURL("/"); const header = page.getByLabel("Global"); await expect(header).toBeVisible(); await expect(header.getByAltText("Hyku logo")).toBeVisible(); - await page - .getByRole("link", { name: "Features and Implementations" }) - .nth(1) - .click(); - await expect( - page.getByRole("heading", { name: "Features and Implementations" }), - ).toBeVisible(); - - await page.getByRole("link", { name: "Getting Started" }).nth(1).click(); - await expect( - page.getByRole("heading", { name: "Getting Started" }), - ).toBeVisible(); - - await page - .getByRole("link", { name: "Presentations and Demos" }) - .nth(1) - .click(); - await expect( - page.getByRole("heading", { name: "Presentations and Demos" }), - ).toBeVisible(); - - await page.getByRole("link", { name: "News" }).nth(1).click(); - await expect( - page.getByRole("heading", { name: "News and Events" }), - ).toBeVisible(); - - await page.getByRole("link", { name: "Contact" }).nth(1).click(); - await expect( - page.getByRole("heading", { name: "Get in touch" }), - ).toBeVisible(); - - await expect( - page.getByRole("link", { name: "Learn more" }).nth(1), - ).toHaveAttribute("href", "https://github.com/samvera/hyku"); + // Test desktop navigation + if (!isMobile) { + await page + .getByRole("link", { name: "Features and Implementations" }) + .nth(1) + .click(); + await page.waitForURL("**/features"); + await expect( + page.getByRole("heading", { name: "Features and Implementations" }), + ).toBeVisible(); + + await page.getByRole("link", { name: "Getting Started" }).nth(1).click(); + await page.waitForURL("**/getting-started"); + await expect( + page.getByRole("heading", { name: "Getting Started" }), + ).toBeVisible(); + + await page + .getByRole("link", { name: "Presentations and Demos" }) + .nth(1) + .click(); + await page.waitForURL("**/presentations"); + await expect( + page.getByRole("heading", { name: "Presentations and Demos" }), + ).toBeVisible(); + + await page.getByRole("link", { name: "News" }).nth(1).click(); + await page.waitForURL("**/news"); + await expect( + page.getByRole("heading", { name: "News and Events" }), + ).toBeVisible(); + + await page.getByRole("link", { name: "Contact" }).nth(1).click(); + await page.waitForURL("**/contact"); + await expect( + page.getByRole("heading", { name: "Get in touch" }), + ).toBeVisible(); + + await expect( + page.getByRole("link", { name: "Learn more" }).nth(1), + ).toHaveAttribute("href", "https://github.com/samvera/hyku"); + } + + // Test mobile navigation + if (isMobile) { + await page.goto("/"); + await page.waitForURL("/"); + + const mobileMenuEl = page.getByTestId("mobile-menu"); + const hamburgerEl = page.getByRole("button", { name: "Open main menu" }); + + await hamburgerEl.click(); + await mobileMenuEl + .getByRole("link", { name: "Features and Implementations" }) + .click(); + + await expect(page.locator("h1")).toContainText( + "Features and Implementations", + ); + + await hamburgerEl.click(); + await mobileMenuEl.getByRole("link", { name: "Getting Started" }).click(); + + await expect(page.locator("h1")).toContainText("Getting Started"); + + await hamburgerEl.click(); + await mobileMenuEl + .getByRole("link", { name: "Presentations and Demos" }) + .click(); + + await expect(page.locator("h1")).toContainText("Presentations and Demos"); + + await hamburgerEl.click(); + await mobileMenuEl.getByRole("link", { name: "News" }).click(); + + await expect(page.locator("h1")).toContainText("News and Events"); + + await hamburgerEl.click(); + await mobileMenuEl.getByRole("link", { name: "Contact" }).click(); + + await expect( + page.getByRole("heading", { name: "Get in touch" }), + ).toBeVisible(); + } }); test("has footer with links to social media", async ({ page }) => {