fix(a11y): expose public landing landmarks

This commit is contained in:
cesnimda
2026-11-18 07:25:19 +01:00
parent 5b50cb2713
commit 36084473c3
2 changed files with 17 additions and 4 deletions
+11 -1
View File
@@ -1,6 +1,6 @@
import React from "react";
import "@testing-library/jest-dom";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";
import { api } from "./api";
@@ -21,6 +21,16 @@ beforeEach(() => {
(api.get as jest.Mock).mockRejectedValue({ response: { status: 401 } });
});
test("public content is reachable through one main landmark separate from header and footer", async () => {
render(<MemoryRouter><I18nProvider><LandingPage /></I18nProvider></MemoryRouter>);
await screen.findByRole("heading", { name: "Two clear plans" });
const main = screen.getByRole("main");
expect(within(main).getByRole("heading", { level: 1 })).toBeInTheDocument();
expect(within(main).getByRole("heading", { name: "Two clear plans" })).toBeInTheDocument();
expect(main).not.toContainElement(screen.getByRole("banner"));
expect(main).not.toContainElement(screen.getByRole("contentinfo"));
});
test("shows exactly Free and Pro without invented commercial terms", async () => {
render(
<MemoryRouter>
+6 -3
View File
@@ -69,7 +69,7 @@ export default function LandingPage() {
if (checking) {
return (
<Box sx={{ minHeight: "100vh", display: "grid", placeItems: "center", bgcolor: BRAND_DARK }}>
<Box component="main" sx={{ minHeight: "100vh", display: "grid", placeItems: "center", bgcolor: BRAND_DARK }}>
<Typography sx={{ color: "#94a3b8" }}>{t("loading")}</Typography>
</Box>
);
@@ -91,7 +91,7 @@ export default function LandingPage() {
return (
<Box sx={{ bgcolor: "background.default" }}>
{/* Top bar */}
<Box sx={{ position: "sticky", top: 0, zIndex: 10, bgcolor: alpha(BRAND_DARK, 0.85), backdropFilter: "blur(8px)", borderBottom: `1px solid ${alpha("#ffffff", 0.08)}` }}>
<Box component="header" sx={{ position: "sticky", top: 0, zIndex: 10, bgcolor: alpha(BRAND_DARK, 0.85), backdropFilter: "blur(8px)", borderBottom: `1px solid ${alpha("#ffffff", 0.08)}` }}>
<Container maxWidth="lg">
<Stack direction="row" alignItems="center" justifyContent="space-between" sx={{ height: 64 }}>
<Stack direction="row" alignItems="center" spacing={1.25}>
@@ -108,6 +108,7 @@ export default function LandingPage() {
</Container>
</Box>
<Box component="main">
{/* Hero */}
<Box sx={{ background: `radial-gradient(1200px 500px at 80% -10%, ${alpha("#6366f1", 0.35)}, transparent), linear-gradient(180deg, ${BRAND_DARK}, ${BRAND_PANEL})`, color: "#fff", py: { xs: 8, md: 12 } }}>
<Container maxWidth="lg">
@@ -267,8 +268,10 @@ export default function LandingPage() {
</Box>
</Container>
</Box>
{/* Footer */}
<Box sx={{ borderTop: "1px solid", borderColor: "divider", py: 4 }}>
<Box component="footer" sx={{ borderTop: "1px solid", borderColor: "divider", py: 4 }}>
<Container maxWidth="lg">
<Stack direction={{ xs: "column", sm: "row" }} justifyContent="space-between" alignItems="center" spacing={1}>
<Typography sx={{ color: "text.secondary", fontSize: 14 }}>{t("landingFooter", { year: new Date().getFullYear() })}</Typography>