-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some tests for the monthly activity email
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/emails/templates/monthlyActivity/MonthlyActivityEmail.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |