Skip to content

Commit

Permalink
Add some tests for the monthly activity email
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinnl committed Apr 29, 2024
1 parent 3d7f91b commit 56c50e9
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/emails/templates/monthlyActivity/MonthlyActivityEmail.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { it, expect } from "@jest/globals";
import { composeStory } from "@storybook/react";
import { render, screen } from "@testing-library/react";
import Meta, {
MonthlyActivityEmailFreeStory,
MonthlyActivityEmailPlusWithManualStory,
MonthlyActivityEmailPlusWithoutManualStory,
} from "./MonthlyActivityEmail.stories";

it("has an upgrade banner for free users", () => {
const ComposedEmail = composeStory(MonthlyActivityEmailFreeStory, Meta);
render(<ComposedEmail />);

const banner = screen.getByText("Upgrade for extra protection");
expect(banner).toBeInTheDocument();
});

it("does not imply we did everything when a user has fixed exposures/breaches themselves", () => {
const ComposedEmail = composeStory(
MonthlyActivityEmailPlusWithManualStory,
Meta,
);
render(<ComposedEmail />);

const whatWeFixedInHeroText = screen.queryByText(
"Here’s how we’ve protected you.",
);
const whatWeFixedInLeadText = screen.queryByText("Here’s what we fixed:");
expect(whatWeFixedInHeroText).not.toBeInTheDocument();
expect(whatWeFixedInLeadText).not.toBeInTheDocument();
});

it("emphasises that things have happened while someone was subscribed to Plus and didn't do anything themselves", () => {
const ComposedEmail = composeStory(
MonthlyActivityEmailPlusWithoutManualStory,
Meta,
);
render(<ComposedEmail />);

const dashboardLink = screen.getByRole("link", { name: "View all activity" });
expect(dashboardLink).toBeInTheDocument();
});

0 comments on commit 56c50e9

Please sign in to comment.