Test poll verification (#463)

* Test poll verification

* Fix linting
This commit is contained in:
Luke Vella 2023-02-01 09:49:50 +00:00 committed by GitHub
parent fc08d1b922
commit 4918aaef71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 7 deletions

View file

@ -1,3 +1,5 @@
const port = process.env.PORT || 3000;
const getVercelUrl = () => {
return process.env.NEXT_PUBLIC_VERCEL_URL
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
@ -5,9 +7,9 @@ const getVercelUrl = () => {
};
export function absoluteUrl(path = "") {
return `${
const baseUrl =
process.env.NEXT_PUBLIC_BASE_URL ??
getVercelUrl() ??
"http://localhost:3000"
}${path}`;
`http://localhost:${port}`;
return `${baseUrl}${path}`;
}

View file

@ -1,4 +1,5 @@
import { expect, test } from "@playwright/test";
import { load } from "cheerio";
import smtpTester from "smtp-tester";
test.describe.serial(() => {
@ -45,6 +46,16 @@ test.describe.serial(() => {
await page.click('text="Create poll"');
const title = page.getByTestId("poll-title");
await title.waitFor();
await expect(title).toHaveText("Monthly Meetup");
pollUrl = page.url();
});
test("verify poll", async ({ page, baseURL }) => {
const { email } = await mailServer.captureOne("john.doe@email.com", {
wait: 5000,
});
@ -53,13 +64,18 @@ test.describe.serial(() => {
"Rallly: Monthly Meetup - Verify your email address",
);
const title = page.getByTestId("poll-title");
const $ = load(email.html);
const verifyLink = $("#verifyEmailUrl").attr("href");
await title.waitFor();
expect(verifyLink).toContain(baseURL);
pollUrl = page.url();
if (!verifyLink) {
throw new Error("Could not get verification link from email");
}
await expect(title).toHaveText("Monthly Meetup");
await page.goto(verifyLink);
await expect(page.getByTestId("poll-title")).toHaveText("Monthly Meetup");
});
// delete the poll we just created