Skip to content

Commit

Permalink
Extend validation for email information
Browse files Browse the repository at this point in the history
  • Loading branch information
mpanne committed Dec 19, 2024
1 parent aea4100 commit a480736
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/dito/tests/e2e/assessment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@ import { ROUTE_RESULT } from "resources/staticRoutes";
async function interceptMailToRedirectAndExpect(
page: Page,
expected?: {
subject: string;
subject?: string;
recipient?: string;
bodyContains?: string;
},
) {
await page.route("**", async (route) => {
const response = await route.fetch();
const status = response.headers()["x-remix-status"];
const redirectUrl = response.headers()["x-remix-redirect"];

const mailTo = new URL(redirectUrl);

if (status === "302" && redirectUrl?.startsWith("mailto:")) {
if (expected !== undefined)
expect(mailTo.searchParams.get("subject")).toBe(expected.subject);
const mailTo = new URL(redirectUrl);
expect(mailTo.pathname).toContain(expected?.recipient || "");
expect(mailTo.searchParams.get("subject")).toBe(expected?.subject || "");
expect(mailTo.searchParams.get("body")).toContain(
expected?.bodyContains || "",
);
await route.abort();
} else {
await route.continue();
Expand Down Expand Up @@ -122,6 +126,8 @@ test.describe("test quicksend email", () => {

await interceptMailToRedirectAndExpect(page, {
subject: "Digitalcheck Vorprüfung: „Policy ABCDEFG“",
bodyContains: "ausgefüllten Vorprüfung im Rahmen des Digitalcheck",
recipient: "[email protected]",
});
await page.getByTestId("result-email-button").click();
});
Expand Down

0 comments on commit a480736

Please sign in to comment.