Skip to content

Commit

Permalink
State that we don't endorse breached sites
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinnl committed Feb 19, 2025
1 parent 8d380ac commit 40ee813
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const BreachDetailsView = (props: Props) => {
href={`https://${breach.Domain}`}
eventData={{ link_id: breach.Domain }}
target="_blank"
rel="noopener noreferrer"
rel="nofollow noopener noreferrer"
>
{breach.Domain}
</TelemetryLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

import { it, expect } from "@jest/globals";
import { composeStory } from "@storybook/react";
import { type ComponentProps } from "react";
import { render, screen } from "@testing-library/react";
import Meta, { BreachDetailViewStory } from "./BreachDetailView.stories";
import { createRandomHibpListing } from "../../../../../../apiMocks/mockData";
import { type TelemetryLink } from "../../../../../components/client/TelemetryLink";

jest.mock("../../../../../components/client/SignInButton", () => {
return {
Expand All @@ -15,7 +17,10 @@ jest.mock("../../../../../components/client/SignInButton", () => {
});
jest.mock("../../../../../components/client/TelemetryLink", () => {
return {
TelemetryLink: () => null,
TelemetryLink: ({
eventData: _eventData,
...otherProps
}: ComponentProps<typeof TelemetryLink>) => <a {...otherProps} />,
};
});

Expand All @@ -30,6 +35,26 @@ it("details the breach", () => {
expect(overviewSection).toBeInTheDocument();
});

it("tells search engines that we do not endorse breached websites, even if we link to them", () => {
const ComposedBreachDetailView = composeStory(BreachDetailViewStory, Meta);
const breachedDomain = "example.com";
render(
<ComposedBreachDetailView
breach={createRandomHibpListing({ Domain: breachedDomain })}
/>,
);

const linksToBreachedDomain = screen
.getAllByRole("link")
.filter(
(link) => link.getAttribute("href") === `https://${breachedDomain}`,
);
expect(linksToBreachedDomain).not.toHaveLength(0);
linksToBreachedDomain.forEach((link) => {
expect(link.getAttribute("rel")).toMatch("nofollow");
});
});

it("special-cases the description for BVD, as per their request", () => {
const ComposedBreachDetailView = composeStory(BreachDetailViewStory, Meta);
render(
Expand Down

0 comments on commit 40ee813

Please sign in to comment.