BS-002 Establish public marketing routes and navigation
This commit is contained in:
@@ -1,66 +1,39 @@
|
||||
import AxeBuilder from '@axe-core/playwright'
|
||||
import { expect, test } from '@playwright/test'
|
||||
|
||||
const publicPages = [
|
||||
['/', 'Build your application from here'],
|
||||
['/contact', 'Contact'],
|
||||
['/privacy', 'Privacy policy'],
|
||||
['/terms', 'Terms of service'],
|
||||
['/login', 'Login'],
|
||||
['/register', 'Register'],
|
||||
['/forgot-password', 'Reset password'],
|
||||
]
|
||||
|
||||
for (const [path, heading] of publicPages) {
|
||||
test(`${path} renders without horizontal overflow`, async ({ page }) => {
|
||||
for (const [path, heading] of [
|
||||
['/', 'Software development for real-world needs'], ['/services', 'Services'],
|
||||
['/projects', 'Projects'], ['/projects/example', 'Project details'],
|
||||
['/about', 'About BortStack'], ['/contact', 'Contact'], ['/privacy', 'Privacy policy'],
|
||||
['/login', 'Page not found'], ['/dashboard', 'Page not found'],
|
||||
]) {
|
||||
test(`${path} renders without overflow or auth requests`, async ({ page }) => {
|
||||
const errors = []
|
||||
const accountRequests = []
|
||||
page.on('pageerror', error => errors.push(error.message))
|
||||
page.on('request', request => { if (/\/api\//.test(request.url())) accountRequests.push(request.url()) })
|
||||
await page.goto(path)
|
||||
await expect(page.getByRole('heading', { name: heading, exact: true })).toBeVisible()
|
||||
const dimensions = await page.locator('html').evaluate((element) => ({
|
||||
viewport: element.clientWidth,
|
||||
content: element.scrollWidth,
|
||||
}))
|
||||
expect(dimensions.content).toBeLessThanOrEqual(dimensions.viewport)
|
||||
expect(await page.locator('html').evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true)
|
||||
expect(errors).toEqual([])
|
||||
expect(accountRequests).toEqual([])
|
||||
})
|
||||
}
|
||||
|
||||
test('public shell passes automated accessibility diagnostics', async ({ page }) => {
|
||||
await page.goto('/contact')
|
||||
const results = await new AxeBuilder({ page }).analyze()
|
||||
expect(results.violations).toEqual([])
|
||||
})
|
||||
|
||||
test('skip link is the first keyboard navigation target', async ({ page }) => {
|
||||
test('public shell has accessible landmarks and first keyboard skip link', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
await page.keyboard.press('Tab')
|
||||
const skipLink = page.getByRole('link', { name: 'Skip to main content' })
|
||||
await expect(skipLink).toBeFocused()
|
||||
await expect(skipLink).toHaveAttribute('href', '#main-content')
|
||||
await expect(page.getByRole('link', { name: 'Skip to main content' })).toBeFocused()
|
||||
await expect(page.getByRole('main')).toHaveCount(1)
|
||||
expect((await new AxeBuilder({ page }).analyze()).violations).toEqual([])
|
||||
})
|
||||
|
||||
test('mobile navigation expands and exposes public destinations', async ({ page, isMobile }) => {
|
||||
test.skip(!isMobile, 'mobile navigation diagnostic')
|
||||
test('navigation works and closes on mobile selection', async ({ page, isMobile }) => {
|
||||
await page.goto('/')
|
||||
await page.getByRole('button', { name: 'Toggle navigation' }).click()
|
||||
await expect(page.getByRole('link', { name: 'Contact', exact: true }).first()).toBeVisible()
|
||||
await expect(page.getByRole('link', { name: 'Login', exact: true })).toBeVisible()
|
||||
})
|
||||
|
||||
test('contact form reports mocked delivery success', async ({ page }) => {
|
||||
await page.route('**/api/contact', async (route) => {
|
||||
await route.fulfill({ status: 200, contentType: 'application/json', body: '{"success":true}' })
|
||||
})
|
||||
await page.goto('/contact')
|
||||
await page.getByLabel('Name').fill('Example Person')
|
||||
await page.getByLabel('Email').fill('person@example.com')
|
||||
await page.getByLabel('Subject').fill('A useful question')
|
||||
await page.getByLabel('Message').fill('This message is long enough to be accepted.')
|
||||
await page.getByRole('button', { name: 'Send message' }).click()
|
||||
await expect(page.getByRole('status')).toContainText('message has been sent')
|
||||
})
|
||||
|
||||
test('protected dashboard with no session does not expose its content', async ({ page }) => {
|
||||
await page.goto('/dashboard')
|
||||
await expect(page.getByRole('heading', { name: 'Unauthorized' })).toBeVisible()
|
||||
await expect(page.getByText('Protected application workspace')).toHaveCount(0)
|
||||
await expect(page.locator('meta[name="robots"]')).toHaveAttribute('content', 'noindex, nofollow')
|
||||
const navigation = page.getByRole('navigation', { name: 'Main navigation' })
|
||||
if (isMobile) await page.getByRole('button', { name: 'Toggle navigation' }).click()
|
||||
await navigation.getByRole('link', { name: 'Services', exact: true }).click()
|
||||
await expect(page.getByRole('heading', { name: 'Services', exact: true })).toBeVisible()
|
||||
if (isMobile) await expect(page.getByRole('button', { name: 'Toggle navigation' })).toHaveAttribute('aria-expanded', 'false')
|
||||
await expect(page.getByRole('link', { name: /login|register|dashboard/i })).toHaveCount(0)
|
||||
})
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="A reusable Flask and React web application foundation." />
|
||||
<meta name="description" content="Custom software, websites, APIs, hosting and ongoing maintenance for businesses and research projects." />
|
||||
<meta name="robots" content="index, follow" />
|
||||
<meta name="theme-color" content="#343a40" />
|
||||
<title>BortStack</title>
|
||||
|
||||
+31
-45
@@ -1,57 +1,43 @@
|
||||
import "./styles/custom.scss";
|
||||
|
||||
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
||||
import { AuthProvider } from "./contexts/AuthContext";
|
||||
import ProtectedRoute from "./routing/ProtectedRoute";
|
||||
import PageNotFound from "./views/PageNotFound/PageNotFound";
|
||||
|
||||
import Login from "./views/Login/Login";
|
||||
import Register from "./views/Register/Register";
|
||||
import ForgotPassword from "./views/ForgotPassword/ForgotPassword";
|
||||
import ResetPassword from "./views/ResetPassword/ResetPassword";
|
||||
import VerifyEmail from "./views/VerifyEmail/VerifyEmail";
|
||||
import Contact from "./views/Contact/Contact";
|
||||
import Privacy from "./views/Legal/Privacy";
|
||||
import Terms from "./views/Legal/Terms";
|
||||
import Header from "./components/Header/Header";
|
||||
import Footer from "./components/Footer/Footer";
|
||||
import PageMeta from "./components/PageMeta/PageMeta";
|
||||
|
||||
import Homepage from "./views/Home/Homepage";
|
||||
import Dashboard from "./views/Dashboard/Dashboard";
|
||||
import RoutePlaceholder from "./views/RoutePlaceholder";
|
||||
|
||||
const pages = [
|
||||
["services", "Services", "Website development, custom software, APIs and managed hosting."],
|
||||
["projects", "Projects", "Project details will be added after publication permissions and genuine imagery are confirmed."],
|
||||
["projects/:slug", "Project details", "This case study is not available. Only verified, approved work will be published."],
|
||||
["about", "About BortStack", "Business background and working approach are being prepared."],
|
||||
["contact", "Contact", "The enquiry form and verified business email will be available here. Enquiries cannot be submitted yet."],
|
||||
["privacy", "Privacy policy", "Privacy information is awaiting review against the actual website data flows before publication."],
|
||||
];
|
||||
|
||||
const App = () => {
|
||||
export default function App() {
|
||||
return (
|
||||
<div className="app" data-bs-theme="dark">
|
||||
<div className="app">
|
||||
<BrowserRouter>
|
||||
<AuthProvider>
|
||||
<>
|
||||
<a className="skipLink" href="#main-content">Skip to main content</a>
|
||||
<Header />
|
||||
<div id="main-content" className="pageContent" tabIndex="-1">
|
||||
<Routes>
|
||||
<Route index element={<><PageMeta /><Homepage /></>} />
|
||||
<Route element={<ProtectedRoute />}>
|
||||
<Route path="dashboard" element={<><PageMeta title="Dashboard" noIndex /><Dashboard /></>} />
|
||||
</Route>
|
||||
<Route path="login" element={<><PageMeta title="Login" noIndex /><Login /></>} />
|
||||
<Route path="register" element={<><PageMeta title="Register" noIndex /><Register /></>} />
|
||||
<Route path="forgot-password" element={<><PageMeta title="Reset password" noIndex /><ForgotPassword /></>} />
|
||||
<Route path="reset-password" element={<><PageMeta title="Choose a password" noIndex /><ResetPassword /></>} />
|
||||
<Route path="verify-email" element={<><PageMeta title="Verify email" noIndex /><VerifyEmail /></>} />
|
||||
<Route path="contact" element={<><PageMeta title="Contact" description="Contact the application team." /><Contact /></>} />
|
||||
<Route path="privacy" element={<><PageMeta title="Privacy policy" /><Privacy /></>} />
|
||||
<Route path="terms" element={<><PageMeta title="Terms of service" /><Terms /></>} />
|
||||
<Route path="*" element={<><PageMeta title="Page not found" noIndex /><PageNotFound /></>} />
|
||||
</Routes>
|
||||
</div>
|
||||
<Footer />
|
||||
</>
|
||||
</AuthProvider>
|
||||
</BrowserRouter>
|
||||
<a className="skipLink" href="#main-content">Skip to main content</a>
|
||||
<Header />
|
||||
<main id="main-content" className="pageContent" tabIndex="-1">
|
||||
<Routes>
|
||||
<Route index element={<><PageMeta /><Homepage /></>} />
|
||||
{pages.map(([path, title, description]) => (
|
||||
<Route key={path} path={path} element={<>
|
||||
<PageMeta title={title} description={description} noIndex />
|
||||
<RoutePlaceholder title={title} description={description} />
|
||||
</>} />
|
||||
))}
|
||||
<Route path="*" element={<>
|
||||
<PageMeta title="Page not found" noIndex />
|
||||
<RoutePlaceholder title="Page not found" description="This page is not available. Use the navigation to explore BortStack." />
|
||||
</>} />
|
||||
</Routes>
|
||||
</main>
|
||||
<Footer />
|
||||
</BrowserRouter>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
}
|
||||
|
||||
@@ -1,33 +1,21 @@
|
||||
import styles from "./Footer.module.scss";
|
||||
import { Container } from "react-bootstrap";
|
||||
import { NavLink } from "react-router-dom";
|
||||
import { site } from "../../config/site";
|
||||
import styles from "./Footer.module.scss";
|
||||
|
||||
const Footer = () => {
|
||||
return (
|
||||
<footer className={styles.footer}>
|
||||
<nav className={styles.links} aria-label="Footer navigation">
|
||||
<NavLink to="/contact">Contact</NavLink>
|
||||
<NavLink to="/privacy">Privacy</NavLink>
|
||||
<NavLink to="/terms">Terms</NavLink>
|
||||
</nav>
|
||||
<div className={styles.developerSlot}>
|
||||
<a
|
||||
href={site.developer.url}
|
||||
aria-label={site.developer.linkLabel}
|
||||
rel="noreferrer"
|
||||
>
|
||||
<img
|
||||
src={site.developer.logoPath}
|
||||
alt={site.developer.name}
|
||||
className={styles.developerLogo}
|
||||
/>
|
||||
export default function Footer() {
|
||||
return <footer className={styles.footer}>
|
||||
<Container>
|
||||
<div className={styles.footerRow}>
|
||||
<p className={styles.copyright}>© {new Date().getFullYear()} BortStack</p>
|
||||
<nav className={styles.links} aria-label="Footer navigation">
|
||||
<NavLink to="/contact">Contact</NavLink>
|
||||
<NavLink to="/privacy">Privacy</NavLink>
|
||||
</nav>
|
||||
<a href={site.developer.url} aria-label={site.developer.linkLabel} rel="noreferrer" className={styles.developerSlot}>
|
||||
<img src={site.developer.logoPath} alt={site.developer.name} className={styles.developerLogo} />
|
||||
</a>
|
||||
</div>
|
||||
<p className={styles.copyright}>
|
||||
© {new Date().getFullYear()} Web App
|
||||
</p>
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
|
||||
export default Footer;
|
||||
</Container>
|
||||
</footer>;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,22 @@
|
||||
import { Container, Navbar } from "react-bootstrap";
|
||||
import { useState } from "react";
|
||||
import { Container, Nav, Navbar } from "react-bootstrap";
|
||||
import { NavLink } from "react-router-dom";
|
||||
import Logo from "../Logo/Logo";
|
||||
import styles from "./Header.module.scss";
|
||||
import PageNav from "../PageNav/PageNav"
|
||||
import Logo from "../Logo/Logo"
|
||||
import { useAuth } from "../../contexts/AuthContext";
|
||||
import GuestNav from "../GuestNav/GuestNav";
|
||||
|
||||
|
||||
const Header = () => {
|
||||
const { user } = useAuth()
|
||||
|
||||
return (
|
||||
<Navbar expand="sm" className={styles.header} variant="dark">
|
||||
<Container>
|
||||
export default function Header() {
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
return <Navbar variant="dark" expand="md" expanded={expanded} onToggle={setExpanded} className={styles.header} aria-label="Main navigation">
|
||||
<Container>
|
||||
<Navbar.Brand as="div"><Logo /></Navbar.Brand>
|
||||
<Navbar.Toggle aria-controls="navbar-nav" />
|
||||
<Navbar.Collapse id="navbar-nav" className={styles.navbarCollapse}>
|
||||
{
|
||||
user ? <PageNav /> : <GuestNav />
|
||||
}
|
||||
|
||||
<Navbar.Toggle aria-controls="main-navigation" aria-expanded={expanded} />
|
||||
<Navbar.Collapse id="main-navigation" className={styles.navbarCollapse}>
|
||||
<Nav>
|
||||
{["Services", "Projects", "About", "Contact"].map(label => (
|
||||
<Nav.Link as={NavLink} key={label} to={`/${label.toLowerCase()}`} onClick={() => setExpanded(false)}>{label}</Nav.Link>
|
||||
))}
|
||||
</Nav>
|
||||
</Navbar.Collapse>
|
||||
</Container>
|
||||
</Navbar>
|
||||
)
|
||||
</Container>
|
||||
</Navbar>;
|
||||
}
|
||||
|
||||
export default Header
|
||||
|
||||
@@ -2,7 +2,7 @@ export const site = Object.freeze({
|
||||
name: "BortStack",
|
||||
defaultTitle: "BortStack",
|
||||
titleTemplate: "%s | BortStack",
|
||||
description: "A reusable Flask and React web application foundation.",
|
||||
description: "Custom software, websites, APIs, hosting and ongoing maintenance for businesses and research projects.",
|
||||
developer: Object.freeze({
|
||||
name: "roborto.net",
|
||||
url: "https://roborto.net/",
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
import styles from "./Homepage.module.scss";
|
||||
|
||||
const Homepage = () => {
|
||||
return (
|
||||
<main className={styles.homepage}>
|
||||
<section>
|
||||
<p>Reusable Flask and React application foundation</p>
|
||||
<h1>Build your application from here</h1>
|
||||
<p>
|
||||
Replace this placeholder with the generated project's
|
||||
purpose, primary action, and product-specific content.
|
||||
</p>
|
||||
</section>
|
||||
</main>
|
||||
)
|
||||
import { Container } from "react-bootstrap";
|
||||
export default function Homepage() {
|
||||
return <Container className="routePlaceholder">
|
||||
<p className="eyebrow">BortStack · Website in development</p>
|
||||
<h1>Software development for real-world needs</h1>
|
||||
<p>The approved BortStack homepage is being prepared.</p>
|
||||
</Container>;
|
||||
}
|
||||
|
||||
export default Homepage
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { fireEvent, render, screen, within } from "@testing-library/react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import App from "../App";
|
||||
|
||||
afterEach(() => { window.history.replaceState({}, "", "/"); vi.unstubAllGlobals(); });
|
||||
describe("public marketing routes", () => {
|
||||
it.each([
|
||||
["/services", "Services"], ["/projects", "Projects"],
|
||||
["/projects/example", "Project details"], ["/about", "About BortStack"],
|
||||
["/contact", "Contact"], ["/privacy", "Privacy policy"],
|
||||
["/login", "Page not found"], ["/register", "Page not found"], ["/dashboard", "Page not found"],
|
||||
])("loads %s without account infrastructure", (path, heading) => {
|
||||
const fetchMock = vi.fn();
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
window.history.replaceState({}, "", path);
|
||||
render(<App />);
|
||||
expect(screen.getByRole("heading", { level: 1, name: heading })).toBeInTheDocument();
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
expect(screen.queryByRole("link", { name: /login|register|dashboard/i })).not.toBeInTheDocument();
|
||||
});
|
||||
it("exposes the four marketing links and closes navigation on selection", async () => {
|
||||
render(<App />);
|
||||
const nav = screen.getByRole("navigation", { name: "Main navigation" });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Toggle navigation" }));
|
||||
await within(nav).findByRole("link", { name: "Services" });
|
||||
for (const name of ["Services", "Projects", "About", "Contact"]) {
|
||||
expect(within(nav).getByRole("link", { name })).toBeInTheDocument();
|
||||
}
|
||||
fireEvent.click(within(nav).getByRole("link", { name: "Services" }));
|
||||
expect(screen.getByRole("button", { name: "Toggle navigation" })).toHaveAttribute("aria-expanded", "false");
|
||||
expect(screen.getByRole("heading", { name: "Services" })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -9,9 +9,9 @@ import Terms from "./Legal/Terms";
|
||||
afterEach(() => vi.unstubAllGlobals());
|
||||
|
||||
describe("generic public pages", () => {
|
||||
it("marks homepage content as replaceable", () => {
|
||||
it("shows the marketing homepage shell", () => {
|
||||
render(<MemoryRouter><Homepage /></MemoryRouter>);
|
||||
expect(screen.getByRole("heading", { name: /build your application/i })).toBeInTheDocument();
|
||||
expect(screen.getByRole("heading", { name: /software development for real-world needs/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("marks legal pages as placeholders", () => {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import PropTypes from "prop-types";
|
||||
import { Container } from "react-bootstrap";
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
export default function RoutePlaceholder({ title, description }) {
|
||||
return <Container className="routePlaceholder">
|
||||
<p className="eyebrow">BortStack · Website in development</p>
|
||||
<h1>{title}</h1>
|
||||
<p>{description}</p>
|
||||
<Link to="/">Back to homepage <span aria-hidden="true">→</span></Link>
|
||||
</Container>;
|
||||
}
|
||||
RoutePlaceholder.propTypes = { title: PropTypes.string.isRequired, description: PropTypes.string.isRequired };
|
||||
Reference in New Issue
Block a user