Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

Test poll verification (#463)

Luke Vella4918aaef71ea
diff --git a/src/utils/absolute-url.ts b/src/utils/absolute-url.ts
index 2385c5e2c..fba32a0a5 100644
--- a/src/utils/absolute-url.ts
+++ b/src/utils/absolute-url.ts
@@ -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}`;
}
diff --git a/tests/create-delete-poll.spec.ts b/tests/create-delete-poll.spec.ts
index c40de6951..aeab2b6c4 100644
--- a/tests/create-delete-poll.spec.ts
+++ b/tests/create-delete-poll.spec.ts
@@ -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("[email protected]", {
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