* Add email domain array * Create numbered email domain object * Check email domain * Rename function * Add tests * Frontend enable skip ownership check if free email domain * Backend ignore adding ownership to return records if free email domain check is enabled * feat: Only require confirmation for free email domains (#17917) * Add requiresConfirmationForFreeEmail to db * Add option to event type settings * Get requiresConfirmationForFreeEmail for event type page * Include requiresConfirmationForFreeEmail in fetching event type * Pass bookerEmail to `getRequiresConfirmationFlags` * Add free email domain check to `determineRequiresConfirmation` * Add `requiresConfirmationForFreeEmail` to types * Add severity to Watchlist table * Add migration for watchlist severity * Add `getEmailDomainInWatchlist` method to watchlist repository * Use watchlist repository to check for free email domain * Mock watchlist repository in test * Update test * Rename method * Add severity to blocked list * Move check free email domain to async * Type checks * Adjust for promise returned * Fix tests * Fix * Fix tests
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { describe, expect, test, vi } from "vitest";
|
|
|
|
import { WatchlistRepository } from "@calcom/features/watchlist/watchlist.repository";
|
|
|
|
import { checkIfFreeEmailDomain } from "./checkIfFreeEmailDomain";
|
|
|
|
describe("checkIfFreeEmailDomain", () => {
|
|
test("If gmail should return true", async () => {
|
|
expect(await checkIfFreeEmailDomain("test@gmail.com")).toBe(true);
|
|
});
|
|
test("If outlook should return true", async () => {
|
|
expect(await checkIfFreeEmailDomain("test@outlook.com")).toBe(true);
|
|
});
|
|
test("If work email, should return false", async () => {
|
|
const spy = vi.spyOn(WatchlistRepository.prototype, "getFreeEmailDomainInWatchlist");
|
|
spy.mockImplementation(() => {
|
|
return null;
|
|
});
|
|
expect(await checkIfFreeEmailDomain("test@cal.com")).toBe(false);
|
|
});
|
|
test("If free email domain in watchlist, should return true", async () => {
|
|
const spy = vi.spyOn(WatchlistRepository.prototype, "getFreeEmailDomainInWatchlist");
|
|
spy.mockImplementation(() => {
|
|
return { value: "freedomain.com" };
|
|
});
|
|
expect(await checkIfFreeEmailDomain("test@freedomain.com")).toBe(true);
|
|
});
|
|
});
|