Files
community-rule/tests/unit/confirmLinkPaths.test.ts
T
adilallo a725cf1a32 Spend login, invite, and email-change links only after a confirm POST so mail scanners cannot use them up.
GET still shows a one-button page, a used invitation can resend or reopen for the signed-in invitee, and an email-change GET no longer signs the account out.
2026-11-22 16:58:30 -07:00

34 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
emailChangeConfirmPath,
emailChangeVerifyPath,
inviteConfirmPath,
inviteVerifyPath,
magicLinkConfirmPath,
magicLinkVerifyPath,
} from "../../lib/create/confirmLinkPaths";
describe("confirmLinkPaths", () => {
it("encodes tokens on confirm and verify URLs", () => {
expect(magicLinkConfirmPath("a+b")).toBe("/login/confirm?token=a%2Bb");
expect(magicLinkVerifyPath("a+b")).toBe(
"/api/auth/magic-link/verify?token=a%2Bb",
);
expect(emailChangeConfirmPath("a+b")).toBe(
"/email-change/confirm?token=a%2Bb",
);
expect(emailChangeVerifyPath("a+b")).toBe(
"/api/user/email-change/verify?token=a%2Bb",
);
});
it("keeps copy=1 on invitation confirm and verify URLs", () => {
expect(inviteConfirmPath("abc1234567", { copy: true })).toBe(
"/invite/confirm?token=abc1234567&copy=1",
);
expect(inviteVerifyPath("abc1234567", { copy: true })).toBe(
"/api/invites/rule-stakeholder/verify?token=abc1234567&copy=1",
);
});
});