Skip to content

Commit

Permalink
chore: Add unit test for free scan sign in URL
Browse files Browse the repository at this point in the history
  • Loading branch information
flozia committed Jul 12, 2024
1 parent dd9b54d commit 64ac5c5
Showing 1 changed file with 48 additions and 14 deletions.
62 changes: 48 additions & 14 deletions src/app/(proper_react)/(redesign)/(public)/LandingView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -849,9 +849,7 @@ describe("Free scan CTA experiment", () => {
/>,
);

const inputField = screen.getAllByLabelText(
"Enter your email address to check for data breach exposures and sites selling your info.",
);
const inputField = screen.getAllByTestId("signup-form-input");
expect(inputField[0]).toBeInTheDocument();

const submitButton = screen.getAllByRole("button", {
Expand All @@ -874,9 +872,7 @@ describe("Free scan CTA experiment", () => {
/>,
);

const inputField = screen.queryAllByLabelText(
"Enter your email address to check for data breach exposures and sites selling your info.",
);
const inputField = screen.getAllByTestId("signup-form-input");
expect(inputField[0]).toBeInTheDocument();

const submitButton = screen.getAllByRole("button", {
Expand All @@ -899,10 +895,8 @@ describe("Free scan CTA experiment", () => {
/>,
);

const inputField = screen.queryAllByLabelText(
"Enter your email address to check for data breach exposures and sites selling your info.",
);
expect(inputField[0]).toBeUndefined();
const inputField = screen.queryAllByTestId("signup-form-input");
expect(inputField.length).toBe(0);

const submitButton = screen.getAllByRole("button", {
name: "Get free scan",
Expand All @@ -924,10 +918,8 @@ describe("Free scan CTA experiment", () => {
/>,
);

const inputField = screen.queryAllByLabelText(
"Enter your email address to check for data breach exposures and sites selling your info.",
);
expect(inputField[0]).toBeUndefined();
const inputField = screen.queryAllByTestId("signup-form-input");
expect(inputField.length).toBe(0);

const submitButton = screen.getAllByRole("button", {
name: "Sign in to get free scan",
Expand Down Expand Up @@ -986,6 +978,48 @@ describe("Free scan CTA experiment", () => {
expect.objectContaining({ button_id: "clicked_get_scan_header-ctaOnly" }),
);
});

it("passes the expected URL to the identity provider", async () => {
const user = userEvent.setup();
const ComposedDashboard = composeStory(LandingUs, Meta);
render(
<ComposedDashboard
experimentData={{
...defaultExperimentData,
"landing-page-free-scan-cta": {
enabled: true,
variant: "ctaWithEmail",
},
}}
/>,
);

const inputField = screen.getAllByTestId("signup-form-input");
await user.type(inputField[0], "[email protected]");

const submitButton = screen.getAllByRole("button", {
name: "Get free scan",
});
await user.click(submitButton[0]);

expect(signIn).toHaveBeenCalledWith(
"fxa",
expect.any(Object),
expect.stringContaining(
[
"entrypoint=monitor.mozilla.org-monitor-product-page",
"form_type=email",
"service=edd29a80019d61a1",
"email=mail%40example.com",
"entrypoint_experiment=landing-page-free-scan-cta",
"entrypoint_variation=ctaWithEmail",
"utm_source=product",
"utm_medium=monitor",
"utm_campaign=get_free_scan",
].join("&"),
),
);
});
});

it("does not show a confirmaton message if the user has just deleted their account", () => {
Expand Down

0 comments on commit 64ac5c5

Please sign in to comment.