fix: harden editorial thumbnail authorization
This commit is contained in:
1 parent
66f0599653
commit
846904f3db
11 files changed
+182
-36
No files matched your search
@@ -0,0 +1,34 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import { PortalShell } from "@/components/layout/portal-shell";
|
||||
import { BrandLogo } from "./logo";
|
||||
|
||||
test("uses each supplied logo's true intrinsic dimensions", () => {
|
||||
const { rerender } = render(<BrandLogo variant="white" />);
|
||||
const logo = screen.getByAltText("Leon Tonhäuser Sportfotografie");
|
||||
expect(logo.getAttribute("width")).toBe("250");
|
||||
expect(logo.getAttribute("height")).toBe("250");
|
||||
|
||||
rerender(<BrandLogo variant="black" />);
|
||||
expect(logo.getAttribute("width")).toBe("1000");
|
||||
expect(logo.getAttribute("height")).toBe("1000");
|
||||
});
|
||||
|
||||
test("keeps masthead controls keyboard-focusable with a paper-coloured focus outline", () => {
|
||||
render(
|
||||
<PortalShell>
|
||||
<p>Archiv</p>
|
||||
</PortalShell>,
|
||||
);
|
||||
|
||||
expect(screen.getByRole("link", { name: /zur albenübersicht/i }).tagName).toBe("A");
|
||||
expect(screen.getByRole("link", { name: "Alben" }).tagName).toBe("A");
|
||||
const styles = readFileSync("src/app/globals.css", "utf8");
|
||||
expect(styles).toContain(".portal-masthead :focus-visible");
|
||||
expect(styles).toContain("outline-color: var(--paper)");
|
||||
});
|
||||
@@ -5,15 +5,18 @@ type BrandLogoProps = {
|
||||
};
|
||||
|
||||
export function BrandLogo({ variant }: Readonly<BrandLogoProps>) {
|
||||
const source = variant === "white" ? "/brand/logo-white.png" : "/brand/logo-black.png";
|
||||
const logo =
|
||||
variant === "white"
|
||||
? { source: "/brand/logo-white.png", width: 250, height: 250 }
|
||||
: { source: "/brand/logo-black.png", width: 1000, height: 1000 };
|
||||
|
||||
return (
|
||||
<img
|
||||
alt="Leon Tonhäuser Sportfotografie"
|
||||
className="brand-logo"
|
||||
height="64"
|
||||
src={source}
|
||||
width="250"
|
||||
height={logo.height}
|
||||
src={logo.source}
|
||||
width={logo.width}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user